Kids VoIP line

A common problem amongst many of the parents I speak with is how young children seem to want cell phones these days. So many of my 8 year old son's friends already have cell phones!! The following is my geeky dad solution to the dilemma.

I told him that he wouldn't be getting a cell phone. But I remembered that I had some left over hardware from some previous VoIP projects I had done. One was a Sipura SPA-3000 ATA. Basically, it does many things, but one thing it does is act like an adapter for a regular phone to become an internet phone.

So, I set up a gizmo account. This is a free internet phone service, similar to Skype, except they use open standards and protocols (like SIP), so you can use whatever software and hardware you want. This worked out for my situation since I already had hardware. After setting up the account, I upgraded it to have it's own phone number (called "Call-In") and added some minutes for Call-Out so that it could be used as a regular phone with a real number and everything. Of course, calls to and from internet users are always free.

The setup took some time to figure out, but if someone has an SPA-3000 and would like some help with the settings, just let me know. The basic settings for a SIP device on the gizmo service are here.

So, after getting that working, we effectively had a phone for Neo in his room with its own number and speed dial settings for mom and dad's phone. On top of that, we used his cool "Incredibles" phone which you can see below. This makes it a bit cooler for a kid.

Incredibles Phone

The next issue was voicemail. Gizmo has voicemail for free, but the only way to check it is through email (it emails you a wav file). That means there isn't a good way to know if you have a voicemail without having your email open.

This was just screaming for a fun weekend project. Basically, what I want is to have some sort of visual indicator in his room to let him know he has a voicemail. Even better, it could be a generic indicator for email since he sometimes has trouble remembering to check his email for new messages. Since the voicemails come in as emails, this would knock out 2 birds with one stone.

But what to use as a visual indicator? I thought about using an X10 module and just turning it on and off from my linux server (like I did here) when he has new email messages, but I don't really want a whole lamp on. I thought about buying one of these little orbs which would do the trick. But that would cost money, and I wanted something cooler.

But then I thought about the Incredibles phone. It has a built in LED as a Message Waiting Indicator (known as MWI). It supports MWI and so does the SPA-3000!! It's just gizmo that doesn't support MWI SIP messages. If I could write a script to tell the SPA-3000 that messages were waiting, it would automatically tell the phone to turn on the MWI LED (which flashes in a cool way as if it will calling the Incredibles to an important mission).

To do this, I needed a way to first check my sons gmail account for new messages from the command line in linux. This turned out to be super easy using the Atom feed. Check out the following example bash script:
mails="$(wget --secure-protocol=TLSv1 --timeout=3 -t 1 -q -O - \
https://${gmail_login}:${gmail_password} \
--no-check-certificate | grep 'fullcount' \
| sed -e 's/.*<fullcount>//;s/<\/fullcount>.*//' 2>/dev/null)"

echo "There are $mails new messages"

After being able to tell how many new messages are available, I just need to send a SIP message to the SPA-3000 to tell it whether or not messages are waiting. I did this using a program called "sipsak". It's a super small slick program for sending SIP messages.

After building sipsak, I set up the following script (based off of a script by Paul Norris, Silicon Valley Products 2006) to tell the SPA-3000 how many messages were waiting:
# Mods for gizmo account on SPA-3000 by Frank Graffagnino
# Written by Paul Norris, Silicon Valley Products 2006
# You may use this code subject to the GNU GPL.

if [ $# -ne 1 ]; then
   echo "Usage: $0 <number_of_new_messages>"
   exit 1


if [ $num_messages -gt 0 ]; then

myagent="sipsak 0.9.6"
clen=$(expr 72 + ${#myip} + ${#myrealm})

echo "NOTIFY $contact SIP/2.0" > /tmp/mwisip.txt
echo "From: $myrealm <sip:$myrealm@$myip>;tag=as2276ae9c" >> /tmp/mwisip.txt
echo "To: <$contact>" >> /tmp/mwisip.txt
echo "Contact: <sip:$myrealm@$myip>" >> /tmp/mwisip.txt
echo "Call-ID: 493ea14847f1e9a474a6b2ec3bf8c8bf@$myip" >> /tmp/mwisip.txt
echo "CSeq: 102 NOTIFY" >> /tmp/mwisip.txt
echo "User-Agent: $myagent" >> /tmp/mwisip.txt
echo "Max-Forwards: 70" >> /tmp/mwisip.txt
echo "Event: message-summary" >> /tmp/mwisip.txt
echo "Content-Type: application/simple-message-summary" >> /tmp/mwisip.txt
echo "Content-Length: $clen" >> /tmp/mwisip.txt
echo "" >> /tmp/mwisip.txt
echo "Messages-Waiting: $msgwaiting" >> /tmp/mwisip.txt
echo "Message-Account: sip:$myrealm@$myip" >> /tmp/mwisip.txt
echo "Voice-Message: $num_messages/$num_messages (0/0)" >> /tmp/mwisip.txt

/usr/local/bin/sipsak -f /tmp/mwisip.txt -s $contact

That script just takes an argument with the number of new messages and sends the message out. All I need now is a wrapper script to check gmail, then call the script above with the number of new messages:
mails="$(wget --secure-protocol=TLSv1 --timeout=3 -t 1 -q -O - \
https://${gmail_login}:${gmail_password} \
--no-check-certificate | grep 'fullcount' \
| sed -e 's/.*<fullcount>//;s/<\/fullcount>.*//' 2>/dev/null)"

if [ "$mails" != "" ]; then
    <> $mails


Last step is to automate. I call the above script every couple of minutes to check for new messages. I also set up the cron entry to not check during the night so that we don't get a mini ring or something waking someone up because an email came in during the middle of the night. To check for email every couple of minutes between the hours of 9am and 7pm, I have the following cron line:

  # FG ++ Update the MWI light on Neo's phone
  */2 9-19 * * * root

And that's it. Now, my son is exciting about having his own phone and his own line. Mom and Dad are happy. And he now has a cool "calling all superheroes" indicator to let him know when he has new emails. :)

Last Modified: 05.31.09    Valid XHTML 1.0!    Valid CSS! Powered by Blogger