[Dahdi 2.4.0] Flash() hangs up

Hello

I need Asterisk (1.4.39.2) to simulate a flash hook (ie. hitting the "R" key on European handsets) so I can put a call on hold, dial a second number, and set up a three-way, conference call.

By default, linux/include/dahdi/kernel.h sets the flashtime to 750ms, which appears to be too long for European telcos, as they seem to expect a line cut of about 100ms.

After editing the DAHDI_DEFAULT_FLASHTIME accordingly, I recompiled/upgraded Dahdi, and ran the script, but Flash() still hangs up the call. Per Google, I also made sure zapata.conf contained “threewaycalling=yes”, to no avail:

/etc/asterisk/zapata.conf

[trunkgroups]

[channels]
context=from_fxo
switchtype=national
usecallerid=yes
hidecallerid=no
usecallingpres=yes
callwaitingcallerid=no
threewaycalling=yes
transfer=yes
canpark=yes
cancallforward=yes
callreturn=yes

echocancel=yes
;OSLEC
;echocancelwhenbridged=yes
echocancelwhenbridged=no
echotraining=no

rxgain=0.0
txgain=0.0
immediate=no

;IGNORED BY ZAPTEL
;flash=100 ; Flash time ZT_DEFAULT_FLASHTIME 750

callwaiting=yes
busydetect=yes

signalling = fxs_ks
channel => 1

extensions.conf

[from_fxo]
exten => s,1,Wait(2)
exten => s,n,Set(GLOBAL(CID)=${CALLERID(num)})
exten => s,n,Hangup()

;build and mv callfile to spool directory
exten => h,1,system(/var/tmp/test10.lua ${CID}&)

;used by callfile
[callback]
exten => start,1,NoOp(In callback, CID is ${CID})
;how to wait until remote phone picked up?
exten => start,n,Wait(5)
exten => start,n,Answer()
exten => start,n,Playback(please-wait)

;HERE Dahdi hangs up instead of getting a dialtone
exten => start,n,Flash()

exten => start,n,Dial(Dahdi/1/{GSM})
exten => start,n,Wait(5)

exten => start,n,Hangup()

;0 - Failed (not busy or congested)
;1 - Hung up
;3 - Ring timeout
;5 - Busy
;8 - Congestion
exten => failed,1,NoOp(Reason call failed is ${REASON})

Has someone successfully gotten Asterisk/Dahdi to use two-way calling?

Thank you.

Turns out that instead or in addition to the above, SHORT_FLASH_TIME should be uncommented in linux/include/dahdi/dahdi_config.h.

Flash() now works :smile:

However, after putting call #1 on hold, Asterisk is unable to dial the second number:
asterisk/chan_dahdi.conf

[channels]
usecallerid = yes
hidecallerid = no
callwaiting = yes
usecallingpres = yes
callwaitingcallerid = yes
threewaycalling = yes
transfer = yes
canpark = yes
cancallforward = yes
callreturn = yes
echocancel = yes
echocancelwhenbridged = yes
relaxdtmf = yes
rxgain = 0.0
txgain = 0.0
immediate = no
context = from_fxo
signalling = fxs_ks
channel => 1

extensions.conf

[from_fxo]
exten => s,1,Wait(2)
exten => s,n,Set(GLOBAL(CID)=${CALLERID(num)})
exten => s,n,Hangup()

exten => h,1,system(/var/tmp/test10.lua ${CID}&)

[callback]
exten => start,1,NoOp(In callback, CID is ${CID})
;how to wait until remote phone picked up?
exten => start,n,Wait(5)
exten => start,n,Answer()
exten => start,n,Playback(tt-monkeysintro)

exten => start,n,Flash()
exten => start,n,Dial(Dahdi/1/${GSM})
exten => start,n,Wait(5)

exten => start,n,Hangup()

;0 - Failed (not busy or congested)
;1 - Hung up
;3 - Ring timeout
;5 - Busy
;8 - Congestion
exten => failed,1,NoOp(Reason call failed is ${REASON})

centos*CLI>

    -- Starting simple switch on 'DAHDI/1-1'
    -- Executing [s@from_fxo:1] Wait("DAHDI/1-1", "2") in new stack
    -- Executing [s@from_fxo:2] Set("DAHDI/1-1", "GLOBAL(CID)=123456")
