For manual management of module you can use the following commands in asterisk CLI:
module load chan_dongle.so
/path_to_asterisk_config/dongle.conf
module unload chan_dongle.so
module reload chan_dongle.so
chan_dongle provides the following CLI commands:
dongle cmd <device> <at_command>
dongle stop gracefully <device>
dongle stop now <device>
dongle stop when convenient <device>
dongle show device settings <device>
dongle show device state <device>
dongle show device statistics <device>
dongle show devices
dongle show version
dongle sms <device> <number> <message>
dongle pdu <device> <pdu>
dongle ussd <device> <ussd>
dongle start <device>
dongle restart gracefully <device>
dongle restart now <device>
dongle restart when convenient <device>
dongle remove gracefully <device>
dongle remove now <device>
dongle remove when convenient <device>
dongle reload gracefully
dongle reload now
dongle reload when convenient
The following applications are provided by chan_dongle:
The following functions are provided by chan_dongle:
CHANNEL(callstate)
when reading may has values
for example, you can separate incoming calls from waiting:
[dongle-incoming] exten => s,1,GotoIf($["${CHANNEL(callstate)}" = "waiting"]?waiting-call)
Also, you can assign to this functions too, but this useful only when callstate changed from 'held' to 'active' and mean put on held other calls on this device and activate call linked with current asterisk channel. For example
exten => s,n,Set(CHANNEL(callstate)=active)
But remember that putting on hold GSM calls, does not cause termination or freeze dialplan execution for linked asterisk channels.
For each asterisk's channel created by chan_dongle (both incoming and outgoing legs) next channel variables are set
name of device name
same as 'Provider Name' column of 'dongle show devices' CLI command
same as 'IMEI' column of 'dongle show devices' CLI command
same as 'IMSI' column of 'dongle show devices' CLI command
same as 'Number' column of 'dongle show devices' CLI command
For 'ussd' extension of incoming context next channel variables are set
numberic type of USSD Response from 0 till 5
textual type of USSD Response one from 'USSD Notify', 'USSD Request', 'USSD Terminated by network', 'Other local client has responded', 'Operation not supported', 'Network time out'
Content of USSD Response
Content of USSD Response encoded to Base64, useful when USSD is multiline
For 'sms' extension of incoming context next channel variables are set
Content of SMS
Content of SMS encoded to Base64, useful when SMS is multiline
Raw CMGR response from dongle
Type Of Address of SMS originator see also ${CALLERID(num)}
On incoming call, chan_dongle tries to find matching exten in defined context (see dongle.conf). There is 3 different exten to search, in the following order:
exten
in dongle.conf
s
extenTo save Subscriber Number, you can write an entry for OWN NUMBERS storage on SIM. For example, in asterisk CLI
dongle cmd dongle0 AT+CPBS=\"ON\" dongle cmd dongle0 AT+CPBW=1,\"+79139131234\",145
After restarting dongle0, incoming calls will start dialplan from exten
exten => +79139131234,1,Noop()
also variable CALLERID(dnid)
will be set to +79139131234
If subscriber number is unknown, then you can set this in in dongle.conf
exten = +79139131234
If subscriber number is unknown and there is no exten
entry in dongle.conf
, then s
exten will be used as starting point in dialpan.
You can handle received SMS and USSD using sms
and ussd
exten, respectively.
Example for received sms
[dongle-incoming-sms] exten => sms,1,Noop(Incoming SMS from ${CALLERID(num)} ${BASE64_DECODE(${SMS_BASE64})}) exten => sms,n,System(echo '${STRFTIME(${EPOCH},,%Y-%m-%d %H:%M:%S)} - ${DONGLENAME} - ${CALLERID(num)}: ${BASE64_DECODE(${SMS_BASE64})}' >> /var/log/asterisk/sms.txt) exten => sms,n,Hangup()
Example for received USSD
[dongle-incoming-ussd] exten => ussd,1,Noop(Incoming USSD: ${BASE64_DECODE(${USSD_BASE64})}) exten => ussd,n,System(echo '${STRFTIME(${EPOCH},,%Y-%m-%d %H:%M:%S)} - ${DONGLENAME}: ${BASE64_DECODE(${USSD_BASE64})}' >> /var/log/asterisk/ussd.txt) exten => ussd,n,Hangup()
Also note, execution of this exten takes place in a “Local” channel.
Always define sms
and ussd
extens for context where you handle incoming calls for dongle device!
Otherwise, incoming SMS or USSD can execute extensions for voice call with unpredictable results.
[dongle-incoming] include => dongle-incoming-sms include => dongle-incoming-ussd
Also note that h
exten is executed for SMS/USSD just before Local channel is destroyed.
Chan_dongle can provide the following manager commands:
Chan_dongle generates the following manager events:
You can send AT commands to any modem using
CLI>dongle cmd <device> <AT_command>
Some useful AT commands:
AT command | Description |
---|---|
AT+CCWA=0,0,1 | disable call-waiting |
AT+CFUN=1,1 | reboot modem |
AT^CARDLOCK=“<code>” | send unlock code |
AT^SYSCFG=13,0,3FFFFFFF,0,3 | modem 2G only, automatic search any band, no roaming |
AT^SYSCFG=2,0,3FFFFFFF,2,4 | Any |
AT^SYSCFG=13,1,3FFFFFFF,2,4 | 2G only |
AT^SYSCFG=14,2,3FFFFFFF,2,4 | 3G only |
AT^SYSCFG=2,1,3FFFFFFF,2,4 | 2G preferred |
AT^SYSCFG=2,2,3FFFFFFF,2,4 | 3G preferred |
AT^U2DIAG=0 | enable modem function only |
ATI | get relevant information from modem |
ATZ | reset modem configuration |
AT+CIMI | read IMSI |
AT+CLCK=“SC”,0,“<pin>” | disable PIN verification |