Solution for dialtone delay

i have successfully installed asterisk server and connected to normal pstn line. But thr is a small problem, because when the asterisk going to pick the pstn line it will get some time to give the dialtone. It various from 5sec to 10 due to exchange congestion. But asterisk dont detect the dial tone before get the channel and dial the number. It just pick the channel and dial the number. But after few second dial tone get feed and it can hear to the other party.

So i need to asterisk to detect the dialtone before dial. Is thr any option that i can do ?

try the hint mentioned in http://www.voip-info.org/wiki/view/Asterisk+ZAP+channels under Analog Dial section.

HTH,
Ioan.

Hi indreias,

Thank you for the reply. According to that explanation i found that thr is a nice way to do this thing with macro. Any way it explained with ZAPTA drivers. But im using DAHDI with asterisk 1.6. I’m curious wether can i use same macro with my dahdi stuff.

Please tell me whr should i put this macro. Thank you.

macro-dialanalog
exten => s,1,NoOp
exten => s,n(clear), Dial(${DIALOUTANALOG}|${ARG2}|M(dialanalogcont^${ARG1}))
exten => s,clear+101, Set(MACRO_OFFSET=100)

macro-dialanalogcont
exten => s,1,NoOp
exten => s,n(silence), WaitForSilence(100)
exten => s,n, GotoIf($"${WAITSTATUS}" = “SILENCE”?silence) ; Loop if silence is detected
exten => s,n(realdial),SendDTMF(${ARG1})
exten => s,n, Goto(end)
exten => s,n(end), Macro(record-on)

from dialplan perspective DAHDI is the same as ZAP - so you should not have any problems on this issue.

in order to understand how to use the macros and the example provided in voip-info wiki you have to understand Asterisk dialplans. I advice to read the free “Asterisk the future of telephony” book, available online.

HTH,
Ioan

HI,

I think You can insert that macro under extentions.conf file.

Hi,

Thx for your reply. I read that book and try to understand the behavior of extentions.conf. Any way i have edited the extentions.conf. But it dosen’t work correctly. I’m not good in programming. Please help me to fix this problem.

Extentions.conf

; dialout using default OUT trunk - no prefix
[macro-dialout-default]
exten => s,1,Macro(user-callerid,SKIPTTL)
exten => s,2,Macro(record-enable,${CALLERID(number)},OUT)
exten => s,3,Macro(outbound-callerid,${ARG1})
exten => s,4,Dial(${OUT}/${ARG1})
exten => s,5,Playtones(congestion)
exten => s,6,Congestion(5)
exten => s,105,Macro(outisbusy)

[macro-dialout-trunk-predial-hook]
; this macro intentionally left blank so it may be safely overwritten for any custom
; requirements that an installation may have.
;
; MACRO RETURN CODE: ${PREDIAL_HOOK_RET}
; if set to “BYPASS” then this trunk will be skipped
;

exten => s,n,macro(dialanalog)

[macro-dialanalog]
exten => s,1,NoOp
exten => s,n(clear), Dial(${DIALOUTANALOG}|${ARG2}|M(dialanalogcont^${ARG1}))
exten => s,clear+101, Set(MACRO_OFFSET=100)

[macro-dialanalogcont]
exten => s,1,NoOp
exten => s,n(silence), WaitForSilence(100)
exten => s,n, GotoIf($"${WAITSTATUS}" = “SILENCE”?silence) ; Loop if silence is detected
exten => s,n(realdial),SendDTMF(${ARG1})
exten => s,n, Goto(end)
exten => s,n(end), Macro(record-on)

; This macro is for dev purposes and just dumps channel/app variables. Useful when designing new contexts.
[macro-dumpvars]

I called that macro under macro-dialout-trunk-predial-hook. Below is the debug message.

