Simple PBX tutorial for FreeSWITCH

Here is a short tutorial that helps building a PBX with FreeSWITCH.

, , ,

Leave a comment

3G connectivity for PC Engines APU (MU609)

HUAWEI MU609 Mini-PCIe card is available at aliexpress.com for about $40. Comparing to DW5550 card, MU609 is more expensive, but it”s a current hardware, actively supported by the manufacturer.

MU609 supports the traditional PPP interface, as well as CDC Ethernet interface for Linux.

It also has a built-in support for mobile voice calls, but its audio is only available on the physical PCM GPIO interface, which is wired to pins 45, 47, 49, and 51 on the Mini-PCIe plug. These pins are not standardized and marked as “reserved” in Mini-PCIe specification. The PC Engines APU board does not connect these pins to anything.

The card initializes 5 serial-USB devices (ttyUSB0 – ttyUSB4). ttyUSB0 can be used for modem control with AT commands. Detailed documentation for the rest of devices is available at Huawei website. The CDC Ethernet card is initialized as eth3 (because eth0-eth2 are onboard Ethernet adapters).

Setting up the card for automatic startup under Debian:

apt-get install -y picocom ppp

cat >/etc/chatscripts/sunrise.MU609 <<'EOT'
ABORT BUSY
ABORT 'NO CARRIER'
ABORT ERROR
TIMEOUT 10
'' ATZ
OK 'AT+CFUN=1'
OK 'AT+CMEE=1'
OK 'AT\^NDISDUP=1,1,"internet"'
OK
EOT

cat >/etc/chatscripts/gsm_off.MU609 <<'EOT'
ABORT ERROR
TIMEOUT 5
'' AT+CFUN=0 OK
EOT

vi /etc/network/interfaces
allow-hotplug eth3
iface eth3 inet dhcp
    pre-up /usr/sbin/chat -v -f /etc/chatscripts/sunrise.MU609 >/dev/ttyUSB0 </dev/ttyUSB0
    post-down /usr/sbin/chat -v -f /etc/chatscripts/gsm_off.MU609 >/dev/ttyUSB0 </dev/ttyUSB0


, , , ,

Leave a comment

Call generator for performance tests

Here I wrote a simple call generator for FreeSWITCH, and it can be used for performance tests:

https://github.com/voxserv/freeswitch-perf-dialer

, , ,

Leave a comment

3G connectivity for PC Engines APU (DW5550)

In addition to Sierra Wireless MC8775 3G modem, there’s now a new offering for Dell DW5550 (or Ericsson F5521gw, which is the same hardware) mini-PCIe 3G cards at Aliexpress.com, in the price range of $20. This is a newer hardware (the ones I received were manufactured in mid-2012), and it supports higher UMTS speeds and an CDC Ethernet interface in Linux.

This page refers to Ericsson F3507g card, but all instructions are relevant for DW5550. The device identifies itself as Dell DW5550, firmware version R3B01 (Command for retrieving the version: AT+CGMR).

Default Linux kernel 3.2.0 in Debian Wheezy names the CDC Ethernet interface as usb0, and 3.16.0 from Wheezy backports names it as wwan0. Other than that, everything else works the same.

Out of 3 ordered cards, two worked immediately, and one was broken. The seller has kindly offered a replacement for additional $10.

for n in `ls /sys/class/*/*{ACM,wdm,usb0}*/device/interface`;do echo $(echo $n|awk -F '/' '{print $5}') : $(cat $n);done

usb0 : Dell Wireless 5550 HSPA+ Mobile Broadband Mini-Card Network Adapter
ttyACM0 : Dell Wireless 5550 HSPA+ Mobile Broadband Mini-Card Modem
ttyACM1 : Dell Wireless 5550 HSPA+ Mobile Broadband Mini-Card Data Modem
ttyACM2 : Dell Wireless 5550 HSPA+ Mobile Broadband Mini-Card GPS Port
cdc-wdm0 : Dell Wireless 5550 HSPA+ Mobile Broadband Mini-Card Device Management
cdc-wdm1 : Dell Wireless 5550 HSPA+ Mobile Broadband Mini-Card USIM Port

