Piccolo How To su come inviare comandi tramite SMS ad server dove risiede Asterisk.
Ovviamente e' necessario aver installato chan_dongle (canale GSM con dongle Huawey).

Questo esempio si basa su Asterisk 13, ma dovrebbe andare bene anche per le versioni precedenti.

nano /etc/asterisk/extensions.conf

codice:
[from-dongle]

;
exten => sms,1,Noop(Incoming SMS from ${CALLERID(num)} ${BASE64_DECODE(${SMS_BASE64})}) 
exten => sms,n,System(echo 'From: ${CALLERID(num)} \n${BASE64_DECODE(${SMS_BASE64})}' >> /tmp/sms.txt)
exten => sms,n,Wait(3)
exten => sms,n,System(/bin/sh /root/getsms.sh)
exten => sms,n,Wait(15)
exten => sms,n,System(/bin/rm -f /tmp/sms.txt) 
exten => sms,n,Wait(2)
exten => sms,n,Hangup()


script da lanciare quando il SMS viene ricevuto:nano /root/getsms.sh

codice:
#!/bin/sh
#################################################
# GetSMS - script to check for commands 
#################################################

# Variables
folder=/www/sms                
dbsms=$folder/dbsms.txt         # SMS received database
newcmd=$folder/newcmd.txt       # new commands to be executed
dbcmd=$folder/dbcmd.txt         # executed commands database
now=$(date)                     # current date and time

# fill newcmd file with new commands received, if any
/bin/grep XX /tmp/sms.txt > $newcmd

# count the commands received, if any
numcmd=$(grep -c "^" $newcmd)

# if no commands are found, go ahed
if [ $numcmd -eq 0 ]
then
    exit 1
fi

# check for  any new command  
for ancmd in $(cat $newcmd)
do
    case $ancmd
    in
        XXon) /root/on.sh &    # if the body of the message contains "XXon", launch the on.sh script
        echo $ancmd >> $dbcmd;;

        XXoff) /root/off.sh &    # if the body of the message contains "XXoff", launch the off.sh script
        echo $ancmd >> $dbcmd;;

   
*) ;;
    esac
done

# add new sms to database file

/bin/cat /tmp/sms.txt >> $dbsms
echo -n '<p>' >> $dbsms

# wait 2 seconds
/bin/sleep 2

# empty newcmd file
> $newcmd


chmod 755 /root/getsms.sh

file di configurazione di chan_dongle

nano /etc/asterisk/dongle.conf

codice:
[general]

interval=15

[defaults]

context=from-dongle
group=1
rxgain=5
txgain=-3
autodeletesms=yes
resetdongle=yes
u2diag=-1
usecallingpres=yes
callingpres=allowed_passed_screen
disablesms=no
language=en
smsaspdu=yes
mindtmfgap=15
mindtmfduration=40
mindtmfinterval=200
callwaiting=auto
disable=no
initstate=start
exten=+39xxxxxxxxx # put your mobile number here
dtmf=relax

[dongle0]
audio=/dev/ttyUSB1
data=/dev/ttyUSB2
;imei=358109024359102
;imsi=222956701469191


In questo esempio i due comandi che sono configurati nello script sopra sono:

XXon and XXoff , XX is the prefix to recognize a command

XX rappresenta il prefisso (o password) per il riconoscimento del comando.

suggerisco di sostituire XX con qualcosa di piu' complesso per aumentare la scicurezza del sistema ed evitare che qualcuno possa inviare comandi al Vostro sistema, quindi i due comandi potrebbero essere ad esempio:
Sd543fgdsn-on e Sd543fgdsn-off, in questo caso il prefisso (password) e' Sd543fgdsn-