UK BT POTS on Digium TDM800 no CallerID

We’ve set up our Digium TDM800 with 4 FXO and 4FXS ports onto BT POTS lines but we can’t get external calls showing up with CallerID. They work but no go on the callerid I’ve tried a few fixes posted around on the forums and the net but to no avail.

Our first system setup so if you see any other glaringly obvious errors in the configs please let us know.

/etc/asterisk/extensions.conf

[code];!
;! Automatically generated configuration file
;! Filename: extensions.conf (/etc/asterisk/extensions.conf)
;! Generator: Manager
;! Creation Date: Fri Feb 10 18:18:33 2012
;!
; extensions.conf - the Asterisk dial plan
;
; Static extension configuration file, used by
; the pbx_config module. This is where you configure all your
; inbound and outbound calls in Asterisk.
;
; This configuration file is reloaded
; - With the “dialplan reload” command in the CLI
; - With the “reload” command (that reloads everything) in the CLI

;
; The “General” category is for certain variables.
;
[general]
static = yes
writeprotect = no
clearglobalvars = no

format = wav
serveremail =
attach = yes
mailcmd = /usr/sbin/sendmailmp3

[globals]
CONSOLE=DAHDI/1
TRUNK = DAHDI/G2 ; Trunk interface
TRUNKMSD = 1 ; MSD digits to strip (usually 1 or 0)
FEATURES =
DIALOPTIONS = kKTt
RINGTIME = 20
FOLLOWMEOPTIONS =
PAGING_HEADER = Intercom

trunk_1 = DAHDI/g1
trunk_2 = DAHDI/g2
trunk_3 = DAHDI/g3
trunk_4 = DAHDI/g4

group_1 = DAHDI/g1
group_2 = DAHDI/g2
group_3 = DAHDI/g3
group_4 = DAHDI/g4

timeinterval_Working-Hours = 09:00-17:30,mon-fri,,
timeinterval_OOHMorning = 00:01-08:59,mon-fri,,
timeinterval_OOHEvening = 17:31-23:59,mon-fri,,
timeinterval_Weekend = ,sat-sun,,*
timeinterval_ALL = ,mon-sun,,*
CID_trunk_1 =
CID_trunk_2 =
CID_trunk_3 =
CID_trunk_4 =

[ringgroups]
exten = 1401,1,Goto(ringroups-custom-2,s,1)
exten = 1400,1,Goto(ringroups-custom-1,s,1)
exten = 1403,1,Goto(ringroups-custom-4,s,1)
exten = 1402,1,Goto(ringroups-custom-3,s,1)

[voicemenus]
exten = 1998,1,Goto(voicemenu-custom-2,s,1)
exten = 1999,1,Goto(voicemenu-custom-3,s,1)
exten = 1998,1,Goto(voicemenu-custom-2,s,1)
exten = 1998,1,Goto(voicemenu-custom-2,s,1)
exten = 1999,1,Goto(voicemenu-custom-3,s,1)
exten = 1998,1,Goto(voicemenu-custom-2,s,1)
exten = 1998,1,Goto(voicemenu-custom-2,s,1)
exten = 1999,1,Goto(voicemenu-custom-3,s,1)
exten = 1998,1,Goto(voicemenu-custom-2,s,1)

[voicemailgroups]
[directory]
exten = 2500,1,Directory(default,default,ef)

[asterisk_guitools]
exten = executecommand,1,System(${command})
exten = executecommand,n,Hangup()
exten = record_vmenu,1,Answer
exten = record_vmenu,n,Playback(vm-intro)
exten = record_vmenu,n,Record(${var1},0,500,k)
exten = record_vmenu,n,Playback(vm-saved)
exten = record_vmenu,n,Playback(vm-goodbye)
exten = record_vmenu,n,Hangup
exten = play_file,1,Answer
exten = play_file,n,Playback(${var1})
exten = play_file,n,Hangup

[macro-local-callingrule-cid-0.1]
exten = s,1,Set(CALLERID(all)=${IF($[${LEN(${ARG4})} > 2]?${ARG4}:)})
exten = s,n,Goto(${ARG1},${ARG2},${ARG3})

