Passing variable to Dynamic Feature

Is there a way to pass variable (e.g. ${SIPCALLID}) to dynamic feature function call?

What I need to do is to record DTMF digits pressed in a call and somehow relate it back to particular CDR via SIPCALLID or any other vairable.

And by the way I am not talking about using the READ function. I simply need Asterisk constantly scan for DTMF digits (so that is why I choose using dyanmic feature map) and whatever DTMF digits is being pressed during a CONNECTED call, asterisk will record it. I know I can turn on the logger, but still that won’t let me relate dtmf digits to a particular call.

Is that possible?

I checked the example in the features.conf file which:

retrieveinfo => #8,peer,Set(ARRAY(CDR(mark),CDR(name))=${ODBC_FOO(${CALLERID(num)})})

so using that example, I wrote:

retrieveinfo => #8,peer,Set(ODBC_InsDTMFPressed()=${CALLERID(num)},8)

where InsDTMFPressed is in func_odbc.conf:

Insert Into DTMF_Pressed (SIPCallID,DTMF_Digit) Values (’${SQL_ESC(${VAL1})}’,’${SQL_ESC(${VAL2})}’)

But when I tried using it, in the database, it recorded the string “${CALLERID(num)}” instead of the actuall callerid number. So it leads me think that dynamic feature is NOT capable of getting variable from the call itslef? Or am I missing some setting so that it will actually get the variable duirng the call?

Thank you!

David55, you have any idea? It seems you are always around to help!

Thank you!

Variables are expanded when the dialplan line is processed. That step doesn’t happen when the parameters are supplied through features.conf, and if it did, would probably happen when features.conf was parsed.

Although some people report that macros and subroutines work, the official position is that they don’t,

So either try a macro or subroutine at your own risk, or accept that Asterisk doesn’t work the way that you want.

Again, thank you very much for your help. So in the features.conf of Asterisk 11, why did they give out the example below:

; Example Usage:
;
;testfeature => #9,peer,Playback,tt-monkeys ;Allow both the caller and callee to play
; ;tt-monkeys to the opposite channel
;
; Set arbitrary channel variables, based upon CALLERID number (Note that the application
; argument contains commas)
;retrieveinfo => #8,peer,Set(ARRAY(CDR(mark),CDR(name))=${ODBC_FOO(${CALLERID(num)})})

Where it made it looks like it can pass the variable ${CALLERID(num}} into the odbc function call in the extensions.conf when #8 is pressed? Especially they said “based upon CALLERID number” which made me think that during a call, #8 pressed and in the Callerid will be passed to the features.conf…

Weird…

Thank you David55, macro works!

I haven’t specifically checked whether or not the line is put through the pbx.c variable expansion process, so I could be wrong on that, or the example could have been optimistic. The fact that it didn’t get expanded for your does suggest that the example is wrong.

Hello David55,

I guess I got happy too fast… Here is my code:

In the extensions.conf:

