tisdag 30 oktober 2012

Caller ID project

I have a problem with caller id. In my cordless phone the number is not stored when you answer in that phone and in my old cable-connected phone (with caller id) the battery is out. The easy fix is of course to replace the batteries but wheres the fun in that?

Instead I remembered that I have an old NIM Personal on a shelf from an earlier (think 2007) idea about a caller id project. A NIM Personal (Link) is a rather nice looking caller id device what instead of presenting the incoming number on a display, sends it on a RS232 serial port (9600) baud.

Wouldn't it be nice to log all incoming calls and automatically look them up in an online directory and same them in a database accessible from a browser or smartphone? I think so and it is much more fun than just replacing the batteries in the old phone.

To make things a little bit harder, serial ports are not the common today as they were in 2007. Therefore I bought a ATEN USB-to-Serial Converter (Link). I plugged everything into a Windows 7 PC and installed the drivers. After that I launched putty, opened COM4 and called my land line from my cellphone. And it worked!
In putty I got this line:

!A**********C,820629123034,000;

But instead of the * I got my cell phone number...
The protocol seams to be quite easy, first the phone number and then some kind of time stamp (I tried calling multiple times and it increased).

The next step is to get it to work with Raspian on my 512 Mb Raspberry PI (Link), set up a database, a lookup service and a simple web-page.

Update 2012-10-31
Now I have tested the NIM Personal connected to Raspberry PI with the ATEN USB-to-Serial converter. With the command "dd if=/dev/ttyUSB0 count=22" I got the caller id information into Linux. I also used "stty -F /dev/ttyUSB0 -ixon raw speed 9600" to set the speed and flow control of the serial port.
I also found a Java software called Who's Calling (Link) that included all the functionality I want. It put the incoming numbers in a database and use online directories to lookup the name of the caller and then stores it in the database.

The next step is to install Open JDK 7 on the PI and try to get Who's Calling to work.

Update 2012-10-01
It almost worked! But unfortunately the Who's Calling installation program return an error on a file called wrapper. After a little digging I found out that it is a service wrapper for java programs and the version bundled with Who's Calling are most likely an x86 binary. Fortunately the vendor also had ARM binaries on their site (Link).
Of course the problems didn't end here, the next problem was the error message:
"; nested exception is java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path"
That I got when I tried to start Who's Calling.

Update 2012-11-09
Success! Now I got the software up and running. The above error was solved by installing the package librxtx-java:
sudo apt-get install librxtx-java

and adding the directory /usr/lib/jni to the wrapper.java.library.path in the WhosCalling/config/wrapper.conf file:

wrapper.java.library.path.1=../lib:/usr/lib/jni

This project is now completed and the software and hardware will be added to the "production system" RaspberryPi in the Network Connection room (with the ADSL modem, WIFI-Router, IP-Telephony box, Ethernet Switch and network patch panel).