Getting NCID working on every device possible

So this weekend I decided it was time to resurrect some of the old caller-id scripts I used to utilise.  Previously I had used YAC as my caller-id server and listener on a windows pc, and used a python script on XBMC to display the caller ID on the old xboxes I used as media centres.Due to the latest version of XBMC (EDEN) the older scripts no longer function.  The next problem is I no longer use a windows machine anywhere near a telephone point.  There is however a linux server running right next to a telephone point I could hook an old external modem to and utilise that way.

After some research online, I found there was a package called NCID (network caller-id) that would happily monitor the responses from a serial modem and broadcast the caller-id information around my network.

In the interest of squeezing every last bit of usage from my new iPhone I also decided I needed to be able to send CID info to my phone via something like growl etc.

So now that we know all that, the software want list looks like this:

  • Ubuntu Linux Box
  • Windows YAC listener
  • Some kind of push notification app for the iPhone
  • NCID client for OSX so we can see the popup info on our Macbook
  • A python script to install on the Apple TV’s I have replaced old xboxes with.

So for the Ubuntu linux box – That’s already setup and working as an sql server for sharing the media database between multiple xbmc clients

  • We also need a serial modem that supports Caller-ID AT Commands.. Just so happens I have a netcomm roadster (Used to be US Robotics)

Windows YAC client is easy.  We simply download the package from: http://sunflowerhead.com/software/yac/

Push notifications to the iPhone was a little more complex.  Originally I was going to use Prowl and have the ubuntu box push the information out using that.  However being a “thrifty” fellow (RE: TIGHTARSE) I decided to use boxcar as my app of choice.  For those that don’t know, boxcar is used to push a number of different notifications to your iPhone via push messaging.  Things like twitter updates, Facebook, and all sorts of other services.  The beauty of box car is you can setup your own “Service” using their API and have custom icons etc assigned to that service.  Otherwise you can simply do it with your own username and password, and skip the pretty icons.  Boxcar will interpret your messages as Growl notifications and still display them on your iPhone.  You can read more about boxcar and get the app from: http://boxcar.io/

Finally a way to push the information to XBMC running on any platform.  xbmc now ships with a command called “xbmc-send” which can be used to send JSON-RPC commands to XBMC clients on your network.  Rather than re-invent the wheel I decided to use this as a way to popup the notification box that displays the CID information.  On the main AppleTV i’ve also used that same command to pause the video on an incoming call.

So lets finally get down to business.

Windows Setup

Download the Yac client from the above listed website, and install it on your windows machine.

Once install head over to your start menu and run the Yac Listener application.

At this point, if you right click and drag the listener app from the yac item of your start menu into the startup item, the listener will run each time windows start up and you’re logged in.

Ubuntu Server Setup

First we need to download the ncid package.  For me, this wasn’t already available from the repo’s I had setup, so i had to setup repos using the following commands:

wget -q -O - http://archive.getdeb.net/getdeb-archive.key | sudo apt-key add -sudo sh -c 'echo "deb http://archive.getdeb.net/ubuntu precise-getdeb apps" >> /etc/apt/sources.list.d/getdeb.list'

once thats done we run:

sudo apt-get update
sudo apt-get install ncid

This will install both the ncid Server and the ncid-client which we will need to send info to xbmc and to our iPhone.

The next step is to configure NCID to actually utilise the modem.

next we enter:

sudo nano /etc/ncid/ncidd.conf

Search (CTRL+W) for the line that states:

# Set noserial = 1

and change it to

Set noserial = 0

Save the file (CTRL+O) and then exit nano (CTRL+X)

Now we need to edit the ncidmodules.conf file to send cid info to our yac listeners

sudo nano /etc/ncid/ncidmodules.conf

Search for YACLIST=”127.0.0.1″ and change it to the ip address of your windows computer.  IE: YACLIST=”192.168.0.XXX”

Save and close this file as we’re now done with it.

Next we need to create a script that will handle the notifications for us.  I decided to add all my custom notifiers into the one file, however you could launch separate processes for each notification (Now that I think of it, I’ll try that next :D)

sudo nano /etc/ncid/ncid-prowl

Copy and paste the following in as your script

# !/bin/sh
 # ncid-prowl output module
 # Modify as needed for new module
 # kiip "ncid-" in the name
 # input is 5 lines obtained from ncid
 # input: DATEnTIMEnNUMBERnNAMEnLINEn #
 # input is 5 lines if a message was sent
 # input: nnnMESSAGEnn
 # Message will be in $CIDNAME#
 # ncid usage:
 # ncid --nogui [--message] --program ncid-prowl