Registered SIP ‘100’ at 192.168.1.3 port 22560
== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
– Executing [0772328091@from-internal:1] Macro(“SIP/100-00000000”, “user-callerid,SKIPTTL,”) in new stack
– Executing [s@macro-user-callerid:1] Set(“SIP/100-00000000”, “AMPUSER=100”) in new stack
– Executing [s@macro-user-callerid:2] GotoIf(“SIP/100-00000000”, “0?report”) in new stack
– Executing [s@macro-user-callerid:3] ExecIf(“SIP/100-00000000”, “1?Set(REALCALLERIDNUM=100)”) in new stack
– Executing [s@macro-user-callerid:4] Set(“SIP/100-00000000”, “AMPUSER=100”) in new stack
– Executing [s@macro-user-callerid:5] Set(“SIP/100-00000000”, “AMPUSERCIDNAME=sam”) in new stack
– Executing [s@macro-user-callerid:6] GotoIf(“SIP/100-00000000”, “0?report”) in new stack
– Executing [s@macro-user-callerid:7] Set(“SIP/100-00000000”, “AMPUSERCID=100”) in new stack
– Executing [s@macro-user-callerid:8] Set(“SIP/100-00000000”, “CALLERID(all)=“sam” <100>”) in new stack
– Executing [s@macro-user-callerid:9] GotoIf(“SIP/100-00000000”, “1?continue”) in new stack
– Goto (macro-user-callerid,s,18)
– Executing [s@macro-user-callerid:18] NoOp(“SIP/100-00000000”, “Using CallerID “sam” <100>”) in new stack
– Executing [0772328091@from-internal:2] Set(“SIP/100-00000000”, “_NODEST=”) in new stack
– Executing [0772328091@from-internal:3] Macro(“SIP/100-00000000”, “record-enable,100,OUT,”) in new stack
– Executing [s@macro-record-enable:1] GotoIf(“SIP/100-00000000”, “1?check”) in new stack
– Goto (macro-record-enable,s,4)
– Executing [s@macro-record-enable:4] AGI(“SIP/100-00000000”, “recordingcheck,20100419-080133,1271644293.0”) in new stack
– Launched AGI Script /var/lib/asterisk/agi-bin/recordingcheck
recordingcheck,20100419-080133,1271644293.0: Outbound recording not enabled
– <SIP/100-00000000>AGI Script recordingcheck completed, returning 0
– Executing [s@macro-record-enable:5] MacroExit(“SIP/100-00000000”, “”) in new stack
– Executing [0772328091@from-internal:4] Macro(“SIP/100-00000000”, “dialout-trunk,1,0772328091,”) in new stack
– Executing [s@macro-dialout-trunk:1] Set(“SIP/100-00000000”, “DIAL_TRUNK=1”) in new stack
– Executing [s@macro-dialout-trunk:2] GosubIf(“SIP/100-00000000”, “0?sub-pincheck,s,1”) in new stack
– Executing [s@macro-dialout-trunk:3] GotoIf(“SIP/100-00000000”, “0?disabletrunk,1”) in new stack
– Executing [s@macro-dialout-trunk:4] Set(“SIP/100-00000000”, “DIAL_NUMBER=0772328091”) in new stack
– Executing [s@macro-dialout-trunk:5] Set(“SIP/100-00000000”, “DIAL_TRUNK_OPTIONS=tr”) in new stack
– Executing [s@macro-dialout-trunk:6] Set(“SIP/100-00000000”, “OUTBOUND_GROUP=OUT_1”) in new stack
– Executing [s@macro-dialout-trunk:7] GotoIf(“SIP/100-00000000”, “0?nomax”) in new stack
– Executing [s@macro-dialout-trunk:8] GotoIf(“SIP/100-00000000”, “0?chanfull”) in new stack
– Executing [s@macro-dialout-trunk:9] GotoIf(“SIP/100-00000000”, “0?skipoutcid”) in new stack
– Executing [s@macro-dialout-trunk:10] Set(“SIP/100-00000000”, “DIAL_TRUNK_OPTIONS=”) in new stack
– Executing [s@macro-dialout-trunk:11] Macro(“SIP/100-00000000”, “outbound-callerid,1”) in new stack
– Executing [s@macro-outbound-callerid:1] ExecIf(“SIP/100-00000000”, “0?Set(CALLERPRES()=)”) in new stack
– Executing [s@macro-outbound-callerid:2] ExecIf(“SIP/100-00000000”, “0?Set(REALCALLERIDNUM=100)”) in new stack
– Executing [s@macro-outbound-callerid:3] GotoIf(“SIP/100-00000000”, “1?normcid”) in new stack
– Goto (macro-outbound-callerid,s,6)
– Executing [s@macro-outbound-callerid:6] Set(“SIP/100-00000000”, “USEROUTCID=”) in new stack
– Executing [s@macro-outbound-callerid:7] Set(“SIP/100-00000000”, “EMERGENCYCID=”) in new stack
– Executing [s@macro-outbound-callerid:8] Set(“SIP/100-00000000”, “TRUNKOUTCID=0812222240”) in new stack
– Executing [s@macro-outbound-callerid:9] GotoIf(“SIP/100-00000000”, “1?trunkcid”) in new stack
– Goto (macro-outbound-callerid,s,12)
– Executing [s@macro-outbound-callerid:12] ExecIf(“SIP/100-00000000”, “1?Set(CALLERID(all)=0812222240)”) in new stack
– Executing [s@macro-outbound-callerid:13] ExecIf(“SIP/100-00000000”, “0?Set(CALLERID(all)=)”) in new stack
– Executing [s@macro-outbound-callerid:14] ExecIf(“SIP/100-00000000”, “0?Set(CALLERPRES()=prohib_passed_screen)”) in new stack
– Executing [s@macro-dialout-trunk:12] ExecIf(“SIP/100-00000000”, “1?AGI(fixlocalprefix)”) in new stack
– Launched AGI Script /var/lib/asterisk/agi-bin/fixlocalprefix
== fixlocalprefix: Dialpattern XXXXXXXXXX matched. 0772328091 -> 0772328091
– <SIP/100-00000000>AGI Script fixlocalprefix completed, returning 0
– Executing [s@macro-dialout-trunk:13] Set(“SIP/100-00000000”, “OUTNUM=0772328091”) in new stack
– Executing [s@macro-dialout-trunk:14] Set(“SIP/100-00000000”, “custom=DAHDI/g0”) in new stack
– Executing [s@macro-dialout-trunk:15] ExecIf(“SIP/100-00000000”, “0?Set(DIAL_TRUNK_OPTIONS=M(setmusic^))”) in new stack
– Executing [s@macro-dialout-trunk:16] Macro(“SIP/100-00000000”, “dialout-trunk-predial-hook,”) in new stack
– Executing [s@macro-dialout-trunk-predial-hook:1] Macro(“SIP/100-00000000”, “dialanalog”) in new stack
– Executing [s@macro-dialanalog:1] NoOp(“SIP/100-00000000”, “”) in new stack
– Executing [s@macro-dialanalog:2] Dial(“SIP/100-00000000”, “|0772328091|M(dialanalogcont^)”) in new stack
== Spawn extension (macro-dialanalog, s, 2) exited non-zero on ‘SIP/100-00000000’ in macro ‘dialanalog’
== Spawn extension (macro-dialout-trunk-predial-hook, s, 1) exited non-zero on ‘SIP/100-00000000’ in macro ‘dialout-trunk-predial-hook’
== Spawn extension (macro-dialout-trunk, s, 16) exited non-zero on ‘SIP/100-00000000’ in macro ‘dialout-trunk’
== Spawn extension (from-internal, 0772328091, 4) exited non-zero on ‘SIP/100-00000000’
– Executing [h@from-internal:1] Macro(“SIP/100-00000000”, “hangupcall”) in new stack
– Executing [s@macro-hangupcall:1] GotoIf(“SIP/100-00000000”, “1?skiprg”) in new stack
– Goto (macro-hangupcall,s,4)
– Executing [s@macro-hangupcall:4] GotoIf(“SIP/100-00000000”, “1?skipblkvm”) in new stack
– Goto (macro-hangupcall,s,7)
– Executing [s@macro-hangupcall:7] GotoIf(“SIP/100-00000000”, “1?theend”) in new stack
– Goto (macro-hangupcall,s,9)
– Executing [s@macro-hangupcall:9] Hangup(“SIP/100-00000000”, “”) in new stack
== Spawn extension (macro-hangupcall, s, 9) exited non-zero on ‘SIP/100-00000000’ in macro ‘hangupcall’
== Spawn extension (from-internal, h, 1) exited non-zero on 'SIP/100-00000000’
pbx*CLI>

