Hi all,
I am writing a program (using version 1.05 and 1.07 of asterisk) which
accepts an incoming call, plays some messages, accepts some DTMF digits
(which make up an outgoing phone number) and then dials the provided
number. However, the problem I am suffering is the loss of DTMF digits when
the program is busy performing other actions. The first instance is
in-between playing soundfiles, e.g.
##
my $ret1 = $AGI->stream_file( '/sound/dialtone', '01' );
my $ret2 = $AGI->stream_file( '/sound/welcome', 01' );
##
In the instance above the program is meant to play a half second dialtone
and then a welcome message. If the user presses a key to start dialling
straight away the playback stops and the digit is returned to $ret.
Unfortunately, if someone presses a key in the half-second in-between
messages the digit is lost.
The second instance is:
##
# grabbing DTMF digits to make outgoing telephone number
my $timeout = 3000; # 3 second timeout
while ( $wait ) {
my $digit = $AGI->wait_for_digit( $timeout );
if( $digit > 0 ) { # if digit is input, wait for more digits
$digit -= 48; # making digit decimal from ascii
$outgoing_number .= $digit;
}
else { # stop waiting for more digits
$wait = 0;
}
}
my $ret3 = $AGI->exec( 'dial', "Zap/G1/$outgoing_number" );
# dial outgoing
number
##
In this instance once the user stops dialling for three seconds the program
assumes the user has entered the complete number and starts dialling. If
however, the user is just slow and has yet to input some digits, any digits
entered while the program is trying to dial are lost. The program will
start listening for more digits if the dial fails but it will still have
lost the digits input during the dial.
If anyone has any idea how to capture the 'lost' DTMF digits while the
program is busy performing other actions I would be much obliged. Even
better would be a way to be constantly listening for DTMF digits in the
background of the program so I could grab the DTMF presses at my leisure
and run commands without fear of 'losing' anything.
Many thanks in advance for your help.
David Farrant