OBiTALK Community

General Support => On-Topic: Obihai and OBi Products => Topic started by: cssobi on November 29, 2013, 05:18:38 am



Title: routing all calls thru asterisk 11.2 using Obi202 and obi110 with pstn
Post by: cssobi on November 29, 2013, 05:18:38 am
Need help on routing all calls thru asterisk 11.2 using Obi202 and obi110 with pstn.

What are the basics that need to be setup to get the following working?

We have the following hardware/software and are located in the USA
Obi110 static ip 192.168.1.25 with connected telco line (pstn)
Obi202 static ip 192.168.1.23 [actually 3 obi202 but listing one to get basics working]
asterisk [11.2] static ip 192.168.1.3

we want all calls that originate from either obi or pstn to go through asterisk first with one possible exception 911.
for example with 4 requirements:
requirement 1) if user dials other obi phone extensions that it first is sent to asterisk and then asterisk calls the corresponding extension
requirement 2) if user wants to make outside call using the pstn that it first is sent to asterisk and then asterisk sends it to  [or back to]  obi110 pstn to make the call
requirement 3)  on incoming obi110 pstn calls they are routed to asterisk which decides which extensions to ring or perhaps AA
requirement 4) on all phones if  7 to 11 digits are dialed to route to asterisk first and then to obi110 pstn
without selecting any prefix codes such as **8 or **3, etc. International calls can required those codes.

we are not interested at this time to do anything with obitalk nor google voice.
We are familiar with asterisk sip.conf and extension.conf.

It appears we need to know what to setup on the obi's side in
service providers->
voice services-> [including trunk groups]

can someone spell out especially the obi sides to do the above?

Thanx

css


Title: Re: routing all calls thru asterisk 11.2 using Obi202 and obi110 with pstn
Post by: Usetheforceobiwan on November 29, 2013, 06:18:24 am
This would be a good start:  http://tech.iprock.com/?p=3279


Title: Re: routing all calls thru asterisk 11.2 using Obi202 and obi110 with pstn
Post by: cssobi on November 29, 2013, 07:10:03 am
saw that before ... and revisited ... it is overwhelming with things such as gv and obitalk
which are not in our needs.

seems what we are trying to accomplish should not be that unusual




Title: Re: routing all calls thru asterisk 11.2 using Obi202 and obi110 with pstn
Post by: drgeoff on November 29, 2013, 10:38:53 am
I'm somewhat reluctant to respond on this as I won't be able to give precise step by step instructions.  My experience with Asterisk/FreePBX is limited and not doing what you are seeking.  However, some guidelines.

1.  Don't try to get it all working in one shot.  Build it up bit by bit, testing each bit as you go along.

2.  Use fixed IP addresses for the OBis and the PBX.

3.  Configuring the OBis should be relatively straightforward.  There are 3 aspects:

3.1  If you want 911 calls to not go through the Asterisk then you need another Service Provider for that.  So you need to configure 2 Service Providers and 2 Voice Services.  (SP1 for Asterisk and SP2 for the VoIP SP you are using for 911.)

3.2 You need to think about numbering so that you can craft dial plans which route outgoing calls 2 ways on the OBis and 2 (or more?) ways on Asterisk.  The OBis need to recognise 911 calls and send them to SP2 while all others go to Asterisk on SP1.  Asterisk needs to differentiate calls to other extensions (OBis) from calls to external numbers.

3.3  As far as Asterisk is concerned the OBis (except 110) are extensions and are configured on Asterisk in the normal way with extension number and 'secret'.  Configure the OBis with the same number and secret (Voice services/SP1/SIP credentials) to register with Asterisk.  Use the IP address of your Asterisk box for the field at Service providers/ITSP Profile A/SIP/proxy Server.

With the above, you should be able to make calls between the OBis and make 911 calls.

Next task would be to the PSTN line (in and out) operational.  This is where I'm getting out of my depth as I have no first hand experience with that.  :(  Have a good read of http://www.obitalk.com/forum/index.php?topic=57.0 and http://www.obitalk.com/forum/index.php?topic=1157.0 .


Title: Re: routing all calls thru asterisk 11.2 using Obi202 and obi110 with pstn
Post by: azrobert on November 29, 2013, 03:47:46 pm
I'm an Asterisk novice.
I hope this give you a guide on how to accomplish your requirements.
I did not test any of this.

