Provider Configuration: Gradwell

From FreeSWITCH Wiki
Jump to: navigation, search

Note - this may not be the best or the right configuration - I offer it purely on a it-works-for-me basis! Feel free to improve!

The important thing with Gradwell is that they don't do SIP registration. Incoming calls are directed to an IP address and port that you set up with them. Outgoing calls are authenticated using a combination of IP address and caller ID number. Usernames and passwords are not needed but the Username is used as the default outgoing CID (See Question at end), and you don't need to have a gateway setup - you can just bridge outgoing calls to Gradwell and receive calls on the phone numbers you've set with them.

I do use a gateway, though, because I have several others and like to keep them together and treat them the same way. In the following, [my gradwell phone number] is, for example, 01122334455:

<include>
  <gateway name="gradwell">
  <!--/// by default username is not ignored but is used as the presented outgoing Caller ID - see Question ///-->
  <param name="username" value="[my Gradwell phone number]"/>
  <!--/// account password required by freeswitch but ignored ///-->
  <param name="password" value="pass"/> 

  <!--/// proxy host: *optional* same as realm, if blank ///-->
  <param name="proxy" value="sip.trunk.gradwell.com"/>
  <param name="register" value="false"/>

  <!--send an options ping every x seconds, failure will unregister and/or mark it down-->
  <param name="ping" value="25"/>
  </gateway>
</include>

Inbound routing in dialplan/public/10_gradwell.xml is then:

<include>
  <extension name="inbound_gradwell">
    <condition field="destination_number" expression="^([my Gradwell phone number])$">
      <action application="set" data="domain_name=$${domain}"/>
      <!-- Our main incoming greeting extension is called 'frontdoor' -->
      <action application="transfer" data="frontdoor XML default"/>
    </condition>
  </extension>
</include>

For outgoing calls, I use something like the following:

<include>
  <extension name="outgoing">      
    <condition field="destination_number" expression="^9([0-9]+)$">
     <!-- effective_caller_id must be set to a number Gradwell recognise as belonging to your account otherwise call will be rejected --> 
     <action application="set" data="effective_caller_id_number=[my Gradwell phone number]" />
      <action application="bridge" data="sofia/gateway/gradwell/$1" />
    </condition>
  </extension>
</include>

Q:I'd like to set the effective caller id as part of the gateway declaration, but I don't think I can do that?

A: Gradwell OpenSIPS server take the number ahead of the @ sign in the SIP FROM: entry of the outgoing packets as the Outgoing CID and it cannot be overwritten by any setting within default FreeSWITCH configuration. This value is taken from the USERNAME field of the gateway configuration and if this is not a valid number then they take the first DID number listed under your account and present that.

This behavior can be changed by setting the caller-id-in-from element within the gateway xml file to true; With this set, FreeSWITCH will alter the FROM: entry by honoring the EFFECTIVE_CALLER_ID_NUMBER setting as long as it is within the range of numbers that Gradwell recognise as valid DID.

My working gradwell.xml gateway file is:

  <include>
    <gateway name="gradwell">
      <param name="username" value="[default CID number required to be presented]"/>
      <param name="password" value="nopassword"/>
      <param name="proxy" value="sip.trunk.gradwell.com"/>
      <param name="expire-seconds" value="2400"/>
      <param name="register" value="false"/>
      <param name="retry-seconds" value="60"/>
      <param name="ping" value="60"/>
      <param name="context" value="public"/>
      <param name="caller-id-in-from" value="true"/>
    </gateway>
  </include>