Cannot get outside called number in sub routine

Hi,

I’m using Asterisk 16 and I’am having a hard time to make part of my dialplan work:

I’d like to pass the outgoing called number to my sub routine when dialing multiple destinations.

Here’s what I have so far:

Basically I want to pass all the dialed numbers to my sub routine.
In other words I want to see 15558882222 or 2005 in sub_answer if one of the remote call is answered.

I have tried many asterisk variable and nothing work for outside number.
${exten} is not working because it’s trying to pass 4444.

exten => 4444,1,NoOp()
same => n,Dial(PJSIP/2005&PJSIP/15558882222@callcentric,20,U(sub_answer_3636^${CHANNEL(contact)})))
same => n,Hangup()


[sub_answer]
exten => s,1,NoOp()
same  => n,Verbose(My variable: ${ARG1})
same => n,Return()

The values in the U paramater are determined when the dialplan line is parsed not at the time the subroutine is called, so no parameter is going to tell you which of the multiple destinations answered.

If it is possible at all, you will need to do this by referencing systemd defined variables, like BRIDGEPEER, although I’m not sure if that one is set at the time. If I were doing this in anger, I would probably look at the source code of app_dial.c to see what if any variables were set between answer and the U subroutine’s being called.

Thanks for your response. I’ve finally been able to do it by setting a hangup handler and using the ${DIALEDPEERNUMBER} variable.

I’m not sure if it is the best way to do it but it’s working.

exten => 4444,1,NoOp()
same => n,Dial(PJSIP/2005&PJSIP/15558882222@callcentric,20,U(sub_answer_3636))
same => n,Hangup()


[sub_answer]
exten => s,1,NoOp()
;Hangup handler
same  => n,Set(CHANNEL(hangup_handler_push)=hdlr_Incoming,s,1(args))
same => n,Return()

[hdlr_Incoming]
exten => s,1,NoOp()
same  => n,Set(dialedcalle=${DIALEDPEERNUMBER:0:11})
same => n,Return()

Result for the cell phone that answered the call:

Executing [s@hdlr_Incoming:1] NoOp("PJSIP/callcentric-00000359", "") in new stack
Executing [s@hdlr_Incoming:2] Set("PJSIP/callcentric-00000359", "dialedcalle=14185592667") in new stack
Executing [s@hdlr_Incoming:3] Return("PJSIP/callcentric-00000359", "") in new stack

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.