The following commands initiate a 3G connection for a sunrise.ch SIM card:

apt-get install -y picocom ppp
picocom -b 115200 /dev/ttyACM1

AT+CFUN=1
AT+CGDCONT=1,"IP","internet"
AT*ENAP=1,1

Ctrl-a Ctrl-x
dhclient usb0

This Debian wiki page explains how to bring up the connection automatically at Linux startup:

cat >/etc/chatscripts/sunrise.DW5550 <<'EOT'
ABORT BUSY
ABORT 'NO CARRIER'
ABORT ERROR
TIMEOUT 10
'' AT+CFUN=1 OK
\dAT+CGDCONT=1,"IP","internet" OK
\d\d\dAT*ENAP=1,1 OK
EOT

cat >/etc/chatscripts/gsm_off.DW5550 <<'EOT'
ABORT ERROR
TIMEOUT 5
'' AT+CFUN=4 OK
EOT

vi /etc/network/interfaces

allow-hotplug usb0
iface usb0 inet dhcp
    pre-up /usr/sbin/chat -v -f /etc/chatscripts/sunrise.DW5550 >/dev/ttyACM0 </dev/ttyACM0
    post-down /usr/sbin/chat -v -f /etc/chatscripts/gsm_off.DW5550 >/dev/ttyACM0 </dev/ttyACM0

, , , ,

Leave a comment

Connecting Yeastar TG200 GSM gateway to FreeSWITCH

I needed to connect a GSM gateway to my FreeSWITCH PBX, in order to receive SMS and mobile calls and emulate a normal mobile phone. I’ve got the Yeastar Neogate TG200 V2 for this purpose (Firmware Version: 53.18.0.39, running Asterisk 1.6.2.6 on an ARM processor).

This blog entry has helped a lot and saved a bunch of time.

The box supports OpenVPN, so you can place it in some remote location behind NAT, and manage it via the VPN connection. The client version is rather old (2.0.5), so it does not support embedded certificates in the client config, and also “topology subnet” option is not supported. You need to pack your vpn.conf and the certificates and pivate key into a TAR archive and upload to Neogate via its web interface.

It’s sufficient to configure one SIP trunk to your PBX, and manipulate the To: header in order to distinguish between SIM cards on incoming calls.

When the SIP trunk was configured (FreeSWITCH as a registrar), I started receiving the following warnings on FreeSWITCH, and the registration status was quickly removed after neogate’s REGISTER message:

2014-12-22 12:29:42.208567 [WARNING] sofia.c:5721 Sip user 'gsm01@xxxxx.net' is now Unreachable
2014-12-22 12:29:42.208567 [WARNING] sofia.c:5732 Expire sip user 'gsm01@xxxxx.net' due to options failure

My FreeSWITCH was sending SIP OPTIONS requests to all registered users and removed the registrations unless the clients responded with status 200 or 468. Neogate responds with 404 Not Found on such requests toward the trunk SIP user. I had to disable “unregister-on-options-fail” option in FreeSWITCH internal SIP profile.

In SIP trunk configuration, “Advanced->Caller ID” was automatically set to my trunk’s registration user name. Because of this, all incoming calls had this name as the caller ID, and the original caller number was lost. After setting this field to blank, the problem was resolved.

In “Mobile to IP” rules, you can set a different rule for each SIM card. The “Hotline” field should not be blank, and should contain some distinguishing number. It will be used in To field in the SIP INVITE on incoming calls. If you leave “Hotline” empty, the Neogate will respond with dial tone and collect DTMF digits before placing the call to your SIP trunk. So far I could not find any documentation that describes this.

Also in trunk configuration, sometimes I had to reboot the box in order for my changes to take effect.

The box uses the standard Asterisk management interface for sending and receiving SMS, and I’m planning to use this Perl module through the VPN connection.

, , ,

Leave a comment

Inspiration projects for next-generation Torrus

It’s not yet clear when I can start working on a new-generation Torrus, but here are some nice software projects which would probably inspire the new design, or probably be part of the new design. I haven’t looked into them in depth though.

  • Bosun is a distributed monitoring system produced by StackExchange. It uses distributed collector agents which write data into OpenTSDB. Bosun and its collector are written in Go, and OpenTSDB is written in Java.
  • InfluxDB is a time-series database written in Go.

