[asterisk-users] Getting DIALSTATUS via agi

Mike Diehl mdiehlenator at gmail.com
Mon Apr 1 16:21:56 CDT 2013


Hi all,

Hopefully, I just need a second set of eyes on this one, but I just can't
figure out what I'm doing wrong.  I'm using an agi script to dial a number,
check the dial result, and act accordingly.

The problem is that I'm not getting anything back from DIALSTATUS, or
HANGUPCAUSE.

Here is the relevant perl code:

===============================================================

$main::agi->verbose("====================================================================================
", 1);
                $main::agi->exec("dial",
"sip/$t->{trunk}/$t->{prefix}$o->{number},240,KrTWX");
                $result = $main::agi->get_variable("DIALSTATUS");
                $cause = $main::agi->get_variable("HANGUPCAUSE");

                $o->{DIALSTATUS} = $result;
                $o->{HANGUPCAUSE} = $cause;
                $main::agi->verbose("============================= The
result of the last call was ($o->{DIALSTATUS}) ($o->{HANGUPCAUSE})", 1);
$main::agi->verbose("====================================================================================
", 1);

===============================================================

Here is the relevant output with agi debug turned on:

===============================================================

[Apr  1 15:01:55] <SIP/CCEF485BC606-2-00007787>AGI Tx >> 200 result=0
[Apr  1 15:01:55] <SIP/CCEF485BC606-2-00007787>AGI Rx << VERBOSE
"====================================================================================
" 1
[Apr  1 15:01:55]  magic_switch.pl:
====================================================================================

[Apr  1 15:01:55] <SIP/CCEF485BC606-2-00007787>AGI Tx >> 200 result=1
[Apr  1 15:01:55] <SIP/CCEF485BC606-2-00007787>AGI Rx << EXEC dial
"sip/didlogic/15058457900,240,KrTWX"
[Apr  1 15:01:55]     -- AGI Script Executing Application: (dial) Options:
(sip/didlogic/15058457900,240,KrTWX)
[Apr  1 15:01:55]   == Using SIP RTP TOS bits 24
[Apr  1 15:01:55]   == Using SIP RTP CoS mark 5
[Apr  1 15:01:55]     -- Called sip/didlogic/15058457900
[Apr  1 15:01:55]     -- Got SIP response 603 "Declined" back from
178.63.143.236:5060
[Apr  1 15:01:55]     -- SIP/didlogic-00007788 is busy
[Apr  1 15:01:55]   == Everyone is busy/congested at this time (1:1/0/0)
[Apr  1 15:01:55] <SIP/CCEF485BC606-2-00007787>AGI Tx >> 200 result=0
[Apr  1 15:01:55] <SIP/CCEF485BC606-2-00007787>AGI Rx << GET VARIABLE
DIALSTATUS
[Apr  1 15:01:55] <SIP/CCEF485BC606-2-00007787>AGI Tx >> 200 result=1 (BUSY)
[Apr  1 15:01:55] <SIP/CCEF485BC606-2-00007787>AGI Rx << GET VARIABLE
HANGUPCAUSE
[Apr  1 15:01:55] <SIP/CCEF485BC606-2-00007787>AGI Tx >> 200 result=1 (21)
[Apr  1 15:01:55] <SIP/CCEF485BC606-2-00007787>AGI Rx << VERBOSE
"============================= The result of the last call was () ()" 1
[Apr  1 15:01:55]  magic_switch.pl: ============================= The
result of the last call was () ()
[Apr  1 15:01:55] <SIP/CCEF485BC606-2-00007787>AGI Tx >> 200 result=1
[Apr  1 15:01:55] <SIP/CCEF485BC606-2-00007787>AGI Rx << VERBOSE
"====================================================================================
" 1
[Apr  1 15:01:55]  magic_switch.pl:
====================================================================================


===============================================================



So, the result of my previous AGI command was 200.  Then I can clearly see
that the result of this dial is BUSY/21, which I understand.  But, my perl
script isn't getting this value.  I do the assignment to/from $result and
$cause because I use those values later in the script, but have to pass
them back to a global routine, as well.

Can anyone see what I'm doing wrong?

Mike Diehl.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20130401/b86afe55/attachment.htm>


More information about the asterisk-users mailing list