Search code examples
phpmysqlodbcasteriskamazon-ami

Wrong CDR dst on Asterisk AMI when call is busy


I am trying to set up the CDR record using MySQL. When a call is answered or it is not answered it writes on dst field the correct value that is the phone number called and outgoing in dcontext field.

But when the call is rejected or phone is off it writes "s" in the dst field and transmit_voice in dcontext field. We want asterisk to write also the phone number in this situation.

When call is answered or no answered goes to this context:

[outgoing]

exten =>_X., 1,Answer()
same=>n, Set(j=0) 
same=>n, Set(message=message)
same => n,While($[${j} < ${I}])
same => n,Playback(${${message}${j}})
same => n,Set(j=$[${j} + 1])
same => n,EndWhile
same=>n,Set(CDR(target)=${EXTEN})
same => n,Hangup()

When a call is rejected or phone is off goes to this context:

[transmit_voice]
exten => _X!,1,NoOp


#include extensions_custom.conf

Here is the PHP snippet:

fputs($this->socket,"Action: originate\r\n");
fputs($this->socket,"Channel: SIP/".$this->strTrunkName."/".$phone."\r\n");
fputs($this->socket,"Variable: canal= SIP/".$this->strTrunkName."/".$phone."\r\n");
fputs($this->socket,"Timeout: ".$this->strWaitTime."\r\n");
fputs($this->socket,"Callerid: ".$this->strCallerId."\r\n");
fputs($this->socket,"Exten: ".$phone."\r\n");
fputs($this->socket,"Context: outgoing\r\n");
while ($audio < count($this->arrAudioPath))
{
  fputs($this->socket,"Variable: message".$audio."=".$this->arrAudioPath[$audio]."\r\n");
  $audio++;
}  
fputs($this->socket,"Variable: I=".$audio."\r\n");
fputs($this->socket,"Async: yes\r\n");
fputs($this->socket,"Priority: 1\r\n\r\n");

Solution

  • It is expected behavour. When call is busy there are no dst.

    If you want change that, call via Local/ channel, not via sip.