FSSCRIPTS-17 and FSSCRIPTS-16

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13896 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Brian West 2009-06-22 18:53:49 +00:00
parent 49c1dc415f
commit 836f84100d
5 changed files with 352 additions and 8 deletions

View File

@ -40,3 +40,24 @@ Configuration fragments look something like:
Tested using FreeSWITCH SVN 10428 running on FreeBSD 6.3 Tested using FreeSWITCH SVN 10428 running on FreeBSD 6.3
with a Sangoma A200DX Analog Series w/ Echo Cancellation with a Sangoma A200DX Analog Series w/ Echo Cancellation
ports card containing 2 FXO modules. ports card containing 2 FXO modules.
Note that the PBX is * very * sensitive to how long it takes
for the line to be hung up after it sends the DTMF hangup
command. Failure to apply the following patch will cause
the PBX to occasionally believe that some vmail lines were
off hook for too long and are therfore out of service.
Index: src/zap_io.c
===================================================================
--- src/zap_io.c (revision 745)
+++ src/zap_io.c (working copy)
@@ -1728,7 +1728,8 @@
zchan->dtmf_hangup_buf[zchan->span->dtmf_hangup_len - 1] = *p;
if (!strcmp(zchan->dtmf_hangup_buf, zchan->span->dtmf_hangup)) {
zap_log(ZAP_LOG_DEBUG, "DTMF hangup detected.\n");
- zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_HANGUP);
+ zchan->caller_data.hangup_cause = ZAP_CAUSE_NORMAL_CLEARING;
+ zap_set_state_locked(zchan, ZAP_CHANNEL_STATE_DOWN);
break;
}
}

View File

@ -0,0 +1,72 @@
This directory contains software for configuring FreeSWITCH
to provide AT&T (aka Lucent aka Avaya) System 25 PBX compatible
park and pickup park functions. Specifically:
a) Putting a call on hold and then dialing *5 will park the
call on your phone.
b) Dialing *8 followed by an extension will pickup a call parked
on that extension.
as a bonus:
c) Doing a blind transfer of a call to *5 will park the call
on your phone.
d) Doing a blind transfer of a call to *5 followed by an extension
will park the call on that extension.
e) Dialing *8 without an extension will prompt for an extension.
s25park.js goes into the FreeSWITCH scripts directory.
Configuration fragments look something like:
conf/dialplan/default.xml
<extension name="system25_park">
<condition field="source" expression="mod_sofia"/>
<condition field="destination_number" expression="^\*5$"/>
<condition field="${sip_h_Referred-By}" expression="^<sip:([0-9]{4})@.*$">
<action application="transfer" data="*5$1"/>
<anti-action application="javascript" data="s25park.js"/>
</condition>
</extension>
<extension name="system25_park_on_extension">
<condition field="destination_number" expression="^\*5([0-9]{4})$">
<action application="set" data="fifo_music=$${hold_music}"/>
<action application="set" data="fifo_orbit_exten=$1:120"/>
<action application="fifo" data="$1@$${domain} in"/>
</condition>
</extension>
<extension name="system25_pickup">
<condition field="destination_number" expression="^\*8$">
<action application="answer"/>
<action application="sleep" data="1"/>
<action application="read" data="3 5 $${base_dir}/sounds/en/us/callie/ivr/8000/ivr-enter_ext.wav ext 1000 #"/>
<action application="transfer" data="*8${ext}"/>
</condition>
</extension>
<extension name="system25_pickup_from_extension">
<condition field="destination_number" expression="^\*8[0-9]{3,4}$"/>
<condition field="destination_number" expression="^\*8([0-9]{4})$">
<action application="fifo" data="$1@$${domain} out nowait"/>
<anti-action application="bridge" data="openzap/5/a/${destination_number}"/>
</condition>
</extension>
The system25 park and pickup dialplan patterns are designed
to only consider four digit extensions for local parking.
"system25_pickup_from_extension" recognizes three digit
extensions as being parked on a foreign PBX ... modify
as appropriate for your installation.
Be aware that the default dialplan contains an extension
called "group-intercept" which needs to be commented out
in order for "system25_pickup" to work since they both
match *8.
Tested using FreeSWITCH SVN 13769 running on FreeBSD 6.4.

178
scripts/s25vmail/s25park.js Normal file
View File

