
My home Asterisk configuration has been pretty static for a while. It works
well, and so I haven't had a need to mess around with it.
There's a couple of outstanding features I've wanted to implement for a
while though, and I've now got one of them out of the way.
All calls that come in from the local PSTN line, the Vonage ATA, and the SIP
connection to Engin, hit a menu, where the caller selects whether they want
to speak to Sarah or myself. The sole purpose of this is to determine what
to do with the call if no one answers (which voicemail box or cell phone to
send the call to). A convenient side-effect of this is that it defeats most
telemarketers.
Ages ago,
I set
up caller ID announcement to my MythTV setup, so if we happened to be
watching TV or a recording when a call came in, it briefly popped up on the
TV.
Fortunately, we're not huge square-eyes, and spend more time goofing off on
our laptops, so I wanted a way to display notifications on our laptops when
calls came in as well.
I had this crazy design in my head of having a server process on my Asterisk
box, and then clients on our laptops could connect to it, and be informed of
new calls. Before I went on a coding frenzy, and did something with the
Observer pattern and more socket programming than I really wanted to, I
thought I'd check if this was solved problem. Turns out, it kind of is.
I found the
Notify
application for Asterisk (which I've made
a package
for Debian Etch), which blats a UDP message to particular host as part
of a dialplan. It's more intended to go in person-specific extensions, but
as the majority of calls go into the main menu and never come out before
hitting a person-specific extension, and I still wanted to know about them
for my own perverse pleasure, I added multiple calls to the Notify
application in the main menu dialplan.
The site for the application also mentioned some third-party clients for
Linux and MacOS, but I've been looking for an excuse to try and write
something that used Growl, so I wrote my own Python application, initially
on Linux, and then I essentially swapped out the
pynotify code for
the equivalent Growl code, and it worked just as well on Sarah's Mac.
So it's not quite the solution that I had in mind, because it doesn't really
scale, but for our two-user home setup, it's adequate. I might still try
and write some middleware between a client for this application and an
infinite number of observers, but there's no urgency.
The dialplan for our main menu now looks something like this:
exten => s,1,Background(for)
exten => s,n,AGI(mythtv-cid.agi)
exten => s,n,Notify($ CALLERID(num) $ CALLERID(name) $ EXTEN /icarus)
exten => s,n,Notify($ CALLERID(num) $ CALLERID(name) $ EXTEN /iapyx)
exten => s,n,Set(TIMEOUT(digit)=5) ; Set Digit Timeout to 5 seconds
exten => s,n,Set(TIMEOUT(response)=10) ; Set Response Timeout to 10 seconds
exten => s,n,Background(names/sarah)
exten => s,n,Background(press-1)
exten => s,n,Background(for)
exten => s,n,Background(names/andrew)
exten => s,n,Background(press-2)
exten => s,n,WaitExten
A call comes in, hits the menu, and the caller ID info is displayed on
MythTV (if something's being watched) and our two laptops (if they're
awake).
Unfortunately my Git-fu is atrocious, so I can't figure out how to link to
a web-browseable repository that contains the source for my client, but if I
figure that out, I'll update this with a link later.
Update
I managed to summon enough Git-fu to put the repository online. It's
available at
http://git.andrew.net.au/?p=asterisk-notify-client.git;a=summary
Now I just have to use it properly.