ConfigDir=/etc/ncid
 ConfigFile=$ConfigDir/ncidmodules.conf

[-f $ConfigFile ] && .$ConfigFile

read CIDDATE
 read CIDTIME
 read CIDNMBR
 read CIDNAME
 read CIDLINE

# Test to see if the number has an alias assigned to it - or if ncid is unaware who owns this number
 # If there is an alias assigned - push this value to the T1 variable, otherwise set T1 to the number of the incomming call

if [ "$CIDNAME" = "NO NAME" ];
 then T1=$CIDNMBR
 else T1=$CIDNAME
 fi

##############################
 # Send notifications to XBMC #
 ##############################

# Send notification without pausing currently playing item - Uncomment if you dont want a pause
 # xbmc-send --host=IPOFXMBC -a "Notification(Incomming Call,Call From $T1)"

# Send noticiation and PAUSE the currently playing item - Comment if you dont want a pause
 xbmc-send --host=IPOFXBMC -a "Pause"
 xbmc-send --host=IPOFXBMC -a "Notification(Incomming Call,Call From $T1)"

###############################
 # Send noticiations to boxcar #
 ###############################

# Replace UN with your boxcar username(email address)
 # Replace PA with your boxcar password

/usr/bin/curl -d "notification[from_screen_name]=Incoming Call" -d "notification[message]=Call From: $T1" -user "un:pa" <a href="https://boxcar.io/notifications">https://boxcar.io/notifications</a>

exit 0

Save and close nano with this new script

next we make it executable

sudo chmod +x /etc/ncid/ncid-prowl

Now that we’ve got all that setup we need to set the ncid client and the ncidd daemon to start on startup

sudo update-rc.d ncidd defaults

now to create a scrip that will start ncid and push the notifications to our ncid-prowl script.

sudo nano /etc/init.d/start-ncid.sh
#!/bin/bash

ncid --no-gui --program /etc/ncid/ncid-prowl &

Save and close the script

now we need to make it executable