exten => _X.,n,Set(__DYNAMIC_FEATURES=DTMF0#DTMF1#DTMF2#DTMF3#DTMF4#DTMF5#DTMF6#DTMF7#DTMF8#DTMF9)

[macro-DTMF]
exten => s,1,Set(ODBC_DTMFPressed()=${SIPID},${ARG1},${STRFTIME(${EPOCH},GMT,%F %H:%M:%S.%3q)})

And in the features.conf:
DTMF0 => 0,peer,Macro(DTMF,0)
DTMF1 => 1,peer,Macro(DTMF,1)
DTMF2 => 2,peer,Macro(DTMF,2)
DTMF3 => 3,peer,Macro(DTMF,3)
DTMF4 => 4,peer,Macro(DTMF,4)
DTMF5 => 5,peer,Macro(DTMF,5)
DTMF6 => 6,peer,Macro(DTMF,6)
DTMF7 => 7,peer,Macro(DTMF,7)
DTMF8 => 8,peer,Macro(DTMF,8)
DTMF9 => 9,peer,Macro(DTMF,9)

So when caller A calls B and that B press the keypad (or vise versa), A do not hear any DTMF or something A will hear a “dud” rather then a tone, but alot of time, not even a “dud” just nothing.

although I turn on the dtmf at the logger.conf and I see Asterisk get the DTMF and the row was inserted in the database by the macro-DTMF. But it seems asterisk does NOT passing the DTMF correctly. Do you know why that would be?

Frank

So now I am trying to use

[macro-DTMF]
exten => s,1,SendDTMF(${ARG1})
exten => s,n,Set(ODBC_DTMFPressed()=${SIPID},${ARG1},${STRFTIME(${EPOCH},GMT,%F %H:%M:%S.%3q)})

in the console I see:

WARNING[2744][C-0000003a]: pbx.c:4621 pbx_extension_helper: No application ‘SendDTMF’ for extension (macro-DTMF, s, 1)

why is that? Is there a module I need to load?

Ok I found the issue, when I do “core show applications” I do NOT see sendDTMF app in the list. But when I exit asterisk and do a “make menuselect” I DO see sendDTMF app selected, so why is it not loaded? Any idea?

Nevermind… found the issue… in the modules.conf, it has “noload” infront… really need a good memory so that I can remember how to do what when…

So it seems that by enabling Dynamic feature, it really distort the DTMF tone going to the far end. Is there any reason this suppose to happen? Or any fix?

Or can we strip out the “original” dtmf and just have asterisk regenerate the DTMF by using the sendDTMF?

also with this dynamic feature, it seems sometime it does not do what it suppose to if I press digiti too fast? In the example below, I hit 106 but it seems it “ignore” the “zero”, why is that?

[Mar 25 09:21:26] DTMF[1666][C-00000013]: channel.c:4170 __ast_read: DTMF begin ‘1’ received on SIP/xxx-00000024
[Mar 25 09:21:26] DTMF[1666][C-00000013]: channel.c:4181 __ast_read: DTMF begin passthrough ‘1’ on SIP/xxx-00000024
– Feature Found: DTMF1 exten: DTMF1
[Mar 25 09:21:26] DTMF[1666][C-00000013]: channel.c:4084 __ast_read: DTMF end ‘1’ received on SIP/xxx-00000024, duration 180 ms
[Mar 25 09:21:26] DTMF[1666][C-00000013]: channel.c:4125 __ast_read: DTMF end accepted with begin ‘1’ on SIP/xxx-00000024
[Mar 25 09:21:26] DTMF[1666][C-00000013]: channel.c:4154 __ast_read: DTMF end passthrough ‘1’ on SIP/xxx-00000024
– Feature Found: DTMF1 exten: DTMF1
– Executing [s@macro-DTMF:1] SendDTMF(“SIP/yyy-00000025”, “1”) in new stack
[Mar 25 09:21:27] DTMF[1574][C-00000013]: channel.c:4170 __ast_read: DTMF begin ‘0’ received on SIP/xxx-00000024
[Mar 25 09:21:27] DTMF[1574][C-00000013]: channel.c:4174 __ast_read: DTMF begin ignored ‘0’ on SIP/xxx-00000024
[Mar 25 09:21:27] DTMF[1574][C-00000013]: channel.c:4084 __ast_read: DTMF end ‘0’ received on SIP/xxx-00000024, duration 190 ms
[Mar 25 09:21:27] DTMF[1574][C-00000013]: channel.c:4154 __ast_read: DTMF end passthrough ‘0’ on SIP/xxx-00000024
– Executing [s@macro-DTMF:2] Set(“SIP/yyy-00000025”, “ODBC_DTMFPressed()=1142545675253201416266@20.20.20.20,1,2014-03-25 16:21:27.000”) in new stack
[Mar 25 09:21:27] DTMF[1574][C-00000013]: channel.c:4170 __ast_read: DTMF begin ‘6’ received on SIP/xxx-00000024
[Mar 25 09:21:27] DTMF[1574][C-00000013]: channel.c:4174 __ast_read: DTMF begin ignored ‘6’ on SIP/xxx-00000024
[Mar 25 09:21:27] DTMF[1666][C-00000013]: channel.c:4084 __ast_read: DTMF end ‘6’ received on SIP/xxx-00000024, duration 190 ms
[Mar 25 09:21:27] DTMF[1666][C-00000013]: channel.c:4111 __ast_read: DTMF begin emulation of ‘6’ with duration 190 queued on SIP/WTIAC8-00000024
– Feature Found: DTMF6 exten: DTMF6

It seems that if the gap between dialing the digit, if is too close, it will “ignore” it? Is there a timer for that? Where I can set it to less so that if someone dials fast, it would work too?

Or it got ignore due to the fact it was still processing the macro for “1” so it ignore it? Because look at the where it process the “0” it is sandwiched between the “senddtmf” app and the “odbc” app. Is that why?