Page 4 of 6

Re: Flexible table-controlled dialplan, Version 2

Posted: Fri Aug 20, 2010 4:13 am
by MikeTelis
You need to fix the problems with your ATA. PAP2T's Line1 and Line2 must behave identically. If you "swap" Line1 and Line2 settings but the problem stays with Line1, most certainly something is wrong with your device.

Re: Flexible table-controlled dialplan, Version 2

Posted: Fri Aug 20, 2010 4:28 am
by beaver
Sipsorcery Registration - Failed.
please try the fix in that thread.

Re: Flexible table-controlled dialplan, Version 2

Posted: Fri Aug 20, 2010 5:00 pm
by jay75
HI Mike,
I'm trying to use your new version 2 of the dial plan, after i customized all my entries, and tried to make a call it wouldn't go through and while i was trying to trouble shoot i found out that i had to comment out this line to make it work.

Code: Select all

  #EnumDB.map! {|x| x.class == Hash ? keys_to_ENUM(x) : x } # rebuild local ENUM table
do you know why?
Thank you.

Re: Flexible table-controlled dialplan, Version 2

Posted: Fri Aug 20, 2010 5:04 pm
by MikeTelis
I guess you commented out something that was necessary for the code to work (or removed an object leaving a link to that object in place). I can't be more specific without Console trace.

Re: Flexible table-controlled dialplan, Version 2

Posted: Fri Aug 20, 2010 6:44 pm
by jay75
Hi Mike thanks for the fast reply,
actually the issue is here:
This works.

Code: Select all

CNAM = {
  '(206) 424-1234'      => 'My Home',
}
This breaks it, basically when i add my other Extension it breaks and doesn't allow the plan to continue and gives Error Wrong number see the error below.

Code: Select all

CNAM = {
  '(206) 424-1234'         => 'My Home',
  '10.mySipUserName'   => 'Jay', #when i add this it breaks. Ext 10 for ex.
}

10.mySSUserName is an account i created under the main account mySSUserName and has it's own ATA in a different location.

The Trace Log:

Code: Select all

DialPlan 18:38:36:997 sip1: New call from udp:xx.140.154.xxx:5060 successfully authenticated by digest.
DialPlan 18:38:37:013 sip1: Using dialplan main for Out call to sip:10@sip1.sipsorcery.com.
NewCall 18:38:37:029 sip1: Executing script dial plan for call to 10.
DialPlan 18:38:37:154 sip1: ** Call from "My Home" <sip:mySSUserName@sip1.sipsorcery.com>;tag=d57476b95bc4d2d1o0 to 10 **
DialPlan 18:38:37:154 sip1: Local time: 08/21/2010 02:38
DialPlan 18:38:37:169 sip1: URI dialing: 10.mySSUserName.@local[ma=false]
DialPlan 18:38:37:169 sip1: Commencing Dial with: 10.mySSUserName@local[ma=false].
DialPlan 18:38:37:185 sip1: Call leg is for local domain forwarding to incoming dialplan for 10.mySSUserName@sipsorcery.com.
DialPlan 18:38:37:185 sip1: ForkCall commencing call leg to sip:10.mySSUserName@local.
DialPlan 18:38:37:185 sip1: Creating B2B call for sip:10.mySSUserName@local.
DialPlan 18:38:37:216 sip1: Using dialplan gv_simple for In call to sip:10.mySSUserName@local.
NewCall 18:38:37:247 sip1: Executing script dial plan for call to 10.mySSUserName.
DialPlan 18:38:37:388 sip1: ** Call from <sip:mySSUserName@sipsorcery.com>;tag=1470999200 to 10.mySSUserName **
DialPlan 18:38:37:388 sip1: Local time: 08/21/2010 02:38
DialPlan 18:38:37:404 sip1: user ****** 10.mySSUserName  and cname=  and cid=mySSUserName
DialPlan 18:38:37:419 sip1: Dialplan cleanup for mySSUserName.
DialPlan 18:38:37:419 sip1: Call failed: code 603, Wrong number: '', check & dial again
DialPlan 18:38:37:419 sip1: UAS call failed with a response status of 603 and Wrong number: '', check & dial again.
DialPlan 18:38:37:419 sip1: Dialplan cleanup for mySSUserName.
DialPlan 18:38:37:513 sip1: Dial plan execution completed with normal clearing.
DialPlan 18:38:37:529 sip1: Dial plan execution completed with normal clearing.
I hope you can shed some light on this..

