[Asterisk-Users] Help DIALSTATUS gives ANSWER when line is BUSY?

Jeremy Lichfield jeremy at daqe.com
Fri Jan 21 09:03:41 MST 2005


I'm running Asterisk CVS-v1-0-12/20/04.

I'm using PHP with Manager API Here is the code:

####################################################################
# Make call
####################################################################
$socket = fsockopen($ask_db,"5038", $errno, $errstr, $timeout);
if (!$socket) {
echo "$errstr ($errno)<br /\n";
} else {
fputs($socket, "Action: Login\r\n");
fputs($socket, "UserName: $ask_us\r\n");
fputs($socket, "Secret: $ask_pd\r\n\r\n");

fputs($socket, "Action: Originate\r\n");
// Note I have tried both using the remote SIP user throught IAX2 and  
Originating the call using the Zap channel
fputs($socket, "Channel:  
IAX2/askdaqe:a\$teri\$k at teenlighthouse/$user_ext at auto_answer\r\n");    
//This connects to a remote SIP user
fputs($socket, "Context: askdaqe\r\n");
fputs($socket, "Exten: 100\r\n");
fputs($socket, "Priority: 1\r\n");
fputs($socket, "Variable:  
UID=$uid|USER_EXT=$user_ext|COMPANY=teenlighthouse|USER_PHONE=$ask_phone 
\r\n");
fputs($socket, "Callerid: DAQE Dialer\r\n\r\n"); // DAQE is the name of  
my CRM

fclose($socket);u fputs($socket, "Action: Logoff\r\n\r\n");

while (!feof($socket)) {
$content = fread($socket, 8192);
echo $content."<br\n";
}
fclose($socket);

Here is my Dial Plan:

[askdaqe]

; DAQE Dialing Out
exten =100,1,Playback(vm-dialout)
exten =100,2,Dial(Zap/g2/1${USER_PHONE},10,tT)
exten =100,3,Goto(s-${DIALSTATUS},1)
exten =s-CANCEL,1,NoOp(Cancell)
exten =s-ANSWER,1,NoOp(Test Were In)
exten =s-ANSWER,2,Goto(h,1)
exten =s-NOANSWER,1,NoOp(NOANSWER)
exten =s-BUSY,1,NoOp(BUSY)
exten =s-CONGESTION,1,NoOp(CONGESTION)
exten =s-CHANUNAVAIL,1,NoOp(CHANUNAVAIL)

; When DAQE Dialer Hangs Up
exten =h,1,DeadAGI(end_call.php)
exten =h,2,NoOp(Hang Up Dail Status ${DIALSTATUS})

Let me explain the problem. When using the Originate 
command from the manager api, the dialstatus variable returns results 
for whichever phone picks up first, and in this case it is the IAX/2 
connection. It doesn't matter if Zap/G2/XXXXXXX is set as the channel, 
or an extension either. What I am ultimately trying to do is get the 
dialstatus of the Zap/X/XXXXXXX channel, i.e., BUSY, ANSWER, 
  NOANSWER........ Is there anyway to specify which channel you want to 
monitor with dialstatus?

Here is the response in the AGI with the setup like I have it
above and I'm calling a busy number:

Channel: IAX2/teenlighthouse/16384
State: Down
Callerid: <unknown
Uniqueid: 1106323559.4

Event: Newcallerid
Channel: IAX2/teenlighthouse/16384
Callerid: DAQE Dialer
Uniqueid: 1106323559.4

Event: Newchannel
Channel: IAX2/teenlighthouse/16384
State: Ringing
Callerid: DAQE Dialer
Uniqueid: 1106323559.4

Event: Newstate
Channel: IAX2/teenlighthouse/16384
State: Up
Callerid: DAQE Dialer
Uniqueid: 1106323559.4

Event: Newexten
Channel: IAX2/teenlighthouse/16384
Context: askdaqe
Extension: 100
Priority: 1
Application: Playback
AppData: vm-dialout
Uniqueid: 1106323559.4

Event: Newexten
Channel: IAX2/teenlighthouse/16384
Context: askdaqe
Extension: 100
Priority: 2
Application: Dial
AppData: Zap/g2/14356355785|10|tT
Uniqueid: 1106323559.4

Event: Newchannel
Channel: Zap/1-1
State: Rsrvd
Callerid: <unknown
Uniqueid: 1106323562.5

Event: Newstate
Channel: Zap/1-1
State: Dialing
Callerid: DAQE Dialer
Uniqueid: 1106323562.5

Event: Newstate
Channel: Zap/1-1
State: Ringing
Callerid: DAQE Dialer
Uniqueid: 1106323562.5

Event: Newstate
Channel: Zap/1-1
State: Up
Callerid: DAQE Dialer
Uniqueid: 1106323562.5

Event: Link
Channel1: IAX2/teenlighthouse/16384
Channel2: Zap/1-1
Uniqueid1: 1106323559.4
Uniqueid2: 1106323562.5

Event: Unlink
Channel1: IAX2/teenlighthouse/16384
Channel2: Zap/1-1
Uniqueid1: 1106323559.4
Uniqueid2: 1106323562.5

Event: Hangup
Channel: Zap/1-1
Uniqueid: 1106323562.5
Cause: 0

Event: Newexten
Channel: IAX2/teenlighthouse/16384
Context: askdaqe
Extension: h
Priority: 1
Application: DeadAGI
AppData: end_call.php
Uniqueid: 1106323559.4

Event: Newexten
Channel: IAX2/teenlighthouse/16384
Context: askdaqe
Extension: h
Priority: 2
Application: NoOp
AppData: Hang Up Dail Status ANSWER
Uniqueid: 1106323559.4

Event: Hangup
Channel: IAX2/teenlighthouse/16384
Uniqueid: 1106323559.4
Cause: 0

Here is it using the Zap Channel again calling a busy number:

Event: Newchannel
Channel: Zap/1-1
State: Rsrvd
Callerid: <unknown
Uniqueid: 1106323968.10

Event: Newcallerid
Channel: Zap/1-1
Callerid: DAQE Dialer
Uniqueid: 1106323968.10

Event: Newstate
Channel: Zap/1-1
State: Dialing
Callerid: DAQE Dialer
Uniqueid: 1106323968.10

Event: Newstate
Channel: Zap/1-1
State: Ringing
Callerid: DAQE Dialer
Uniqueid: 1106323968.10

Event: Newstate
Channel: Zap/1-1
State: Up
Callerid: DAQE Dialer
Uniqueid: 1106323968.10

Event: Newexten
Channel: Zap/1-1
Context: askdaqe
Extension: 100
Priority: 1
Application: Playback
AppData: vm-dialout
Uniqueid: 1106323968.10

Event: Newexten
Channel: Zap/1-1
Context: askdaqe
Extension: 100
Priority: 2
Application: Dial
AppData: IAX2/askdaqe:a$teri$k at teenlighthouse/101 at auto_answer|10|tT
Uniqueid: 1106323968.10

Event: Newchannel
Channel: IAX2/teenlighthouse/16385
State: Down
Callerid: <unknown
Uniqueid: 1106323973.11

Event: Newchannel
Channel: IAX2/teenlighthouse/16385
State: Ringing
Callerid: DAQE Dialer
Uniqueid: 1106323973.11

Event: Newstate
Channel: IAX2/teenlighthouse/16385
State: Up
Callerid: DAQE Dialer
Uniqueid: 1106323973.11

Event: Link
Channel1: Zap/1-1
Channel2: IAX2/teenlighthouse/16385
Uniqueid1: 1106323968.10
Uniqueid2: 1106323973.11

Event: Unlink
Channel1: Zap/1-1
Channel2: IAX2/teenlighthouse/16385
Uniqueid1: 1106323968.10
Uniqueid2: 1106323973.11

Event: Hangup
Channel: IAX2/teenlighthouse/16385
Uniqueid: 1106323973.11
Cause: 0

Event: Newexten
Channel: Zap/1-1
Context: askdaqe
Extension: h
Priority: 1
Application: DeadAGI
AppData: end_call.php
Uniqueid: 1106323968.10

Event: Newexten
Channel: Zap/1-1
Context: askdaqe
Extension: h
Priority: 2
Application: NoOp
AppData: Hang Up Dail Status ANSWER
Uniqueid: 1106323968.10

Event: Hangup
Channel: Zap/1-1
Uniqueid: 1106323968.10
Cause: 0

Both ways give me the same DIALSTATUS? ANSWER? How do I get the  
DIALSTATUS of the Zap Channel?

Is there any patches in the latest CVS-HEAD? Also do you know if having  
a PRI and getting the HANGUPCAUSE might solve the problem?

Thanking you in advance,
Jeremy



More information about the asterisk-users mailing list