From the log you have sent you mixed a FreePBX dialplan and your dialplan - and in your case is not a good starting point…

It is better to ask on FreePBX forum how to integrate the hint into a FreePBX dialplan.

My advice is to take another approach and customize [from-internal-custom] context. This context is usually found in extension-custom.conf file. Also please add there the macros in order to have all in the same place.

something like:

[from-internal-custom]
exten => _81X.,1,Set(DIALOUTANALOG=DAHDI/g0)
exten => _81X.,n,Macro(dialanalog,${EXTEN:2},20)

[macro-dialanalog]
exten => s,1,NoOp 
exten => s,n(clear),Dial(${DIALOUTANALOG}|${ARG2}|M(dialanalogcont^${ARG1})) 
exten => s,clear+101,Set(MACRO_OFFSET=100) 
    
[macro-dialanalogcont]
exten => s,1,NoOp
exten => s,n(silence), WaitForSilence(100,1,1) ; Timeout after 1 sec
exten => s,n,GotoIf($["${WAITSTATUS}" = "SILENCE"]?silence) ; Loop if silence is detected
exten => s,n(realdial),SendDTMF(${ARG1})
exten => s,n,Goto(end)

You have to prefix your outgoing call with 81 and the call will go on DAHDI/g0 with a timeout of 20 seconds.

HTH,
Ioan

sorry to forget - please do an asterisk reload (or dialplan reload) in order to have the new dialplan activated

Hi indreias,

i have inserted the mentioned codes to my from-internal-custom config file. After that when i dial a number from sip phone i can hear dialtone on the sip phone. I think something is wrong on the macro. Like it doesn’t dial the number and just hook the channel. After certen period it release it and clear the call.

pbxCLI>
pbx
CLI>
== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
– Executing [810442134564@from-internal:1] Set(“SIP/100-00000002”, “DIALOUTANALOG=DAHDI/g0”) in new stack
– Executing [810442134564@from-internal:2] Macro(“SIP/100-00000002”, “dialanalog,0442134564,3”) in new stack
– Executing [s@macro-dialanalog:1] NoOp(“SIP/100-00000002”, “”) in new stack
– Executing [s@macro-dialanalog:2] Dial(“SIP/100-00000002”, “DAHDI/g0|3|M(dialanalogcont^0442134564)”) in new stack
– Called g0|3|M(dialanalogcont^0442134564)
– DAHDI/2-1 answered SIP/100-00000002
– Hungup ‘DAHDI/2-1’
== Spawn extension (macro-dialanalog, s, 2) exited non-zero on ‘SIP/100-00000002’ in macro ‘dialanalog’
== Spawn extension (from-internal, 810772328091, 2) exited non-zero on ‘SIP/100-00000002’
– Executing [h@from-internal:1] Macro(“SIP/100-00000002”, “hangupcall”) in new stack
– Executing [s@macro-hangupcall:1] GotoIf(“SIP/100-00000002”, “1?skiprg”) in new stack
– Goto (macro-hangupcall,s,4)
– Executing [s@macro-hangupcall:4] GotoIf(“SIP/100-00000002”, “1?skipblkvm”) in new stack
– Goto (macro-hangupcall,s,7)
– Executing [s@macro-hangupcall:7] GotoIf(“SIP/100-00000002”, “1?theend”) in new stack
– Goto (macro-hangupcall,s,9)
– Executing [s@macro-hangupcall:9] Hangup(“SIP/100-00000002”, “”) in new stack
== Spawn extension (macro-hangupcall, s, 9) exited non-zero on ‘SIP/100-00000002’ in macro ‘hangupcall’
== Spawn extension (from-internal, h, 1) exited non-zero on 'SIP/100-00000002’
pbx*CLI>

