bar top left
bar top right
left curve
right curve
Welcome, Guest

Stripping the "+" char. off of dialed string
(1 viewing) (1) Guest
Go to bottom
Post Reply
Post New Topic
Page: 12
TOPIC: Stripping the "+" char. off of dialed string
#15280
Stripping the "+" char. off of dialed string 3 Years ago Karma: 0
We are using Elastix with Nokia SIP clients (e71, e90, etc.), and are facing a challenge to get things working correctly.

When users dial from their phonebook, they are sending numbers in +NNNXXXXXXX format (including the "+").

Stripping off the country code, adding a leading 0, etc is not a problem. but I can not seem to do anything to strip the "+" correctly...


When i put
Code:

[+]|.


in the route, it acually strips the "+" as well as the next three characters!

Any advice on how to handle this?
Enter code here   
Please note: although no board code and smiley buttons are shown, they are still usable.
protenus
Fresh Boarder
Posts: 44
graphgraph
User Offline Click here to see the profile of this user
Reply Quote
 
#15283
Re:Stripping the "+" char. off of dialed string 3 Years ago Karma: 8
Try this and please let me know if it works - I haven't tested it but I think it will work. First, add a context to /etc/asterisk/extensions_custom.conf -

Code:


[custom-strip-plus]
exten => _+.,1,Noop(Stripping + from start of number)
exten => _+.,n,Goto(from-internal,${EXTEN:1},1)
exten => _.,1,Goto(from-internal,${EXTEN},1)
exten => h,1,Hangup()



Now go into one of your extensions and change the context from from-internal to custom-strip-plus - Make a test call from that extension and see if it works. If it does, change the context in all your other extensions that are affected by this problem. If it doesn't, try changing the _+. to _+X. in the first two lines, and see if that makes any difference. If you need to add any digits, such as "011" or "00" to the start of the dialed number in place of the +, simply put them immediately before ${EXTEN:1} (between the comma and the $) in the second line. Either way, please let me know if it worked (and whether you had to change the pattern). If it doesn't work either way, we may need to add a line or two, but give this a try first.
Enter code here   
Please note: although no board code and smiley buttons are shown, they are still usable.
wiseoldowl
Senior Boarder
Posts: 251
graphgraph
User Offline Click here to see the profile of this user
Last Edit: 2009/01/19 14:05 By wiseoldowl.
Reply Quote
 
#15285
Re:Stripping the "+" char. off of dialed string 3 Years ago Karma: 0
Thanks...

Here is the way I ended up taking care of this....

The code you sent worked perfectly....

