[Asterisk-doc] Using an additional modem to get CallerID information

Jonathan McHarg asterisk-doc@lists.digium.com
Sat, 31 Jan 2004 14:46:49 -0000


This is a multi-part message in MIME format.

------=_NextPart_000_009A_01C3E809.0EF0FD10
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit

There are two stages in the process of getting callerID information from a
standard modem, to be used in Asterisk. The first stage is actually
capturing the information from the modem, the second stage is importing the
captured data into Asterisk.

Capturing the caller ID details from the modem

I will presume at this stage, that you have a modem that supports caller ID
and it is installed and configured to work with your Linux box.

Here is my first script that reads the details in...

#!/usr/bin/perl
$PortName = "/dev/ttyn00";
$PortObj =  open(MODEM,$PortName) || die "Can't open $PortName: $!\n";
while (1==1) {
  local $/ = "\n";
  while ($line=<MODEM>) {
    chomp;
    if ($line =~ s/NMBR = //) {
      open(OUTFILE, ">/usr/src/myperl/callerid.txt") or die "Can't open
callerid.txt: $!";
      print OUTFILE "$line";
      close OUTFILE;
    };
  }
}

depending on your setup, you'll need to amend the $portName variable to
point to the port that you've installed the modem on. You also may want to
change the path that the callerid.txt file is written to.

Once the script is written, used the chmod A+X callerid.pl to change the
mode so that the program can be executed.

Finally run the program with & parameter, to spawn the program as a new
process.


Using the callerid.txt file in Asterisk

Once the callerid.pl file has captured the callerid data, the number needs
to be loaded into asterisk. This is done using AGI functions within
asterisk.

Firstly create a perl script as follows.

#!/usr/bin/perl
open(INFILE, "/usr/src/myperl/callerid.txt") or die "cannot open file";
if ($callerID=<INFILE>) {
  print "SET CALLERID $callerID"};
close INFILE;

once created, this script should be placed in the AGI directory.

Finally add a line to your extensions.conf file to call this script, an
example line would be.

Exten=>_.,1,agi,getcallerid.pl

Hopefully, this should now leave you with CID working !!

------=_NextPart_000_009A_01C3E809.0EF0FD10
Content-Type: application/ms-tnef;
	name="winmail.dat"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
	filename="winmail.dat"

eJ8+IjEOAQaQCAAEAAAAAAABAAEAAQeQBgAIAAAA5AQAAAAAA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