Thx,

regards,
Sam

Hello Sam,

Something is wrong in your dialplan - please use 20 and not 3. Also I found that the dialanalogcont macro is not called and this is something strange.

Also please check again the dialplan I recommend as I have found a mistake inside it and I correct it.

After reload please try again and in case of a failure just post the log.

HTH,
Ioan

Hi,

Thx for your quick reply. I really appreciate it. I already check with 20. It failed then i tried with 3. Any way i have check with 20 again and post the error log. I think it detect the dial tone. But it doesn’t dial the number,

pbxCLI>
== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
– Executing [810112525277@from-internal:1] Set(“SIP/100-00000001”, “DIALOUTANALOG=DAHDI/g0”) in new stack
– Executing [810112525277@from-internal:2] Macro(“SIP/100-00000001”, “dialanalog,0112525277,20”) in new stack
– Executing [s@macro-dialanalog:1] NoOp(“SIP/100-00000001”, “”) in new stack
– Executing [s@macro-dialanalog:2] Dial(“SIP/100-00000001”, “DAHDI/g0|20|M(dialanalogcont^0112525277)”) in new stack
– Called g0|20|M(dialanalogcont^0112525277)
– DAHDI/2-1 answered SIP/100-00000001
– Hungup ‘DAHDI/2-1’
== Spawn extension (macro-dialanalog, s, 2) exited non-zero on ‘SIP/100-00000001’ in macro ‘dialanalog’
== Spawn extension (from-internal, 810112525277, 2) exited non-zero on ‘SIP/100-00000001’
– Executing [h@from-internal:1] Macro(“SIP/100-00000001”, “hangupcall”) in new stack
– Executing [s@macro-hangupcall:1] GotoIf(“SIP/100-00000001”, “1?skiprg”) in new stack
– Goto (macro-hangupcall,s,4)
– Executing [s@macro-hangupcall:4] GotoIf(“SIP/100-00000001”, “1?skipblkvm”) in new stack
– Goto (macro-hangupcall,s,7)
– Executing [s@macro-hangupcall:7] GotoIf(“SIP/100-00000001”, “1?theend”) in new stack
– Goto (macro-hangupcall,s,9)
– Executing [s@macro-hangupcall:9] Hangup(“SIP/100-00000001”, “”) in new stack
== Spawn extension (macro-hangupcall, s, 9) exited non-zero on ‘SIP/100-00000001’ in macro ‘hangupcall’
== Spawn extension (from-internal, h, 1) exited non-zero on 'SIP/100-00000001’
pbx
CLI>

regards,
Sam

the problem in your case is that is not “jumping” to “macro-dialanalogcont” context.

what is the output of the following command:

Ioan

[quote=“indreias”]the problem in your case is that is not “jumping” to “macro-dialanalogcont” context.

what is the output of the following command:

Ioan[/quote]

Hi,

Thx for the reply. Hear are the macro-dialanalogcont details.

root@pbx:~ $ asterisk -rx “dialplan show macro-dialanalogcont”
[ Context ‘macro-dialanalogcont’ created by ‘pbx_config’ ]
‘s’ => 1. NoOp() [pbx_config]
[silence] 2. WaitForSilence(100,1,1) [pbx_config]
3. GotoIf($["${WAITSTATUS}" = “SILENCE”]?silence) [pbx_config]
[realdial] 4. SendDTMF(${ARG1}) [pbx_config]
5. Goto(end) [pbx_config]

-= 1 extension (5 priorities) in 1 context. =-
root@pbx:~ $

hi ioan,

Any updates ?

Thx lot.

well - because there is no jump to macro-dialanalogcont the number is not dialed using DTMF codes.
in order to understand why is not working well we have to look further into asterisk log (not the CLI log).

thus - please run “asterisk -rx logger rotate” made another call and post Asterisk log (it should be in /var/log/asterisk/full).

the dialplan was tested with a 1.4 Asterisk version and I do not understand why is not good for you.

BR,
Ioan

Thx for your repply.
Did u try this macro already ?
I’m using asterisk 1.6. Below is the requested details.


