I'm going to try and explain this as best I can and hope perhaps someone can give me an insight on what I could do to make this work. I'm sure if I think about it long enough I'll figure out a way (and really, I have, I just don't much care for the approach I'm thinking of). Since what I'm thinking might not be the best way, I'm asking for thoughts here.
Basically I have set up my OBi100 as described in
my article, where SP1 is set up with a Google Voice account and SP2 is used as a trunk to Asterisk (
trunk, not extension). However, I got to thinking that it would be more useful yet if the phone port could also be made an extension off the Asterisk box. This would be easy if there were another service provider slot but since there are only two, it makes things a little more challenging.
In FreePBX you can create what's called a CUSTOM extension, and I found that sending calls to the phone port are easy. You simply create your custom extension, and then using the "dial" string, send your calls to
sip/trunk_name/extension_number. So if your trunk (that is used with SP2 on the OBi device) is named OBi, and the extension number is 345, your dial string would be
sip/OBi/345. Then on the OBi device, you simply go into your SP2 Service settings, and add {>(345):ph}, (including the comma at the end) to the start of your X_InboundCallRoute. When you do that, any call you dial to extension 345 will be routed to the phone port on the device.
The problem is handling outgoing calls FROM the phone port. I can, of course, set the calls to go out via SP2 or use the **2 prefix, but Asterisk thinks they are coming from the trunk (and therefore, from either the Google Voice account or the OBiTalk account). So from the phone, I can only dial a number associated with an Inbound Route in FreePBX, otherwise the call is rejected. This is because Asterisk has no way to distinguish between a call coming from the phone port and a call coming from either the Google Voice or the OBiTalk trunk.
I'm sure I could write some custom dial plan (a custom trunk context) that would look at the number called and if it's one of the two numbers associated with Google Voice or the OBiTALK network, send the call on to from-trunk for processing by the inbound routes, and if it's anything else assume it's from the phone port and send it to the from-internal context. That is just a bit more complicated than I'd prefer, and I was wondering if there might be an easier way. What I'm trying to figure out is if there's some way to mark the call as coming from the phone port, perhaps by sending a specific Caller ID name and number. It might still require a bit of custom trunk context but at least it could be something more generic.
Of course what would be ideal is if perhaps we could have a couple additional Service Provider slots (SP3 and SP4, perhaps), but I suppose those eat up a lot of the device's memory. I know as I'm writing this that I'm not thinking this through clearly, but I'm just not sure what other approach I could take to make this work. I'd appreciate any thoughts on this.