sudo chmod +x /etc/init.d/start-ncid.sh[/code[

then add it to the default startup items

sudo update-rc.d start-ncid.sh defaults

reboot the box with

sudo shutdown -r now

and on reboot your caller id should be working without a problem

if you want to have peoples names appear instead of simply their numbers (For known callers) simply edit the file /etc/ncid/ncidd.alias file and follow the comments in the file.

Mac Setup

To have the notifications sent to your mac download and install a program called NCIDPop.  Don't bother turning on growl notifications as they don't work with the latest version of growl.

So after all that.. you finally have NCID setup and sending Caller-ID info to as many devices as possible. And all for free 😀

Enjoy!

UPDATE: After mucking around with this some more, I decided to go ahead and split the xbmc and boxcar notifications into different scripts.

The advantage of this is that now my iphone is alerted at almost the exact same time as xbmc.  So in the interest of speed I created a second script.  All thats required is to copy the entire ncid-prowl script and edit it a little to remove the xbmc notification part.  We do the same for ncid-prowl by removing the boxcar part

sudo cp /etc/ncid/ncid-prowl /etc/ncid/ncid-boxcar
sudo nano /etc/ncid/ncid-prowl

Delete the lines related to boxcar notifications then close and save this file

sudo nano /etc/ncid/ncid-boxcar

Delete the lines related to xbmc notifications, then close and save this file.

Make the ncid-boxcar script executable (I think it already is as we copied it, however just in case)

sudo chmod +x /etc/ncid/ncid-boxcar

next we need to update the /etc/init.d/start-ncid.sh script file to run a second instance of ncid.  From the documentation it's stated we can run as many instances of ncid as we like/require so we simply add another line to enable our boxcar script

sudo nano /etc/init.d/start-ncid.sh

add the following line under the first line that starts our xbmc script:

ncid --no-gui --program /etc/ncid/ncid-boxcar &

close and save this file and kill any running ncid processes

sudo ps -aux |grep ncid

once you identify the process ID for the running ncid issue

sudo kill -9 PROCESSNUMBER

then run

sudo /etc/init.d/start-ncid.sh

And enjoy your multiple instant alerts.

Next I'll look at integrating this into the main ncidd script.  Its already doing it for ncid-yac so I dont see why it can't run our scripts as well.

ENJOY!

UPDATE 18/04/12:

For those that want to do the same thing without the linux box and using windows to send to their xbmc machines (Thats any box running a current version of xbmc from Dharma up)

  1. Download and install YAC Server from http://sunflowerhead.com/software/yac/yac-0.16-win32.zip
  2. Once thats installed download this file: http://www.endpoint.eclipse.co.uk/wordpress/yac-0.17-win32.zip
  3. Extract that zip file to the same folder as your YAC installation and overwrite any files.  I pulled this file from here: http://mattcollinge.wordpress.com/2007/05/18/spoken-caller-id-using-yac/
  4. Download and install WGET into C:\windows\system32 or anywhere else in your command path.   http://gnuwin32.sourceforge.net/packages/wget.htm
  5. Edit the Yac-helper.cmd file to the following:
@echo off
02  
03 rem  ----------------------------------------------------------
04 rem  Matt Collinge :: http://www.mattcollinge.co.uk :: 17 April 2007
05 rem  ----------------------------------------------------------
06 rem  Helper Script for YAC 0.17. When present in the same 
07 rem  folder as "yac.exe" this will be run each time a call is 
08 rem  received. The type of data being passed through 
09 rem  in %2 &amp; %3 is specified in %1. 
10 rem  
11 rem    %1 = ( call | message )
12 rem    %2 = either the calling number or text-based message
13 rem    %3 = the calling name (not set for a text-based message)
14 rem  ----------------------------------------------------------
15  
16 rem This next line simply passes the parameters on to a piece of VBScript. But you can
17 rem modify this line to call any app you like :)
18  

Edit line 19's username/password to match what you have setup in xbmc, and ensure you enable all the options in xbmc network services.  Not only will this help this script to work, but lets you do some pretty funky stuff with your xbmc machine 😀

You can also use the same principal to adapt the boxcar notification stuff into windows as well.

I haven't been able to test this script as I dont have a windows machine thats running yac server.  Give it a go and if it doesn't work I'm happy to take suggestions that do make it work.

There is another solution to this though:  http://forum.xbmc.org/showthread.php?tid=105931 There they edit the .vbs script and make changes in there to get things happening.  In saying that, I don't see the point to do this when the solution is so elegantly simple

So there you have it, a linux and windows solution.  AND YES YOU CAN DO IT ON A MAC.. you'd use NCID and automater.

Advertisements

23 thoughts on “Getting NCID working on every device possible

  1. Jim, thanks for taking the time to write this article!

    I’m trying to do something similar with XBMC but all my PC’s are Windows and my XBMC box is an Apple TV. I can’t quite figure out if XBMC is running on the Ubuntu box where you placed the script in your write up. Is that the case?

    • Hi Ken,

      I’ve updated the post to include a way to do exactly what you ask. I too am using ATV2’s as my xbmc machines. Its not so much the hardware you run on, its more the version of xbmc you run thats important, so long as its Dharma and up the linux stuff will work, the windows stuff should work with version below even dharma.

      Cheers
      Jim

  2. Finally getting some more time to work on this. It seems wget is having trouble sending the variables from YAC in the URL. I can make it send just a blob of text, but as soon as I add the %2, %3 things get ugly. I’ll continue messing. If you think of a fix please let me know! Thanks!

      • No luck so far. I’m sure it’s a formatting problem. I even tried CURL, but I think the way windows uses curl and wget is part of the issue. Even trying to send a simple message wouldn’t work with curl but did with wget. When I add the variables back in wget breaks the command into multiple parts and errors. So I think you’re right about the quotes, and I think it’s just a matter of figuring out where they need to go!

      • I fixed it –

        Add this at line 18 and change 19 to:

        18 set text=Incomming Call From %2%
        19 http://username:password@IPADDRESSOFXBMC:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn(Notification(“Incomming%20Call”,”%text%”,7000))

        Give that a whril, I got it working using a simple batch file to test that looks like this:

        new file and call it test.bat

        set text=Incomming Call From %2%
        wget.exe –tries=1 –timeout=1 http://xbmc@127.0.0.1:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn(Notification(“Incomming Call”,”%text%”,7000))

        save it and then call it from the command line with variables to replace the output from yac so

        C:> test.bat call 12345678 my_Mobile

        at the moment it only shows the number itself, but with some fiddling around i’m sure you can get the name to display as well 😀

        Cheers
        James

  3. Well I finally have it working! In the end I used some vbscript to get it to produce the name and number. No matter what I tried using a batch file or command file it just threw up on the spaces or the wrong use of quotes. So not to promote my own blog here, but I’m going to do a write up on my efforts over there. It’s http://www.shieldsit.com If you’d like I can also send you a copy of the code I have if you’d like it, or if you’d like to share it here.

    Thanks again for all your help and for the great write up!

  4. Hi Jim, you can always rely on the internet to show you someone else that has for hours on end slavishly compiled>tested>failed>goto compiled scripts for no reward, and in many cases, no real reason, to arrive at something that no-one else even new they wanted!

    Praise be to the internet. I’ve had an obsession with getting caller id everywhere and from every device for many years and if it wasn’t for people like you sharing your discoveries, the nights would be so much longer.

    I am currently using a nifty little conexant USB modem (dell) that supports UK caller id which was about £3 from ebay (so I can dump the hefty Pace solo), feeding into a hacked O2 Joggler running Ubuntu Netbook Edition of a memory stick. This little baby, if you didn’t know, has built in wireless, so sends the caller id from a bit of perl I wrote (ncid wouldn’t compile) using netcat to yac listeners on various PCs and laptops. I’m just playing with the idea of getting it displayed on my Humax digital tv box.

    I am also waiting for my NeTV box to arrive from the US which, thanks to bunnie, allows you to overlay on HDMI and as it is linux based I am sure that the next step is caller ID on the big screen without getting rid of the sky HD box. Info here if interested including a video: http://hackaday.com/2012/01/21/overlaying-video-on-encrypted-hdmi-connections/

    The final part that I didn’t know I wanted was the iPhone integration and that’s where you super nugget about boxcar has put decorating the living room on the back burner [again]

    • There’s a few options

      Growl for android
      Notify my android

      Personally I’d use growl for android and install growl on your windows pc to pipe the notifications to your tablet.

      • I installed growl for windows and growl on android. However, in the growl for windows GUI there is no applications registered. If you don’t mind, how do I pipe the info from yac to growl? Or maybe that should be how do I get yac registered? I’m using YAC 0.16. Thanks again.

  5. Jim, have you messed with changing the picture’s in YAC? Or, do you know of a place that discusses is? I’d like to personalize it a bit and I’m getting a little tired of the YAC image 🙂

    Ken

    • Hey bud, apologies for the long delay…

      If I remember right, you put a .jpg picture in the YAC folder with the number of the person calling as the filename so for a phone number of 1234567 you’d make the file “1234567.jpg”

      Having to re-set things up on this end as I upgraded the linux box I’m using so I could run the PVR option through a PS3 Playtv box and stream it to the rest of the house 😀 Have you discovered the wonders of linux yet? or still trying to wrestle with windows? lol

  6. Jim, awesome article, I have followed this but am stuck, I am using an o2 joggler with xbuntu12.10 and with ncid installed as server and client with a USB modem. I currently get an error saying cannot read sock 6 connection refused, could you point me in the right direction to get this fixed?

  7. Just ran across this and WOW! Awesome…. thank you very much.

    I am using the YAC server in Windows… One thing I would love to implement in addition to the XBMC notification is that it will PAUSE anything that is playing automatically when a call comes in; so one can go answer the phone. What would the WGET command for this look like? Can the command be sent to more than one xbmc machine?

    Thanks again for this. My media center is just that much cool because of this.

  8. I wanted to be able to see my NCID Server’s call log on my iPhone without needing my computer turned on (my NCID Server runs directly inside my router), so I made an app to do that:

    https://itunes.apple.com/us/app/easyncid/id740578199?ls=1&mt=8

    Because of Apple’s strict policies, it can’t run in the background that long and so isn’t a substitute for the solution with the Prowl app (which uses push notifications, something that wasn’t a possibility when a computer isn’t running like in my case). But perhaps I can release something in Cydia to fix that 😉

    • Hi. I have made many CallerID and blockers devices using arduino and one serial modem 56k and also using the so called Ferduino CallerID hardware. I have indeed transform serial modem 56K into a bluetooth serial modem 56K that can be controlled for my arduino callerid and blocker device. The fact is that I do not have any skill in programming android, and ever I ask myself why there is no app that can do a Caller ID and block procedure, using the serial modem 56k or the bluetooth derivative. It is more complex to do a caller ID procedure over serial and a number database comparison in android, than in C++, linux or windows environment?
      Thanks for your NCID efforts.

      • Block data base would be simple if you can see the serial data coming in.

        Cid enabled on the serial modem would mean the arduino could see the incoming number. Match that char by char to an array with numbers in it snd youre done.

    • NCID pop does not understand YAC packets, they need to be “translated” to NCID packets. To accomplish this, you need to (1) set up an NCID server on your MBA, (2) setup yac2ncid to get the YAC packets to the NCID server, (3) point NCIDpop at the NCID server, (4) enjoy NCIDpop working on your MBA.

      If you have problems getting this working, the docs on ncid.sourceforge.net have lots and lots of information. Failing that, the NCID forums are a much better place to get help.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s