[root@localhost ~]# cat /var/log/asterisk/full
[Apr 26 15:19:57] VERBOSE[3158] logger.c: Asterisk Event Logger restarted
[Apr 26 15:19:57] VERBOSE[3158] logger.c: Asterisk Queue Logger restarted
[Apr 26 15:19:57] VERBOSE[3158] logger.c: – Remote UNIX connection disconnected
[Apr 26 15:20:01] VERBOSE[2995] logger.c: – Remote UNIX connection
[Apr 26 15:20:07] VERBOSE[3161] logger.c: – Executing [810112222300@from-internal:1] Set(“SIP/100-096275e8”, “DIALOUTANALOG=DAHDI/g0”) in new stack
[Apr 26 15:20:07] VERBOSE[3161] logger.c: – Executing [810112222300@from-internal:2] Macro(“SIP/100-096275e8”, “dialanalog|0112222300|20”) in new stack
[Apr 26 15:20:07] VERBOSE[3161] logger.c: – Executing [s@macro-dialanalog:1] NoOp(“SIP/100-096275e8”, “”) in new stack
[Apr 26 15:20:07] DEBUG[3161] app_macro.c: Executed application: NoOp
[Apr 26 15:20:07] VERBOSE[3161] logger.c: – Executing [s@macro-dialanalog:2] Dial(“SIP/100-096275e8”, “DAHDI/g0|20|M(dialanalogcont^0112222300)”) in new stack
[Apr 26 15:20:07] DEBUG[3161] chan_dahdi.c: Dialing ‘’
[Apr 26 15:20:07] DEBUG[3161] chan_dahdi.c: Deferring dialing…
[Apr 26 15:20:07] VERBOSE[3161] logger.c: – Called g0
[Apr 26 15:20:07] DEBUG[3161] chan_dahdi.c: Sent deferred digit string: Tw
[Apr 26 15:20:15] VERBOSE[3161] logger.c: – Hungup ‘DAHDI/5-1’
[Apr 26 15:20:15] VERBOSE[3161] logger.c: == Spawn extension (macro-dialanalog, s, 2) exited non-zero on ‘SIP/100-096275e8’ in macro ‘dialanalog’
[Apr 26 15:20:15] VERBOSE[3161] logger.c: == Spawn extension (from-internal, 810112222300, 2) exited non-zero on ‘SIP/100-096275e8’
[Apr 26 15:20:15] VERBOSE[3161] logger.c: – Executing [h@from-internal:1] Macro(“SIP/100-096275e8”, “hangupcall”) in new stack
[Apr 26 15:20:15] VERBOSE[3161] logger.c: – Executing [s@macro-hangupcall:1] ResetCDR(“SIP/100-096275e8”, “w”) in new stack
[Apr 26 15:20:15] DEBUG[3161] app_macro.c: Executed application: ResetCDR
[Apr 26 15:20:15] VERBOSE[3161] logger.c: – Executing [s@macro-hangupcall:2] NoCDR(“SIP/100-096275e8”, “”) in new stack
[Apr 26 15:20:15] DEBUG[3161] app_macro.c: Executed application: NoCDR
[Apr 26 15:20:15] VERBOSE[3161] logger.c: – Executing [s@macro-hangupcall:3] GotoIf(“SIP/100-096275e8”, “1?skiprg”) in new stack
[Apr 26 15:20:15] VERBOSE[3161] logger.c: – Goto (macro-hangupcall,s,6)
[Apr 26 15:20:15] DEBUG[3161] app_macro.c: Executed application: GotoIf
[Apr 26 15:20:15] VERBOSE[3161] logger.c: – Executing [s@macro-hangupcall:6] GotoIf(“SIP/100-096275e8”, “1?skipblkvm”) in new stack
[Apr 26 15:20:15] VERBOSE[3161] logger.c: – Goto (macro-hangupcall,s,9)
[Apr 26 15:20:15] DEBUG[3161] app_macro.c: Executed application: GotoIf
[Apr 26 15:20:15] VERBOSE[3161] logger.c: – Executing [s@macro-hangupcall:9] GotoIf(“SIP/100-096275e8”, “1?theend”) in new stack
[Apr 26 15:20:15] VERBOSE[3161] logger.c: – Goto (macro-hangupcall,s,11)
[Apr 26 15:20:15] DEBUG[3161] app_macro.c: Executed application: GotoIf
[Apr 26 15:20:15] VERBOSE[3161] logger.c: – Executing [s@macro-hangupcall:11] Hangup(“SIP/100-096275e8”, “”) in new stack
[Apr 26 15:20:15] VERBOSE[3161] logger.c: == Spawn extension (macro-hangupcall, s, 11) exited non-zero on ‘SIP/100-096275e8’ in macro ‘hangupcall’
[Apr 26 15:20:15] VERBOSE[3161] logger.c: == Spawn extension (from-internal, h, 1) exited non-zero on ‘SIP/100-096275e8’
[Apr 26 15:21:10] VERBOSE[3160] logger.c: – Remote UNIX connection disconnected
[root@localhost ~]#


[root@localhost ~]# cat /etc/asterisk/extensions_custom.conf

[from-internal-custom]
exten => _81X.,1,Set(DIALOUTANALOG=DAHDI/g0)
exten => _81X.,n,Macro(dialanalog,${EXTEN:2},20)