in new stack
  == Setting global variable 'CID' to '123456'
    -- Executing [s@from_fxo:3] Hangup("DAHDI/1-1", "") in new stack
  == Spawn extension (from_fxo, s, 3) exited non-zero on 'DAHDI/1-1'
    -- Executing [h@from_fxo:1] System("DAHDI/1-1",
"/var/tmp/test10.lua 123456&") in new stack
    -- Hungup 'DAHDI/1-1'
    -- Attempting call on Dahdi/1/123456 for start@callback:1 (Retry
1)
       > Channel DAHDI/1-1 was answered.
    -- Executing [start@callback:1] NoOp("DAHDI/1-1", "In callback|
CID is 123456") in new stack
    -- Executing [start@callback:2] Wait("DAHDI/1-1", "5") in new
stack
    -- Executing [start@callback:3] Answer("DAHDI/1-1", "") in new
stack
    -- Executing [start@callback:4] Playback("DAHDI/1-1",
"tt-monkeysintro") in new stack
    -- <DAHDI/1-1> Playing 'tt-monkeysintro' (language 'en')
    -- Executing [start@callback:5] Flash("DAHDI/1-1", "") in new
stack
    -- Flashed channel DAHDI/1-1
    -- Executing [start@callback:6] Dial("DAHDI/1-1",
"Dahdi/1/456789") in new stack
[Feb 28 12:46:22] WARNING[9301]: app_dial.c:1310 dial_exec_full:
Unable to create channel of type 'Dahdi' (cause 0 - Unknown)
  == Everyone is busy/congested at this time (1:0/0/1)
    -- Executing [start@callback:7] Wait("DAHDI/1-1", "5") in new
stack

Does someone use three-way calling successfully with Dahdi?

Thank you.

Asterisk is unable to create a second channel when the previous one is still in use. The trick is to use SendDTMF() to dial the second number:

...
exten => start,n,Flash()

exten => start,n,SendDTMF(${SECOND_NUMBER},500)
;how to pause until party has answered?
exten => start,n,Wait(5)

exten => start,n,Flash()
exten => start,n,Wait(1)
;activate conference call
exten => start,n,SendDTMF(3)

However, hard to believe, but Asterisk/Zaptel doesn’t provide call supervision, so there’s no way to tell if/when the callee answered the phone :-/

Asterisk/DAHDI supports answer supervision if your PSTN provider provides it and your FXO card supports it and you enable it in your configuration. That is at least true for line reversal answer supervision.

However, you will have to give the whole number to Dial if you want to use it. I don’t think you will be able to simulate a timed break recall prior to answer, directly from the dialplan. I’m not sure or which network would actually accept TBR pre-answer.

Thanks for the feedback. I tried the following, call supervision-related settings in zapata.conf to make a call through “originate” in the CLI but they either don’t do anything or prevent the script from working (nothing happens):

;/etc/asterisk/zapata.conf
...
busydetect=yes
busycount=4

;USELESS
;progzone=fr

;DON'T USE! US-SPECIFIC
;callprogress=yes

;Doesn't work with ISP/ADSL modem: "originate" calls out but script doesn't run
;answeronpolarityswitch=yes
;hanguponpolarityswitch=yes
;polarityonanswerdelay=1
;polarityevents=yes

Context used by callfile or originate for outgoing call:

[callback]
exten => start,1,NoOp(DialStatus is ${DIALSTATUS})

;how to pause until party has answered?
exten => start,n,Wait(7)

exten => start,n,Playback(tt-monkeysintro)

exten => start,n,NoOp(${CHANNEL(state)})
exten => start,n,NoOp(DialStatus is ${DIALSTATUS})

exten => start,n,Hangup

I guess I’m stuck with just playing a message to the callee for a few seconds (“This is a call from Joe. Please wait while I connect you”) after dialing out the number through SendDTMF.

Considering that development of Zaptel/Dahdi started in 2001 and I guess a lot of SOHO users rely on Digium’s PCI card + FXO module to connect Asterisk to a POTS line, I expected call supervision to be part of the driver by now :confused:

Thank you.

Supervision IS part of the driver, but the Asterisk core assumes that answer will occur in the Dial application.

Nice to know. And unfortunately, the CHANNEL() doesn’t work, as it always returns “Up” even while still receiving the ringback or the remote party has answered:

exten => start,n,Set(INDEX=0)

;Down, Rsrvd, OffHook, Dialing, Ring, Ringing, Up, Busy, Dialing Offhook, Pre-ring, Unknown
exten => start,n,NoOp(${CHANNEL(state)})

BAD exten => start,n,While($["${CHANNEL(state)}" != "Up" & ${INDEX} < 10])
BAD exten => start,n,While($["${CHANNEL(state)}" != "OffHook" & ${INDEX} < 10])
exten => start,n,While($["${CHANNEL(state)}" != "Rsrvd" & ${INDEX} < 10])

exten => start,n,NoOp(Channel still ringing: ${CHANNEL(state)})
exten => start,n,NoOp(DialStatus is ${DIALSTATUS})
exten => start,n,NoOp(INDEX is ${INDEX})
exten => start,n,Wait(1)
exten => start,n,Set(INDEX=$[${INDEX} + 1])

exten => start,n,EndWhile()

exten => start,n,Hangup

I guess the right way to build a robocall is to call out through either a VoIP provider in SIP or through an ISDN line.

Supervision isn’t going to work if answeron… is commented out.

However, I’m not clear that you are testing the right channel, anyway.

It’s commented out because those settings prevent Asterisk/Zaptel from running the script in the callback context. I guess the VoIP in my ADSL modem doesn’t provide polarity switch for answer/hangup, so Asterisk/Zaptel doesn’t detect that the remote answer.

Too bad CHANNEL() only reports “Up”, while I expected something like “Ringing”, followed by “OffHook”, and “Down”.