hello, i just got a question. Is it possible somehow to achieve a DTMF collect cancel feature. quite hard to explain :)) lets suppose you have an extension that collects some digits ... e.g. 123456789 .. and in the middle you realized you entered a wrong digit and u want to correct it. Is there any way you can assign a digit e-g. * or # to interupt te current input and to start over again by lets say transfering back to the extension collecting digits? Any hint ?
On Tue, 2010-08-24 at 12:52 +0200, Tihomir Culjaga wrote:
hello, i just got a question.
Is it possible somehow to achieve a DTMF collect cancel feature. quite hard to explain :))
lets suppose you have an extension that collects some digits ... e.g. 123456789 .. and in the middle you realized you entered a wrong digit and u want to correct it. Is there any way you can assign a digit e-g. * or # to interupt te current input and to start over again by lets say transfering back to the extension collecting digits?
It shouldn't be hard to do with a small lua script with an input callback handling DTMFs. You could even create a small DTMF editor with a digit for "backspace" character for example, that would erase the last digit, or a digit that would say the current sequence.... Check out: http://wiki.freeswitch.org/wiki/Lua#session:setInputCallback François.
It shouldn't be hard to do with a small lua script with an input
callback handling DTMFs.
You could even create a small DTMF editor with a digit for "backspace" character for example, that would erase the last digit, or a digit that would say the current sequence....
Check out: http://wiki.freeswitch.org/wiki/Lua#session:setInputCallback
François.
Nice! i wrote a small script: function onInput(s, type, obj) if (type == "dtmf") then freeswitch.consoleLog("info", "DTMF Digit: " .. obj.digit .. "\n"); freeswitch.consoleLog("info", "DTMF Duration: " .. obj.duration .. "\n"); if (obj.duration > 2000) then freeswitch.consoleLog("info", "we got long DTMF \n"); end end end session:answer(); session:setInputCallback("onInput"); session:sleep(200); while (session:ready() == true) do session:sleep(100); end i run it in dialplan as: <include> <extension name="longPound"> <condition field="destination_number" expression="^pound$"> <action application="lua" data="Pound.lua"/> <action application="playback" data="bla1"/> <action application="playback" data="bla2"/> <action application="playback" data="bla3"/> <!-- <action application="sleep" data="10000"/> --> </condition> </extension> </include> but it seems the lua scripts is blocking .... i never get to playback part. I need to make it run in background for the entire duration of the session how can i do it? T.
Move the playback inside the script -- View this message in context: http://freeswitch-users.2379917.n2.nabble.com/long-DTMF-tp5456386p5458183.ht... Sent from the freeswitch-users mailing list archive at Nabble.com.
On Tue, Aug 24, 2010 at 8:41 PM, Jeff Lenk <jeff@jefflenk.com> wrote:
Move the playback inside the script
not really feasible, all the logic is already done in DP... Im missing just
this feature. what is the bgapi equivalent of: <action application="set" data="api_result=${lua(script.lua)}"/>
On Tue, Aug 24, 2010 at 9:05 PM, Tihomir Culjaga <tculjaga@gmail.com> wrote:
On Tue, Aug 24, 2010 at 8:41 PM, Jeff Lenk <jeff@jefflenk.com> wrote:
Move the playback inside the script
not really feasible, all the logic is already done in DP... Im missing
just this feature.
what is the bgapi equivalent of:
<action application="set" data="api_result=${lua(script.lua)}"/>
anyone who can know this ? how to run a lua script in background ?
Have you tried using the event socket library http://wiki.freeswitch.org/wiki/Esl --- On Wed, 25/8/10, Tihomir Culjaga <tculjaga@gmail.com> wrote: From: Tihomir Culjaga <tculjaga@gmail.com> Subject: Re: [Freeswitch-users] long DTMF To: "FreeSWITCH Users Help" <freeswitch-users@lists.freeswitch.org> Date: Wednesday, 25 August, 2010, 16:46 On Tue, Aug 24, 2010 at 9:05 PM, Tihomir Culjaga <tculjaga@gmail.com> wrote: On Tue, Aug 24, 2010 at 8:41 PM, Jeff Lenk <jeff@jefflenk.com> wrote: Move the playback inside the script not really feasible, all the logic is already done in DP... Im missing just this feature. what is the bgapi equivalent of: <action application="set" data="api_result=${lua(script.lua)}"/> anyone who can know this ? how to run a lua script in background ? -----Inline Attachment Follows----- _______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
On Wed, Aug 25, 2010 at 7:47 PM, Nigel Kent <ktngl@yahoo.co.uk> wrote:
Have you tried using the event socket library http://wiki.freeswitch.org/wiki/Esl
well, i could have used esl from the start but thats and external application controling FS... and its totally a different approach from where im now:(. I have everything up & running except this feature .. so is there any chance to run a lua script in background (by allowing the normal callflow to go on) to collect a special DTMF event ? something like this: <action application="set" data="api_result=${lua(script.lua)}"/> ? T.
as usual we are alone here ... I just lost my patience and did it directly in code! Once rewriting according to FS requirements done , will provide a patch if anyone interested. -----------------<-snip->----------------------- /*it's hardcoded but who cares at that point :))*/ if (dtmf->digit == '#') { int ok = 0; *digit = dtmf->digit; dval = atoi(digit); dval=0; /* temporary fake the bind key */ if (direction == SWITCH_DTMF_RECV && (md->sr[direction].map[dval].bind_flags & SBF_DIAL_ALEG)) { ok = 1; } else if (direction == SWITCH_DTMF_SEND && (md->sr[direction].map[dval].bind_flags & SBF_DIAL_BLEG)) { ok = 1; } if (ok && md->sr[direction].map[dval].app) { uint32_t flags = md->sr[direction].map[dval].flags; if ((md->sr[direction].map[dval].bind_flags & SBF_EXEC_OPPOSITE)) { if (direction == SWITCH_DTMF_SEND) { flags |= SMF_ECHO_ALEG; } else { flags |= SMF_ECHO_BLEG; } } else if ((md- >sr[direction].map[dval].bind_flags & SBF_EXEC_SAME)) { if (direction == SWITCH_DTMF_SEND) { flags |= SMF_ECHO_BLEG; } else { flags |= SMF_ECHO_ALEG; } } else if ((md- >sr[direction].map[dval].bind_flags & SBF_EXEC_ALEG)) { flags |= SMF_ECHO_ALEG; } else if ((md->sr[direction].map[dval].bind_flags & SBF_EXEC_BLEG)) { flags |= SMF_ECHO_BLEG; } else { flags |= SMF_ECHO_ALEG; } if ((md->sr[direction].map[dval].bind_flags & SBF_EXEC_INLINE)) { flags |= SMF_EXEC_INLINE; } switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Processing meta digit '%c' [%s]\n", switch_channel_get_name(channel), dtmf->digit, md->sr[direction].map[dval].app); if (switch_channel_test_flag(channel, CF_PROXY_MODE)) { broadcast_in_thread(session, md->sr[direction].map[dval].app, flags | SMF_REBRIDGE); } else { switch_ivr_broadcast(switch_core_session_get_uuid(session), md->sr[direction].map[dval].app, flags); } if ((md->sr[direction].map[dval].bind_flags & SBF_ONCE)) { memset(&md->sr[direction].map[dval], 0, sizeof(md->sr[direction].map[dval])); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Unbinding meta digit '%c'\n", switch_channel_get_name(channel), dtmf->digit); } } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s Ignoring meta digit '%c' not mapped\n", switch_channel_get_name(channel), dtmf->digit); } /* return SWITCH_STATUS_SUCCESS; */ return SWITCH_STATUS_FALSE; } -----------------<-snip->----------------------- usage in DP: <action application="bind_long_dtmf" data="0 a s transfer::myExtension XML myContext"/> in myExtension you do your stuff! On Wed, Aug 25, 2010 at 10:14 PM, Tihomir Culjaga <tculjaga@gmail.com>wrote:
On Wed, Aug 25, 2010 at 7:47 PM, Nigel Kent <ktngl@yahoo.co.uk> wrote:
Have you tried using the event socket library http://wiki.freeswitch.org/wiki/Esl
well, i could have used esl from the start but thats and external application controling FS... and its totally a different approach from where im now:(. I have everything up & running except this feature ..
so is there any chance to run a lua script in background (by allowing the normal callflow to go on) to collect a special DTMF event ?
something like this:
<action application="set" data="api_result=${lua(script.lua)}"/>
?
T.
TtT -----Original Message----- From: Tihomir Culjaga <tculjaga@gmail.com> Sender: freeswitch-users-bounces@lists.freeswitch.org Date: Fri, 27 Aug 2010 11:03:19 To: FreeSWITCH Users Help<freeswitch-users@lists.freeswitch.org> Reply-To: FreeSWITCH Users Help <freeswitch-users@lists.freeswitch.org> Subject: Re: [Freeswitch-users] long DTMF _______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
I did read your emails, and I thought the Lua script idea was nice. The ESL was more complicated, but also good. But, you didn't accept either. So, I was wondering, is this "bind_long_DTMF" something that allows you to capture DTMF during the full length of the call, i.e. even after bridge? Is that what you wished to accomplish? Regards HASSAN On Fri, Aug 27, 2010 at 15:03, Tihomir Culjaga <tculjaga@gmail.com> wrote:
as usual we are alone here ... I just lost my patience and did it directly in code!
Once rewriting according to FS requirements done , will provide a patch if anyone interested.
-----------------<-snip->----------------------- /*it's hardcoded but who cares at that point :))*/ if (dtmf->digit == '#') { int ok = 0; *digit = dtmf->digit; dval = atoi(digit); dval=0; /* temporary fake the bind key */ if (direction == SWITCH_DTMF_RECV && (md->sr[direction].map[dval].bind_flags & SBF_DIAL_ALEG)) { ok = 1; } else if (direction == SWITCH_DTMF_SEND && (md->sr[direction].map[dval].bind_flags & SBF_DIAL_BLEG)) { ok = 1; }
if (ok && md->sr[direction].map[dval].app) { uint32_t flags = md->sr[direction].map[dval].flags;
if ((md->sr[direction].map[dval].bind_flags & SBF_EXEC_OPPOSITE)) { if (direction == SWITCH_DTMF_SEND) { flags |= SMF_ECHO_ALEG; } else { flags |= SMF_ECHO_BLEG; } } else if ((md- >sr[direction].map[dval].bind_flags & SBF_EXEC_SAME)) { if (direction == SWITCH_DTMF_SEND) { flags |= SMF_ECHO_BLEG; } else { flags |= SMF_ECHO_ALEG; } } else if ((md- >sr[direction].map[dval].bind_flags & SBF_EXEC_ALEG)) { flags |= SMF_ECHO_ALEG; } else if ((md->sr[direction].map[dval].bind_flags & SBF_EXEC_BLEG)) { flags |= SMF_ECHO_BLEG; } else { flags |= SMF_ECHO_ALEG; }
if ((md->sr[direction].map[dval].bind_flags & SBF_EXEC_INLINE)) { flags |= SMF_EXEC_INLINE; }
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Processing meta digit '%c' [%s]\n",
switch_channel_get_name(channel), dtmf->digit, md->sr[direction].map[dval].app);
if (switch_channel_test_flag(channel, CF_PROXY_MODE)) { broadcast_in_thread(session, md->sr[direction].map[dval].app, flags | SMF_REBRIDGE); } else {
switch_ivr_broadcast(switch_core_session_get_uuid(session), md->sr[direction].map[dval].app, flags); } if ((md->sr[direction].map[dval].bind_flags & SBF_ONCE)) {
memset(&md->sr[direction].map[dval], 0, sizeof(md->sr[direction].map[dval]));
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Unbinding meta digit '%c'\n",
switch_channel_get_name(channel), dtmf->digit); } } else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s Ignoring meta digit '%c' not mapped\n",
switch_channel_get_name(channel), dtmf->digit); }
/* return SWITCH_STATUS_SUCCESS; */ return SWITCH_STATUS_FALSE;
}
-----------------<-snip->-----------------------
usage in DP:
<action application="bind_long_dtmf" data="0 a s transfer::myExtension XML myContext"/>
in myExtension you do your stuff!
On Wed, Aug 25, 2010 at 10:14 PM, Tihomir Culjaga <tculjaga@gmail.com>wrote:
On Wed, Aug 25, 2010 at 7:47 PM, Nigel Kent <ktngl@yahoo.co.uk> wrote:
Have you tried using the event socket library http://wiki.freeswitch.org/wiki/Esl
well, i could have used esl from the start but thats and external application controling FS... and its totally a different approach from where im now:(. I have everything up & running except this feature ..
so is there any chance to run a lua script in background (by allowing the normal callflow to go on) to collect a special DTMF event ?
something like this:
<action application="set" data="api_result=${lua(script.lua)}"/>
?
T.
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
On Fri, Aug 27, 2010 at 1:17 PM, Nyamul Hassan <mnhassan@usa.net> wrote:
I did read your emails, and I thought the Lua script idea was nice.
lua was nice but it was blocking ... no further dialplan processing before it ends (at least this is what i went into)... and if it ends there is no Callback to collect DTMF digits :( I tried to put it in background but i was not able to... anyhow it was a nice experience ... my 1st lua scripting :)
The ESL was more complicated, but also good. But, you didn't accept either.
ESL ... huh its really nice but not applicable to my application :( ... I decided to go dialplan way and did everything within. honestly a separate daemon than interacts with FS and decides what to do according to events scares me a bit ... I have never done something like this and i was not confident i would complete the task on time. This means moving the logic outside FS... anyhow this is something on my next ToDo list :)
So, I was wondering, is this "bind_long_DTMF" something that allows you to capture DTMF during the full length of the call, i.e. even after bridge? Is that what you wished to accomplish?
This is a callingCard application and one of the requirments was to be able to cancel the wrong destination number entry with a single # (* is end of dial digit) starting from the point it asks you for the destination number afterwards. This means you can cancel an while; getting destination number, calls in being bridged, already bridged calls and return the A-leg call state back to enter another destination.
As i didn't find any solution around here to do such a thing in dialplan or via scripting i went down to the original code and wrote my own function. BTW: Also, i will extend the function to do what it's name says "long". If someone press # for a certain amount of time (topically 2 seconds) an action will be triggered. If the duration is less than the specified time nothing will happen. Thanks for your e-mail. T.
participants (6)
-
Budi wibowo
-
François Delawarde
-
Jeff Lenk
-
Nigel Kent
-
Nyamul Hassan
-
Tihomir Culjaga