This article was originally written in January, 2011. Some edits have been made in an attempt to bring it up to date, however it was a first attempt at doing this and does not necessarily show the current best method. It is reposted here because it was part of the original review series.
This article sort of assumes that you have read the earlier parts of this series, including Review of the Obihai OBi110 VoIP device, Part 1: Use your phone with Google Voice for free incoming and outgoing calls, Review of the Obihai OBi110 VoIP device, Part 2: The OBiTALK portal, documentation, and using the device as an FXO port with Asterisk, and Review of the Obihai OBi110 VoIP device, Part 3: 911 on the cheap?
I’m sure some of you have been waiting for this, but I just want to say up front that whenever you use any kind of PSTN interface with Asterisk, be it an Obihai OBi110, a Sipura SPA-3000, a Linksys/Cisco SPA-3102, a USB device, or a card that is inserted into your server computer, you’re probably going to face a few challenges. Some of these devices offer more challenges than others! Getting the OBi110 Line port to work as an Asterisk trunk definitely wasn’t the hardest thing I’ve ever done, but it wasn’t something I figured out in 15 minutes, either. And just because I finally got it working doesn’t necessarily mean that if you follow my “recipe”, yours will work. As I pointed out in Part 2, I gave up my landline many moons ago, so the only way I have to test this is by connecting it to the FXS (phone) port of another VoIP adapter, which is acting as a stand-in for a telephone company central office. However, that connection is via a six-foot long phone cord. Things may be different if you are connected to a real PSTN line over miles of old copper (or worse). I’m only saying this in case you try to emulate what I’ve done and it doesn’t work as you expect — there’s a possibility that could happen and if it does, you have my sympathy, but I probably won’t be able to offer any concrete assistance.
That said, I figure any instructions are better than none, so here’s what I’ve done. Some of the information here was obtained from this thread on the OBiTALK forum.
As always, this article is intended for experimental purposes only — if it works for you, great, but I make no guarantees. Don’t use this in a production environment until you have satisfied yourself that it works the way you need it to. If you use my instructions and have lost income due to missed calls, or if someone manages to hack into your device and runs up your phone bill, you agree that by using these instructions all the liability for that rests on you and nobody else! If you’re the type of person who wants to sue someone else when things go wrong, then you absolutely may not use these instructions. We’re all experimenters here, and nobody’s offering insurance that nothing will go wrong.
All of the images below can be viewed in a larger format by clicking on them. If a page is shown here, any settings on it that are not specifically mentioned or shown should be set to their default values (except on the first screen shown below — on that page just leave any settings I don’t specifically mention alone). These instructions sort of assume you’ll be connecting to a PSTN line with a ten-digit phone number, which for convenience is used in several places. If that’s not the case for you, you’ll have to make a mental substitution.
This article was originally written before Obihai introduced the OBi Expert Configuration feature in the OBiTALK portal. You can (and should) make the following changes there if you normally use the OBiTALK portal to configure your device. Note, however, that you will still need to enter the device’s local web portal long enough to change the IP address to a static one — that is one of the few things you cannot do from the OBi Expert Configuration section of the OBiTALK portal.
If you have not done so already, you’ll want to make sure the device has a static IP address on your network. I show some typical values in the example below, but be sure to use values that are sane for your network. This must be done from the OBi110’s internal web interface. You can get the address by picking up the phone connected to the phone PORT and dialing * * * 1. When you go to the device in your web browser, the user name will be “admin” and the password will be whatever you chose when you set up the device using the OBiTALK portal (you can yiew it there if you have forgotten what it is). Navigate to System Management, Networks settings to set up your static IP address, and after making the changes be sure to click Submit at the bottom of the page (and don’t forget to click Submit on any page where you make changes).
The rest of this configuration can and should be done using the OBi Expert Configuration feature in the OBiTALK portal, even though the screenshots below show manual configuration – again, that’s only because the OBi Expert Configuration feature had not yet been rolled out when this article was originally written.
I’m going to assume that you want to keep using your phone port with Google Voice and that it’s Service Provider A, so we’ll use Service Provider B to set up our Asterisk trunk information. So go to Service Providers, ITSP Profile B, SIP. In the Proxy Server field, put the address of your Asterisk server. Then scroll down (quite a way down) and find the X_SpoofCallerID field and make sure that is checked (otherwise you won’t get Caller ID passed through on incoming calls). Also, for security reasons, you may want to put the address of your Asterisk server in the X_AccessList field — I will draw your attention to this (slightly edited) note in the original thread on the OBiTALK forum:
NOTE: [The OBi110] does not challenge inbound INVITE [from the Asterisk server]. However you can setup a list of trusted IP addresses in the X_AccessList parameter (under ITSP Profile – SIP) to limit who can send SIP messages to the OBi [Service Provider]. Usually the gateway (OBi) and Asterisk machines are in the same subnet; normally not a big issue.
But it could be an issue if the OBi110 is not behind a firewall, and therefore could be accessed from the wide open Internet — in that case, anyone could make calls on your PSTN line unless you use the X_AccessList parameter to limit access. So to be safe, I strongly suggest putting the IP address of your Asterisk server in the X_AccessList parameter.
Next, go to Voice Services, SP2 Service. There are several settings on this page. Make sure that Enable, X_RegisterEnable, and X_KeepAliveEnable are all checked. Set X_RingProfile to A (the default) but set X_ServProvProfile and X_CodecProfile to B. X_InboundCallRoute must be set to LI (very important!). Then further below, in the SIP Credentials section, put the 10 digit number of your PSTN line in the AuthUserName, a good strong password in the AuthPassword field, and a URI string composed of the 10 digit number of your PSTN line, the @ symbol, and the address of your server (but preferably not in dotted IP format — even if you use the dotted IP address elsewhere, here you should use the address that is used to reach your server from the Internet. Believe it or not, getting the URI right can make all the difference between it working and not working).
Finally, go to Physical Interface, Line Port and make two changes. For the InboundCallRoute put SP2 and then in parenthesis the 10 digit number of your PSTN line. The RingDelay value is how long it will wait to try to obtain incoming Caller ID data – the default is 5500 (5.5 seconds) and as you may know, I hate to make callers wait unnecessarily, so I pared off a couple of seconds and set it to 3500 – that works for me, but you may need to experiment to find what works for you.
While you are in the Line Port settings, scroll down to the PSTN Disconnect Detection settings. This section control what conditions on your PSTN line will cause the OBi110 to think that the call has ended and hang up the call. Most lines will present at least one of the triggers shown – a CPC signal (drop in voltage), a polarity reversal on the line, or a disconnect tone (what people often call a “fast busy” signal, though you can change the tone that’s used for detection in the “Disconnect Tone Pattern” setting). But as a fallback, in case none of those triggers are present, the OBi110 will consider 60 seconds of silence from the far end as a disconnect. The problem with that is that if you call into a business and they put you on hold, and they don’t provide music or “comfort tones” or some other indication that you’re still on hold, the Obi110 will disconnect you after 60 seconds. So unless your PSTN line provides none of the other indications, I would suggest either unchecking the “DetectFarEndLongSilence” checkboxes, or setting the SilenceTimeThreshold to a much higher value than 60. In this example I have set SilenceTimeThreshold to 1800 (30 minutes) – I figure that if we’ve received nothing but silence from the distant end for that long, it’s time to give up! Please keep in mind that if the non-PSTN side of the call disconnects it will also end the call and cause the OBi110 to disconnect the PSTN line, so it would be a very rare situation where this timeout would ever be invoked, if you set it to a reasonably long value.
After you’ve saved all those, you may want to hold off on rebooting the adapter until you have set up your FreePBX trunk. And here’s a slightly modified screenshot of the FreePBX trunk page (the USER details field was enlarged so you could see everything):
Note this is from FreePBX 2.7 – later versions will look a little different but the settings should be the same. They are:
Trunk Description: Whatever you like — I used OBi110.
Maximum Channels: I now recommend that you leave this blank. The Obihai device notifies Asterisk when it cannot complete a call.
Dial Rules: 1+NXXNXXXXXX (in FreePBX 2.8 or later, put “1” in the first field and “NXXNXXXXXX” in the third field, without the quotation marks, of course).
Trunk Name: OBi110
host=192.168.0.222 (use the Static IP address of your OBi110)
USER Context: the 10 digit number of your PSTN line
secret=the AuthPassword from your OBi110
host=dynamic (really! This is important!)
nat=yes (yes even if device and server are on same LAN!*)
permit=192.168.0.0/255.255.255.0 (use sane values for your network)
*Never use nat=never — it won’t work. nat=no might work if the device and server are on the same LAN, but nat=yes will most likely work in any situation, and there doesn’t appear to be any downside to setting it that way.
After you’ve saved the above settings and have done an “orange bar reload”, then you can reboot your OBi110. Hopefully it will register with Asterisk and you’ll be all set.
Now, am I saying the above settings are perfect? Absolutely not! I tried a whole bunch of different things and when it finally started working I pretty much stopped tinkering, so there may be an unnecessary setting or two. In particular, note that there is a way to do the trunk configuration without using the USER Details section at all, as explained in the comments on this article. This article was a first attempt to get this working.
If you run into an issue where, when the device’s Line port is already in use on one call and another call tries to use it, the subsequent call doesn’t properly “fall through” to another unused trunk, you could try setting Maximum Channels to 1. But if you do that, you should also set the context line to read context=from-trunk-sip-OBi110, so that both incoming and outgoing calls count toward the Maximum Channels count. That’s so that when the PSTN line is in use, another available trunk will be used if anyone else attempts to make an outgoing call (assuming that another trunk is available). This should not be an issue with recent versions of the OBi110 firmware and therefore you should not make this change unless you actually experience this issue, because doing so could cause some unintended and unwanted side effects.
The format from-trunk-sip-trunk_name is a FreePBX thing. If you mouse over Maximum Channels, the tool tip that pops up will show you the context you would need to use to have both inbound and outbound calls counted against the maximum channels count.
In very limited testing it seems to work great — the sound quality seems excellent — but as I say, it might be a bit different when you have it connected to some old decrepit copper pair from the local telephone company that runs for several miles.
If you use Asterisk but NOT FreePBX, you might also want take a look at this article: Configuring the OBi110 to replace a linksys spa-3102 as a google voice and pstn gateway using asterisk 1.4
The Obihai OBi110 can be purchased at Amazon.com and at some other online retailers.
For another variation on the subject of this article, see How to use the Obihai OBi100 or OBi110 VoIP device as a gateway between Asterisk/FreePBX and Google Voice and/or the OBiTALK network, or preferably the newer revision, How to use the Obihai OBi100, OBi110, OBi200, or OBi202 VoIP device as a gateway between Asterisk/FreePBX and Google Voice and/or the OBiTALK network (UPDATED).