Asterisk and MythTV integration
After much more work than was necessary, I managed to get Asterisk to blat on the TV the caller ID information of an incoming call. Next I need to see if I can pause the TV, and resume it when the call ends.
The MythTV side just needed to be configured to listen on the UDP notify port, the XML templates and whatnot were already there for it (I think installed by MythPhone), so all I had to do was get Asterisk to run this script when a call came in:
#!/usr/bin/perl use Asterisk::AGI; use IO::Socket; # Set this to the broadcast address for your network $netbroadcast = "172.16.0.255"; $AGI = new Asterisk::AGI; my %input = $AGI->ReadParse(); my $num = $input{'callerid'}; my $name = $input{'calleridname'}; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(); $date = sprintf("%02d/%02d/%4d %d:%02d:%02d",$mday,$mon+1,$year+1900,$hour,$min,$sec); $sock = IO::Socket::INET->new(PeerPort => 6948, PeerAddr => $netbroadcast, Proto => udp, Broadcast => 1 ) or die "Can't bind : $@\n"; print $sock <<EOT; <?xml version="1.0"?> <mythnotify version="1"><container name="notify_cid_info"><textarea name="notify_cid_line"><value>Unused</value></textarea> <textarea name="notify_cid_name"><value>NAME: $name</value></textarea><textarea name="notify_cid_num"><value>NUM : $num</value> </textarea><textarea name="notify_cid_dt"><value>$date</value></textarea></container></mythnotify> EOT close $sock; exit(0);
That was accomplished by just adding an AGI(mythcid.agi) application call to one my existing extensions that handled incoming calls. Future enhancements will involve displaying who the caller wants to speak to after they've selected the appropriate response from the menu we give most callers.
The Asterisk::AGI Perl module was a bit hard to track down. I've made a 2 second (dh-make-perl) Debian package of it, available here. If I get sufficiently motivated, I'll consider cleaning it up and uploading it to Debian.