OpenWrt Forum Archive

Topic: [How To] Asterisk 11+GSM/SMS channel+Google Voice+OpenWRT SIP Client

The content of this topic has been archived between 25 Apr 2018 and 5 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

This is the Asterisk dialplan for triggering the 4 channels ON and OFF.

;; Home Automation Box - 4 channels relay board
;; Asterisk 11 & OpenWRT
;; see
;; By pilovis -
; put this code in "/etc/asterisk/extensions.conf" under [default] section
;Relay 1 = key 1 on , key 5 off
;Relay 2 = key 2 on , key 6 off
;Relay 3 = key 3 on , key 7 off
;Relay 4 = key 4 on , key 8 off
;IVR password: 1234
; IVR with vocal guide.
; find asterisk sound files (.gsm) on your language named:
; and copy them to /usr/lib/asterisk/sounds of your OpenWRT router
exten => xxxxxxxxxx,1,Answer()
exten => xxxxxxxxxx,n,Ringing
exten => xxxxxxxxxx,n,Set(TIMEOUT(digit)=7)
exten => xxxxxxxxxx,n,Set(TIMEOUT(response)=21)
; password "1234" required to continue
exten => xxxxxxxxxx,n,Authenticate(1234,,4)
; IVR vocal guide
exten => xxxxxxxxxx,n,Background(1&2&3&4&activated&5&6&7&8&de-activated)
exten => xxxxxxxxxx,n,WaitExten(5,4)
exten => xxxxxxxxxx,n,Hangup()
exten => 1,1,Playback(1&activated)
exten => 1,2,System(/root/ &)
exten => 1,3,Wait(2)
exten => 1,4,Hangup()
exten => 2,1,Playback(2&activated)
exten => 2,2,System(/root/ &)
exten => 2,3,Wait(2)
exten => 2,4,Hangup()
exten => 3,1,Playback(3&activated)
exten => 3,2,System(/root/ &)
exten => 3,3,Wait(2)
exten => 3,4,Hangup()
exten => 4,1,Playback(4&activated)
exten => 4,2,System(/root/ &)
exten => 4,3,Wait(2)
exten => 4,4,Hangup()
exten => 5,1,Playback(1&de-activated)
exten => 5,2,System(/root/ &)
exten => 5,3,Wait(2)
exten => 5,4,Hangup()
exten => 6,1,Playback(2&de-activated)
exten => 6,2,System(/root/ &)
exten => 6,3,Wait(2)
exten => 6,4,Hangup()
exten => 7,1,Playback(3&de-activated)
exten => 7,2,System(/root/ &)
exten => 7,3,Wait(2)
exten => 7,4,Hangup()
exten => 8,1,Playback(4&de-activated)
exten => 8,2,System(/root/ &)
exten => 8,3,Wait(2)
exten => 8,4,Hangup()
; eof

Note: change "xxxxxxxxxx," with your extension.