[macro-dialanalog]
exten => s,1,NoOp
exten => s,n(clear),Dial(${DIALOUTANALOG}|${ARG2}|M(dialanalogcont^${ARG1}))
exten => s,clear+101,Set(MACRO_OFFSET=100)

[macro-dialanalogcont]
exten => s,1,NoOp
exten => s,n(silence), WaitForSilence(100,1,1) ; Timeout after 1 sec
exten => s,n,GotoIf($["${WAITSTATUS}" = “SILENCE”]?silence) ; Loop if silence is detected
exten => s,n(realdial),SendDTMF(${ARG1})
exten => s,n,Goto(end)


== Parsing ‘/etc/asterisk/asterisk.conf’: Found
Connected to Asterisk 1.4.24 currently running on localhost (pid = 2994)
Verbosity is at least 3
– Executing [810112222300@from-internal:1] Set(“SIP/100-096275e8”, “DIALOUTANALOG=DAHDI/g0”) in new stack
– Executing [810112222300@from-internal:2] Macro(“SIP/100-096275e8”, “dialanalog|0112222300|20”) in new stack
– Executing [s@macro-dialanalog:1] NoOp(“SIP/100-096275e8”, “”) in new stack
– Executing [s@macro-dialanalog:2] Dial(“SIP/100-096275e8”, “DAHDI/g0|20|M(dialanalogcont^0112222300)”) in new stack
– Called g0
– Hungup ‘DAHDI/5-1’
== Spawn extension (macro-dialanalog, s, 2) exited non-zero on ‘SIP/100-096275e8’ in macro ‘dialanalog’
== Spawn extension (from-internal, 810112222300, 2) exited non-zero on ‘SIP/100-096275e8’
– Executing [h@from-internal:1] Macro(“SIP/100-096275e8”, “hangupcall”) in new stack
– Executing [s@macro-hangupcall:1] ResetCDR(“SIP/100-096275e8”, “w”) in new stack
– Executing [s@macro-hangupcall:2] NoCDR(“SIP/100-096275e8”, “”) in new stack
– Executing [s@macro-hangupcall:3] GotoIf(“SIP/100-096275e8”, “1?skiprg”) in new stack
– Goto (macro-hangupcall,s,6)
– Executing [s@macro-hangupcall:6] GotoIf(“SIP/100-096275e8”, “1?skipblkvm”) in new stack
– Goto (macro-hangupcall,s,9)
– Executing [s@macro-hangupcall:9] GotoIf(“SIP/100-096275e8”, “1?theend”) in new stack
– Goto (macro-hangupcall,s,11)
– Executing [s@macro-hangupcall:11] Hangup(“SIP/100-096275e8”, “”) in new stack
== Spawn extension (macro-hangupcall, s, 11) exited non-zero on ‘SIP/100-096275e8’ in macro ‘hangupcall’
== Spawn extension (from-internal, h, 1) exited non-zero on 'SIP/100-096275e8’
localhost*CLI>

Thank you.

yup - as I have mentioned I have tested with Asterisk 1.4.28 and it works ok.

Please find bellow my dialplan:

[code]exten => _87X.,1,Set(DIALOUTANALOG=DAHDI/32)
exten => _87X.,n,Macro(dialanalog,${EXTEN:2},20)

[macro-dialanalog]
exten => s,1,NoOp
exten => s,n(clear),Dial(${DIALOUTANALOG}|${ARG2}|M(dialanalogcont^${ARG1}))
exten => s,clear+101,Set(MACRO_OFFSET=100)

[macro-dialanalogcont]
exten => s,1,NoOp
;exten => s,n,Answer
exten => s,n(silence),WaitForSilence(100,1,1)
exten => s,n,GotoIf($["${WAITSTATUS}" = “SILENCE”]?silence) ; Loop if silence is detected
exten => s,n(realdial),SendDTMF(${ARG1})
exten => s,n,Goto(end)
[/code]

and the logs

