FreeTDM OpenR2

From FreeSWITCH Wiki
Jump to: navigation, search

FreeTDM OpenR2 Installation

If you want to use MFC-R2 signaling with FreeTDM (most likely to use it with FreeSWITCH), follow this steps:

1. You need first to download openr2 svn trunk.

$ svn co http://openr2.googlecode.com/svn/trunk/ openr2

2. Install the library using CMake.

$ cd openr2/
$ mkdir mybuild
$ cd mybuild
$ cmake -DCMAKE_INSTALL_PREFIX=/usr ..
$ make && sudo make install

3. Proceed to install the Wanpipe drivers (use the latest drivers found at http://wiki.sangoma.com/) or if you have a Digium board install DAHDI (see point 5 for clarification)

4. In other directory proceed to checkout and install FreeSWITCH as usual.

$ git clone git://git.freeswitch.org/freeswitch.git
$ cd freeswitch
$ ./boostrap.sh
$ ./configure
$ make && sudo make install

5. Configure the freetdm.conf spans to use CAS channels in E1 mode. The following samples assume you use span 1. You can use either Zaptel/DAHDI or Sangoma Wanpipe mode.

Before looking at the configuration, let me explain a bit better what Zaptel/DAHDI or Sangoma Wanpipe mode means. When I talk about Zaptel, I mean Zaptel or DAHDI, both are supported.

Sangoma Wanpipe mode is used when you have a Sangoma board (Although Sangoma cards can also be used in Zaptel/DAHDI mode).

Zaptel mode is used typically when you have a Zaptel compatible board, like Sangoma or Digium boards. However if you have a Sangoma board there is no point in using it in Zaptel mode for FreeSWITCH, Sangoma boards support Zaptel mode just to be able to plug into Asterisk channel driver chan_zap/chan_dahdi, but FreeSWITCH can use Sangoma boards directly in Wanpipe mode.

If you have a Sangoma board, you DON'T need Zaptel/DAHDI drivers, use Wanpipe mode and follow the instructions in the ./Setup script to install the drivers in API mode (The menu says which one for FreeSWITCH). More detailed instructions can be found at the Sangoma wiki: http://wiki.sangoma.com/wanpipe-freeswitch-install

At this date, the latest Sangoma drivers are 3.5.15

If you have a Zaptel compatible board, install the latest Zaptel/DAHDI drivers as usual (instructions can be found on voip-info.org I think)

Once you have installed either the Sangoma Wanpipe drivers or Zaptel/DAHDI drivers, you can proceed to configure /usr/local/freeswitch/conf/autoload_configs/freetdm.conf (the prefix /usr/local/freeswitch assumes you installed freetdm as part of FreeSWITCH).

For Wanpipe mode:

[span wanpipe myspan]
trunk_type => E1
cas-channel => 1:1-15:1101
cas-channel => 1:17-31:1101

For Zaptel/DAHDI mode:

[span zt myspan]
trunk_type => E1
cas-channel => 1-15:1101
cas-channel => 17-31:1101

Remember that Zaptel/DAHDI spans channel numbering starts at 1 and keeps incrementing across spans up to infinity, where Wanpipe channel specification always is span based

 <span>:<channel-range>:<cas_bits>

That is, regardless of how many spans you have, you will not have any channel higher than 31, where in Zaptel/DAHDI, for span 2 you would start at channel 32.

6. Configure FreeSWITCH to use R2 spans, edit /usr/loca/freeswitch/conf/autoload_configs/freetdm.conf.xml and add the R2 spans:

   <r2_spans>
     <span name= "myspan">

             <!-- ONLY THIS PARAMETERS REQUIRED -->
             <param name="variant" value="br"/>
             <param name="max_ani" value="20"/>
             <param name="max_dnis" value="10"/>
             <param name="dialplan" value="XML"/>
             <param name="context" value="default"/>

             <!-- ONLY USE THE FOLLOWING PARAMETERS TO TWEAK ADVANCED SETTINGS -->
             <!--
             <param name="category" value="national_subscriber"/>
             <param name="allow_collect_calls" value="yes"/>
             <param name="immediate_accept" value="yes"/>
             <param name="double_answer" value="yes"/>
             <param name="skip_category" value="yes"/>
             <param name="forced_release" value="yes"/>
             <param name="charge_calls" value="yes"/>
             <param name="get_ani_first" value="yes"/>

             <param name="mfback_timeout" value="7000"/>
             <param name="metering_pulse_timeout" value="1000"/>
             <param name="advanced_protocol_file" value="/etc/r2proto.conf"/>
             <param name="use_channel_native_mf_generation" value="yes"/>
              -->

             <!-- USE THIS FOR DEBUGGING MFC-R2 PROTOCOL -->
             <param name="logdir" value="mfcr2"/>
             <param name="logging" value="notice,warning,error,mf,cas"/>
             <param name="call_files" value="yes"/>

             <param name="dial-regex" value=""/>
             <param name="fail-dial-regex" value=""/>

     </span>
   </r2_spans>

There is documentation about each parameter in the sample configuration provided inside libs/freetdm/conf/freetdm.conf.xml

There is no parameters to set openr2_context_t::dial_with_dtmf and openr2_context_t::detect_dtmf. So if you want to use standart DTMF instead of MF, you should modify r2proto.c (some function, e.g. :: r2config_itu(1)) or ftmod_r2.c :: ftdm_r2_configure_span_signaling(3).

FreeTDM OpenR2 Commands

From the FreeSWITCH CLI you can execute:

$ ftdm r2 status 1

That will show you the status and basic configuration for the span 1, like this:

freeswitch@localhost.localdomain> ftdm r2 status 1
API CALL [ftdm(r2 status 1)] output:
Variant: MX
Max ANI: 10
Max DNIS: 4
ANI First: No
Immediate Accept: No

Channel Tx CAS       Rx CAS
  63    IDLE         IDLE
  64    IDLE         IDLE
  65    IDLE         IDLE
  66    IDLE         IDLE
  67    IDLE         IDLE
  68    IDLE         IDLE
  69    IDLE         IDLE
  70    IDLE         IDLE
  71    IDLE         IDLE
  72    IDLE         IDLE
  73    IDLE         IDLE
  74    IDLE         IDLE
  75    IDLE         IDLE
  76    IDLE         IDLE
  77    IDLE         IDLE
  79    IDLE         IDLE
  80    IDLE         IDLE
  81    IDLE         IDLE
  82    IDLE         IDLE
  83    IDLE         IDLE
  84    IDLE         IDLE
  85    IDLE         IDLE
  86    IDLE         IDLE
  87    IDLE         IDLE
  88    IDLE         IDLE
  89    IDLE         IDLE
  90    IDLE         IDLE
  91    IDLE         IDLE
  92    IDLE         IDLE
  93    IDLE         IDLE

+OK.

Other misc commands:

$ ftdm r2 status <span_id|span_name>
$ ftdm r2 loopstats <span_id|span_name>
$ ftdm r2 block|unblock <span_id|span_name> [<chan_id>]
$ ftdm r2 version
$ ftdm r2 variants

See Also