<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">I did managed to solve my problem by
      using tone_detect to handle "busy"/"decline" and using an event
      hook script that listens for "CHANNEL_CALLSTATE" events (for
      "unavailable").<br>
        <br>
      So, if: Channel-Call-State = RINGING, Call-Direction = outbound,
      Answer-State = early, Original-Channel-Call-State = EARLY,
      Caller-ANI = "one_of_my_DIDs" and (Event-Date-Timestamp -
      Caller-Channel-Created-Time) is lower than 7 seconds then I
      execute a sched_cancel on the session ( to delete the
      sched_hangup).<br>
      <br>
      <br>
      -------- Original Message --------<br>
      <b>Subject: </b>Re: [Freeswitch-users] Detecting multiple tones
      with freeswitch<br>
      <b>From: </b>Michael Collins <a class="moz-txt-link-rfc2396E" href="mailto:msc@freeswitch.org">&lt;msc@freeswitch.org&gt;</a><br>
      <b>To: </b>FreeSWITCH Users Help
      <a class="moz-txt-link-rfc2396E" href="mailto:freeswitch-users@lists.freeswitch.org">&lt;freeswitch-users@lists.freeswitch.org&gt;</a><br>
      <b>Date: </b>06.01.2015 19:23<br>
    </div>
    <blockquote
cite="mid:CAKzWOxXgnXudKARjhF=JszBx7Bv-_NMc3RyKGhwDhTQG00gdSw@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>
          <div>I'm with Jerris on the reliability issue, but if you
            can't switch carriers and they won't budge on sending the
            audio inline then you're pretty much stuck with what you've
            got. I do know that the tone_detect app works well. It's
            been years since I've done anything with it so I'm a bit
            rusty. In your case what I would do is use the
            execute_on_tone_detect to issue an info app. I think you
            might have a value in there somewhere that will help you
            differentiate between whether busy or ring was detected. <br>
            <br>
          </div>
          I wish you well. This is not a fun endeavor...<br>
          <br>
        </div>
        -MC<br>
        <br>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Mon, Jan 5, 2015 at 12:32 PM, Bunea
          Lucian <span dir="ltr">&lt;<a moz-do-not-send="true"
              href="mailto:lucibunea@gmail.com" target="_blank">lucibunea@gmail.com</a>&gt;</span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div bgcolor="#FFFFFF" text="#000000">
              <div>I have a dedicated short number and multiple DIDs. I
                also have a database with customer phone numbers and
                their corresponding DIDs.<br>
                Each field agent has a mobile phone (from the same
                provider).<br>
                When a call comes in freeswitch automatically routes the
                call to the designated field agent via the corresponding
                DID.<br>
                I want to monitor what happens with the call after that,
                to be able to decide what to do with the call next.<br>
                So basically, the call never leaves the provider's
                network.<br>
                <br>
                Btw, I did asked the provider to switch back the
                settings but the feedback was:<br>
                "The behavior is normal because for calls made inside
                Vodafone network, we generate tones. Thus, for Busy, we
                play specific tone and then disconnect the call,
                signaling with SIP 480 (corresponding to the end of
                announcement). If a call comes from another network,
                User Busy is signaled on ISUP and SIP returned as such.
                The settings can not be changed per customer. "<br>
                Unofficially, they acknowledged that their PBX behaved
                differently before because it was not correctly
                configured.<br>
                <br>
                PS: My provider sends the description of the tones using
                a reason header inside the SIP/183 message. But I was
                unable to find a way to extract it:<br>
                <br>
                <a moz-do-not-send="true"
href="http://lists.freeswitch.org/pipermail/freeswitch-users/2014-March/103645.html"
                  target="_blank">http://lists.freeswitch.org/pipermail/freeswitch-users/2014-March/103645.html</a>
                <div>
                  <div class="h5"><br>
                    <br>
                    <br>
                    -------- Original Message --------<br>
                    <b>Subject: </b>Re: [Freeswitch-users] Detecting
                    multiple tones with freeswitch<br>
                    <b>From: </b>Michael Jerris <a
                      moz-do-not-send="true"
                      href="mailto:mike@jerris.com" target="_blank">&lt;mike@jerris.com&gt;</a><br>
                    <b>To: </b>FreeSWITCH Users Help <a
                      moz-do-not-send="true"
                      href="mailto:freeswitch-users@lists.freeswitch.org"
                      target="_blank">&lt;freeswitch-users@lists.freeswitch.org&gt;</a><br>
                    <b>Date: </b>05.01.2015 20:02<br>
                  </div>
                </div>
              </div>
              <div>
                <div class="h5">
                  <blockquote type="cite">
                    <pre>You can never reliably depend on the tones, particularly with international traffic.  This is never going to work reliably unless you get useful sip signaling.  I would be demanding the carrier change settings back.


</pre>
                    <blockquote type="cite">
                      <pre>On Jan 3, 2015, at 7:46 AM, Bunea Lucian <a moz-do-not-send="true" href="mailto:lucibunea@gmail.com" target="_blank">&lt;lucibunea@gmail.com&gt;</a> wrote:

Hello,

My SIP provider (Vodafone) decided to make me a Christmas present: they 
change the configuration of their SIP server.

Using the old configuration they were sending SIP codes for decline, 
busy and unavailable.
Now they are sending early media with tones (for decline and busy) and a 
one minute message for unavailable.
Each status is followed by a SIP/480.

