login | register
Thu 08 of Jan, 2009 [22:49 UTC]

voip-info.org

Discuss [11] History

Asterisk and UK Caller ID

Created by: drbob,Last modification on Wed 30 of Aug, 2006 [09:32 UTC] by tzafrir

Getting it to work with a TDM400 for incoming call from BT line and internal analogue phone on UK phones


To get callerid to work with the TDM400 you have to add a few options to the zapata.conf, These are,

; in the global section
usecallerid=yes
cidsignalling=v23 ; Added for UK CLI detection
cidstart=polarity ; Added for UK CLI detection

For your incoming BT line connected to an FXO module (red)

signalling=fxs_ks
callerid=asreceived ; propagate the CID received from BT

for your internal analogue phone lines connected to an FSX module (green)

signalling=fxo_ks
sendcalleridafter=2 ; the hidden option given by Slav from Digium
callerid="Dominique DECT"<621> ; the CID that any call make from this line will pushed to other phone


In your file extension.conf I advise you to add a debug statment which will help you to see from your asterisk log if you receive the CID
You need to add the "o" flag in the Dial command to push the CID

incoming ; I assume that incoming call are routed to the incoming context.
exten => s,1,Verbose(Incoming call from BT line — CallerID=${CALLERID}) ; add a debug line with the received CID on asterisk console
exten => s,n,Dial(Zap/1,90,190,o) ;dial DECT base via analog interface the "o" flag push the CID as received



Latest Update

The CVS has been patched to facilitate various non-US caller ID standards including UK CID. However, Mark will not add the specific support for the X100P as "adds otherwise needless bloat to the zaptel side". Ho hum. You must either use a TDM400 with FXO module or use a patch against the latest CVS. This is available from Kevin Walsh ( kevin .at. cursor .dot. biz ). Patches written by Marc McLaughlin for v1.0 are also available and can be downloaded from LUSYN's website.

Update

A patch has just been submitted which allows the digium x100p analog line cards to receive UK caller id! It may take a little while before this patch gets included in asterisk but if you need the feature now, it can be done. The patch was designed for cvs head as of late May 2004, YMMV on other versions.

The patch

Announcement of patch on mailing list

Asrterisk/zaptel debs, currently with UK Caller ID patch, for Debian/Sarge



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.

{CODE()}
  1. !/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;
  };
}
}
{CODE}
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.

{CODE()}
  1. !/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;
{CODE}
To run this script, change the s extension in the default config to look something like:
{CODE()}
exten => s,1,agi,/var/scratch/cid/getcid.pl
exten => s,2,Dial(extensions to ring)
{CODE}
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.
  • Non-BT lines in the UK (eg cable company lines) may use another (partially bellcore compatible) standard - see here.

See also:

Comments

Comments Filter
222

333Patch to fix intermittent CID detection

by kingmob, Wednesday 26 of September, 2007 [12:11:14 UTC]
I've been having problems getting CallerID to be recognised on my TDM400P.

I tried paying with the gain, but it made no difference.

The patch here solved all my detection problems.

To quote the post:

Some UK BT lines seem to be able to trigger a false ring on the tdm400p at exactly 380ms after the CID starts. This results in * giving up on the CID and going into a fallback state where it just gets on with the call
222

333Caller ID is still not showing up always on Sangoma A200

by HarvSki, Wednesday 27 of December, 2006 [10:36:11 UTC]
Thanks Martin, turning up the gain worked for me on a Sangoma A200 card, here is my working zapata.conf for the Sangoma

cidsignalling=v23
cidstart=polarity
callerid=asreceived
usecallerid = yes
;For your incoming BT line connected to an FXO module (red)
immediate=yes ; will take the line on the first ring
context = from-zaptel
;switchtype = national  
echocancel = yes
echocancelwhenbridged = yes
echotraining = yes
;add the is option if you are problems with DTMF detection
;relaxdtmf = yes 
rxgain = 6.0
txgain = 6.0
signalling = fxs_ks
group = 0
channel => 1-2 
language=en
callgroup=1

222

333Caller ID is still not showing up?

by nothinman, Friday 23 of June, 2006 [11:39:21 UTC]
Sometimes you're getting CID, sometimes not. The reason is simple, but I was trying to resolve this issue for a couple of days now...
Anyway. The problem seems to be line quality, or actually attenuation.

If it still doesn't work for you try to modify zapata.conf adding following lines:

rxgain=15.0
txgain=5.0

Depending on your line length, quality and many other things you basically have to try different rxgain parameters. If it's too high it won't accept DTMF tones. If it's too low CID won't work.
I suggest you start with 5 and try to increase it by 5... so 5, 10, 15 and so on.

Good luck,
Martin
222

333UK Caller ID on X100P

by avrono, Monday 27 of March, 2006 [13:40:31 UTC]
Hi Can anyone help me ?