[Apr 27 09:43:46] VERBOSE[13998] logger.c:     -- Executing [870741019123@from-internal:1] Set("SIP/108-00000032", "DIALOUTANALOG=DAHDI/32") in new stack
[Apr 27 09:43:46] VERBOSE[13998] logger.c:     -- Executing [870741019123@from-internal:2] Macro("SIP/108-00000032", "dialanalog|0741019123|20") in new stack
[Apr 27 09:43:46] VERBOSE[13998] logger.c:     -- Executing [s@macro-dialanalog:1] NoOp("SIP/108-00000032", "") in new stack
[Apr 27 09:43:46] DEBUG[13998] app_macro.c: Executed application: NoOp
[Apr 27 09:43:46] VERBOSE[13998] logger.c:     -- Executing [s@macro-dialanalog:2] Dial("SIP/108-00000032", "DAHDI/32|20|M(dialanalogcont^0741019123)") in new stack
[Apr 27 09:43:46] DEBUG[13998] dsp.c: dsp busy pattern set to 0,0
[Apr 27 09:43:46] DEBUG[13998] chan_dahdi.c: Dialing ''
[Apr 27 09:43:46] DEBUG[13998] chan_dahdi.c: Deferring dialing... (res -1)
[Apr 27 09:43:46] VERBOSE[13998] logger.c:     -- Called 32
[Apr 27 09:43:46] VERBOSE[23505] logger.c:  Extension Changed 600[ext-group-custom] new state InUse for Notify User 108
[Apr 27 09:43:47] DEBUG[13998] chan_dahdi.c: Sent deferred digit string: Tw
[Apr 27 09:43:47] VERBOSE[13998] logger.c:     -- DAHDI/32-1 answered SIP/108-00000032
[Apr 27 09:43:47] VERBOSE[13998] logger.c:     -- Executing [s@macro-dialanalogcont:1] NoOp("DAHDI/32-1", "") in new stack
[Apr 27 09:43:47] DEBUG[13998] app_macro.c: Executed application: NoOp
[Apr 27 09:43:47] VERBOSE[13998] logger.c:     -- Executing [s@macro-dialanalogcont:2] WaitForSilence("DAHDI/32-1", "100|1|1") in new stack
[Apr 27 09:43:47] VERBOSE[13998] logger.c:     -- Waiting 1 time(s) for 100 ms silence with 1 timeout
[Apr 27 09:43:48] DEBUG[13998] app_waitforsilence.c: WAITSTATUS was set to TIMEOUT
[Apr 27 09:43:48] DEBUG[13998] app_macro.c: Executed application: WaitForSilence
[Apr 27 09:43:48] VERBOSE[13998] logger.c:     -- Executing [s@macro-dialanalogcont:3] GotoIf("DAHDI/32-1", "0?silence") in new stack
[Apr 27 09:43:48] DEBUG[13998] app_macro.c: Executed application: GotoIf
[Apr 27 09:43:48] VERBOSE[13998] logger.c:     -- Executing [s@macro-dialanalogcont:4] SendDTMF("DAHDI/32-1", "0741019123") in new stack
[Apr 27 09:43:48] DEBUG[13998] chan_dahdi.c: Started VLDTMF digit '0'
[Apr 27 09:43:48] DEBUG[13998] chan_dahdi.c: Ending VLDTMF digit '0'
[Apr 27 09:43:48] DEBUG[13998] chan_dahdi.c: Started VLDTMF digit '7'
[Apr 27 09:43:48] DEBUG[13998] chan_dahdi.c: Ending VLDTMF digit '7'
[Apr 27 09:43:48] DEBUG[13998] chan_dahdi.c: Started VLDTMF digit '4'
[Apr 27 09:43:48] DEBUG[13998] chan_dahdi.c: Ending VLDTMF digit '4'
[Apr 27 09:43:49] DEBUG[13998] chan_dahdi.c: Started VLDTMF digit '1'
[Apr 27 09:43:49] DEBUG[13998] chan_dahdi.c: Ending VLDTMF digit '1'
[Apr 27 09:43:49] DEBUG[13998] chan_dahdi.c: Started VLDTMF digit '0'
[Apr 27 09:43:49] DEBUG[13998] chan_dahdi.c: Ending VLDTMF digit '0'
[Apr 27 09:43:49] DEBUG[13998] chan_dahdi.c: Started VLDTMF digit '1'
[Apr 27 09:43:49] DEBUG[13998] chan_dahdi.c: Ending VLDTMF digit '1'
[Apr 27 09:43:50] DEBUG[13998] chan_dahdi.c: Started VLDTMF digit '9'
[Apr 27 09:43:50] DEBUG[13998] chan_dahdi.c: Ending VLDTMF digit '9'
[Apr 27 09:43:50] WARNING[23609] chan_sip.c: Maximum retries exceeded on transmission 4a41cb0e1e8f4fa716aaf0410230f7fe@127.0.0.1 for seqno 2989 (Critical Request) -- See doc/sip-retransmit.txt.
[Apr 27 09:43:50] DEBUG[13998] chan_dahdi.c: Started VLDTMF digit '1'
[Apr 27 09:43:50] DEBUG[13998] chan_dahdi.c: Ending VLDTMF digit '1'
[Apr 27 09:43:50] DEBUG[13998] chan_dahdi.c: Started VLDTMF digit '2'
[Apr 27 09:43:51] DEBUG[13998] chan_dahdi.c: Ending VLDTMF digit '2'
[Apr 27 09:43:51] DEBUG[13998] chan_dahdi.c: Started VLDTMF digit '3'
[Apr 27 09:43:51] DEBUG[13998] chan_dahdi.c: Ending VLDTMF digit '3'
[Apr 27 09:43:51] DEBUG[13998] app_macro.c: Executed application: SendDTMF
[Apr 27 09:43:51] VERBOSE[13998] logger.c:     -- Executing [s@macro-dialanalogcont:5] Goto("DAHDI/32-1", "end") in new stack
[Apr 27 09:43:51] NOTICE[13998] pbx.c: No such label 'end' in extension 's' in context 'macro-dialanalogcont'
[Apr 27 09:43:51] WARNING[13998] pbx.c: Priority 'end' must be a number > 0, or valid label
[Apr 27 09:43:51] VERBOSE[13998] logger.c:   == Spawn extension (macro-dialanalogcont, s, 5) exited non-zero on 'DAHDI/32-1' in macro 'dialanalogcont'
[Apr 27 09:43:51] DEBUG[13998] app_dial.c: Macro exited with status -1
[Apr 27 09:44:00] NOTICE[23609] chan_sip.c:    -- Registration for 'testcarrier@193.231.199.70' timed out, trying again (Attempt #2888)
[Apr 27 09:44:03] VERBOSE[13998] logger.c:     -- Hungup 'DAHDI/32-1'

You could see how it jumps to macro-dialanalogcont:
[Apr 27 09:43:47] VERBOSE[13998] logger.c: – Executing [s@macro-dialanalogcont:1] NoOp(“DAHDI/32-1”, “”) in new stack

as opposed to your situation.

What DAHDI config do you have? Probably you have answerpolarityonswitch=yes and the channel is not considered Answered thus there is no “jump” to macro-dialanalogcont.

HTH,
Ioan.

Hi,

Thank you for your repply. Honestly i don’t have good idea about macros and scripting idea. As i feel it detect the dial tone. But it doesn’t dial the number. Because i calling party can hear that dial tone clearly. Below is my DAHDI configuration. Do you have any suggestion ?

[root@localhost ~]# cat /etc/asterisk/chan_dahdi.conf
[trunkgroups]
[channels]
answeronpolarityswitch=yes
hanguponpolarityswitch=yes
echocancel=yes
echocancelwhenbridged=yes
ringtimeout=8000
rxgain=4.0
txgain=4.0

#include dahdi-channels.conf
[root@localhost ~]#

Thank you.

please try with answeronpolarityswitch=no in /etc/asterisk/chan_dahdi.conf

after the change you have to reload DAHDI (run ‘dahdi restart’ in Asterisk CLI)

is is working now or not?

BR,
Ioan.

Hi,

You are corerct, When i set answeronpolarityswitch=no it worked fine. Below is the log file for that. But my billing records are critical for me. So i can’t set answeronpolarityswitch=no.
I have to use answeronpolarityswitch=yes with this macro.

Please advice.

localhostCLI>
– Executing [810112555555@from-internal:1] Set(“SIP/100-08ff7a58”, “DIALOUTANALOG=DAHDI/g0”) in new stack
– Executing [810112555555@from-internal:2] Macro(“SIP/100-08ff7a58”, “dialanalog|0112555555|20”) in new stack
– Executing [s@macro-dialanalog:1] NoOp(“SIP/100-08ff7a58”, “”) in new stack
– Executing [s@macro-dialanalog:2] Dial(“SIP/100-08ff7a58”, “DAHDI/g0|20|M(dialanalogcont^0112555555)”) in new stack
– Called g0
– DAHDI/5-1 answered SIP/100-08ff7a58
– Executing [s@macro-dialanalogcont:1] NoOp(“DAHDI/5-1”, “”) in new stack
– Executing [s@macro-dialanalogcont:2] WaitForSilence(“DAHDI/5-1”, “100|1|1”) in new stack
– Waiting 1 time(s) for 100 ms silence with 1 timeout
– Executing [s@macro-dialanalogcont:3] GotoIf(“DAHDI/5-1”, “0?silence”) in new stack
– Executing [s@macro-dialanalogcont:4] SendDTMF(“DAHDI/5-1”, “0112555555”) in new stack
– Executing [s@macro-dialanalogcont:5] Goto(“DAHDI/5-1”, “end”) in new stack
== Spawn extension (macro-dialanalogcont, s, 5) exited non-zero on ‘DAHDI/5-1’ in macro ‘dialanalogcont’
– Hungup ‘DAHDI/5-1’
== Spawn extension (macro-dialanalog, s, 2) exited non-zero on ‘SIP/100-08ff7a58’ in macro ‘dialanalog’
== Spawn extension (from-internal, 810112555555, 2) exited non-zero on ‘SIP/100-08ff7a58’
– Executing [h@from-internal:1] Macro(“SIP/100-08ff7a58”, “hangupcall”) in new stack
– Executing [s@macro-hangupcall:1] ResetCDR(“SIP/100-08ff7a58”, “w”) in new stack
– Executing [s@macro-hangupcall:2] NoCDR(“SIP/100-08ff7a58”, “”) in new stack
– Executing [s@macro-hangupcall:3] GotoIf(“SIP/100-08ff7a58”, “1?skiprg”) in new stack
– Goto (macro-hangupcall,s,6)
– Executing [s@macro-hangupcall:6] GotoIf(“SIP/100-08ff7a58”, “1?skipblkvm”) in new stack
– Goto (macro-hangupcall,s,9)
– Executing [s@macro-hangupcall:9] GotoIf(“SIP/100-08ff7a58”, “1?theend”) in new stack
– Goto (macro-hangupcall,s,11)
– Executing [s@macro-hangupcall:11] Hangup(“SIP/100-08ff7a58”, “”) in new stack
== Spawn extension (macro-hangupcall, s, 11) exited non-zero on ‘SIP/100-08ff7a58’ in macro ‘hangupcall’
== Spawn extension (from-internal, h, 1) exited non-zero on 'SIP/100-08ff7a58’
localhost
CLI>

Thank you.