Since I need to be able to distinguish between different statuses, I 
have determined the following:
- if I don't receive a ring tone within 7 second, the called number is 
unavailable;
- if I receive a busy tone within 4 seconds the called number is busy;
- if I receive a busy tone after 4 second the call number has declined 
the call;

This is how I tried to implement it:
- after receiving early media (SIP/180 or SIP/183) a timer is started 
for call hangup (sched_hangup)
- if I receive a ring tone within 7 seconds the timer is canceled 
(sched_cancel);
- if I receive a busy tone a lua script is called;


&lt;action application="set" data="sip_ignore_remote_cause=true"/&gt;
&lt;action application="set" data="execute_on_media=sched_hangup +7 
SUBSCRIBER_ABSENT"/&gt;

&lt;action application="tone_detect" data="busy 425 w +60000 lua 
'busy_detected.lua ${uuid} ${created_time}' 2"/&gt;
&lt;action application="tone_detect" data="ring 450 w +7000 sched_cancel"/&gt;

&lt;action application="bridge" 
data=<a moz-do-not-send="true" href="mailto:sofia/external/$%7Bdestination_number%7D@XXX.XXX.XXX.XXX" target="_blank">"sofia/external/${destination_number}@XXX.XXX.XXX.XXX"</a>/&gt;

But, for some reason, the tones are detected, but the applications are 
never called.


If I add one of the following lines to the dialplan the corresponding 
application is called:

 &lt;action application="set" data="execute_on_tone_detect=sched_cancel"/&gt;

or

 &lt;action application="set" data="execute_on_tone_detect=lua 
busy_detected.lua ${uuid} ${created_time}"/&gt;

but I can't tell which tone was detected...

What am I missing?

PS: Tested with FreeSWITCH Version 1.4.14-1~64bit.

 Regards,
Lucian
</pre>
                    </blockquote>
                    <pre>_________________________________________________________________________
Professional FreeSWITCH Consulting Services: 
<a moz-do-not-send="true" href="mailto:consulting@freeswitch.org" target="_blank">consulting@freeswitch.org</a>
<a moz-do-not-send="true" href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.com</a>

Official FreeSWITCH Sites
<a moz-do-not-send="true" href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a>
<a moz-do-not-send="true" href="http://confluence.freeswitch.org" target="_blank">http://confluence.freeswitch.org</a>
<a moz-do-not-send="true" href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a>

FreeSWITCH-users mailing list
<a moz-do-not-send="true" href="mailto:FreeSWITCH-users@lists.freeswitch.org" target="_blank">FreeSWITCH-users@lists.freeswitch.org</a>
<a moz-do-not-send="true" href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a>
UNSUBSCRIBE:<a moz-do-not-send="true" href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a>
<a moz-do-not-send="true" href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a>
</pre>
                  </blockquote>
                  <br>
                </div>
              </div>
            </div>
            <br>
_________________________________________________________________________<br>
            Professional FreeSWITCH Consulting Services:<br>
            <a moz-do-not-send="true"
              href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a><br>
            <a moz-do-not-send="true"
              href="http://www.freeswitchsolutions.com" target="_blank">http://www.freeswitchsolutions.com</a><br>
            <br>
            Official FreeSWITCH Sites<br>
            <a moz-do-not-send="true" href="http://www.freeswitch.org"
              target="_blank">http://www.freeswitch.org</a><br>
            <a moz-do-not-send="true"
              href="http://confluence.freeswitch.org" target="_blank">http://confluence.freeswitch.org</a><br>
            <a moz-do-not-send="true" href="http://www.cluecon.com"
              target="_blank">http://www.cluecon.com</a><br>
            <br>
            FreeSWITCH-users mailing list<br>
            <a moz-do-not-send="true"
              href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
            <a moz-do-not-send="true"
              href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users"
              target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
            UNSUBSCRIBE:<a moz-do-not-send="true"
              href="http://lists.freeswitch.org/mailman/options/freeswitch-users"
              target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
            <a moz-do-not-send="true" href="http://www.freeswitch.org"
              target="_blank">http://www.freeswitch.org</a><br>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_________________________________________________________________________
Professional FreeSWITCH Consulting Services: 
<a class="moz-txt-link-abbreviated" href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a>
<a class="moz-txt-link-freetext" href="http://www.freeswitchsolutions.com">http://www.freeswitchsolutions.com</a>

Official FreeSWITCH Sites
<a class="moz-txt-link-freetext" href="http://www.freeswitch.org">http://www.freeswitch.org</a>
<a class="moz-txt-link-freetext" href="http://confluence.freeswitch.org">http://confluence.freeswitch.org</a>
<a class="moz-txt-link-freetext" href="http://www.cluecon.com">http://www.cluecon.com</a>

FreeSWITCH-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a>
<a class="moz-txt-link-freetext" href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a>
UNSUBSCRIBE:<a class="moz-txt-link-freetext" href="http://lists.freeswitch.org/mailman/options/freeswitch-users">http://lists.freeswitch.org/mailman/options/freeswitch-users</a>
<a class="moz-txt-link-freetext" href="http://www.freeswitch.org">http://www.freeswitch.org</a></pre>
    </blockquote>
    <br>
  </body>
</html>