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 https://forum.openwrt.org/viewtopic.php?id=53874
;; By pilovis - parknat12@yahoo.com
;
; 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:
;"1,2,3,4,5,6,7,8,agent-pass,auth-incorrect,auth-thankyou,activated,de-activated,vm-goodbye"
; 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/on1.sh &)
exten => 1,3,Wait(2)
exten => 1,4,Hangup()
;;
exten => 2,1,Playback(2&activated)
exten => 2,2,System(/root/on2.sh &)
exten => 2,3,Wait(2)
exten => 2,4,Hangup()
;;
exten => 3,1,Playback(3&activated)
exten => 3,2,System(/root/on3.sh &)
exten => 3,3,Wait(2)
exten => 3,4,Hangup()
;;
exten => 4,1,Playback(4&activated)
exten => 4,2,System(/root/on4.sh &)
exten => 4,3,Wait(2)
exten => 4,4,Hangup()
;;
exten => 5,1,Playback(1&de-activated)
exten => 5,2,System(/root/off1.sh &)
exten => 5,3,Wait(2)
exten => 5,4,Hangup()
;;
exten => 6,1,Playback(2&de-activated)
exten => 6,2,System(/root/off2.sh &)
exten => 6,3,Wait(2)
exten => 6,4,Hangup()
;;
exten => 7,1,Playback(3&de-activated)
exten => 7,2,System(/root/off3.sh &)
exten => 7,3,Wait(2)
exten => 7,4,Hangup()
;;
exten => 8,1,Playback(4&de-activated)
exten => 8,2,System(/root/off4.sh &)
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)

/root/on1.sh

#!/bin/sh
# 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

/root/off1.sh

#!/bin/sh
# 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/extract_and_restore-status-relay1.sh" in "/etc/rc.local" right before the "exit 0" line)

/root/extract_and_restore-status-relay1.sh

#!/bin/sh
# extract and restore status of relay1
#
while IFS=: read relay1
do
/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/on1.sh
KEY_KP2 1 /bin/sh /root/on2.sh
KEY_KP3 1 /bin/sh /root/on3.sh
KEY_KP4 1 /bin/sh /root/on4.sh
KEY_KP5 1 /bin/sh /root/off1.sh
KEY_KP6 1 /bin/sh /root/off2.sh
KEY_KP7 1 /bin/sh /root/off3.sh
KEY_KP8 1 /bin/sh /root/off4.sh
# switch off all 4 channels
KEY_NUMLOCK 1 /root/off1.sh ; /root/off2.sh ; /root/off3.sh ; /root/off4.sh
# switch on all 4 channels
KEY_KPDOT 1 /root/on1.sh ; /root/on2.sh ; /root/on3.sh ; /root/on4.sh

(Last edited by pilovis on 15 Sep 2016, 21: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, 16: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 http://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/packages/telephony/baresip_0.4.11-3_ar71xx.ipk

opkg install --force-downgrade http://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/packages/telephony/baresip-mod-g711_0.4.11-3_ar71xx.ipk

opkg install --force-downgrade http://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/packages/telephony/baresip-mod-evdev_0.4.11-3_ar71xx.ipk

opkg install --force-downgrade http://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/packages/telephony/baresip-mod-alsa_0.4.11-3_ar71xx.ipk

opkg install --force-downgrade http://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/packages/telephony/baresip-mod-cons_0.4.11-3_ar71xx.ipk

opkg install --force-downgrade http://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/packages/telephony/baresip-mod-stdio_0.4.11-3_ar71xx.ipk

opkg install --force-downgrade http://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/packages/telephony/baresip-mod-uuid_0.4.11-3_ar71xx.ipk

(Last edited by pilovis on 2 Jun 2017, 03: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 dl.eko.one.pl):
http://www.lovisolo.com/asterisk/softwa … HG553-FXS/

Essentially you have to install this specific Firmware (Custom Chaos Calmer 15.05 release without Luci):
http://www.lovisolo.com/asterisk/softwa … fs-cfe.bin

To access the router with telnet (no password required), configure your network card to 192.168.1.2 and connect the ethernet cable to the port 1 of the router LAN (192.168.1.1), 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 http://downloads.openwrt.org/chaos_calmer/15.05/brcm63xx/generic/packages/base
src/gz chaos_calmer_telephony http://downloads.openwrt.org/chaos_calmer/15.05/brcm63xx/generic/packages/telephony
src/gz chaos_calmer_packages http://downloads.openwrt.org/chaos_calmer/15.05/brcm63xx/generic/packages/packages
src/gz chaos_calmer_routing http://downloads.openwrt.org/chaos_calmer/15.05/brcm63xx/generic/packages/routing
src/gz chaos_calmer_luci http://downloads.openwrt.org/chaos_calmer/15.05/brcm63xx/generic/packages/luci
src/gz chaos_calmer_management http://downloads.openwrt.org/chaos_calmer/15.05/brcm63xx/generic/packages/management
src/gz eko1 http://dl.eko.one.pl/chaos_calmer/brcm63xx/packages

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:

bcm63xx-phone-test_3.18.45-3.18.45_brcm63xx.ipk    
kmod-bcm63xx-phone_3.18.45+0.1-1_brcm63xx.ipk
asterisk11-codec-a-mu_11.22.0-1_brcm63xx.ipk    
asterisk11-codec-alaw_11.22.0-1_brcm63xx.ipk    
asterisk11-format-sln_11.22.0-1_brcm63xx.ipk   
asterisk11-res-musiconhold_11.22.0-1_brcm63xx.ipk   
asterisk11_11.22.0-1_brcm63xx.ipk   
asterisk11-chan-bcm63xx-phone_3.18.45-3.18.45_brcm63xx.ipk

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

extensions.conf
modules.conf
bcm63xx_phone.conf

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:

https://github.com/pgid69/bcm63xx-phone
http://dl.eko.one.pl (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, 21: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:
http://wiki.perugiagnulug.org/images/8/ … 508_VS.zip

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 192.168.1.2 etc. (no DHCP, no LAN LED on the box)
Browse to http://192.168.1.1
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 192.168.1.1

The configuration manual of this firmware is here:
http://wiki.perugiagnulug.org/images/c/ … _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, 13: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, 15: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, 15: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:

root:x:0:0:root:/root:/bin/bash

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/ http://cmikavac.net/download/.bashrc

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


Extracted from: http://cmikavac.net/2012/06/03/tp-link- … tion-tips/

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

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

The discussion might have continued from here.