Hello, i try to originate a call from my mobile phone. If the mobile answers, it will ring an internal extension.
sudo asterisk -rx "originate SIP/012345678@DT_08154711 extension 700@ext-local"
Then the log shows
– Called 012345678@DT_08154711
– SIP/DT_08154711-00000011 is making progress
– SIP/DT_08154711-00000011 is making progress
– SIP/DT_08154711-00000011 is ringing
– SIP/DT_08154711-00000011 is making progress
– SIP/DT_08154711-00000011 is ringing
– SIP/DT_08154711-00000011 is making progress
– Got SIP response 486 “Besetzt (0)” back from 217.0.23.100:5060
– SIP/DT_08154711-00000011 is busy
How do i get this busy status as a return code on the command line?
It also works with this php-socket file to originate the file, but i don’t know how to get the return code / hangup cause:
<?php
$strUser = 'manager_user';
$strSecret = 'manager_pwd';
$ext = $_GET['ext'];
$number = $_GET['number'];
$callerid = $_GET['callerid'] . " <$number>";
$strChannel = "local/".$number . "@my_trunk";
$strContext = "ext-local";
$strTimeout = 15000;
$strPriority = "1";
$errno=0 ;
$errstr=0 ;
$oSocket = fsockopen ("localhost", 5038, $errno, $errstr, 20);
if (!$oSocket) {
echo "Socket error: $errstr ($errno)<br>\n";
} else {
fputs($oSocket, "Action: login\r\n");
fputs($oSocket, "Username: $strUser\r\n");
fputs($oSocket, "Secret: $strSecret\r\n\r\n");
fputs($oSocket, "Action: originate\r\n");
fputs($oSocket, "Channel: $strChannel\r\n");
fputs($oSocket, "Context: $strContext\r\n");
fputs($oSocket, "Exten: $ext\r\n");
fputs($oSocket, "Priority: $strPriority\r\n");
fputs($oSocket, "Timeout: $strTimeout\r\n");
fputs($oSocket, "CallerId: $callerid\r\n");
fputs($oSocket, "Async: false\r\n\r\n");
fputs($oSocket, "Variable: DID=$ext\r\n");
fputs($oSocket, "Action: Logoff\r\n\r\n");
$lineno=0;
$match_texts = array("Asterisk Call Manager/2.8.0\r\n", "Response: Success\r\n", "Message: Authentication accepted\r\n");
while (($wrets=fgets($oSocket)) !== false) {
if($lineno++ < 3) {
if(!in_array($wrets, $match_texts)) {
echo $wrets . "<br />";
exit(1);
} else {
continue;
}
}
if($wrets == "Response: Goodbye\r\n") {
break;
}
if(preg_match('[Cause:|Cause-txt|Response:|Message:]', $wrets)) {
echo $wrets . "<br />";
}
flush();
ob_flush();
}
fclose($oSocket);
}
?>
Whould the hangupcause variable be set? http://www.voip-info.org/wiki/view/Asterisk+variable+hangupcause