and yes, the new project will most probably have its core in Go. But the SNMP discovery engine will most probably remain in Perl because of a big list of supported vendors.

, , ,

Leave a comment

Using Voxbeam for outbound calls with FreeSWITCH

Voxbeam is providing worldwide PSTN connectivity at competitive rates, and it allows you to use any Caller ID, which is very convenient for call forwarding. The Voxbeam gateway authenticates the clients by their IP addresses only, so you need a static IP address, and no username or password are required. The FreeSWITCH configuration shown below allows you to control which destinations should be routed to Voxbeam. With a bit of further extension, you can also control which destinations would use different tariff plans at Voxbeam. This configuration covers only their Standard pricing plan. Here INTERNALDOMAIN is a name of the SIP realm that is used for registered users. We assume that the variable “outbound_caller_id_number” is set elsewhere above in the dialplan.

--- File: ip_profiles/external/voxbeam.xml ---
<include>
  <gateway name="voxbeam_outbound">
    <param name="realm" value="sbc.voxbeam.com" />
    <param name="register" value="false" />
    <!-- important, so that your caller ID is transmitted properly -->
    <param name="caller-id-in-from" value="true"/> 
  </gateway>
</include> 

--- File: dialplan/INTERNALDOMAIN/05_pstn_outbound.xml ---
<include>
  <!-- Express destination and caller numbers in E.164 notation without leading plus sign.
       Note that we treat numbers with one leading zero as local Swiss numbers -->
  <extension name="pstn_normalize" continue="true">
    <condition field="destination_number" expression="^00([1-9]\d+)$" break="never">
      <action inline="true" application="set" data="e164_dest=$1"/>
    </condition>
    <condition field="destination_number" expression="^0([1-9]\d+)$" break="never">
      <action inline="true" application="set" data="e164_dest=41$1"/>
    </condition>
    <condition field="${outbound_caller_id_number}" expression="^00([1-9]\d+)$" break="never">
      <action inline="true" application="set" data="e164_cid=$1"/>
    </condition>
    <condition field="${outbound_caller_id_number}" expression="^0([1-9]\d+)$" break="never">
      <action inline="true" application="set" data="e164_cid=41$1"/>
    </condition>
  </extension>

  <!-- Here we define that calls to Russia and Ukraine should go through Voxbeam -->
  <extension name="pstn_select_itsp" continue="true">
    <condition field="${e164_dest}" expression="^(7|38)" break="on-true">
      <action inline="true" application="set" data="outbound_itsp=voxbeam"/>
    </condition>
  </extension>

  <!-- send matched calls to Voxbeam -->
  <extension name="pstn_voxbeam">
    <condition field="${outbound_itsp}" expression="^voxbeam$" break="on-false">
      <action application="set" data="effective_caller_id_number=${e164_cid}"/>
      <action application="bridge" data="sofia/gateway/voxbeam_outbound/0011103${e164_dest}"/>
    </condition>
  </extension>

  <!-- send everything else to Sipcall.ch -->
  <extension name="pstn_sipcall">
    <condition field="destination_number" expression="^(0\d+)$">
      <action application="set" data="effective_caller_id_number=${outbound_caller_id_number}"/>
      <action application="bridge" data="sofia/gateway/sipcall/$1"/>
    </condition>
  </extension>
</include>

This is a very simple example, and a bit more logic can be introduced, such as looking up in some kind of a database for least cost routing, and so on.

 

, , ,

Leave a comment

Installing Go 1.3 in debian wheezy

The original script is found here: http://www.snip2code.com/Snippet/79027/How-to-install-Go-1-3-in-debian-wheezy

The original script is a bit dated, and now 1.3-1 is the latest version:


## File: go1.3-install-deb.sh
apt-get install devscripts build-essential
apt-get build-dep golang-go