But to allow for dial rules in the trunks to work more universally, made the following change to strip the "+" and replace with 00 (standard international dial prefix..

[custom-strip-plus]
exten => _+.,1,Noop(Stripping + from start of number)
exten => _+.,n,Goto(from-internal,00${EXTEN:1},1)
exten => _.,1,Goto(from-internal,${EXTEN},1)
exten => h,1,Hangup()

Then in the trunk normally used, added the following dial rule to look for 00385 (the local country code), and strip off the 00385 part and add the leading 0 required for in country dialing....
(in Outgoing Dial Rules)
Code:


0+[0][0][3][8][5]|.



Not sure if that is the most efficient manner to do that... but it works.

So now if i dial +1(555)555-4444 here in croatia, it will put the correct international dial prefix and call...
and if it is +385 (99) 555 5555 it will dial 099 555 5555 as it is supposed to...

this rule also has the benifit that if someone dials a national number as international, the PBX will dial correctly.....


Should I leave this in that custom context, or is there a way to apply that generically so that I dont have to treat nokia extensions specially?


Thanks again,

M
Enter code here   
Please note: although no board code and smiley buttons are shown, they are still usable.
protenus
Fresh Boarder
Posts: 44
graphgraph
User Offline Click here to see the profile of this user
Last Edit: 2009/01/19 14:45 By protenus.Reason: formatting
Reply Quote
 
#15286
Re:Stripping the "+" char. off of dialed string 3 Years ago Karma: 127
It's very interesting.

But, I don't understand very well the first line: (Stripping + from start of number)
For exemple, what can I put into this line: (Stripping+33)?

Noop, it's an asterisk information that not execute this line, no?
So the first line is a comment, no?
Enter code here   
Please note: although no board code and smiley buttons are shown, they are still usable.
danardf
Moderator
Posts: 5164
graph
User Offline Click here to see the profile of this user
Gender: Male Location: France - Trans sur Erdre Birthday: 12/31
Last Edit: 2009/01/19 14:58 By danardf.

Links hidden for unregistered users. Login or register Here - Links hidden for unregistered users. Login or register Here - Franck Danard - franckd@agmp.org
Reply Quote
 
#15294
Re:Stripping the "+" char. off of dialed string 3 Years ago Karma: 8
protenus: I'm glad you got it working, and thank you for sharing the code you used - I was hoping that I wasn't leading you down the wrong path. As for your question about whether you should leave that in the custom context, until and unless the FreePBX developers figure out a way to let you include a + in dial rules without it having a special meaning (it's been requested more than once), I don't know of any other way to do it. If you actually figure out any other way, I'd love to hear it. I know it's a pain to change the context manually for every affected extension, but I just don't know any other way to handle it. I'm sure that some other people (some of the ones that like to give advice in the IRC channel) would likely have told you that there's no way to do it at all.

As for your trunk dial rule, I guess I don't get the point of the square brackets, they seem superfluous around a single digit. Why not just:
0+00385|.

I THINK you will find that will work just as well and not consume as much CPU time (not that you'd ever notice). Normally you only use square brackets if you are specifying a range of digits or a selection of digits (e.g. [1-49] would mean any of the digits 1,2,3,4,9).

danardf: You are correct, the Noop is just a comment. It's there so that if you are watching the CLI to see how the call is progressing (assuming you have the debug level set high enough) it will actually tell you when it is about to strip the +. You can change the text to anything that is meaningful to you, or even omit the line entirely, but if you do that, you have to change the n in the next line to 1 (so instead of _+.,n, you'd have _+.,1,).
Enter code here   
Please note: although no board code and smiley buttons are shown, they are still usable.
wiseoldowl
Senior Boarder
Posts: 251
graphgraph
User Offline Click here to see the profile of this user
Last Edit: 2009/01/20 00:27 By wiseoldowl.
Reply Quote
 
#15300
Re:Stripping the "+" char. off of dialed string 3 Years ago Karma: 8
Just in case this ever comes up again, I made Links hidden for unregistered users. Login or register Here with this information.
Enter code here   
Please note: although no board code and smiley buttons are shown, they are still usable.
wiseoldowl
Senior Boarder
Posts: 251
graphgraph
User Offline Click here to see the profile of this user
Reply Quote
 
#15316
Re:Stripping the "+" char. off of dialed string 3 Years ago Karma: 127
Ok thanks.

That's will be good if freepbx include this function! (add, delete, or replace digits from incoming calls)
Enter code here   
Please note: although no board code and smiley buttons are shown, they are still usable.
danardf
Moderator
Posts: 5164
graph
User Offline Click here to see the profile of this user
Gender: Male Location: France - Trans sur Erdre Birthday: 12/31

Links hidden for unregistered users. Login or register Here - Links hidden for unregistered users. Login or register Here - Franck Danard - franckd@agmp.org
Reply Quote
 
#15318
Re:Stripping the "+" char. off of dialed string 3 Years ago Karma: 127
hmmm .... Another question.

Why put :
    00${EXTEN:1},1) and not
    00${EXTEN},1)


What's the function of ":1" ?
Enter code here   
Please note: although no board code and smiley buttons are shown, they are still usable.
danardf
Moderator
Posts: 5164
graph
User Offline Click here to see the profile of this user
Gender: Male Location: France - Trans sur Erdre Birthday: 12/31

Links hidden for unregistered users. Login or register Here - Links hidden for unregistered users. Login or register Here - Franck Danard - franckd@agmp.org
Reply Quote
 
#15319
Re:Stripping the 3 Years ago Karma: 8
danardf wrote:
hmmm .... Another question.

Why put :
    00${EXTEN:1},1) and not
    00${EXTEN},1)


What's the function of ":1" ?


It's SOOOOO tempting to give a smartass answer here, but I won't...

The whole point of this is to strip the plus sign, which happens to be the first character on the line. The :1 says to take only that part of the string beginning with the SECOND character on the line. If you used :2, it would use the string starting with the THIRD character, etc.

Now, why does Asterisk seem to be off by one in its string position count? Because it starts counting with zero, not one. Ask a silly question...
Enter code here   
Please note: although no board code and smiley buttons are shown, they are still usable.
wiseoldowl
Senior Boarder
Posts: 251
graphgraph
User Offline Click here to see the profile of this user
Reply Quote
 
#15323
Re:Stripping the 3 Years ago Karma: 127
Ha ok! Now i see.

Thanks for this information.
Enter code here   
Please note: although no board code and smiley buttons are shown, they are still usable.
danardf
Moderator
Posts: 5164
graph
User Offline Click here to see the profile of this user
Gender: Male Location: France - Trans sur Erdre Birthday: 12/31

Links hidden for unregistered users. Login or register Here - Links hidden for unregistered users. Login or register Here - Franck Danard - franckd@agmp.org
Reply Quote
 
Go to top
Post Reply
Post New Topic
Page: 12
Moderators: Bob, jgutierrez