[how to] Openwrt + Asterisk 11 + GSM/SMS channel chan_dongle

sezione dedicata ai sistemi operativi alternativi Open Source

Important note on Netgear DGND3700V1 & Barrier Breaker

Messaggio da leggereda root » 15/09/2016, 22:00

Important note on Netgear DGND3700V1 and Barrier Breaker.

This router with its custom OpenWRT Barrier Breaker firmware has a very bad problem: during a reboot, invoked by a program or by the reboot command, the router may hangs forever, unfortunately it happens quite often and the only way to recover it, it is to do a power cycle.
The problem occurs during the shutdown process, just before the reboot, it seems that some process cannot be stopped correctly.

To avoid this problem during reboot cycle, you might use the following command to do an hard_reboot of the router:

/bin/echo b > /proc/sysrq-trigger

this is pretty much the same as pressing the reset button on a PC, no daemons will be shut down gracefully, no filesystem sync will occur (but we don't need it).

So, don't use anymore the "reboot" command (busybox) on this router, also disable watchcat and zram:
/etc/init.d/watchcat disable
/etc/init.d/zram disable
Maurizio
Avatar utente
root
Amministratore
 
Messaggi: 349
Iscritto il: 10/04/2012, 10:55
Località: Ovada

Re: [how to] Openwrt + Asterisk 11 + GSM/SMS channel chan_do

Messaggio da leggereda root » 15/09/2016, 22:01

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


;; Home Automation Box - 4 channels relay board
;; Asterisk 11 & OpenWRT
;; By pilovis - parknat12@yahoo.com
;
; put this code in "/etc/asterisk/extensions.conf" under [default]
;
;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 sounds (.gsm) for:
;"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
;
exten => xxxxxxxxxx,1,NoOp(${CALLERID})
exten => xxxxxxxxxx,n,Answer()
exten => xxxxxxxxxx,n,Ringing
exten => xxxxxxxxxx,n,Set(TIMEOUT(digit)=7)
exten => xxxxxxxxxx,n,Set(TIMEOUT(response)=21)
exten => xxxxxxxxxx,n,Authenticate(1234,,4)
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)

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


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 it on "/etc/rc.local")

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
Maurizio
Avatar utente
root
Amministratore
 
Messaggi: 349
Iscritto il: 10/04/2012, 10:55
Località: Ovada

Precedente

Torna a OpenWRT e sistemi operativi vari

Chi c’è in linea

Visitano il forum: Nessuno e 1 ospite

cron