Call diversion with analoge lines


I do have a problem in diverting an incoming analoge pstn call to an outgoing pstn call to a GSM-phone.

Here is my actual dial plan I’m trying to solve that problem (X=digits):


MOBILE1= ZAP/2/XXXXXXXXX|15|g ; The GSM to call on ZAP channel 2

exten => s,1,Hangup

; Distinguish on which ZAP channel there is an incoming call to divert

exten => s,1,SetVar(zapchannel=${CHANNEL:4:1})
exten => s,2,GotoIf(${zapchannel}=1?201)
exten => s,3,GotoIf(${zapchannel}=2?211)

; Case where channel 1 is used --> put the user to a voice menu:
; press 0 to dial to GSM-phone
; press 1 to leave a voice message

exten => s,201,Wait,2
exten => s,202,Answer
exten => s,203,DigitTimeout,5
exten => s,204,ResponseTimeout,12
exten => s,205,Background(introduction)
exten => s,206,Playback(pbx-invalid)
exten => s,207,Goto(from_pstn,s,205)
exten => h,1,Hangup
exten => i,1,Playback(pbx-invalid)
exten => i,2,Goto(from_pstn,s,205)

exten => _0,1,Goto(to_pstn2,s,1)
exten => _1,1,Goto(to_vm1,s,1)

; Dial now out on ZAP channel 2 --> bridges ZAP1 with ZAP2
exten => s,1,Dial(${MOBILE1})
exten => s,2,SoftHangup(ZAP/2|a)
exten => s,3,Hangup

; Leave a voicemail for customer
exten => _2,1,Voicemail,u40392

; Inform GSM by SMS that there was a call
exten => _2,2,System(/usr/src/asterisk/utils/smsq XXXXXXXXX Testuser called in and left a voicemail for you! --motx-channel=ZAP/2/XXXXXXXXXX)
exten => _1,5,Goto(default,s,1)

Following problems occured so far which I do not know how to solve them yet:

  • the statement: MOBILE1= ZAP/2/XXXXXXXXX|15|g should ring the X-number for 15 sec and the g option should continue in dial plan - but it does’nt. In rings a invinite time

  • if I’m going to pick up the GSM-phone and hang it up again I do have open lines, which Asterisk is not able to hangup (have to do it manually).

Can anybody help me to sort that out - what do I wrong? Please help!