Using syslog to get caller id name and number from the OBi110
etc6849:
Hi,
I'm developing an open source OBi110 driver for Premise (a free home automation program).
So far, I have caller id number working with Google Voice by parsing the number from the following syslog data:
<7> [SLIC] CID to deliver: '' 17855553301
However, I'm curious if a CID syslog packet looks like this for VOIP providers and PSTN land-line calls (I don't have a land-line or VOIP provider to test, only GV)?
For services that provide a caller's name (e.g. not Google Voice) would the first part of the packet with two apostrophes usually contain the caller's name?
Premise wiki: http://www.cocoontech.com/wiki/Premise
Premise Forum (I'll post my code there once the driver is complete):
http://www.cocoontech.com/forums/index.php?showforum=51
PS: When you reply be sure to include which firmware of the OBi110 you are using.
Kiwi Syslog is a free program you can use, or you are welcome to use the perl program below.
Code:
use IO::Socket::INET;
# create a socket to serve syslog data to home automation server
$socket = new IO::Socket::INET(LocalPort => '5000', Proto => 'tcp', Listen => 1, Reuse => 1);
die "Could not create socket: $!\n" unless $socket;
print "Waiting for client connection on port 5000.\n";
# wait for client to connect before proceeding
wait_for_client_connection();
#start writing syslog data to client
$syslog = IO::Socket::INET->new(Proto => 'udp', LocalPort => '514');
die "Could not create syslog socket: $!\n" unless $syslog;
print "Syslog server is online.\n";
#if $syslog is defined, then continuously monitor the socket for incoming data
while (defined($syslog))
{
recv($syslog,$msg,1500,0);
# clean up msg some
print $msg;
$msg =~ s/[^\x{20}-\x{7E}]//g;
#$msg =~ s/[^A-Za-z <>0-9\-\.]//g;
# try to send a line to the client (home automation server),
# next we will check result so we know socket is still connected
$resultsend = $client_socket -> send("$msg\r\n");
# if socket is nolonger connected, wait for a new client connection
if (!$resultsend)
{
print "Client connection is lost.\n";
print "Waiting for new client connection...\n";
close $client_socket;
wait_for_client_connection();
}
}
close($syslog);
print $client_socket "Goodbye!\n";
close($socket);
# subroutine that's waits for client connection
sub wait_for_client_connection()
{
# client connection is lost, so wait for reconnect
$clientnotaccepted = 1;
while($clientnotaccepted)
{
# wait for new client connection.
# continue once client is connected...
$client_socket = $socket->accept();
$clientnotaccepted = 0;
}
print "Accepted new client connection.\n";
}
From the FAQs:
Here are the instructions on how to set-up your OBi so that it sends debug messages to the IP address x.y.w.z and port number ppppp. You will replace x.y.w.z and ppppp with the actual IP address and port number where your syslog server program is running.
Step 1: Find your OBi's IP address. From phone handset attached to the OBi, press ***1. The OBi's IP address will be announced.
Step 2: Configure the OBi's parameters for where to send debug messages. Open the OBi's webpage (http://OBi-IP-address) and navigate to System Management/Device Admin/Syslog. Fill-in the 'Server' parameter with x.y.w.z, and 'Port' parameter ppppp – if different than default (514). Note that ppppp must be in the range 1 - 65535.
Step 3: Enable logging of SIP Messages for SP1 (or SP2) From the OBi device web page Voice Services settings, go to the SP1 Service (or SP2 Service) settings. Change the 'X_SipDebugOption' parameter to 'Log All Messages.'
Note: If your OBi device is managed from within OBiTALK, you have the option of configuring the syslog parameters from the OBiTALK-based OBi Expert Configuration web pages.
Everton:
I cannot answer you specific question, but why not signup for a free Callcentric account or IPcomms or Sipgate (not sure if they have numbers available). Sipgate and Ipcomms have free incoming.
QBZappy:
etc6849,
Hi, welcome
It's exciting to see another OBi app appearing on the scene. Just to keep everything together perhaps you can post in this thread:
3rd party apps development for the OBi 110/100
http://www.obitalk.com/forum/index.php?topic=1648.msg10743#msg10743
infin8loop:
I posted a perl syslog script back in August.
It's here: http://www.obitalk.com/forum/index.php?topic=185.msg9107#msg9107
If I remember correctly it successfully grabbed both GV and AT&T landline calls (at the time). If the messages haven't been changed in a subsequent release, it probably will still work. There are a few comments in the code.
At the time it seemed more efficient to leverage off the syslog messages than scrape the xml pages as others had done. And I'm still not a perl coder, so don't laugh too hard at the code. I had a text editor open in one window and google to search perl command syntax in other. Any "bugs" you might find are really features that are intentionally disabled.
etc6849:
infin8loop, your code is very helpful. So you are able to extract the caller's name, this is good news! I don't have a landline to test, so could you please clarify one question?
Which packet below is the most reliable for extracting the caller id name? I have not seen the <7> [0]DAA CND... packet before; does it always occur along with a [SLIC] CID packet? In other words, is there a definite need for both else if statements in your code?
<7> [SLIC] CID to deliver: 'XXXXXXXXXXXXXXX' 11231231234
<7> [0]DAA CND 08310248,1231231234,XXXXXXXXXXXXXXX,,,
As far as your code, it was very easy to follow; it's good that you commented things. The perl script I posted here was my first perl script. I'd recommend you use perl's regular expressions.
I haven't used regular expressions in perl much, but my home automation driver uses them to parse the syslog data. It leaves things much more generic; e.g. you can easily extract what's inside the single quotes, regardless of length. You can also easily extract numbers, even if their location changes.
Navigation
[0] Message Index
[#] Next page