Hey everyone,
I’m using some custom extensions in my freePBX. Currently, I stumbled across a problem that I can’t seem to fix…
First, this is my extension I’m referring to in the following post:
[test]
exten => s,1,Answer()
same => n,Set(timeout=3) ; Set default timeout value to 3 seconds (adjust as needed)
same => n,Set(digits=)
same => n,Set(start_time=${EPOCH}) ; Get the start time of the call
same => n,Set(digit_input=false) ; Set initial digit input flag to false
same => n,Set(timeout_expired=false) ; Set initial timeout flag to false
same => n(loop_start),Read(digit,,1)
same => n,GotoIf($["${digit}" = ""]?check_digit_input:save_digit_input)
same => n(save_digit_input),Set(digits=${digits}${digit})
same => n,Set(digit_input=true) ; Set digit input flag to true when at least one digit is entered
same => n,Set(start_time=${EPOCH}) ; Reset the start time on new DTMF input
same => n,Goto(check_timeout)
same => n(check_digit_input),GotoIf($[${digit_input} = false]?test,s,1:wait_for_input)
same => n(wait_for_input),Set(time_elapsed=$[${EPOCH}-${start_time}])
same => n,GotoIf($[${time_elapsed} < ${timeout}]?loop_start:process_input)
same => n(check_timeout),Set(time_elapsed=$[${EPOCH}-${start_time}])
same => n,GotoIf($[${time_elapsed} >= ${timeout}]?set_timeout_expired:loop_start)
same => n(set_timeout_expired),Set(timeout_expired=true)
same => n,Goto(process_input)
same => n(process_input),GotoIf($[${timeout_expired} = true]?timeout_exit)
same => n,System(/usr/bin/python3 /home/custom-scripts/xxxxx.py ${digits})
same => n,Playback(/home/custom-scripts/generated-audio/${digits})
same => n,System(/usr/bin/python3 /home/custom-scripts/xxxx2.py ${digits})
same => n(exit),Hangup()
same => n(timeout_exit),Playback(tt-weasels)
same => n,Hangup()
A short explanation:
My extension has a set timeout value that should be editable. It’s this one:
same => n,Set(timeout=10) ; Set default timeout value to 10 seconds (adjust as needed)
When no DTMF-input was detected within the timeout, the extension just starts again, waiting for DTMF input:
same => n(check_digit_input),GotoIf($[${digit_input} = false]?test,s,1:wait_for_input)
When at least one DTMF input was detected during the timeout, these are being called, which then perform some actions:
same => n,System(/usr/bin/python3 /home/custom-scripts/xxxxx.py ${digits})
same => n,Playback(/home/custom-scripts/generated-audio/${digits})
same => n,System(/usr/bin/python3 /home/custom-scripts/xxxx2.py ${digits})
same => n(exit),Hangup()
!IMPORTANT! With every DTMF input detected, the timeout starts again before calling these :
So theoretically when pressing x-digits with each a delay of 3 seconds it would allow infinite DTMF inputs, because the timeout always restarts.
When pressing for example 5-digits with a delay of 3 seconds and then waiting for the defined timeout, the script executes these:
same => n,System(/usr/bin/python3 /home/custom-scripts/xxxxx.py ${digits})
same => n,Playback(/home/custom-scripts/generated-audio/${digits})
same => n,System(/usr/bin/python3 /home/custom-scripts/xxxx2.py ${digits})
same => n(exit),Hangup()
So far, so good. The extension works on my server and does basically everything important…
However, when editing the timeout value, it completely ignores my changes…
It doesn’t matter if I put in (timeout=10) or (timeout=2)… It always uses exactly 10 meaning a 10 sec. timeout…
Does anyone know what’s wrong? I’ve been trying for hours to debug using stopwatches etc. but the timeout value basically doesn’t seem to affect anything… It’s always 10sec no matter what value I define…
Thanks a lot for your help!