Howto: Setup FreePhoneLine.ca for use with FreeSwitch

Stupid me recently commented on FreePhoneLine.ca’s (I’ll refer it to FPL from now on) facebook page bragging on how I got my FreeSwitch + FPL setup working.

Today somebody question on my brag comment:

“@Jeffrey Leung; Could you please share the information how are you using FPL on FreeSwitch softswitch? I’m really interested using it and would really appreciate your reply.”

Okay… But if I only told you my experience, wouldn’t that put you in a huge advantage and others left out in the cold? Don’t worry, I’ll tell you how I got my FreeSwitch setup with FPL! Along with the general population of the Interwebs But before you read on, I assume you know how to install FreeSwitch on pretty much any *nix system out there and I also assume you’re using the latest git build of the softswitch. Note that I made 2 assumptions here.(aka. wink, wink, nudge, nudge… RTFM)

Now I’ll make another assumption, you gotta pay Fibernetics a $56 one-time fee to get your ATA SIP login details. Yes, unfortunately you have pay them to get that information, but in my opinion, it’s totally worth it a million times over.

Okay, assumptions aside, now let’s get into the details on getting FPL to work with FreeSwitch. As I mentioned earlier, FPL is based on SIP, so this is no different than getting Sofia to register with an external SIP gateway. Some of you may be already using CallCentric, VoIP.ms or iCall on your FreeSwitch box. If you are, then that’s great! The only information at this point you’ll need is FPL’s SIP proxy server DNS name, the SIP username and password. Yes, that’s what you’ll need to do, register it as another external gateway. It’s just that easy. Yes, I made another assumption here now…

Now it’s time to get the dialplan working. Again it’s pretty much a cookie cutter approach, if you know what you’re doing with FreeSwitch. You can use the “${sip_to_user}” dialplan variable to get things rolling for incoming calls and getting the internal dialplan directing calls to the external gateway.

One thing to keep in mind, disregard FPL’s suggestion on using G.729 for outgoing calls as the default builds of FreeSwitch doesn’t have full support for G.729 unless you purchase licenses just to use it. Use ulaw instead by prepending {absolute_codec_string=PCMU} on the “bridge” section of the diaplan. FPL works extremely well with ulaw and the quality is noticeably superior to the default G.729 codec as suggested by them.

And oh, another thing, it’s a good idea to add this just before the bridge action in the outgoing dialplan

<action application="start_dtmf_generate" data="true"/>

Adding that will cause FreeSwitch to generate in-band DTMF tones instead of sending RFC2833 or SIP INFO tones. FPL requires in-band tones in uLaw as for some weird reason, they don’t like receiving/sending SIP INFO/RFC2833 DTMF tones.

Hope this information helped others getting this excellent softswitch to work with FPL. And if anybody asks why I use FreeSwitch instead of Asterisk, there’s a simple answer. The messy configuration inside Asterisk just scares me. I prefer nice and clean XML configuration and the power of Regular Expressions for getting dialplans to work.

[b]Reference Material[/b]

The remainder of the post is just for reference for people who don’t remotely have a clue on how things are done in FreeSwitch… If you know what you’re doing, you can pretty much ignore the reference snippets I’m posting here. Also, due to some bug inside s9y, the br code shows inside the code block; You’ll have to remove before you save it on your FreeSwitch configuration until I find a solution to fix this. You can look at it this way, [b]don’t just go copy and pasting stuff inside your FreeSwitch configuration, review it before using it[/b].

This XML snippet goes inside the conf/sip_profiles/external folder

  <gateway name="FPL1XXXXXXXXX">
    <param name="username" value="1XXXXXXXXX" />
    <param name="from-user" value="1XXXXXXXXX" />
    <param name="realm" value="voip.freephoneline.ca"/>
    <param name="proxy" value="voip.freephoneline.ca"/>
    <param name="password" value="PasswordHere" />
    <param name="register" value="true" />
  </gateway>

This is in my public dialplan (Adapt this to your own use)

<extension name="FPL_nottellingyoumyinternalextensions">
  <condition field="${sip_to_user}" expression="^1XXXXXXXXX$">
    <!-- FS uses Regex for dialplans. Don't be too surprised when you see them -->
    <action application="answer" />
    <action application="sleep" data="1500" />
<!--tonedetect is used for incoming faxes if you have mod_spandsp enabled-->
    <action application="tone_detect" data="fax 1100 r +5000 transfer 'fax XML default' 1"/>
    <!--Transfer your call from the public context to the internal extensions-->
    <action application="transfer" data="1000 XML default" />
  </condition>
</extension>

This is my outgoing dialplan (Goes in the internal dialplan!)

  <extension name="FPL1XXXXXXXXX">
    <condition field="caller_id_number" expression="^1000$"/>
    <!--<condition field="destination_number" expression="^([2-9]d{2})(d{7})$">-->
    <condition field="destination_number" expression="^(250|416|604|778|647)(d{7})$">
      <action application="bridge" data="{absolute_codec_string=PCMU}sofia/gateway/FPL1XXXXXXXXX/$1$2"/>
    </condition>
  </extension>  

Leave a Reply

Your email address will not be published. Required fields are marked *