I have asterisk 1.2.5 running with the UK Caller ID patch. I have Caller ID enabled on my phone line.

My Zapata.conf :

channels
usecallerid=yes
ukcallerid=yes
cidsignalling=v23
cidstart=usehist
signalling=fxs_ks
language=en
context=test
channel => 1

I am getting the following error when running asterisk and making a call

Mar 27 14:13:12 DEBUG7521: chan_zap.c:5829 ss_thread: Using history buffer to extract caller ID
Mar 27 14:13:12 ERROR7521: chan_zap.c:5837 ss_thread: zt_get_history failed: Inappropriate ioctl for device
   — Executing Wait("Zap/1-1", "10") in new stack
Mar 27 14:13:12 DEBUG7521: chan_zap.c:4364 __zt_exception: Exception on 20, channel 1
Mar 27 14:13:12 DEBUG7521: chan_zap.c:3547 zt_handle_event: Got event Ring/Answered(2) on channel 1 (index 0)
Mar 27 14:13:12 DEBUG7521: chan_zap.c:3899 zt_handle_event: Setting IDLE polarity due to ring. Old polarity was 0
......

Any ideas on what I need to do to get CallerID working correctly ?

Thanks Avron
222

333UK Ring vs. UK Caller ID with Zap

by Guernseypilot, Tuesday 03 of January, 2006 [11:06:18 UTC]
Possible response for Phil below also;

I have a TDM400P and have successfully implemented caller id using the lines shown at the top of this page.

However, I wanted to go one step further and change the ring type to UK, following instructions elsewhere on this site I changed the defaultzone and loadzone in zaptel.conf from US to UK. Sure enough the phones then rang with the UK style double ring but caller ID was lost...

Is there some sort of compatibility issue here, anyone know of a way around this?

Thanks...Jason.
222

333

by tmp, Monday 28 of November, 2005 [22:45:51 UTC]
If you are using BT then these are the settings that I am using


in zapata.conf

usecallerid=yes
add below this line the following
ukcallerid=yes


222

333Trouble with TDM400P and UK CLID...

by phil_hodges, Tuesday 15 of November, 2005 [15:28:31 UTC]
Can anyone help... I'm just in the middle of setting up an Asterisk box with 4 pots lines going through a TDM400P... I'm having a little trouble getting the CLID to work... I have looked through pages of data, some of which contradicts... The CLID seems to be working intermittently, some calls it will pick it up, others nothing... Also since I have added the CLID settings into the zapata.conf file the sound quality have been reduced... I had the sound levels and echo ironed out but now it is clipping and stuttering all the time... Any ideas?? (please find my zapata.conf settings bellow)

Kind regards,
Phil Hodges

Zapata.conf

channels
language=en
context=landlines
signalling=fxs_ks
usecallerid=yes
cidsignalling=v23
cidstart=polarity
callerid=asreceived
immediate=yes
echotraining=yes
echocancel=yes
echocancelwhenbridged=yes
musiconhold=default
group=1,2,3,4
pickupgroup=1,2,3,4
rxgain=9.0
txgain=7.0
channel => 1-4

222

333Trouble with TDM400P and UK CLID...

by phil_hodges, Tuesday 15 of November, 2005 [14:29:37 UTC]
Can anyone help... I'm just in the middle of setting up an Asterisk box with 4 pots lines going through a TDM400P... I'm having a little trouble getting the CLID to work... I have looked through pages of data, some of which contradicts... The CLID seems to be working intermittently, some calls it will pick it up, others nothing... Also since I have added the CLID settings into the zapata.conf file the sound quality have been reduced... I had the sound levels and echo ironed out but now it is clipping and stuttering all the time... Any ideas?? (please find my zapata.conf settings bellow)

Kind regards,
Phil Hodges

Zapata.conf

channels
language=en
context=landlines
signalling=fxs_ks
usecallerid=yes
cidsignalling=v23
cidstart=polarity
callerid=asreceived
immediate=yes
echotraining=yes
echocancel=yes
echocancelwhenbridged=yes
musiconhold=default
group=1,2,3,4
pickupgroup=1,2,3,4
rxgain=9.0
txgain=7.0
channel => 1-4

222

333Re: Thanks!

by aargent, Thursday 03 of November, 2005 [17:55:21 UTC]
Hello Jon and Quentin, I am also trying to get caller id working with my tdm30b using Telewest. What does the cidstart=ring switch do. I have been told that my 3 lines are connected to a Nortel DMS 100. Caller id is active. Any other advise would be appreciated.

Update - Now resolved, good old Telewest changed type of caller id from "Name and number" to just "number"
222

333Thanks!

by quentinsf, Tuesday 18 of October, 2005 [14:43:35 UTC]
Thanks, Jon - I had tried a whole load of combinations on NTL without success - this is great!

I also had to make sure I had

cidstart=ring

in zapata.conf.