Re: Flexible table-controlled dialplan, Version 2

Posted: Fri Aug 20, 2010 8:11 pm
by MikeTelis
I sure can! It has nothing to do with EnumDB you diagnosed in the first place. The problem comes from this code:

Code: Select all

# **********************  k e y s   t o   E N U M  *************************

def keys_to_ENUM (table)
  Hash[*table.keys.map! {|key| to_ENUM(key.dup)}.zip(table.values).flatten]
end
This code converts keys in hash table supplied as the argument into ENUM format. For example, if your area code is 408 and hash table entry is:

'370-1234' => 'Home'

it will be converted into:

'14083701234' => 'Home'

The keys_to_ENUM() method is used here:

if !(@cname = keys_to_ENUM(CNAM)[@cid]) && @cid =~ /^1([2-9]\d\d[2-9]\d{6})$/ && defined?(WP_key)

Read my manual, number format is explained in the Caller’s Name lookup section. You broke the rules, to_ENUM method couldn't decode '10.mySipUserName' and raised "Wrong number" condition.

There are two ways out:

1. Stop using keys_to_ENUM on CNAM hash table. Then you'll have to enter all numbers in ENUM format ('14083701234'), no spaces, no fancy chars like dashes.
2. Create a separate CNAM hash for sip-to-sip callers and check both:

if !(@cname = keys_to_ENUM(CNAM)[@cid]) && !@cname = CNAM1[@cid] && @cid =~ /^1([2-9]\d\d[2-9]\d{6})$/ && defined?(WP_key)

Re: Flexible table-controlled dialplan, Version 2

Posted: Sun Aug 22, 2010 12:22 am
by jay75
As always very helpfull, thank you Mike.

i may suggest including the code to handle the SIP to SIP CNAM, since i'm sure others will eventually run into the same issues.

Thank you again for sharing the dial plan...

Re: Flexible table-controlled dialplan, Version 2

Posted: Sun Aug 22, 2010 5:15 am
by MikeTelis
i may suggest including the code to handle the SIP to SIP CNAM, since i'm sure others will eventually run into the same issues.
I'm not sure, it would make the things more complicated and harder to understand. Probably it's more appropriate to leave it to the user (I mean the incomingCall method), like that:

Code: Select all

def IncomingCall
  @cname ||= CNAM1[@cid]
  sys.SetFromHeader(formatNum(@cname || @cid,true), nil, Host)  # Set FromName & FromHost for sys.Dial
#     ...

Re: Flexible table-controlled dialplan, Version 2

Posted: Fri Sep 03, 2010 4:35 am
by sint
Would you please make the following code stripping the *1, *2 and *3:

case num # Special cases
( ..... SOME CODE HERE NOT SHOWN ........)
when /^*/ # *1: route_to provider_1, *2: route_to provider_2, *3: route_to provider_3
num # ... as is
else
rejectCall(603,"Wrong number: '#{num}', check & dial again. Line 191")
end
end
( ..... SOME CODE HERE NOT SHOWN ........)
.........................................................................

# ******************** s e l e c t V S P *******************************

def selectVSP # VoIP provider selection
case @num
when /^\*1/
route_to Provider_1, "Provider_1 for US/Canada", false
when /^\*2/
route_to Provider_2, "Provider_2 for US/Canada", false
when /^\*3/
route_to Provider_3, "Provider_3 for Europe/Asia", false

The person who dials will dial:
*1 123-123-4444 then the call route_to provider 1 (stripping *1 first)
*2 123-123-4444 , route_to provider 2 (stripping *2 first), and so on.

Thank you so much.

Re: Flexible table-controlled dialplan, Version 2

Posted: Fri Sep 03, 2010 4:53 am
by MikeTelis
Please refer to the manual, VSP descriptors section:

Prefix is an optional dial prefix you can use to bypass automatic provider selection and place the call with this particular provider. For example, if you dial:

#2 44 20 2345-6789

the dial plan will skip selectVSP and route the call to Google Voice passing 442023456789 to it as the number you wish to call.


I think this is exactly what you want :)