Caller ID Re: [Asterisk-Users] Re: Support Digium

David J Carter david.carter at codepipe.com
Mon May 3 15:00:40 MST 2004


Jon,

Look here http://www.amarok.demon.co.uk/dl/cd50_mod/

Three files also attached.

Dave

-----Original Message-----
From: asterisk-users-admin at lists.digium.com
[mailto:asterisk-users-admin at lists.digium.com]On Behalf Of Jon Lawrence
Sent: 03 May 2004 22:05
To: asterisk-users at lists.digium.com
Subject: Re: Caller ID Re: [Asterisk-Users] Re: Support Digium


On Sunday 02 May 2004 21:07, Kevin Walsh wrote:
>
> The "BT CD50 and soldering iron" plan is looking more and more like the
> one I'll be going with for now.  If anyone has a pre-modified (and
working)
> BT CD50, or similar, and would like to sell it to me then please feel
> free to email me off-list, otherwise I'll order the parts and have a go
> myself.

I picked up a CD50 on ebay for about £5. The parts are pretty cheap.
If anyone has a link to the original thread on google I would be greatful -
even better would be a link to a script to read the data from the serial
port. From what I can see a perl agi script to read the cli from a file
should be pretty straight forward. My prob is how to get the cli info into
the file in the first place.

Jon

_______________________________________________
Asterisk-Users mailing list
Asterisk-Users at lists.digium.com
http://lists.digium.com/mailman/listinfo/asterisk-users
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users
-------------- next part --------------
Asterisk and UK Caller ID

(571 total words in this text)
(58 reads)   



Unfortunately, BT does not use the standard bellcore method for transmitting caller ID information which means that Asterisk (or more specifically, the X100P interface card) can't detect it. 
There is a way round this of course, and that is to use a modem that supports BT CID information, and read this off the serial port. I've managed to get an old Pace modem working quite well, along with a couple of perl scripts. Unfortunately Pace went out of business in 1999, so the only place I've found to get hold of these modems is Ebay, where you can expect to pay around 20 pounds for one. 



--------------------------------------------------------------------------------
Once you have a working modem and have turned caller ID on on it (AT#CID=1 on my Pace modem) you can integrate this with Asterisk. I've used two perl scripts, (provided on the Asterisk-dev mailing list by Jonathan McHarg, edited by me) to collect and process the CID info. The first script runs constantly in the background, listening to the modem port for any line that begins NMBR and grabbing the number it displays. 
#!/usr/bin/perl
$PortName = "/dev/tts/0";
$PortObj =  open(MODEM,$PortName) || die "Can't open $PortName:$!";
print MODEM "AT S7=45 S0=0 L1 V1 X4 &c1 E1 Q0 #CID=1";
while (1==1) {
  local $/ = "\n";
  while ($line=) {
    chomp;
    if ( $line =~ s/NMBR = //) {
      open(OUTFILE, ">/usr/share/cid/callerid.txt") or die "Can't open callerid.txt: $!";
      $line =~ s/^M//; # Strip off any carriage return chars
      $line =~ s/\n//; # Strip off any line feeds
                         # The output must only contain a single line.
      print OUTFILE "$line";
      close OUTFILE;
    };
  }
}

The second script is run using AGI in the extensions.conf file whenever an incoming call is detected and simply sets the CID information. My version also looks the number up in the database and adds the name of the calling party if known. 


#!/usr/bin/perl

use DBI;

open(INFILE, "/usr/share/cid/callerid.txt") or die "cannot open file";
if ($callerID=) {
  my $dbh = DBI->connect ("dbi:mysql:host=alice:database=asterisk","asterisk","password") or die "Can't connect to database: $DBI::errstr
";
  my $sth = $dbh->prepare( "SELECT cid FROM known_numbers WHERE source='$callerID'" );
  $sth->execute();
  @row = $sth->fetchrow_array();
  print "SET CALLERID "@row"<$callerID>";
}
close INFILE;

To run this script, change the s extension in the default config to look something like: 

exten=> s,1,agi,/var/scratch/cid/getcid.pl
exten=>s,2,Dial(extensions to ring)

Now, whenever someone rings, the CID info will be processed by asterisk. 


--------------------------------------------------------------------------------
Notes: 
NB. You must have CID activated on your line! 
I had some problems with the modem not activating the CID mode. In the end I simply used minicom to access the modem, issued the AT#CID=1 command, followed by AT&W to save the current config. 
To use with a database on numbers, just create a table in a database with two columns; source and cid and populate them with a list of numbers. To not use the database just remove all the database commands from the script (including the use DBI; line) 
For more information on CID, check out: CID FAQ 
In the UK, it is best to turn off the caller ID in zapata.conf by adding a line usecallerid=no to the incoming channel. This makes asterisk pick the call up quicker. 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: getcid.pl
Type: application/octet-stream
Size: 453 bytes
Desc: not available
Url : http://lists.digium.com/pipermail/asterisk-users/attachments/20040503/265326e0/getcid.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: getcli.pl
Type: application/octet-stream
Size: 598 bytes
Desc: not available
Url : http://lists.digium.com/pipermail/asterisk-users/attachments/20040503/265326e0/getcli.obj


More information about the asterisk-users mailing list