wget http://ftp.de.debian.org/debian/pool/main/g/golang/golang_1.3-3.dsc
wget http://ftp.de.debian.org/debian/pool/main/g/golang/golang_1.3.orig.tar.gz
wget http://ftp.de.debian.org/debian/pool/main/g/golang/golang_1.3-3.debian.tar.xz

dpkg-source -x golang_1.3-3.dsc
cd golang-1.3/
debuild -us -uc
cd ..
dpkg -i \
golang-go_1.3-3_amd64.deb \
golang-src_1.3-3_amd64.deb \
golang-go-linux-amd64_1.3-3_amd64.deb \
vim-syntax-go_1.3-3_all.deb

echo Finished

,

Leave a comment

mSATA drives for PC Engines APU

Drives with problems:

  1. KingSpec 16GB (Model Number: KingSpec KSM-mSATA.7i-016MJ, Firmware Revision:  SVN454): quite often, the kernel times out to boot at the start.
  2. SuperSSpeed S238: with the old firmware, TRIM operation erased the boot sector. The newer firmware disables TRIM.

Drives without problems (everything works fine with TRIM)

  1. MyDigitalSSD Super Boot Drive (Model Number:  SB mSATA SSD, Firmware Revision: S9FM01.8)
  2. SanDisk X110 (Model Number: SanDisk SD6SF1M032G1022I, Firmware Revision: X231200)
  3. Kingston Now (Model Number: KINGSTON SMS200S330G, Firmware Revision: 524ABBF0)

The testing procedure is quite simple: a background process is massively creating and deleting a small file, and another process calls fstrim every few seconds. Then the health of the filesystem is checked after an hour or so.

while true; do echo xxxxxxxxxxxxxxxxxxxxxxxx >xxx; done &
while true; do fstrim -v /; sleep 10; done

 

,

Leave a comment

3G connectivity for PC Engines APU (MC8775)

PC Engines’ APU board has its mPCIe slot 2 wired to the SIM card socket, which allows using any standard mPCIe 3G modem. Most of modern modems are quite expensive, but there are plenty of Sierra Wireless MC8775 cards at aliexpress.com for around $20 apiece. This is a decent hardware, manufactured around 2007-2011. It doesn’t deliver the highest UMTS speeds possible, but still can be used in situations where speed is unimportant.

The cards that I bought came with firmware version 1_1_8_15, dated 2007/07/17. I didn’t test it fully, but there are some failure reports in the internet.

The firmware upgrade requires an adapter with a SIM card slot. I got mine from this eBay seller.

This page describes the firmware upgrade process. The links to istudioz.net are still valid, but you need to remove # (%23) from the URLs. The 3G watcher for the AirCard 875 is unavailable at its original place, but easy to find with Google. I got mine at this site. The upgrade requires a 32bit Windows machine, and takes about 20 minutes. I upgraded the firmware successfully with my old Vista laptop.

Also I bought the 3G antenna and the pigtail cable at aliexpress.

After inserting the 3G modem into mPCIe slot 2 and booting Debian Wheezy, the device was immediately visible as three serial USB interfaces (/dev/ttyUSB0  /dev/ttyUSB1  /dev/ttyUSB2). ttyUSB0 is used for data, and ttyUSB2 can be used for controlling the device with AT commands. The command “AT^CARDMODE” will tell if the SIM card is inserted, and “AT!GSTATUS?” displays the network status information. “AT+GMR” displays the current firmware version. Ctrl-a Ctrl-x sequence will finish the picocom session.

apt-get install -y wvdial picocom
picocom -b 115200 /dev/ttyUSB2 
AT^CARDMODE
AT!GSTATUS?
AT+GMR
Ctrl-a Ctrl-x

The following /etc/wvdial.conf works with Sunrise.ch 3G network:

[Dialer Defaults]
Modem = /dev/ttyUSB0
Baud = 460800
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Phone = *99#
Username = ''
Password = ''
Ask Password = 0
Stupid Mode = 1
Compuserve = 0
Idle Seconds = 0
ISDN = 0
Auto DNS = 1 

Execute “wvdial” comand from the command line, and it should immediately connect to the internet. The rest is easy: you can place wvdial into a startup script and execute it automatically at boot time.

, , , , ,

Leave a comment