@ -0,0 +1,178 @@
/*
* File: s25park.js
* Purpose: Implement AT&T System 25 PBX style parking.
* Machine: OS:
* Author: John Wehle Date: June 9, 2009
*/
/*
* Copyright (c) 2009 Feith Systems and Software, Inc.
* All Rights Reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* RE to sanity check that the caller id is a valid extension */
var extRE = /^[0-9]{3,4}$/g;
var dtmf_digits;
function on_dtmf (session, type, obj, arg)
{
if (type == "dtmf") {
dtmf_digits += obj.digit;
return false;
}
return true;
}
function normalize_channel_name (name, direction, ip_addr)
{
var re = /^sofia\//g;
var length = name.search (re);
var new_name = name;
if (length == -1)
return new_name;
if (direction == "inbound") {
re = /@.*$/g;
new_name = name.replace (re, "@" + ip_addr);
}
else if (direction == "outbound") {
re = /\/sip:(.*@[^:]*):.*$/g;
new_name = name.replace (re, "/$1");
}
return new_name;
}
session.answer ();
session.execute ("sleep", "1000");
/*
* Figure out the normalized form of the requester's channel name.
*/
var requester_channel_name = normalize_channel_name (
session.getVariable ("channel_name"), "inbound",
session.getVariable ("network_addr"));
/*
* Find the uuid for a call on the requester's phone.
*/
var channels = apiExecute ("show", "channels as xml");
var re = /\s+$/g;
var length = channels.search (re);
if (length == -1)
length = channels.length;
channels = channels.substring (0, length);
var xchannels = new XML (channels);
var our_uuid = session.getVariable ("uuid");
var requester_uuid = "";
for each (var channel in xchannels.row) {
if (channel.uuid.toString () == our_uuid)
continue;
var channel_name = normalize_channel_name (channel.name.toString (),
channel.direction.toString (), channel.ip_addr.toString ());
if (channel_name == requester_channel_name) {
requester_uuid = channel.uuid.toString ();
break;
}
}
if (requester_uuid == "") {
session.sayPhrase ("voicemail_invalid_extension", "#", "", on_dtmf, "");
session.hangup ();
exit ();
}
/*
* Find the peer uuid.
*/
var udump = apiExecute ("uuid_dump", requester_uuid + " xml");
var re = /\s+$/g;
var length = udump.search (re);
if (length == -1)
length = udump.length;
udump = udump.substring (0, length);
var xudump = new XML (udump);
var uuid = xudump.headers['Other-Leg-Unique-ID'].toString ();
if (uuid == "") {
session.sayPhrase ("voicemail_invalid_extension", "#", "", on_dtmf, "");
session.hangup ();
exit ();
}
var requester_id_number = session.getVariable ("caller_id_number");
if (requester_id_number.search (extRE) == -1) {
session.sayPhrase ("voicemail_invalid_extension", "#", "", on_dtmf, "");
session.hangup ();
exit ();
}
apiExecute ("uuid_setvar", uuid + " hangup_after_bridge false");
apiExecute ("uuid_transfer", uuid + " *5" + requester_id_number + " XML default");
/*
* Provide confirmation beeps followed by some silence.
*/
var confirmation = "tone_stream://L=3;%(100,100,350,440)";
session.execute ("playback", confirmation);
var i;
for (i = 0; session.ready () && i < 100; i++)
session.execute("sleep", "100");
exit ();

View File

@ -4,10 +4,40 @@
* Machine: OS: * Machine: OS:
* Author: John Wehle Date: June 24, 2008 * Author: John Wehle Date: June 24, 2008
* *
* The message waiting indicator is handled by a separate program.
*/
/*
* Copyright (c) 2008 Feith Systems and Software, Inc. * Copyright (c) 2008 Feith Systems and Software, Inc.
* All Rights Reserved * All Rights Reserved
* *
* The message waiting indicator is handled by a separate program. * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
@ -33,6 +63,7 @@ function on_dtmf (session, type, obj, arg)
function prompt_for_id () function prompt_for_id ()
{ {
var dto;
var id; var id;
var index; var index;
var repeat; var repeat;
@ -53,7 +84,10 @@ function prompt_for_id ()
id = dtmf_digits; id = dtmf_digits;
if (id.indexOf ('#') == -1) { if (id.indexOf ('#') == -1) {
dtmf_digits = session.getDigits (5, '#', digitTimeOut, dto = digitTimeOut;
if (dtmf_digits.length != 0)
dto = interDigitTimeOut;
dtmf_digits = session.getDigits (5, '#', dto,
interDigitTimeOut, absoluteTimeOut); interDigitTimeOut, absoluteTimeOut);
id += dtmf_digits; id += dtmf_digits;
id += '#'; id += '#';
@ -87,7 +121,14 @@ start = session.getDigits (1, '', digitTimeOut,
interDigitTimeOut, absoluteTimeOut); interDigitTimeOut, absoluteTimeOut);
if (start != "#") { if (start != "#") {
console_log ("err", "Invalid VMAIL start code from PBX\n"); var destination_number = session.getVariable ("destination_number");
console_log ("err", destination_number + " received an invalid VMAIL start code from PBX\n");
if (session.ready ())
session.sayPhrase ("voicemail_goodbye", "#", "", on_dtmf, "");
else
console_log ("err", "Possibly due to early hangup from PBX\n");
session.hangup ();
exit(); exit();
} }
@ -121,7 +162,7 @@ switch (mode) {
from = prompt_for_id (); from = prompt_for_id ();
if (! session.ready ()) { if (! session.ready ()) {
session.hangup(); session.hangup ();
exit(); exit();
} }
@ -182,6 +223,8 @@ switch (mode) {
console_log ("err", "Invalid VMAIL PDC from PBX\n"); console_log ("err", "Invalid VMAIL PDC from PBX\n");
break; break;
} }
console_log ("err", "PBX reports problem with VMAIL PDC " + to + "\n");
break; break;
// Unknown // Unknown

View File

@ -4,9 +4,6 @@
* Machine: OS: * Machine: OS:
* Author: John Wehle Date: July 24, 2008 * Author: John Wehle Date: July 24, 2008
* *
* Copyright (c) 2008 Feith Systems and Software, Inc.
* All Rights Reserved
*
* Tested using a Zyxel U90e configured using: * Tested using a Zyxel U90e configured using:
* *
* at OK at&f OK at&d3&y2q2 OK ats0=0s2=255s15.7=0s18=4s35.1=0 OK * at OK at&f OK at&d3&y2q2 OK ats0=0s2=255s15.7=0s18=4s35.1=0 OK
@ -21,6 +18,39 @@
* ring message off * ring message off
*/ */
/*
* Copyright (c) 2008 Feith Systems and Software, Inc.
* All Rights Reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <ctype.h> #include <ctype.h>
#include <errno.h> #include <errno.h>