Compare DTMF with pattern

Hi, I’m building some test device with asterisk and I need to add a CDR userfield wich says if the DTMF was right or not.
My extensions.conf

exten => 5,1,Answer
exten => 5,n,Read(dtmfinput,19,skip,1,19)
exten => 5,n,Set(CDR(dtmfinput)=${dtmfinput})
exten => 5,n,GotoIf(["${dtmfinput}"=“0123456789876543210”]?OK:mistake)
exten => 5,n(mistake),Set(CDR(dtmfstatus)=wrong)
exten => 5,n(OK),Set(CDR(dtmfstatus)=OK)
exten => 5,n,Hangup

and CLI says

– Accepting AUTHENTICATED call from :
– > requested format = alaw,
– > requested prefs = (alaw|g722),
– > actual format = g722,
– > host prefs = (g722|alaw),
– > priority = mine
– Executing [5@public:1] Answer("IAX2/
-9919", “”) in new stack
– Executing [5@public:2] Read("IAX2/
-9919", “dtmfinput,19,skip,1,19”) in new stack
– Accepting a maximum of 19 digits.
– User entered ‘0123456789876543210’
– Executing [5@public:3] Set("IAX2/
-9919", “CDR(dtmfinput)=012345678987 6543210”) in new stack
– Executing [5@public:4] GotoIf("IAX2/
-9919", “[“0123456789876543210”=” 0123456789876543210"]?OK:mistake") in new stack
– Goto (public,5,6)
– Executing [5@public:6] Set(“IAX2/*****-9919”, “CDR(dtmfstatust)=OK”) in new stack
– Executing [5@public:7] Hangup("IAX2/
-9919", “”) in new stack
== Spawn extension (public, 5, 7) exited non-zero on 'IAX2/
-9919’
– Hungup 'IAX2/
****-9919’

And it is really OK… But

-- Accepting AUTHENTICATED call from **********:
--        > requested format = alaw,
--        > requested prefs = (alaw|g722),
--        > actual format = g722,
--        > host prefs = (g722|alaw),
--        > priority = mine
-- Executing [5@public:1] Answer("IAX2/****-1601", "") in new stack
-- Executing [5@public:2] Read("IAX2/****-1601", "dtmfinput,,19,skip,1,19") in new stack
-- Accepting a maximum of 19 digits.
-- User entered nothing.
-- Executing [5@public:3] Set("IAX2/****-1601", "CDR(dtmfinput)=") in new stack
-- Executing [5@public:4] GotoIf("IAX2/****-1601", "[""="0123456789876543210"]?OK:mistake") in new stack
-- Goto (public,5,6)
-- Executing [5@public:6] Set("IAX2/****-1601", "CDR(dtmfstatus)=OK") in new stack
-- Executing [5@public:7] Hangup("IAX2/*****-1601", "") in new stack

== Spawn extension (public, 5, 7) exited non-zero on ‘IAX2/*****-1601’
– Hungup 'IAX2/****-1601’¨

Does anybody know, where is the problem? thanks

Missing dollars before open square brackets

1 Like

exten => 5,n,GotoIf(["${dtmfinput}"=“0123456789876543210”]?OK:mistake)

Nope, still the same… I have made it like this:

exten => 5,n,GotoIf($["${dtmfinput}"=“0123456789876543210”]?OK:mistake)

The log should have changed.

But it still says that dtmf is correct when its not. And always its the “OK” choice.
Wouldnt be better to store the pattern to variable and then compare the patterns?
Something like
exten => 5,n,Set(${pattern}=0123456789876543210)
exten => 5,n,GotoIf($["${dtmfinput}"="${pattern}"]?OK:mistake)
I believe that the problem is in combination of ‘’ , {} and $… But Ive tried really many combinations.

based on your logs ${dtmfinput} is null, make sure dtmf is captured

He’s setting CDR(dtmfinput) but reading dtmfinput!

Yes you right @david551, But I was taking about this piece of log

– Executing [5@public:2] Read(“IAX2/****-1601”, “dtmfinput,19,skip,1,19”) in new stack
– Accepting a maximum of 19 digits.
– User entered nothing.
it seems user has no entered any DTMF key, he needs to post the new logs after add the dollars before open square brackets

Solved…

exten => 5,n,Goto(end)

was missing

You forget $ before {dtmfinput}