[macro-trunkdial-failover-0.3]
exten = s,1,GotoIf($[${LEN(${FMCIDNUM})} > 6]?1-fmsetcid,1)
exten = s,n,GotoIf($[${LEN(${GLOBAL_OUTBOUNDCIDNAME})} > 1]?1-setgbobname,1)
exten = s,n,Set(CALLERID(num)=${IF($[${LEN(${CID_${CALLERID(num)}})} > 2]?${CID_${CALLERID(num)}}:)})
exten = s,n,Set(CALLERID(all)=${IF($[${LEN(${ARG5})} > 2]?${ARG5}:)})
exten = s,n,GotoIf($[${LEN(${CALLERID(num)})} > 6]?1-dial,1)
exten = s,n,Set(CALLERID(all)=${IF($[${LEN(${CID_${ARG3}})} > 6]?${CID_${ARG3}}:${GLOBAL_OUTBOUNDCID})})
exten = s,n,Set(CALLERID(all)=${IF($[${LEN(${ARG5})} > 2]?${ARG5}:)})
exten = s,n,Goto(1-dial,1)
exten = 1-setgbobname,1,Set(CALLERID(name)=${GLOBAL_OUTBOUNDCIDNAME})
exten = 1-setgbobname,n,Goto(s,3)
exten = 1-fmsetcid,1,Set(CALLERID(num)=${FMCIDNUM})
exten = 1-fmsetcid,n,Set(CALLERID(name)=${FMCIDNAME})
exten = 1-fmsetcid,n,Goto(s,4)
exten = 1-dial,1,Dial(${ARG1})
exten = 1-dial,n,Gotoif(${LEN(${ARG2})} > 0 ?1-${DIALSTATUS},1:1-out,1)
exten = 1-CHANUNAVAIL,1,Dial(${ARG2})
exten = 1-CHANUNAVAIL,n,Hangup()
exten = 1-CONGESTION,1,Dial(${ARG2})
exten = 1-CONGESTION,n,Hangup()
exten = 1-out,1,Hangup()

[DID_trunk_1]
include = parkedcalls
include = DID_trunk_1_timeinterval_ALL,${timeinterval_ALL}
include = DID_trunk_1_timeinterval_Weekend,${timeinterval_Weekend}
include = DID_trunk_1_timeinterval_OOHEvening,${timeinterval_OOHEvening}
include = DID_trunk_1_timeinterval_OOHMorning,${timeinterval_OOHMorning}
include = DID_trunk_1_timeinterval_Working-Hours,${timeinterval_Working-Hours}
include = DID_trunk_1_default
[DID_trunk_1_default]

[DID_trunk_2]
include = parkedcalls
include = DID_trunk_2_timeinterval_Weekend,${timeinterval_Weekend}
include = DID_trunk_2_timeinterval_OOHMorning,${timeinterval_OOHMorning}
include = DID_trunk_2_timeinterval_OOHEvening,${timeinterval_OOHEvening}
include = DID_trunk_2_timeinterval_Working-Hours,${timeinterval_Working-Hours}
include = DID_trunk_2_default
[DID_trunk_2_default]

[DID_trunk_3]
include = parkedcalls
include = DID_trunk_3_timeinterval_Weekend,${timeinterval_Weekend}
include = DID_trunk_3_timeinterval_OOHEvening,${timeinterval_OOHEvening}
include = DID_trunk_3_timeinterval_OOHMorning,${timeinterval_OOHMorning}
include = DID_trunk_3_timeinterval_Working-Hours,${timeinterval_Working-Hours}
include = DID_trunk_3_default
[DID_trunk_3_default]

[DID_trunk_4]
include = parkedcalls
include = DID_trunk_4_timeinterval_Weekend,${timeinterval_Weekend}
include = DID_trunk_4_timeinterval_OOHEvening,${timeinterval_OOHEvening}
include = DID_trunk_4_timeinterval_OOHMorning,${timeinterval_OOHMorning}
include = DID_trunk_4_timeinterval_Working-Hours,${timeinterval_Working-Hours}
include = DID_trunk_4_default
[DID_trunk_4_default]

[DID_trunk_1_timeinterval_Working-Hours]
exten = s,1,ExecIf($[ “${CALLERID(num)}”="" ]?Set(CALLERID(all)=unknown <0000000>))
exten = s,2,Goto(voicemenu-custom-2,s,1)

[DID_trunk_2_timeinterval_Working-Hours]
exten = s,1,ExecIf($[ “${CALLERID(num)}”="" ]?Set(CALLERID(all)=unknown <0000000>))
exten = s,2,Goto(voicemenu-custom-2,s,1)

[DID_trunk_3_timeinterval_Working-Hours]

[DID_trunk_4_timeinterval_Working-Hours]

