简体   繁体   中英

Asterisk, Ignore DTMF special characters in GET DATA

I'm using phpagi $agi->get_data to read digit from user.
In some telephones, user didn't hit any key, but audio playback immediately stops and get result of "D" !!
I searched a lot about it, and looks like $agi-get_dat receives DTMF data that contains 0-9*#ABCD .
1st question is, why my users get "D" without hitting any key!
2nd question is, how can i ignore these characters to prevent interrupting my ivr.

phpagi getdata do this call

https://wiki.asterisk.org/wiki/display/AST/AGICommand_stream+file

so you can extend it by adding allowed digits param. PhpAGI lib is opensource and have source code.

Actualy you can just use stream_file call

stream_file (line 677)

Play the given audio file, allowing playback to be interrupted by a DTMF digit. This command is similar to the GET DATA command but this command returns after the first DTMF digit has been pressed while GET DATA can accumulated any number of digits before returning.

 return: see evaluate for return information. ['result'] is -1 on hangup or error, 0 if playback completes with no digit received, 

otherwise a decimal value of the DTMF tone. Use chr() to convert to ASCII. link: http://www.voip-info.org/wiki-stream+file example: Ping an IP address

array, stream_file (string $filename, [string $escape_digits = ''], integer $offset)

 string $filename: without extension, often in /var/lib/asterisk/sounds string $escape_digits integer $offset 

you can check the logs by the following command :

asterisk -vvvvv

and you can check the value of the input for example in php code :

$val = $agi->get_data exec("echo $val >> /tmp/output")

and then check this file : /tmp/output

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM