bar top left
bar top right
left curve
right curve
Bienvenido, Invitado

Stripping the "+" char. off of dialed string
(1 viendo) (1) Invitado
Abajo
Publicar respuesta
Publicar nuevo tema
Página: 12
TEMA: Stripping the "+" char. off of dialed string
#15280
Stripping the "+" char. off of dialed string hace 1 Año, 6 Meses 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
Código:

[+]|.


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

Any advice on how to handle this?
Introducir código aquí   
Por favor, aunque no se vea ningún BBcode ni botones de smiley, son usables igualmente
protenus
Fresh Boarder
Mensajes: 44
graphgraph
Usuario Offline Presiona aquí para ver el perfil de este usuario
Reply Quote
 
#15283
Re:Stripping the "+" char. off of dialed string hace 1 Año, 6 Meses Karma: 9
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 -

Código:


[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.
Introducir código aquí   
Por favor, aunque no se vea ningún BBcode ni botones de smiley, son usables igualmente
wiseoldowl
Senior Boarder
Mensajes: 252
graphgraph
Usuario Offline Presiona aquí para ver el perfil de este usuario
Última edición: 19/01/2009 14:05 por wiseoldowl.
Reply Quote
 
#15285
Re:Stripping the "+" char. off of dialed string hace 1 Año, 6 Meses 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)
Código:


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
Introducir código aquí   
Por favor, aunque no se vea ningún BBcode ni botones de smiley, son usables igualmente
protenus
Fresh Boarder
Mensajes: 44
graphgraph
Usuario Offline Presiona aquí para ver el perfil de este usuario
Última edición: 19/01/2009 14:45 por protenus.Razón: formatting
Reply Quote
 
#15286
Re:Stripping the "+" char. off of dialed string hace 1 Año, 6 Meses Karma: 81
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?
Introducir código aquí   
Por favor, aunque no se vea ningún BBcode ni botones de smiley, son usables igualmente
danardf
Moderator
Mensajes: 3222
graph
Usuario Offline Presiona aquí para ver el perfil de este usuario
Sexo: Hombre Localización: France - Trans sur Erdre Cumpleaños: 12/31
Última edición: 19/01/2009 14:58 por danardf.
Reply Quote
 
#15294
Re:Stripping the "+" char. off of dialed string hace 1 Año, 6 Meses Karma: 9
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,).
Introducir código aquí   
Por favor, aunque no se vea ningún BBcode ni botones de smiley, son usables igualmente
wiseoldowl
Senior Boarder
Mensajes: 252
graphgraph
Usuario Offline Presiona aquí para ver el perfil de este usuario
Última edición: 20/01/2009 00:27 por wiseoldowl.
Reply Quote
 
#15300
Re:Stripping the "+" char. off of dialed string hace 1 Año, 6 Meses Karma: 9
Just in case this ever comes up again, I made Enlaces ocultos para usuarios no registrados. Inicie sesión o regístrese Aquí with this information.
Introducir código aquí   
Por favor, aunque no se vea ningún BBcode ni botones de smiley, son usables igualmente
wiseoldowl
Senior Boarder
Mensajes: 252
graphgraph
Usuario Offline Presiona aquí para ver el perfil de este usuario
Reply Quote
 
#15316
Re:Stripping the "+" char. off of dialed string hace 1 Año, 6 Meses Karma: 81
Ok thanks.

That's will be good if freepbx include this function! (add, delete, or replace digits from incoming calls)
Introducir código aquí   
Por favor, aunque no se vea ningún BBcode ni botones de smiley, son usables igualmente
danardf
Moderator
Mensajes: 3222
graph
Usuario Offline Presiona aquí para ver el perfil de este usuario
Sexo: Hombre Localización: France - Trans sur Erdre Cumpleaños: 12/31
Reply Quote
 
#15318
Re:Stripping the "+" char. off of dialed string hace 1 Año, 6 Meses Karma: 81
hmmm .... Another question.

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


What's the function of ":1" ?
Introducir código aquí   
Por favor, aunque no se vea ningún BBcode ni botones de smiley, son usables igualmente
danardf
Moderator
Mensajes: 3222
graph
Usuario Offline Presiona aquí para ver el perfil de este usuario
Sexo: Hombre Localización: France - Trans sur Erdre Cumpleaños: 12/31
Reply Quote
 
#15319
Re:Stripping the hace 1 Año, 6 Meses Karma: 9
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...
Introducir código aquí   
Por favor, aunque no se vea ningún BBcode ni botones de smiley, son usables igualmente
wiseoldowl
Senior Boarder
Mensajes: 252
graphgraph
Usuario Offline Presiona aquí para ver el perfil de este usuario
Reply Quote
 
#15323
Re:Stripping the hace 1 Año, 6 Meses Karma: 81
Ha ok! Now i see.

Thanks for this information.
Introducir código aquí   
Por favor, aunque no se vea ningún BBcode ni botones de smiley, son usables igualmente
danardf
Moderator
Mensajes: 3222
graph
Usuario Offline Presiona aquí para ver el perfil de este usuario
Sexo: Hombre Localización: France - Trans sur Erdre Cumpleaños: 12/31
Reply Quote
 
Arriba
Publicar respuesta
Publicar nuevo tema
Página: 12
Moderadores: Bob, dicko