[ringroups-custom-2]
exten = s,1,NoOp(gr1)
exten = s,n,Dial(DAHDI/6&DAHDI/5,30,${DIALOPTIONS}i)
exten = s,n,Goto(voicemenu-custom-2,s,1)

[ringroups-custom-1]
exten = s,1,NoOp(gr0)
exten = s,n,Dial(DAHDI/5&DAHDI/6&DAHDI/7&DAHDI/8,30,${DIALOPTIONS}i)
exten = s,n,Goto(voicemenu-custom-2,s,1)

[ringroups-custom-4]
exten = s,1,NoOp(gr3)
exten = s,n,Dial(DAHDI/6,30,${DIALOPTIONS}i)
exten = s,n,Dial(DAHDI/5,30,${DIALOPTIONS}i)
exten = s,n,Goto(voicemenu-custom-2,s,1)

[ringroups-custom-3]
exten = s,1,NoOp(gr2)
exten = s,n,Dial(DAHDI/5,30,${DIALOPTIONS}i)
exten = s,n,Dial(DAHDI/6,30,${DIALOPTIONS}i)
exten = s,n,Goto(voicemenu-custom-2,s,1)

[macro-stdexten]
exten = s,1,Set(_DYNAMIC_FEATURES=${FEATURES})
exten = s,2,Set(ORIG_ARG1=${ARG1})
exten = s,3,GotoIf($["${FOLLOWME
${ARG1}}" = “1”]?6:4)
exten = s,4,Dial(${ARG2},${RINGTIME},${DIALOPTIONS})
exten = s,5,Goto(s-${DIALSTATUS},1)
exten = s,6,Macro(stdexten-followme,${ARG1},${ARG2})
exten = s-NOANSWER,1,Voicemail(${ORIG_ARG1},u)
exten = s-NOANSWER,2,Goto(default,s,1)
exten = s-BUSY,1,Voicemail(${ORIG_ARG1},b)
exten = s-BUSY,2,Goto(default,s,1)
exten = _s-.,1,Goto(s-NOANSWER,1)
exten = a,1,VoicemailMain(${ORIG_ARG1})

[DID_trunk_1_timeinterval_OOHMorning]
exten = s,1,ExecIf($[ “${CALLERID(num)}”="" ]?Set(CALLERID(all)=unknown <0000000>))
exten = s,2,Goto(voicemenu-custom-5,s,1)

[DID_trunk_2_timeinterval_OOHEvening]
exten = s,1,ExecIf($[ “${CALLERID(num)}”="" ]?Set(CALLERID(all)=unknown <0000000>))
exten = s,2,Goto(voicemenu-custom-5,s,1)

[DID_trunk_1_timeinterval_OOHEvening]
exten = s,1,ExecIf($[ “${CALLERID(num)}”="" ]?Set(CALLERID(all)=unknown <0000000>))
exten = s,2,Goto(voicemenu-custom-5,s,1)

[DID_trunk_2_timeinterval_OOHMorning]
exten = s,1,ExecIf($[ “${CALLERID(num)}”="" ]?Set(CALLERID(all)=unknown <0000000>))
exten = s,2,Goto(voicemenu-custom-5,s,1)

[DID_trunk_3_timeinterval_OOHMorning]

[DID_trunk_3_timeinterval_OOHEvening]

[DID_trunk_4_timeinterval_OOHMorning]

[DID_trunk_4_timeinterval_OOHEvening]

[DID_trunk_1_timeinterval_Weekend]
exten = s,1,ExecIf($[ “${CALLERID(num)}”="" ]?Set(CALLERID(all)=unknown <0000000>))
exten = s,2,Goto(voicemenu-custom-5,s,1)

[DID_trunk_2_timeinterval_Weekend]
exten = s,1,ExecIf($[ “${CALLERID(num)}”="" ]?Set(CALLERID(all)=unknown <0000000>))
exten = s,2,Goto(voicemenu-custom-5,s,1)

[DID_trunk_3_timeinterval_Weekend]

[DID_trunk_4_timeinterval_Weekend]

[DID_trunk_1_timeinterval_ALL]

[DLPN_DialPlan1]
include = CallingRule_999
include = CallingRule_Freephone0500
include = CallingRule_Freephone0800-10
include = CallingRule_Freephone0800-11
include = CallingRule_UK01
include = CallingRule_UK02
include = CallingRule_Local
include = CallingRule_Mobiles
include = default
include = parkedcalls
include = conferences
include = ringgroups
include = voicemenus
include = queues
include = voicemailgroups
include = directory
include = pagegroups
include = page_an_extension

[CallingRule_Mobiles]
exten = _07XXXXXXXXX,1,Macro(trunkdial-failover-0.3,${group_1}/9${EXTEN:0},${group_2}/9${EXTEN:0},trunk_2,trunk_1)

[CallingRule_999]
exten = _999,1,Macro(trunkdial-failover-0.3,${group_1}/9${EXTEN:0},${group_2}/9${EXTEN:0},trunk_2,trunk_1)

[CallingRule_Freephone0500]
exten = _05XXXXXXXX,1,Macro(trunkdial-failover-0.3,${group_1}/9${EXTEN:0},${group_2}/9${EXTEN:0},trunk_2,trunk_1)

[CallingRule_Freephone0800-11]
exten = _08XXXXXXXXX,1,Macro(trunkdial-failover-0.3,${group_1}/9${EXTEN:0},${group_2}/9${EXTEN:0},trunk_2,trunk_1)

[CallingRule_Freephone0800-10]
exten = _08XXXXXXXX,1,Macro(trunkdial-failover-0.3,${group_1}/9${EXTEN:0},${group_2}/9${EXTEN:0},trunk_2,trunk_1)

[CallingRule_UK01]
exten = _01XXXXXXXXX,1,Macro(trunkdial-failover-0.3,${group_1}/9${EXTEN:0},${group_2}/9${EXTEN:0},trunk_2,trunk_1)

[CallingRule_UK02]
exten = _02XXXXXXXXX,1,Macro(trunkdial-failover-0.3,${group_1}/9${EXTEN:0},${group_2}/9${EXTEN:0},trunk_2,trunk_1)

[CallingRule_Local]
exten = _[5-9]XXXXX,1,Macro(trunkdial-failover-0.3,${group_1}/9${EXTEN:0},${group_2}/9${EXTEN:0},trunk_2,trunk_1)

[default]

exten = _#1XXX,1,Set(MBOX=${EXTEN:1}@default)
exten = _#1XXX,n,VoiceMail(${MBOX})
exten = a,1,VoicemailMain(${MBOX})
exten = 2001,1,VoiceMailMain(${CALLERID(num)}@default)

[voicemenu-custom-1]
exten = s,1,NoOp(Christmas)
exten = s,2,Background(Christmas)

[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(DAHDI/1,90,190,o) ;dial DECT base via analog interface the “o” flag push the CID as received

[voicemenu-custom-5]
include = default
exten = s,1,NoOp(ooh)
exten = s,2,Background(ooh)
exten = s,3,WaitExten(30)
exten = s,4,Hangup()
exten = 0,1,Goto(voicemenu-custom-5,s,1)
exten = 1,1,Goto(voicemenu-custom-5,s,1)
exten = 2,1,Goto(voicemenu-custom-5,s,1)
exten = 3,1,Goto(voicemenu-custom-5,s,1)
exten = 4,1,Goto(voicemenu-custom-5,s,1)
exten = 5,1,Goto(voicemenu-custom-5,s,1)
exten = 6,1,Goto(voicemenu-custom-5,s,1)
exten = 7,1,Goto(voicemenu-custom-5,s,1)
exten = 8,1,Goto(voicemenu-custom-5,s,1)
exten = 9,1,Goto(voicemenu-custom-5,s,1)
exten = *,1,Goto(voicemenu-custom-5,s,1)
exten = #,1,Goto(voicemenu-custom-5,s,1)
exten = t,1,Goto(voicemenu-custom-5,s,1)
exten = i,1,Goto(voicemenu-custom-5,s,1)
[voicemenu-custom-3]
include = default
exten = s,1,NoOp(noanswer)
exten = s,2,Playback(noanswer)
exten = s,3,Background(mainmenu)
exten = s,4,Goto(ringroups-custom-1,s,1)
exten = s,5,Hangup()
exten = 0,1,Goto(voicemenu-custom-2,s,1)
exten = 1,1,Goto(ringroups-custom-2,s,1)
exten = 2,1,Goto(ringroups-custom-3,s,1)
exten = 3,1,Goto(ringroups-custom-4,s,1)
exten = 4,1,Goto(voicemenu-custom-2,s,1)
exten = 5,1,Goto(voicemenu-custom-2,s,1)
exten = 6,1,Goto(voicemenu-custom-2,s,1)
exten = 7,1,Goto(voicemenu-custom-2,s,1)
exten = 8,1,Goto(voicemenu-custom-2,s,1)
exten = 9,1,Goto(voicemenu-custom-2,s,1)
exten = *,1,Voicemail(1001,u)
exten = #,1,Goto(default,1001,1)
exten = t,1,Goto(voicemenu-custom-2,s,1)
exten = i,1,Goto(voicemenu-custom-2,s,1)
[voicemenu-custom-2]
include = default
exten = s,1,NoOp(mainmenu)
exten = s,2,Background(mainmenu)
exten = s,3,WaitExten(15)
exten = s,4,Background(mainmenu)
exten = s,5,WaitExten(15)
exten = s,6,HangUp()
exten = 0,1,Goto(voicemenu-custom-2,s,1)
exten = 1,1,Goto(ringroups-custom-2,s,1)
exten = 2,1,Goto(ringroups-custom-3,s,1)
exten = 3,1,Goto(ringroups-custom-4,s,1)
exten = 4,1,Goto(voicemenu-custom-2,s,1)
exten = 5,1,Goto(voicemenu-custom-2,s,1)
exten = 6,1,Goto(voicemenu-custom-2,s,1)
exten = 7,1,Goto(voicemenu-custom-2,s,1)
exten = 8,1,Goto(voicemenu-custom-2,s,1)
exten = 9,1,Goto(voicemenu-custom-2,s,1)
exten = *,1,Voicemail(1001,u)
exten = #,1,Goto(default,1001,1)
exten = t,1,Goto(voicemenu-custom-2,s,1)
exten = i,1,Goto(voicemenu-custom-2,s,1)[/code]

/etc/asterisk/chan_dahdi.conf

[code];
; DAHDI Telephony Configuration file
;
; You need to restart Asterisk to re-configure the DAHDI channel
; CLI> module reload chan_dahdi.so
; will reload the configuration file, but not all configuration options
; are re-configured during a reload (signalling, as well as PRI and
; SS7-related settings cannot be changed on a reload).
;
; This file documents many configuration variables. Normally unless you know
; what a variable means or that it should be changed, there’s no reason to
; un-comment those lines.
;
; Examples below that are commented out (those lines that begin with a ‘;’ but
; no space afterwards) typically show a value that is not the default value,
; but would make sense under certain circumstances. The default values are
; usually sane. Thus you should typically not touch them unless you know what
; they mean or you know you should change them.

[channels]
progzone=uk
signalling=fxs_ks
callerid=asreceived
cidsignalling=v23
cidstart=polarity
sendcalleridafter=2
answeronpolarityswitch=no

relaxdtmf=yes
hidecallerid=no
usecallerid=yes
callwaiting=yes
usecallingpres=yes
callwaitingcallerid=yes
threewaycalling=yes
transfer=yes
canpark=yes
cancallforward=yes
callreturn=yes
echocancel=yes
echocancelwhenbridged=yes
group=1
callgroup=1
pickupgroup=1
;busydetect=yes
;busycount=3
;busypattern=250,250
immediate=yes;
; DAHDI Telephony Configuration file
;
; You need to restart Asterisk to re-configure the DAHDI channel
; CLI> module reload chan_dahdi.so
; will reload the configuration file, but not all configuration options
; are re-configured during a reload (signalling, as well as PRI and
; SS7-related settings cannot be changed on a reload).
;
; This file documents many configuration variables. Normally unless you know
; what a variable means or that it should be changed, there’s no reason to
; un-comment those lines.
;
; Examples below that are commented out (those lines that begin with a ‘;’ but
; no space afterwards) typically show a value that is not the default value,
; but would make sense under certain circumstances. The default values are
; usually sane. Thus you should typically not touch them unless you know what
; they mean or you know you should change them.

[channels]
progzone=uk
signalling=fxs_ks
callerid=asreceived
cidsignalling=v23
cidstart=polarity
sendcalleridafter=2
answeronpolarityswitch=no

relaxdtmf=yes
hidecallerid=no
usecallerid=yes
callwaiting=yes
usecallingpres=yes
callwaitingcallerid=yes
threewaycalling=yes
transfer=yes
canpark=yes
cancallforward=yes
callreturn=yes
echocancel=yes
echocancelwhenbridged=yes
group=1
callgroup=1
pickupgroup=1
;busydetect=yes
;busycount=3
;busypattern=250,250
immediate=yes[/code]

/etc/dahdi/system.conf

fxsks = 1,2,3,4 fxoks = 5,6,7,8 loadzone = uk defaultzone = uk