- Examples of the ON & OFF scripts:
(don't forget to give "chmod 755" to the files)


# switch on relay 1
/bin/echo 1 > /sys/devices/platform/leds-gpio.0/leds/DGND3700v1_3800B:blue:wifi5g/brightness
# Insert channel status (1=on, 0=off) for channel recovering after a reboot/crash
/bin/rm /root/status-relay1
/bin/cat  /sys/devices/platform/leds-gpio.0/leds/DGND3700v1_3800B:blue:wifi5g/brightness >> /root/status-relay1


# swith off relay 1
/bin/echo 0 > /sys/devices/platform/leds-gpio.0/leds/DGND3700v1_3800B:blue:wifi5g/brightness
#  Insert channel status (1=on, 0=off) for channel recovering after a reboot/crash
/bin/rm /root/status-relay1
/bin/cat  /sys/devices/platform/leds-gpio.0/leds/DGND3700v1_3800B:blue:wifi5g/brightness >> /root/status-relay1

- Script to extract channel status and restore it at reboot
(put the line: "/bin/sh /root/" in "/etc/rc.local" right before the "exit 0" line)


# extract and restore status of relay1
while IFS=: read relay1
/bin/echo ${relay1} > /sys/devices/platform/leds-gpio.0/leds/DGND3700v1_3800B:blue:wifi5g/brightness
done < /root/status-relay1

- Configuration file for triggerhappy (/etc/triggerhappy/triggers.d/example.conf) to control the 4 relay by an USB keypad.

# This is an example configuration for the triggerhappy daemon (thd)
# please note that every file to be processed must end in ".conf"
# To view a list of supported event codes, use "thd --listevents" or
# "thd --dump /dev/input/event*"
# Format:
# <eventcode> <value> <command>
# values for key events are 1 (pressed), 0 (released) or 2 (held)
# Relay 1 = key 1 on , key 5 off
# Relay 2 = key 2 on , key 6 off
# Relay 3 = key 3 on , key 7 off
# Relay 4 = key 4 on , key 8 off
KEY_KP1 1 /bin/sh /root/
KEY_KP2 1 /bin/sh /root/
KEY_KP3 1 /bin/sh /root/
KEY_KP4 1 /bin/sh /root/
KEY_KP5 1 /bin/sh /root/
KEY_KP6 1 /bin/sh /root/
KEY_KP7 1 /bin/sh /root/
KEY_KP8 1 /bin/sh /root/
# switch off all 4 channels
KEY_NUMLOCK 1 /root/ ; /root/ ; /root/ ; /root/
# switch on all 4 channels
KEY_KPDOT 1 /root/ ; /root/ ; /root/ ; /root/

(Last edited by pilovis on 15 Sep 2016, 23:34)

hi pilovis !!
i'm studying about asterisk, could you tell me what  is your `xxxxxxxx extension` ?
i'm going to make simple IVR menu for DTMF control ! i'll record incomming call for sound files! can you help me?

(Last edited by phantnang on 21 Feb 2017, 17:38)

I tried baresip with a TP-Link TLWDR4300 and Chaos Calmer 15.05.1 (it really sucks!) and as usual something  doesn't work, baresip does phone calls, but blocks all incoming calls. sad

If you want to use baresip with Chaos Calmer you need to install (downgrade) the baresip version for Barried Breaker.

For ar71xx do the following:

opkg install --force-downgrade

opkg install --force-downgrade

opkg install --force-downgrade

opkg install --force-downgrade

opkg install --force-downgrade

opkg install --force-downgrade

opkg install --force-downgrade

(Last edited by pilovis on 2 Jun 2017, 05:04)

how to make a outgoing gsm call and monitor feedback (busy, answer, ignore..) with asterisk?

How-To enable the 2 FXS port on Huawei-HG553 (Vodafone Station 1) to be used with Asterisk 11

I finally managed to get the 2 FXS ports on this router working with Asterisk 11, without needing to compile anything big_smile.

You may find all files on my website (collected from … HG553-FXS/

Essentially you have to install this specific Firmware (Custom Chaos Calmer 15.05 release without Luci): … fs-cfe.bin

To access the router with telnet (no password required), configure your network card to and connect the ethernet cable to the port 1 of the router LAN (, port 4 is WAN (DHCP).

then you need to change the file "/etc/opkg/distfeeds.conf" as per the following:

src/gz chaos_calmer_base
src/gz chaos_calmer_telephony
src/gz chaos_calmer_packages
src/gz chaos_calmer_routing
src/gz chaos_calmer_luci
src/gz chaos_calmer_management
src/gz eko1

configure networking and internet access then opkg update and install "Asterisk 11" as usual (see the first post of this 3D),

finally install these specific packages you'll find on my website:


You also find my asterisk configuration files for FSX (/etc/asterisk)


Note: modify "extensions.conf" file to match your sip configurations.

you also need to add these lines in /etc/rc.local before the "exit 0" line:

/usr/sbin/insmod bcm63xx-phone
/bin/sleep 10
/etc/init.d/asterisk restart

Reboot and enjoy smile

References: (Great site! Thanks a lot for compiling all modules)

Note: asterisk11_chan_dongle does not work with this firmware!

(Last edited by pilovis on 15 Oct 2017, 23:32)

After the first enthusiasm, I've done some extensive testing on the bcm63xx-phone driver, the results are quite negative sad sad sad the audio is with a lot of crackling.

If you want to use this router (Huawei-HG553) with the two FXS ports and the ADSL internal Modem, forget about OpenWRT and use this custom firmware: …

To install this firmware turn on the system while holding the reset button for 30 sec,
connect via LAN with a manual setup of your workstation of etc. (no DHCP, no LAN LED on the box)
Browse to
Upload the .bin file (extracted from the downloaded file) to router
Wait for it to reboot (about two minutes).

Default user is admin, default password is admin, IP address is

The configuration manual of this firmware is here: … _v1.20.pdf

Note about this firmware:
Audio is perfect
ADSL modem works (ADSL2+)
3G USB dongle internet connection works (the Huawei dongle included with this router)
2 FXS ports work (SIP Voip client)
DTMF tones work with Asterisk
Regional PSTN tones work
WiFi g/n Access Point or Bridge mode
WiFi antenna diversity available
USB Samba Share available
USB Webcam sever available
USB Print Server available

(Last edited by pilovis on 17 Oct 2017, 15:55)

Let's relive the topic! PILOVIS, thanks for great job and info, it was helpful.

No solution on IAX and dongle incompatibility yet?  Point is if unload IAX timing module, IAX2 becomes unusable at all. Any news/solutions/suggestions?

(BB 14.07, Asterisk 11 + dongle)

Don't use Asterisk11 with Chaos Calmer 15.05.1 for ar71xx, the package is broken (as usual)
Use Barrier Breaker instead, the last reliable OpenWRT version, all the newer versions are full of problems.

(Last edited by pilovis on 19 Jan 2018, 16:06)

Asterisk 11 is also broken for BCM63xx, both Chaos Calmer and Lede 17
Barrier Breaker remains the last reliable OpenWRT version sad

Forget about Openwrt and use Raspberry instead wink

(Last edited by pilovis on 19 Jan 2018, 16:09)

In case you have an external overlay (USB) you can have bash instead of ash, so you can save your shell command history.

NOTE: don't do this without an external USB overlay to avoid the internal router flash memory wearing.


OpenWrt comes with Ash shell. If you would like to use Bash instead, here is how you can switch and add some nice colouring to it. Install Bash by issuing the following:
opkg update
opkg install bash

Then edit "/etc/passwd" file and change the root user line to this:


After that, run this command (which will create "/root/.bash_profile" file and put “. $HOME/.bashrc” in it):
echo ". $HOME/.bashrc" > /root/.bash_profile

Then you can either use your own .bashrc or download the one that I use (I got it from Arch wiki a few years ago) and put it in your root directory like this (if you would like to use your own .bashrc, make sure to put it in /root as well):
wget -P /root/

Now log out, and log in again and you should have a brand new prompt.

Extracted from: … tion-tips/

(Last edited by pilovis on 22 Jan 2018, 12:16)

@Pilovis do you still have files for hg553 as the link is not working

The discussion might have continued from here.