I would 1st setup naming convention for OBi extensions something like:
101 - PH1 on OBi110
201 - PH1 on OBi202#1
202 - PH2 on OBi202#1

Setup a trunk for each OBi:
type=peer
username=robert1
host=192.168.1.101 (OBi110 IP addr)
port=5060

type=peer
username=robert2
host=192.168.1.102 (OBi202#1 IP addr)
port=5060

OBi110

Register SP1 as an Asterisk extension.

ITSP A DigitMap
(1?xxxxxxxxxx|xxxxxxx|201|202|011xx.)

ITSP A -> SIP
X_SpoofCallerID: Enabled (checked)
This is needed to pass CallerID to Asterisk.

Phone PortOutboundCallRoute:
{911:li},{(Msp1):sp1},(include defaults if you want)
This will route 911 to line and 7,10 or 11 digit numbers to Asterisk.
Extension numbers will also be routed to Asterisk.

Line InboundCallRoute:
{sp1(999@192.168.1.100:5060}  (Asterisk IP address)
This will route any Line inbound calls to Asterisk.

SP1 service X_InboundCallRoute
{robert1>(Msp1):li},{robert1>101:ph}
This will route 7 10 or 11 digit numbers from Asterisk to Line.
101 from Asterisk will be routed to the phone port.

OBi202

Register SP1 as an Asterisk extension.

ITSP A DigitMap
(911|1?xxxxxxxxxx|xxxxxxx|101|201|202|011xx.)

Phone PortOutboundCallRoute:
{(Msp1):sp1},(include defaults if you want)

SP1 service X_InboundCallRoute
{robert2>201:ph1}.{robert2>202:ph2}



Title: Re: routing all calls thru asterisk 11.2 using Obi202 and obi110 with pstn
Post by: azrobert on November 29, 2013, 04:49:35 pm
Here is another method to route inbound calls to extensions.

Define a dummy extension on Asterisk for each OBi extension.
In the Asterisk extension definition change the Dial parms to:
SIP/101@192.168.1.101:5060
SIP/201@192.168.1.102:5060
SIP/202@192.168.1.102:5060


Obi110
SP1 service X_InboundCallRoute
{robert1>(Msp1):li},{>101:ph}

Obi202
SP1 service X_InboundCallRoute
{>201:ph1},{>202:ph2}

I removed the peer number test in the inbound route because I'm not sure what it would be.
I think it will be the UserName you used for the SP1 extension, so it could be different names depending on which OBi originated the call.
You can see the peer number in the OBI Call History. You can then add it to the X_InboundCallRoute if you want more security.

I made changes to my 1st post. I forgot the extension numbers in the DigitMap.


Title: Re: routing all calls thru asterisk 11.2 using Obi202 and obi110 with pstn
Post by: drgeoff on November 30, 2013, 02:40:26 am
........
Setup a trunk for each OBi:
.........
Register SP1 as an Asterisk extension.
.........
I'm puzzled by that as I would have set the OBis as Asterisk extensions.  However, I did use the word "would" in the previous sentence to make it clear it isn't something I have done and I cannot say with certainty that it works.  Therefore I'm not going to say that setting a trunk for each OBi is incorrect or won't work.


Title: Re: routing all calls thru asterisk 11.2 using Obi202 and obi110 with pstn
Post by: azrobert on November 30, 2013, 08:14:38 am
I have a setup like this and it DOES work.
I'm sure there are other ways to do this.
I can see why my posts can be confusing, so here is an explanation.

In my 1st post you define an extension and a trunk in Asterisk for each OBi.
The extension is used to send outbound calls to Asterisk with a destination of the OBi110 Line Port or OBi Phone Ports.
The Trunk is used to send the above calls back to an OBi.
I used SP1 on the OBi's for both the extension and the trunk. You could use another SPx for the Asterisk trunk. The trunk is not defined on the OBi except for the inbound route and is not registered.

I'm an Asterisk novice and don't know how to send an outbound phone number to the OBi110 destined to the Line Port using only an extension. That is the reason for the Asterisk trunk.

You could use an Asterisk extension to route calls back to the OBi destined for a Phone Port. If you did it this way I think you would need an extension for each OBi Phone Port. The OBi would route the call based on which extension received the call. Doing my way using a trunk you route the call based on the extension number (101,201....).

In my 2nd post you define a dummy extension (not defined on the OBi) for each Obi Phone port. You could use the existing Asterisk extensions from my 1st post, but would need to define a dummy for the 2nd Phone Port on the OBi202s. The call comes in the same as using a trunk and OBi routes the call based on the extension number.

Edit:
I forgot about international calls. The DigitMaps have been updated.


Title: Re: routing all calls thru asterisk 11.2 using Obi202 and obi110 with pstn
Post by: cssobi on November 30, 2013, 11:49:05 am
>I have a setup like this and it DOES work.

Is it in asterisk?
if so what were entries for sip.conf and extensions.conf




Title: Re: routing all calls thru asterisk 11.2 using Obi202 and obi110 with pstn
Post by: azrobert on November 30, 2013, 02:43:41 pm
I'm running PBX in a Flash with FreePBX version 2.9.0.12 and Asterisk version 1.8.13.0. I'm not familiar with any conf files nor do I use them.

There is nothing special you have to define with this setup. You define an extension and a trunk for each OBi. Define an outbound route for the OBi110 trunk that includes phone numbers, 911 and extension number 101. Define an outbound route for the OBi202 trunk which includes extension numbers 201 and 202.

For OBi110 inbound Line calls forwarded to Asterisk use an inbound route to send the call to an extension as described in my second post.


Title: Re: routing all calls thru asterisk 11.2 using Obi202 and obi110 with pstn
Post by: azrobert on November 30, 2013, 03:51:54 pm
Judging by your question I assume you have an Asterisk setup without FreePBX and you're probably not familiar with FreePBX.

I looked at a sample sip.conf and extensions.conf. It looks like sip.conf is the equivalent of FreePBX's trunk and extension definitions and extensions.conf is the equivalent of the inbound and outbound routes.

Here is my trunk definition:
type=peer
username=robert1
host=192.168.1.101
port=5060
fromuser=robert1
canreinvite=no
insecure=invite,port
qualify=yes
nat=yes

I took the default settings for my extension definitions except for Password and Dial.

I have no idea how this translates to sip.conf.

It looks like the Dial function is in extensions.conf.



Title: Re: routing all calls thru asterisk 11.2 using Obi202 and obi110 with pstn
Post by: cssobi on November 30, 2013, 04:13:47 pm
Robert,

when I enter a 11 digit number I see it go to asterisk (CLI) but then it rings busy


css


Title: Re: routing all calls thru asterisk 11.2 using Obi202 and obi110 with pstn
Post by: azrobert on November 30, 2013, 04:45:07 pm
Make the following change.
Obi110
SP1 service X_InboundCallRoute
{robert1>(Msp1):li},{>101:ph},{ph}

This will ring the OBi110 phone port.
This will indicate you're call is getting to the OBi110, but something is not matching.

We are going out for dinner, so I'm signing off for the night.


Title: Re: routing all calls thru asterisk 11.2 using Obi202 and obi110 with pstn
Post by: cssobi on December 02, 2013, 10:57:08 am
thanks for your input,
I was able to get the fundamentals working [will be trying with 3 Obi202s soon]....
the reason I was getting a busy was because of an extra parenthesis in extensions.conf ...

on your post with adding a trunk for obi202 i.e. the one with robert2
I haven't added that ... when might that be useful or needed?


Title: Re: routing all calls thru asterisk 11.2 using Obi202 and obi110 with pstn
Post by: azrobert on December 02, 2013, 02:10:22 pm
I'm not thinking clearly and making things more difficult than it has to be. I have 2 OBi110s and I call the extension on the other OBi110 by passing the extension number out the Asterisk trunk, therefore I need a trunk on Asterisk for each OBi110. I can use the other OBi110's SPx trunks the same way. I had to do it this way because all my OBi110 SPx trunks are used for Service Providers and I can't use them for Asterisk extensions. I use a Voice Gateway to send commands to Asterisk. Anybody out there that thinks I'm crazy to use Asterisk this way, I DON'T. I setup Asterisk as a learning experience and normally have it powered off.

Anyway, it doesn't make sense for you to do it this way since you have the SPx trunks for Asterisk extensions. Here is my revised suggestion for your setup:
 
Asterisk

Setup a trunk for the OBi110:
type=peer
username=robert1
host=192.168.1.101 (OBi110 IP addr)
port=5060

Setup Extensions 101, 201 and 202


OBi110

Register SP1 as Asterisk extension 101.

ITSP A DigitMap:
(1xxxxxxxxxx|xxxxxxx|011xx.)

ITSP A -> SIP
X_SpoofCallerID: Enabled (checked)
This is needed to pass CallerID to Asterisk for inbound calls on Line.

Phone Port DigitMap:
((Msp1)|201|202|911)

Phone PortOutboundCallRoute:
{911:li},{((Msp1)|201|202):sp1}

Line InboundCallRoute:
{sp1(999@192.168.1.100:5060}  (Asterisk IP address)

SP1 service X_InboundCallRoute:
{robert1>((Msp1)|911):li},{ph}

OBi202

Register SP1 as Asterisk extension 201.
Register SP2 as Asterisk extension 202.

ITSP A DigitMap:
(911|1xxxxxxxxxx|xxxxxxx|011xx.)

Phone Port1 DigitMap:
((Msp1)|101|202)

Phone Port1 OutboundCallRoute:
{((Msp1)|101|202):sp1}

SP1 service X_InboundCallRoute:
ph1

ITSP B DigitMap:
(911|1xxxxxxxxxx|xxxxxxx|011xx.)

Phone Port2 DigitMap:
((Msp2)|101|201)

Phone Port2 OutboundCallRoute:
{((Msp2)|101|201):sp2}

SP2 service X_InboundCallRoute:
ph2


Edit:
You should include the default rules for the Phone Port DigitMaps and OutboundCallRoutes.


Title: Re: routing all calls thru asterisk 11.2 using Obi202 and obi110 with pstn
Post by: cssobi on December 10, 2013, 07:00:29 am
>Line InboundCallRoute:
>{sp1(999@192.168.1.100:5060}  (Asterisk IP address)

the routing of '999' to asterisk ip address port 5060 to asterisk [11.2] gets to asterisk however about 1/4 of the times it is rejected because an incorrect [asterisk] context is set. Right now I expect the context to be unauthenicated which it appears to be about 3/4 of the incoming OBI110:LI calls but about 1/4 calls asterisk rejects it because it lands under another context name (LocalSets). 

Anybody have clue why this is so?



Title: Re: routing all calls thru asterisk 11.2 using Obi202 and obi110 with pstn
Post by: cssobi on January 04, 2014, 09:20:20 am
>the routing of '999' to asterisk ip address port 5060 to asterisk [11.2] gets to asterisk >however about 1/4 of the times it is rejected because an incorrect [asterisk] context is set. >Right now I expect the context to be unauthenicated which it appears to be about 3/4 of the >incoming OBI110:LI calls but about 1/4 calls asterisk rejects it because it lands under >another context name (LocalSets). 

I think this is caused by having sp1 doing both obi internal calls and routing of incoming all through same port ....

so I have attempted to make robert1 trunk go through sp2 and port 5061 but now obi110 doesn't see incoming pstn calls nor send them to asterisk ... Can someone tell me which specific adjustments I need to make so incoming pstn stuff goes through sp2 and the robert1 trunk?



Title: Re: routing all calls thru asterisk 11.2 using Obi202 and obi110 with pstn
Post by: azrobert on January 04, 2014, 12:08:48 pm
On the OBi110:

SP2 must be defined as a SIP trunk to send/receive to/from Asterisk.
If SP2 is not defined, setup a dummy SIP definition like this:

Service Providers -> ITSP Profile B -> SIP -> ProxyServer : 127.0.0.1
Voice Services -> SP2 Service -> AuthUserName : (any userid)
Voice Services -> SP2 Service -> X_RegisterEnable : (unchecked)
Voice Services -> SP2 Service -> X_ServProvProfile : B

AND

ITSP B DigitMap:
(1xxxxxxxxxx|xxxxxxx|011xx.)

ITSP B -> SIP
X_SpoofCallerID: Enabled (checked)

SP2 service X_InboundCallRoute:
{robert1>((Msp2)|911):li},{ph}


Title: Re: routing all calls thru asterisk 11.2 using Obi202 and obi110 with pstn
Post by: cssobi on January 04, 2014, 05:01:02 pm
made those mods still nothing on incoming pstn to obi110


Title: Re: routing all calls thru asterisk 11.2 using Obi202 and obi110 with pstn
Post by: cssobi on January 07, 2014, 04:57:42 pm
i have reverted back to only using sp1

while the incoming call on pstn is routed to asterisk: about half the time the caller id
is wrong and makes the incoming pstn call looks like its coming internally from the obi110 and the other half of the time its correct from the pstn.

spent a lot of time on this ... anybody got an answer to resolving this issue?




Title: Re: routing all calls thru asterisk 11.2 using Obi202 and obi110 with pstn
Post by: azrobert on January 08, 2014, 04:06:04 pm
Try This:

Line InboundCallRoute:
{sp1(999@192.168.1.100:5060;ui=$1)}


Title: Re: routing all calls thru asterisk 11.2 using Obi202 and obi110 with pstn
Post by: azrobert on January 08, 2014, 04:29:05 pm
Did you change the RingDelay on the Line Port?

If you did try the default setting.


Title: Re: routing all calls thru asterisk 11.2 using Obi202 and obi110 with pstn
Post by: cssobi on January 08, 2014, 06:38:52 pm
>{sp1(999@192.168.1.100:5060;ui=$1)}

what does the ui=$1 one do? and how can i find out ui's value?

on your subsequent post I discovered that having ringdelay near 4 seconds
improved the condition of getting routing as expected but sometimes still is wrong ... if i increase to 5 seconds seems better ....
but this brings up another issue

asterisk now does not see the call until 9 to 11 seconds after dialed and caller has heard 4 rings and the call then is sent back to obi110 to ring ph and another 3 to 5 seconds also has elapsed so now nearly 5 to 6 rings to caller have occurred before 1st ring is heard on the extensions ... many people will be hanging up by then.

What adjustments can be made to greatly shorten this without losing CID?

Also have audio delay issue with asterisk which I am trying to hide with answer
before dialing the extensions ... using asterisk 11.2cert ... not sure if bug
and or a fix out for that?



Title: Re: routing all calls thru asterisk 11.2 using Obi202 and obi110 with pstn
Post by: azrobert on January 10, 2014, 07:14:43 am
I had you enable X_SpoofCallerID to pass CallerID. "ui=$1" is another method to pass CalledID on a bridged call. "ui" is UserID and $1 is an OBi variable that contains the CallerID on an inbound call. This was a wild guess on solving your problem and probably won't help.

In the U.S. on a PSTN line the CallerID is transmitted between the 1st and 2nd ring. The OBi needs the RingDelay to pause processing and give it enough time to receive the CallerID. For example if you are sending a call to the Auto Attendant based on CallerID you need to set the RingDelay high enough, otherwise the OBi will not see the CallerID in time to process the call properly.

 I believe (not positive) if you are just sending the call to the Phone Port you can set the RingDelay to zero (it still has a delay) and the CallerID might not be displayed until the 2nd ring. I don't know how this process works with a bridged call to Astterisk.

Anyway, I have my RingDelay set to 3 seconds and it works fine. I had it set around 2.5 seconds ( can't remember exactly), but the OBi stopped working correctly after I installed new firmware. It seems odd that you have to set yours so high.


Title: Re: routing all calls thru asterisk 11.2 using Obi202 and obi110 with pstn
Post by: cssobi on January 13, 2014, 09:06:04 am
>I believe (not positive) if you are just sending the call to the Phone Port you can set the RingDelay to zero (it still has a delay) and the CallerID might not be displayed until the 2nd ring. I don't know how this process works with a bridged call to Astterisk.

Is there a second RingDelay setting on the Phone port in addition to the one on the
Line Port?  So on a bridged call don't wait the ringdelay a second time.

>Anyway, I have my RingDelay set to 3 seconds and it works fine. I had it set around 2.5 seconds ( can't remember exactly), but the OBi stopped working correctly after I installed new firmware. It seems odd that you have to set yours so high.

In my testing so far that near 3 seconds or  3.25 seconds produces similar results of having it set to 4 or more .... 2.5 seconds is not reliable

On the audio delay front ... I not sure if an asterisk issue or obi,
I think if we can get over this audio delay (6 seconds) issue without resorting to prematurely answering the call [which produces other unacceptable issues] but rather answering it only after having the ringing extension on an obi 'ph' port works with no audio delay we probably can deploy the system [if no other 'surprises' are found].