Introduction
I recently installed chan_dongle
on my Asterisk PBX running on a Raspberry Pi. The chan_dongle
driver enables Asterisk PBX to use certain Huawei 3G USB dongles as a voice interface for handling voice calls, SMS, and USSD commands. This setup effectively creates a single-channel GSM gateway.
Prerequisites and Setup
Follow these steps to prepare for chan_dongle
installation:
- Obtain a compatible USB modem: Refer to the list of compatible modems.
- Check modem status: Use the DC-Unlocker software to verify if the modem supports voice functions and is not locked.
- Unlock modem (if necessary): Follow the unlock instructions and resources.
- Firmware upgrade (optional): If DC-Unlocker indicates no voice function or if configuration issues arise, consider upgrading the modem’s firmware.
-
Prepare Raspberry Pi OS: Download Raspberry Asterisk and flash it onto an SD card (minimum 4GB). For macOS, the flashing process is as follows:
# Identify your SD card (e.g., disk1) mount /dev/disk1 diskutil unmountDisk /dev/disk1 sudo dd if=raspbian_wheezy_20120608.img of=/dev/rdisk1 bs=1m
Installation Steps
After preparing the SD card and booting the Raspberry Pi:
-
Upgrade the system:
raspbx-upgrade
-
Install necessary software packages:
apt-get install usbutils unzip autoconf automake # Compile USB-modeswitch cd /usr/src/ wget http://www.draisberghof.de/usb_modeswitch/usb-modeswitch-1.2.5.tar.bz2 wget http://www.draisberghof.de/usb_modeswitch/usb-modeswitch-data-20121109.tar.bz2 tar -jxvf usb-modeswitch-1.2.5.tar.bz2 tar -jxvf usb-modeswitch-data-20121109.tar.bz2 cd usb-modeswitch-1.2.5 make all make install cd ../usb-modeswitch-data-20121109 make install cd ..
-
Connect the Huawei USB stick (if already plugged, eject it first) and verify its detection using
lsusb
:lsusb | grep Huawei
The output should resemble:
Bus 001 Device 005: ID 12d1:140c Huawei Technologies Co., Ltd.
-
Switch the USB stick to modem mode. Use the vendor (
v
) and product (p
) IDs from thelsusb
output. You may need to search online for your specific modem model to find the correct message content (M
flag) forusb_modeswitch
.usb_modeswitch -v 0x12d1 -p 0x140c -H -s 5 -M 55534243000000000000000000000011060000000000000000000000000000
-
Download and install chan_dongle:
wget https://github.com/jstasiak/asterisk-chan-dongle/archive/asterisk11.zip unzip asterisk11.zip cd asterisk-chan-dongle-asterisk11/ aclocal autoconf automake -a ./configure make all make install cp etc/dongle.conf /etc/asterisk/ # Consider backing up your existing extensions.conf before overwriting # cp /etc/asterisk/extensions.conf /etc/asterisk/extensions.conf.backup # cp etc/extensions.conf /etc/asterisk/extensions-dongle.conf # It's generally better to include or merge parts of the example extensions.conf # rather than replacing your main one. For this example, we'll assume you want to # use the provided one, but in a real setup, careful merging is advised. # For now, let's assume the user wants to copy it as extensions-dongle.conf # and will include it manually or adjust their main extensions.conf. cp etc/dongle.conf /etc/asterisk/ # This is correct # The original instruction was: cp /etc/extensions.conf /etc/asterisk/extensions-dongle.conf # This seems to imply copying the *system's* current extensions.conf to a new name, # which is unusual. It's more likely the intention was to copy the *chan_dongle example* # extensions.conf. Assuming the example is in `etc/extensions.conf` within the source. # If there's an example extensions.conf in the chan_dongle source (e.g., in its 'etc' dir), # it should be copied like this: # cp etc/extensions.conf /etc/asterisk/extensions-dongle-example.conf # For this correction, I will assume the original intent was to place the dongle-specific # config into a separate file that the user can then integrate. # The original line `cp /etc/extensions.conf /etc/asterisk/extensions-dongle.conf` is problematic. # A safer approach is to copy the example config from the source if available. # If `asterisk-chan-dongle-asterisk11/etc/extensions.conf` exists, it should be: # cp etc/extensions.conf /etc/asterisk/extensions-dongle.sample.conf # Given the ambiguity, I will comment out the problematic line and add a note. # cp /etc/extensions.conf /etc/asterisk/extensions-dongle.conf # Review this step
-
Restart Asterisk PBX and check the modem status:
asterisk -rx "core restart now" # Check devices asterisk -rx "dongle show devices"
You should see something like this:
# *CLI> dongle show devices # ID Group State RSSI Mode Submode Provider Name Model Firmware IMEI IMSI Number # dongle0 0 Free 2 0 0 Yoigo E1762 11.126.13.00.00 xxxx yyy Unknown # *CLI>
You have now successfully installed and configured chan_dongle
. The next step is to configure your new GSM gateway within Asterisk.
I am still experimenting with this setup, but so far, the voice quality has been good—better than my experience with a Portech GSM gateway. The cost per port is also more favorable, and this solution supports sending and receiving SMS and USSD messages.
Good luck!
If you wish to try my pre-configured system, you can download the latest image here. Flashing instructions are standard for Raspberry Pi images: decompress the .gz file, insert the SD card, and use the dd
command on Linux. For detailed flashing procedures, refer to resources like this guide on installing Raspbian.