Detect answer on zap channel

Hello, im having problems with the answeing detection on a zap channel, im using a TDM card with 1 port fxs and 1 fxo, the problem is i have a script that generates a call thrugh the AMI but in the Originate command i have a context which is supose to redirect the call when is answered, but the answer signal gets before the callee really answers.

I have tried callprogress=yes, answeronpolarityswtch=yes but when i enable this options in zapata.conf i can not answer the call.

Here is some aditional data i hope you can tell me how to solve this problem.

BTW, im in Mexico.

Asterisk 1.4.23.1
Zaptel 1.4.12.1

Originate

action: originate
channel: Local/87896544521@from-internal/n
context: sonido
exten: s
priority: 1
timeout: 20000
response: 20000
actionid: 1234
async: true

extensions.conf

exten => s,1,Answer
exten => s,n,Playback(custom/sonido)

zaptel.conf

fxsks=4
fxoks=1

CLI

[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [87896544521@from-internal:1] Macro(“Local/87896544521@from-internal-8336,2”, “user-callerid|SKIPTTL|”) in new stack
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-user-callerid:1] NoOp(“Local/87896544521@from-internal-8336,2”, "user-callerid: ") in new stack
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: Noop
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-user-callerid:2] Set(“Local/87896544521@from-internal-8336,2”, “AMPUSER=”) in new stack
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: Set
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-user-callerid:3] GotoIf(“Local/87896544521@from-internal-8336,2”, “1?report”) in new stack
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Goto (macro-user-callerid,s,13)
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: GotoIf
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-user-callerid:13] NoOp(“Local/87896544521@from-internal-8336,2”, “TTL: ARG1: SKIPTTL”) in new stack
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: Noop
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-user-callerid:14] GotoIf(“Local/87896544521@from-internal-8336,2”, “1?continue”) in new stack
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Goto (macro-user-callerid,s,23)
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: GotoIf
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-user-callerid:23] NoOp(“Local/87896544521@from-internal-8336,2”, “Using CallerID “” <>”) in new stack
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: Noop
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [87896544521@from-internal:2] Set(“Local/87896544521@from-internal-8336,2”, “_NODEST=”) in new stack
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [87896544521@from-internal:3] Macro(“Local/87896544521@from-internal-8336,2”, “record-enable||OUT|”) in new stack
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-record-enable:1] GotoIf(“Local/87896544521@from-internal-8336,2”, “0?2:4”) in new stack
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Goto (macro-record-enable,s,4)
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: GotoIf
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-record-enable:4] AGI(“Local/87896544521@from-internal-8336,2”, “recordingcheck|20080206-081651|1202307411.185”) in new stack
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Launched AGI Script /var/lib/asterisk/agi-bin/recordingcheck
[Feb 6 08:16:51] VERBOSE[13495] logger.c: recordingcheck|20080206-081651|1202307411.185: No AMPUSER db entry for . Not recording
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – AGI Script recordingcheck completed, returning 0
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: AGI
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-record-enable:5] NoOp(“Local/87896544521@from-internal-8336,2”, “No recording needed”) in new stack
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: Noop
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [87896544521@from-internal:4] Macro(“Local/87896544521@from-internal-8336,2”, “dialout-trunk|1|0458681304722||”) in new stack
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-dialout-trunk:1] Set(“Local/87896544521@from-internal-8336,2”, “DIAL_TRUNK=1”) in new stack
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: Set
[Feb 6 08:16:51] DEBUG[13495] func_db.c: DB: AMPUSER//pinless not found in database.
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-dialout-trunk:2] ExecIf(“Local/87896544521@from-internal-8336,2”, “0|Authenticate|”) in new stack
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: ExecIf
[Feb 6 08:16:51] DEBUG[13495] func_db.c: DB: AMPUSER//pinless not found in database.
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-dialout-trunk:3] GotoIf(“Local/87896544521@from-internal-8336,2”, “0?disabletrunk|1”) in new stack
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: GotoIf
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-dialout-trunk:4] Set(“Local/87896544521@from-internal-8336,2”, “DIAL_NUMBER=0458681304722”) in new stack
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: Set
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-dialout-trunk:5] Set(“Local/87896544521@from-internal-8336,2”, “DIAL_TRUNK_OPTIONS=t”) in new stack
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: Set
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-dialout-trunk:6] Set(“Local/87896544521@from-internal-8336,2”, “GROUP()=OUT_1”) in new stack
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: Set
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-dialout-trunk:7] GotoIf(“Local/87896544521@from-internal-8336,2”, “1?nomax”) in new stack
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Goto (macro-dialout-trunk,s,9)
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: GotoIf
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-dialout-trunk:9] GotoIf(“Local/87896544521@from-internal-8336,2”, “0?skipoutcid”) in new stack
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: GotoIf
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-dialout-trunk:10] Set(“Local/87896544521@from-internal-8336,2”, “DIAL_TRUNK_OPTIONS=”) in new stack
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: Set
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-dialout-trunk:11] Macro(“Local/87896544521@from-internal-8336,2”, “outbound-callerid|1”) in new stack
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-outbound-callerid:1] ExecIf(“Local/87896544521@from-internal-8336,2”, “0|SetCallerPres|”) in new stack
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: ExecIf
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-outbound-callerid:2] GotoIf(“Local/87896544521@from-internal-8336,2”, “0?start”) in new stack
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: GotoIf
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-outbound-callerid:3] Set(“Local/87896544521@from-internal-8336,2”, “REALCALLERIDNUM=”) in new stack
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: Set
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-outbound-callerid:4] NoOp(“Local/87896544521@from-internal-8336,2”, "REALCALLERIDNUM is ") in new stack
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: Noop
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-outbound-callerid:5] GotoIf(“Local/87896544521@from-internal-8336,2”, “1?normcid”) in new stack
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Goto (macro-outbound-callerid,s,10)
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: GotoIf
[Feb 6 08:16:51] DEBUG[13495] func_db.c: DB: AMPUSER//outboundcid not found in database.
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-outbound-callerid:10] Set(“Local/87896544521@from-internal-8336,2”, “USEROUTCID=”) in new stack
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: Set
[Feb 6 08:16:51] DEBUG[13495] func_db.c: DB: DEVICE//emergency_cid not found in database.
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-outbound-callerid:11] Set(“Local/87896544521@from-internal-8336,2”, “EMERGENCYCID=”) in new stack
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: Set
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-outbound-callerid:12] Set(“Local/87896544521@from-internal-8336,2”, “TRUNKOUTCID=”) in new stack
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: Set
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-outbound-callerid:13] GotoIf(“Local/87896544521@from-internal-8336,2”, “1?trunkcid”) in new stack
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Goto (macro-outbound-callerid,s,17)
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: GotoIf
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-outbound-callerid:17] GotoIf(“Local/87896544521@from-internal-8336,2”, “1?usercid”) in new stack
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Goto (macro-outbound-callerid,s,19)
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: GotoIf
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-outbound-callerid:19] GotoIf(“Local/87896544521@from-internal-8336,2”, “1?report”) in new stack
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Goto (macro-outbound-callerid,s,23)
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: GotoIf
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-outbound-callerid:23] NoOp(“Local/87896544521@from-internal-8336,2”, “CallerID set to “” <>”) in new stack
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: Noop
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: Macro
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-dialout-trunk:12] AGI(“Local/87896544521@from-internal-8336,2”, “fixlocalprefix”) in new stack
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Launched AGI Script /var/lib/asterisk/agi-bin/fixlocalprefix
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – AGI Script fixlocalprefix completed, returning 0
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: AGI
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-dialout-trunk:13] Set(“Local/87896544521@from-internal-8336,2”, “OUTNUM=0458681304722”) in new stack
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: Set
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-dialout-trunk:14] Set(“Local/87896544521@from-internal-8336,2”, “custom=ZAP/g0”) in new stack
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: Set
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-dialout-trunk:15] GotoIf(“Local/87896544521@from-internal-8336,2”, “1?gocall”) in new stack
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Goto (macro-dialout-trunk,s,17)
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: GotoIf
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-dialout-trunk:17] Macro(“Local/87896544521@from-internal-8336,2”, “dialout-trunk-predial-hook|”) in new stack
[Feb 6 08:16:51] WARNING[13495] app_macro.c: Context ‘macro-dialout-trunk-predial-hook’ for macro ‘dialout-trunk-predial-hook’ lacks ‘s’ extension, priority 1
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: Macro
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-dialout-trunk:18] GotoIf(“Local/87896544521@from-internal-8336,2”, “0?bypass|1”) in new stack
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: GotoIf
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-dialout-trunk:19] GotoIf(“Local/87896544521@from-internal-8336,2”, “0?customtrunk”) in new stack
[Feb 6 08:16:51] DEBUG[13495] app_macro.c: Executed application: GotoIf
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Executing [s@macro-dialout-trunk:20] Dial(“Local/87896544521@from-internal-8336,2”, “ZAP/g0/0458681304722|300|”) in new stack
[Feb 6 08:16:51] DEBUG[13495] dsp.c: dsp busy pattern set to 0,0
[Feb 6 08:16:51] DEBUG[13495] chan_dahdi.c: Dialing ‘87896544521’
[Feb 6 08:16:51] DEBUG[13495] chan_dahdi.c: Deferring dialing…
[Feb 6 08:16:51] VERBOSE[13495] logger.c: – Called g0/87896544521
[Feb 6 08:16:52] DEBUG[13495] chan_dahdi.c: Sent deferred digit string: T87896544521
[Feb 6 08:16:55] DEBUG[13495] chan_dahdi.c: Engaged echo training on channel 4
[Feb 6 08:16:57] DEBUG[13495] chan_dahdi.c: Echo cancellation already on
[Feb 6 08:16:57] VERBOSE[13495] logger.c: – Zap/4-1 answered Local/87896544521@from-internal-8336,2
[Feb 6 08:16:57] VERBOSE[13504] logger.c: – Executing [s@sonido-dialer:1] Aswer() in new stack
[Feb 6 08:16:57] VERBOSE[13504] logger.c: – Executing [s@sonido-dialer:2] Playback(“Local/87896544521@from-internal-8336,1”, “sondio”) in new stack
[Feb 6 08:16:57] VERBOSE[13504] logger.c: – <Local/87896544521@from-internal-8336,1> Playing ‘sonido’ (language ‘en’)
[Feb 6 08:17:01] VERBOSE[13437] logger.c: == Manager ‘dialer’ logged off from 127.0.0.1
[Feb 6 08:17:16] VERBOSE[13495] logger.c: – Executing [h@macro-dialout-trunk:1] Macro(“Local/87896544521@from-internal-8336,2”, “hangupcall|”) in new stack
[Feb 6 08:17:16] VERBOSE[13495] logger.c: – Executing [s@macro-hangupcall:1] ResetCDR(“Local/87896544521@from-internal-8336,2”, “w”) in new stack
[Feb 6 08:17:16] DEBUG[13495] app_macro.c: Executed application: ResetCDR
[Feb 6 08:17:16] VERBOSE[13495] logger.c: – Executing [s@macro-hangupcall:2] NoCDR(“Local/87896544521@from-internal-8336,2”, “”) in new stack
[Feb 6 08:17:16] DEBUG[13495] app_macro.c: Executed application: NoCDR
[Feb 6 08:17:16] VERBOSE[13495] logger.c: – Executing [s@macro-hangupcall:3] GotoIf(“Local/87896544521@from-internal-8336,2”, “1?skiprg”) in new stack
[Feb 6 08:17:16] VERBOSE[13495] logger.c: – Goto (macro-hangupcall,s,6)
[Feb 6 08:17:16] DEBUG[13495] app_macro.c: Executed application: GotoIf
[Feb 6 08:17:16] VERBOSE[13495] logger.c: – Executing [s@macro-hangupcall:6] GotoIf(“Local/87896544521@from-internal-8336,2”, “1?skipblkvm”) in new stack
[Feb 6 08:17:16] VERBOSE[13495] logger.c: – Goto (macro-hangupcall,s,9)
[Feb 6 08:17:16] DEBUG[13495] app_macro.c: Executed application: GotoIf
[Feb 6 08:17:16] VERBOSE[13495] logger.c: – Executing [s@macro-hangupcall:9] GotoIf(“Local/87896544521@from-internal-8336,2”, “1?theend”) in new stack
[Feb 6 08:17:16] VERBOSE[13495] logger.c: – Goto (macro-hangupcall,s,11)
[Feb 6 08:17:16] DEBUG[13495] app_macro.c: Executed application: GotoIf
[Feb 6 08:17:16] VERBOSE[13495] logger.c: – Executing [s@macro-hangupcall:11] Hangup(“Local/87896544521@from-internal-8336,2”, “”) in new stack
[Feb 6 08:17:16] VERBOSE[13495] logger.c: == Spawn extension (macro-hangupcall, s, 11) exited non-zero on ‘Local/87896544521@from-internal-8336,2’ in macro ‘hangupcall’
[Feb 6 08:17:16] VERBOSE[13495] logger.c: == Spawn h extension (macro-dialout-trunk, h, 1) exited non-zero on ‘Local/87896544521@from-internal-8336,2’
[Feb 6 08:17:16] VERBOSE[13495] logger.c: – Hungup ‘Zap/4-1’
[Feb 6 08:17:16] VERBOSE[13495] logger.c: == Spawn extension (macro-dialout-trunk, s, 20) exited non-zero on ‘Local/87896544521@from-internal-8336,2’ in macro ‘dialout-trunk’
[Feb 6 08:17:16] VERBOSE[13495] logger.c: == Spawn extension (from-internal, 80458681304722, 4) exited non-zero on ‘Local/87896544521@from-internal-8336,2’
[Feb 6 08:17:16] VERBOSE[13504] logger.c: == Spawn extension (sonido-dialer, s, 5) exited non-zero on ‘Local/87896544521@from-internal-8336,1’

Thanks.