Upload
mangatono
View
2.952
Download
22
Embed Size (px)
DESCRIPTION
Huawei 3G USB Modem and Asterisk
Citation preview
6th September 2011
Introduction
chan_dongle is an Asterisk channel driver for Huawei UMTS/3G USB modems
(dongles). At this moment, the supported features are:
Voice calls, dialling by modem name, group, round robin, provider name, IMEI or
IMSI.
Call waiting
Call holding
Conference (multiparty) call
Send SMS from CLI, asterisk manager and dialplan
Receive SMS (latin charset and multiline included)
Send USSD
Receive USSD (latin charset and multiline included)
Send DTMF (excluding A,B,C,D letters not supported by Huawei)
Receive DTMF
------------------------------------------------------------------------------------------------
List of Supported Models
At this moment, only Huawei models are supported. ZTE is on the road…
Note: Some users report bad voice quality using Centos 5 (i.e. Elastix). So, please,
be careful with old kernels (i.e. 2.6.18)
Huawei
Device Model Voice SMS USSD Note
E150 - ? ? One way voice 1)
E153 + ? ?
E1550 + + +
E1552 + + +
E156 ? ? ? test required
E160 ? ? ? test required
E1612 - + +
E166 ? ? ? test required
E169 + + +
E1692 + + +
E169G - ? ? test required
E171 + ? +
E172 - ? ? test required
E173 + + - 2)
E175X + + +
E1752C + + + Several interfaces 3)
E178 ? ? ? test required
E180 + + + ok by ramoncio
E220 - + +
FAQ for Huawei 3G USB modemand Asterisk
E270 - + +
EG162G ? ? ? test required
K3520 + + +
K3565 - - - zte model?
K3715 + + +
K3765 + + + Same model as E1762
USB 2.0
For voice call feature, it's highly recommended the use of USB version 2.0
Power specs and USB hubs
According to vendor specs, most usb modems have:
5V/500mA → 2.5 W
Almost every computer has USB ports where you can plug devices such as pen
drives, bluetooth dongles, portable hard disks, etc. 3G modems can also be
plugged, but power source may be a serious limitation. If your computer has
several USB ports, you must check it can deliver all the power needed for your
devices at the same time.
Normally, USB ports can deliver only 500 mA, so if you have more than one modem
(or other hungry devices) plugged, it's possible you get stuck with strange
problems.
Also, USB hubs can be a source of problems if you connect more than one 3G
modem. 500 mA is not enough current for 2 or more dongles. In this case, external
powered USB hub is recommended to avoid strange behavior, but be very careful
with this, not any model is ok for this task. Some of them have serious problems
with RF interferences from GSM side, making impossible to use chan_dongle.
Please, check list of compatible USB hubs
1) See one way audio e150
2) May be cusd_use_7bit_encoding get correct USSD
3) Depending on value for at u2diag, this modem show 3 or 4 interfaces
------------------------------------------------------------------------------------------------
How to unlock Huawei modems?
Modems are often bought from mobile operators and maybe have lock to prevent
using SIM cards from other operators.
If you do not plan to use SIM cards from other operators, skip this section.
You have different ways to unlock:
Unlock code using free calculators, help from people on other forums or buy code
online.
Once you have the code, enter to modem manually with programs like putty,
Once you have the code, enter to modem manually with programs like putty,
terminal or minicom and use AT CARDLOCK=”< code >” command
Using tools like dc-unlocker or other similar tool
Unlock tools: Huawei unlock
Free Calculators:
Huawei codes
ZTE codes
Update firmware
The main source of firmware files are in dc-files. You can browse for your model
and download firmware update (normally zip containing .exe file). For update, need
windows computer (xp, vista or w7). The process is very straightforward, only
execute exe file and follow indications.
Some models need unlock code to flash firmware. You can use unlock huawei tools
for that.
After upgrade process, run dc-unlocker client to check if voice is enabled.
How to activate voice on Huawei modems?
There is a lot of different models from Huawei vendor. Primarly, they are used for
data connection to internet, but some of them are voice capable. This means, that
you can make calls with the right software. Some telcos include this piece of
software, but, in any case, you can use Mobile Partner for that purpose in Windows
systems. Only need to upgrade firmware and install tool.
To know if your dongle supports voice, you can use two methods:
Dc-Unlocker software
Download latest version (only for windows) and check if your modem is voice
capable or not. If supported, you can pay some money and activate automatically.
Find DDSETEX and CVOICE chains
Go to http://www.dc-files.com and download any stable firmware for your model.
Firmware is .exe file, so you must edit (use any text editor like notepad or nano)
and look for DDSETEX and CVOICE chains. If found, that means your modem is
voice capable. The final step is to check if voice is enabled. A good solution is to
use dc-unlocker client for that purpose.
Models k3520, e169, k3765 and k3715 have voice enabled if you upgrade
firmware. E1750 needs dc-unlocker voice activation.
------------------------------------------------------------------------------------------------
Installation
Chan_dongle runs only in asterisk 1.6.2 and asterisk 1.8. Asterisk 1.4 is not
supported.
Asterisk Installation
There is a lot of very good howto's explaining Asterisk installation. Take a look at
this brief summary (Debian), but you can take a look at 1, 2 or 3 (in spanish).
Note that we don't need Dahdi channel to run chan_dongle, so it can be avoided.
Prerequisites
Be careful with iptables and selinux. If needed, edit /etc/selinux/config and write:
SELINUX=disabled
SELINUXTYPE=targeted
Then, disable iptables
iptables -F
iptables-save > /etc/iptables.up.rules
or configure it to allow SIP (port 5060) and RTP (port 10000-20000) if you plan to
use these protocols.
Now upgrade your system
apt-get update
apt-get upgrade
And install packages needed for compilation of asterisk
apt-get install linux-headers-`uname -r` gcc g++ make libnewt-dev libncurses5-dev
openssl libssl-dev zlib1g-dev
Asterisk Installation
Download source files and untar. Asterisk 1.6 is explained, but 1.8 looks similar.
wget http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-
1.6.2.13.tar.gz
tar zxvf asterisk-1.6.2.13.tar.gz
If you will use FreePBX, then install asterisk-addons
wget http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-
addons-1.6.2.2.tar.gz
tar zxvf asterisk-addons-1.6.2.2.tar.gz
Now compile
cd asterisk-1.6.2.13
make clean && ./configure --disable-xmldocs && make && make install && make
config
If needed
make samples
Install chan_dongle
Obtain source code
If you installed asterisk as described here, go ahead. Anyway, check some
dependencies like automake and autoconf. Also must have asterisk sources and
development tools like make, gcc and so on.
SVN Method
svn checkout http://asterisk-chan-dongle.googlecode.com/svn/trunk/ dongle-read-
only
cd dongle-read-only
autoconf && automake -a
Compressed package
Go to http://code.google.com/p/asterisk-chan-dongle/downloads/list and download
.tgz package, then
tar -zxvf chan_donle_%VERSION.r%REVISION.tgz
cd chan_donle_%VERSION.r%REVISION
Set Build options
configure options:
--enable-debug
--disable-debug
--enable-manager
--disable-manager
--enable-apps
--disable-apps
--with-asterisk=/path_to_source/asterisk.h
usefull environment variables
DESTDIR
CFLAGS
LDFLAGS
Examples
DESTDIR=”/usr/lib/asterisk/modules” ./configure
./configure –with-asterisk=/usr/src/asterisk-1.6.2.13/include
CFLAGS=”-I /usr/src/asterisk-1.6.2.13/include” ./configure
./configure --enable-debug
./configure --disable-apps --disable-manager
CFLAGS=”-O0 -g” ./configure
CFLAGS=”-Os” ./configure
default is
./configure --disable-debug --enable-apps --enable-manager
DESTDIR searching in /usr/lib/asterisk/modules /usr/local/lib/asterisk/modules
/opt/local/lib/asterisk/modules
and
and
asterisk.h searching in ../include /usr/include /usr/local/include /opt/local/include
Building
For compile and build source to module
make
Installation
For install property configured and build module:
sudo make install
Module Configuration
Once installed, copy example file dongle-read-only/etc/dongle.conf to
/path_to_asterisk_config/ (i.e. /etc/asterisk/). Configure it as desired and start
asterisk. To load, stop or restart chan_dongle:
CLI>module load chan_dongle.so
CLI>module unload chan_dongle.so
CLI>module reload chan_dongle.so
------------------------------------------------------------------------------------------------
chan_dongle configuration
All the information needed by chan_dongle is stored in
/path_to_asterisk_config/dongle.conf.
dongle.conf
[general]
interval=15 ; Number of seconds between trying to connect to devices
;------------------------------ JITTER BUFFER CONFIGURATION --------------------------
;jbenable = yes ; Enables the use of a jitterbuffer on the receiving side of a
; Dongle channel. Defaults to "no". An enabled jitterbuffer will
; be used only if the sending side can create and the receiving
; side can not accept jitter. The Dongle channel can't accept jitter,
; thus an enabled jitterbuffer on the receive Dongle side will always
; be used if the sending side can create jitter.
;jbforce = no ; Forces the use of a jitterbuffer on the receive side of a Dongle
; channel. Defaults to "no".
;jbmaxsize = 200 ; Max length of the jitterbuffer in milliseconds.
;jbresyncthreshold = 1000 ; Jump in the frame timestamps over which the
;jbresyncthreshold = 1000 ; Jump in the frame timestamps over which the
jitterbuffer is
; resynchronized. Useful to improve the quality of the voice, with
; big jumps in/broken timestamps, usually sent from exotic devices
; and programs. Defaults to 1000.
;jbimpl = fixed ; Jitterbuffer implementation, used on the receiving side of a Dongle
; channel. Two implementations are currently available - "fixed"
; (with size always equals to jbmaxsize) and "adaptive" (with
; variable size, actually the new jb of IAX2). Defaults to fixed.
;jbtargetextra = 40 ; This option only affects the jb when 'jbimpl = adaptive' is set.
; The option represents the number of milliseconds by which the new jitter buffer
; will pad its size. the default is 40, so without modification, the new
; jitter buffer will set its size to the jitter value plus 40 milliseconds.
; increasing this value may help if your network normally has low jitter,
; but occasionally has spikes.
;jblog = no ; Enables jitterbuffer frame logging. Defaults to "no".
;-----------------------------------------------------------------------------------
[defaults]
; now you can set here any not required device settings as template
; sure you can overwrite in any [device] section this default values
context=default ; context for incoming calls, SMS and USSD
group=0 ; calling group
rxgain=0 ; increase the incoming volume; may be negative
txgain=0 ; increase the outgoint volume; may be negative
autodeletesms=yes ; auto delete incoming sms
resetdongle=yes ; reset dongle during initialization with ATZ command
u2diag=-1 ; set U2DIAG parameter on device (0 = disable everything except
modem function)
; -1 not use U2DIAG command
usecallingpres=yes ; use the caller ID presentation or not
callingpres=allowed_passed_screen ; set caller ID presentation. By default use
default network settings
; see http://www.the-asterisk-book.com/unstable/applikationen-setcallerpres.html
disablesms=no ; disable of SMS reading from device when received. Enable this
option to disable
; sms reception. Use smsaspdu=yes to avoid problem when SMS is too long in
TEXT mode.
smsaspdu=yes ; if 'yes' send SMS in PDU mode.
language=en ; set channel default language
mindtmfgap=45 ; minimal interval from end of previews DTMF from begining of next
in ms
mindtmfduration=80 ; minimal DTMF tone duration in ms
mindtmfinterval=200 ; minimal interval between ends of DTMF of same digits in ms
callwaiting=auto ; if 'yes' allow incoming calls waiting; by default use network
settings
settings
; if 'no' waiting calls just ignored
disable=no ; if 'yes' no load this device and just ignore this section
exten=+1234567890 ; exten for start incoming calls, only in case of Subscriber
Number not available!,
; also set to CALLERID(dnid)
dtmf=relax ; control of incoming DTMF detection, possible values:
; off - off DTMF tone detection, voice data passed to asterisk unaltered
; use this value for gateways or if you do not use IVR in diaplan
; inband - do DTMF tones detection
; relax - like inband but with relaxdtmf option
; default is 'relax' for backward compatibility
; dongle required settings
[dongle0]
audio=/dev/ttyUSB1 ; tty port for audio connection;
data=/dev/ttyUSB2 ; tty port for AT commands;
; or you can omit both audio and data parameters and use imei=123456789012345
and/or imsi=612849384756451
; imei and imsi must contain exactly 15 digits !
; imei/imsi discovery is available on Linux only
imei=123456789012345
imsi=612849384756451
; if you set audio and data parameter together with imei and/or imsi, audio and data
is used.
; you can use both imei and imsi together. In this case exact match by imei and imsi
is required.
Dialplan examples
extensions.conf
; this is chunks of Asterisk extensions.conf file for show some chan_dongle features
[general]
[dongle-incoming]
; example of ussd receive
exten => ussd,1,Set(type=${USSD_TYPE})
; values from 0 till 5
; 0 - USSD Notify
; 1 - USSD Request
; 2 - USSD Terminated by network
; 3 - Other local client has responded
; 4 - Operation not supported
; 5 - Network time out
; 5 - Network time out
exten => ussd,n,Set(typestr=${USSD_TYPE_STR})
; type in string, see above
exten => ussd,n,Set(ussd=${USSD})
; USSD text, but may be truncated by first \n
exten => ussd,n,Set(ussd_multiline=${BASE64_DECODE(${USSD_BASE64})})
; USSD text, may be multiline
; Note: this exten run in Local channel not attached to anything, also all
CALLERID() is empty
; example of sms receive
exten => sms,1,Set(sms=${SMS})
; SMS text, but may be truncated by first \n
exten => sms,1,Set(sms_multiline=${BASE64_DECODE(${SMS_BASE64})})
; SMS text, may be multiline
; Note: this exten run in Local channel not attached to anything, also
CALLERID(num) is address of SMS originator
; example of begining context execution from not default exten
exten => +12345678901,1,Verbose(This exten executed if Subscriber Number is
available and equal +12345678901 or exten setting value is +12345678901)
; example of channel variables setting by chan_dongle
exten => s,1,Set(NAME_OF_DEVICE=${DONGLENAME})
; for example 'dongle0' or 'dongle1' see dongle.conf
exten => s,n,Set(NAME_OF_PROVIDE=${DONGLEPROVIDER})
; for example see output of cli 'dongle show devices' column "Provider Name"
exten => s,n,Set(IMEI_OF_DEVICE=${DONGLEIMEI})
; for example see output of cli 'dongle show devices' column "IMEI"
exten => s,n,Set(IMSI_OF_SIMCARD=${DONGLEIMSI})
; for example see output of cli 'dongle show devices' column "IMSI"
exten => s,n,Set(CNUM_NUMBER=${DONGLENUMBER})
; Subscriber Number example see output of cli 'dongle show devices' column
"Number"
; may be empty, use for save in SIM commands AT+CPBS="ON" and
AT+CPBW=1,"+123456789",145
exten => s,n,Set(CNUM_NUMBER=${CALLERID(dnid)})
; Set to Subscriber Number if available
; Set to Subscriber Number if available
; applications of chan_DONGLE
exten => s,n,DongleStatus(dongle0,DONGLE0_STATUS)
; get status of device and store result in variable
; possible values of ${DONGLE0_STATUS}
; -1 invalid argument
; 1 device not found
; 2 device connected
; 3 device connected and in use
exten => s,n,DongleSendSMS(dongle0, "+18004005422", Hello how are you,
Danila?, 1440, yes)
; send SMS on selected device and to specified number
; device name of Dongle device
; destination number in International format with leading '+' or w/o leading '+'
; message maximum 70 UCS-2 symbols
; validity period in minutes, will be round up to nearest possible value, optional
default is 3 days
; report request if true report for this SMS is required, optional default is not
; functions of chan_dongle
exten => s,n,GotoIf($["${CHANNEL(callstate)}" == "waiting"]?waiting-call)
; now we provide channel function argument callstate
; possible values
; active ; enjoy and speek
; held ; this call is held
; dialing ; for outgoing calls
; alerting ; for outgoing calls, number dialed and called party ringing
; incoming ; for incoming calls
; waiting ; for incoming waiting calls;
; if callwaiting=no channels for waiting calls never created
; initialize ; never appear
; released ; never appear
; Answer on waiting call activate this call and place any other active calls
; on hold, but execution of dialplan for these calls not break stopped or frozen
; When active call terminated one of held becomes active.
exten => s,n,Set(CHANNEL(callstate)=active)
; if callstate is 'held' you can assign new value 'active'
; its mean activate this call and place on hold all other active calls but
; execution of dialplan for these calls not break stopped or frozen
exten => s,n,Dial(Dongle/g1/holdother:+79139131234)
exten => s,n,Dial(Dongle/g1/holdother:+79139131234)
exten => s,n,Dial(Dongle/r1/holdother:+79139131234)
exten => s,n,Dial(Dongle/p:PROVIDER NAME/holdother:+79139131234)
exten => s,n,Dial(Dongle/i:123456789012345/holdother:+79139131234)
exten => s,n,Dial(Dongle/s:25099/holdother:+79139131234)
; now we add option 'holdother' for dialing
; this option do
; 1) When looking for available devices by group, provider IMEI,
; IMSI prefix not ignore devices with whose state does not
; prohibit a new outgoing call when other call place on hold
;
; 2) Before actual dialing place active calls on hold
; but execution of dialplan for these calls not break stopped or frozen
; 3) This call will be active if succesfully answered
; BUG !!!
; tested for call waiting and hold features Huawei E1550 has a next bug:
; When local side hangup any call including held call ALL other calls LOST sound
; When remove side hangup active call ALL other calls LOST sound
; Please double check true this for you or not
; If true reduce usage of this useful features
exten => s,n,Dial(Dongle/g1/conference:+79139131234)
exten => s,n,Dial(Dongle/r1/conference:+79139131234)
exten => s,n,Dial(Dongle/p:PROVIDER NAME/conference:+79139131234)
exten => s,n,Dial(Dongle/i:123456789012345/conference:+79139131234)
exten => s,n,Dial(Dongle/s:25099/conference:+79139131234)
; and also option 'conference' added
; this option do
; 1) When looking for available devices by group, provider IMEI,
; IMSI prefix not ignore devices with whose state does not
; prohibit a new outgoing call when other call place on hold
;
; 2) Before actual dialing place active calls on hold
; but execution of dialplan for these calls not break stopped or frozen
; 3) If answered attach hold calls to conrefence (in term of GSM)
; Also if created outgoing channel place call on same device that incoming channel
; both incoming and outgoing channels become readonly to avoid the voice loop.
;
; see also BUG !!! note above
------------------------------------------------------------------------------------------------
Usage of chan_dongle
Module management in Asterisk
For manual management of module you can use the following commands in
asterisk CLI:
module load chan_dongle.so
module load chan_dongle.so
Load module into Asterisk. Config is read from
/path_to_asterisk_config/dongle.conf
module unload chan_dongle.so
Unload module from Asterisk. All modems are de-attached
module reload chan_dongle.so
Reload configuration from config file. If any change is done since last load, then it
will be applied now. It is exactly that dongle reload gracefully
chan_dongle CLI commands
chan_dongle provides the following CLI commands:
dongle cmd
Send to the rfcomm port on the device with the specified
dongle reset
Send reboot command to modem AT+CFUN=1,1
dongle stop gracefully
Stop gracefully. Prevents new incoming and outgoing calls and SMS and outgoing
USSD from starting up, but allows calls/SMS/USSD in progress to continue. When
all the calls/SMS/USSD have finished, stops
dongle stop now
Stop now. Stops immediately, ending any calls/SMS/USSD in progress
dongle stop when convenient
Stop when convenient. Waits until has no calls/SMS/USSD in progress, and then it
stops . It does not prevent new calls/SMS/USSD from entering the .
dongle show device settings
Shows settings for
dongle show device state
Shows detailed state for
dongle show device statistics
Shows statistics for
dongle show devices
Shows summarized state for all devices
dongle show version
Show module version
dongle sms
Send SMS to with the using
dongle pdu
Send PDU using
dongle ussd
Send USSD command using
dongle start
Start if not removed from before.
dongle restart gracefully
Prevents new incoming and outgoing calls and SMS and outgoing USSD from
starting up in , but allows calls/SMS/USSD in progress to continue. When
call/SMS/USSD has finished, restarts. Restart mean first stop device and second
reopen and initialize.
dongle restart now
Restarts immediately, ending any calls/SMS/USSD in progress.
dongle restart when convenient
dongle restart when convenient
Waits until has no calls/SMS/USSD in progress, and then it restarts . It does not
prevent new calls/SMS/USSD from entering the .
dongle remove gracefully
Prevents new incoming and outgoing calls and SMS and outgoing USSD from
starting up in , but allows calls/SMS/USSD in progress to continue. When
call/SMS/USSD has finished, stopping and removed from module.
dongle remove now
Remove from Asterisk immediately.
dongle remove when convenient
Waits until has no calls/SMS/USSD in progress and then remove . It does not
prevent new calls/SMS/USSD from entering the .
dongle reload gracefully
Reloads the chan_dongle configuration gracefully
dongle reload now
Reloads the chan_dongle configuration now
dongle reload when convenient
Reloads the chan_dongle configuration when convenient. BUG: complete removed
devices from dongle.conf not removed from module after reload. Use disable=yes
as workaround.
Dialplan applications
The following applications are provided by chan_dongle:
DongleStatus(, )
DongleSendSMS(, [,Message [, Validity [, Report]]])
Dialplan function
The following functions are provided by chan_dongle:
CHANNEL(callstate)
when reading may has values
active
held
dialing
alerting
incoming
waiting
initialize
released
unknown
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)
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.
Channel variables
For each asterisk's channel created by chan_dongle (both incoming and outgoing
legs) next channel variables are set
DONGLENAME
name of device name
DONGLEPROVIDER
same as 'Provider Name' column of 'dongle show devices' CLI command
DONGLEIMEI
same as 'IMEI' column of 'dongle show devices' CLI command
DONGLEIMSI
same as 'IMSI' column of 'dongle show devices' CLI command
DONGLENUMBER
same as 'Number' column of 'dongle show devices' CLI command
For 'ussd' extension of incoming context next channel variables are set
USSD_TYPE
numberic type of USSD Response from 0 till 5
USSD_TYPE_STR
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'
USSD
Content of USSD Response
USSD_BASE64
Content of USSD Response encoded to Base64, useful when USSD is multiline
For 'sms' extension of incoming context next channel variables are set
SMS
Content of SMS
SMS_BASE64
Content of SMS encoded to Base64, useful when SMS is multiline
CMGR
Raw CMGR response from dongle
TOA
Type Of Address of SMS originator see also ${CALLERID(num)}
Incoming calls
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:
Subscriber Number stored in SIM.
Number defined in variable exten in dongle.conf
s exten
To 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.
Receive SMS and USSD
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.
Manager commands
Chan_dongle can provide the following manager commands:
DongleShowDevices
DongleSendUSSD
DongleSendSMS
DongleSendPDU
DongleSetCCWA
DongleReset
DongleRestart
DongleStop
DongleStart
DongleRemove
DongleReload
Manager Events
Chan_dongle generates the following manager events:
DongleDeviceEntry
DongleShowDevicesComplete
DongleUSSDStatus
DongleSMSStatus
DongleNewCUSD
DongleNewUSSD
DongleNewUSSDBase64
DongleCEND
DongleCallStateChange
DongleStatus
DongleNewCMGR
DongleNewSMS
DongleNewSMSBase64
DonglePortFail
Console AT commands
You can send AT commands to any modem using
CLI>dongle cmd
Some useful AT commands:
AT command Description
AT+CCWA=0,0,1 disable call-waiting
AT+CFUN=1,1 reboot modem
AT CARDLOCK=”” s e n d u n l o c k c o d e
A T ^ S Y S C F G = 1 3 , 0 , 3 F F F F F F F , 0 , 3 m o d e m 2 G o n l y , a u t o m a t i c s e a r c h a n y
b a n d , n o r o a m i n g
A T ^ U 2 D I A G = 0 e n a b l e m o d e m f u n c t i o n o n l y
A T I g e t r e l e v a n t i n f o r m a t i o n f r o m m o d e m
A T Z r e s e t m o d e m c o n f i g u r a t i o n
A T + C I M I r e a d I M S I
A T + C L C K = “ S C ” , 0 , ” ” d i s a b l e P I N v e r i f i c a t i o n
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
H o w t o a c t i v a t e m o d e m f e a t u r e
T o d i s a b l e C D - R O M a n d e n a b l e G S M m o d e m , f o l l o w t h e s e
i n s t r u c t i o n s .
W h a t t o d o i f t t y U S B n u m b e r c h a n g e ?
F o r e x a m p l e , y o u p l u g t w o m o d e m s b u t i n d i f f e r e n t o r d e r , a n d w h e n
p l u g m o d e m X f i r s t i t b e c o m e s / d e v / t t y U S B [ 0 - 2 ] ( d o n g l e 0 a s
d e f i n e d i n d o n g l e . c o n f )
B u t i f p l u g m o d e m Y f i r s t i t b e c o m e s / d e v / t t y U S B [ 0 - 2 ] ( d o n g l e 0 )
a n d m o d e m X b e c o m e s / d e v / t t y U S B [ 3 - 5 ] ( d o n g l e 1 )
T h e s a m e c a n h a p p e n w h e n r e b o o t i n g c o m p u t e r , s o m e t i m e s X b e c o m e s
d o n g l e 0 , b u t s o m e t i m e s d o n g l e 1 .
T o a v o i d t h i s i n d e t e r m i n a t i o n y o u m a y u s e
u d e v r u l e s
C r e a t e / e t c / u d e v / r u l e s . d / 9 9 - h u a w e i - l i n k . r u l e s w i t h t h e f o l l o w i n g
l i n e s
# a d d s y m l i n k s f o r d e v i c e b a s e d o n U S B b u s a d d r e s s i . e . p h y s i c a l
U S B s l o t
A C T I O N ! = " a d d | c h a n g e " , G O T O = " d e v i c e _ h u a w e i _ e n d "
# S U B S Y S T E M ! = " u s b " , G O T O = " d e v i c e _ h u a w e i _ e n d "
# A T T R S { i d V e n d o r } ! = " 1 2 d 1 " , G O T O = " d e v i c e _ h u a w e i _ e n d "
# A T T R S { i d P r o d u c t } = = " 1 4 4 6 " , G O T O = " d e v i c e _ h u a w e i _ l i n k "
# A T T R S { i d P r o d u c t } = = " 1 4 0 c " , G O T O = " d e v i c e _ h u a w e i _ l i n k "
# A T T R S { i d P r o d u c t } = = " 1 0 0 1 " , G O T O = " d e v i c e _ h u a w e i _ l i n k "
# G O T O = " d e v i c e _ h u a w e i _ e n d "
L A B E L = " d e v i c e _ h u a w e i _ l i n k "
L A B E L = " d e v i c e _ h u a w e i _ l i n k "
# U S B s l o t f r o m l e f t t o r i g h t ( b a c k l o o k )
# l e f t
K E R N E L = = " t t y U S B [ 0 - 9 ] * " , I D = = " 1 - 1 : 1 . 0 " , S Y M L I N K + = " h w - m o d e m - 0 "
K E R N E L = = " t t y U S B [ 0 - 9 ] * " , I D = = " 1 - 1 : 1 . 1 " , S Y M L I N K + = " h w - a u d i o - 0 "
K E R N E L = = " t t y U S B [ 0 - 9 ] * " , I D = = " 1 - 1 : 1 . 2 " , S Y M L I N K + = " h w - d a t a - 0 "
K E R N E L = = " t t y U S B [ 0 - 9 ] * " , I D = = " 1 - 1 : 1 . 3 " , S Y M L I N K + = " h w - n e t - 0 "
# l e f t m i d d l e
K E R N E L = = " t t y U S B [ 0 - 9 ] * " , I D = = " 1 - 2 : 1 . 0 " , S Y M L I N K + = " h w - m o d e m - 1 "
K E R N E L = = " t t y U S B [ 0 - 9 ] * " , I D = = " 1 - 2 : 1 . 1 " , S Y M L I N K + = " h w - a u d i o - 1 "
K E R N E L = = " t t y U S B [ 0 - 9 ] * " , I D = = " 1 - 2 : 1 . 2 " , S Y M L I N K + = " h w - d a t a - 1 "
K E R N E L = = " t t y U S B [ 0 - 9 ] * " , I D = = " 1 - 2 : 1 . 3 " , S Y M L I N K + = " h w - n e t - 1 "
# r i g h t m i d d l e
K E R N E L = = " t t y U S B [ 0 - 9 ] * " , I D = = " 1 - 3 : 1 . 0 " , S Y M L I N K + = " h w - m o d e m - 2 "
K E R N E L = = " t t y U S B [ 0 - 9 ] * " , I D = = " 1 - 3 : 1 . 1 " , S Y M L I N K + = " h w - a u d i o - 2 "
K E R N E L = = " t t y U S B [ 0 - 9 ] * " , I D = = " 1 - 3 : 1 . 2 " , S Y M L I N K + = " h w - d a t a - 2 "
K E R N E L = = " t t y U S B [ 0 - 9 ] * " , I D = = " 1 - 3 : 1 . 3 " , S Y M L I N K + = " h w - n e t - 2 "
# r i g h t
K E R N E L = = " t t y U S B [ 0 - 9 ] * " , I D = = " 1 - 4 : 1 . 0 " , S Y M L I N K + = " h w - m o d e m - 3 "
K E R N E L = = " t t y U S B [ 0 - 9 ] * " , I D = = " 1 - 4 : 1 . 1 " , S Y M L I N K + = " h w - a u d i o - 3 "
K E R N E L = = " t t y U S B [ 0 - 9 ] * " , I D = = " 1 - 4 : 1 . 2 " , S Y M L I N K + = " h w - d a t a - 3 "
K E R N E L = = " t t y U S B [ 0 - 9 ] * " , I D = = " 1 - 4 : 1 . 3 " , S Y M L I N K + = " h w - n e t - 3 "
L A B E L = " d e v i c e _ h u a w e i _ e n d "
I n t h i s c a s e , I D = = ” ” i n d i c a t e w h a t i s d i s p l a y e d i n y o u r d m e s g
o u t p u t a f t e r p l u g t h e m o d e m i n t h i s U S B p o r t i n l i n e s o f l i k e
[ 4 8 5 4 . 3 4 4 4 6 0 ] o p t i o n 1 - 1 : 1 . 0 : G S M m o d e m ( 1 - p o r t ) c o n v e r t e r
d e t e c t e d
I n d o n g l e . c o n f u s e t h i s s y m b o l i c l i n k s i n s t e a d o f / d e v / t t y U S B x
f i l e s
[ d o n g l e 0 ]
a u d i o = / d e v / h w - a u d i o - 0
d a t a = / d e v / h w - d a t a - 0
m o d e m s d i s c o v e r y
S i n c e J a n 0 8 , 2 0 1 1 a n d r e v i s i o n 1 5 0 o f
h t t p : / / c o d e . g o o g l e . c o m / p / a s t e r i s k - c h a n - d o n g l e y o u c a n u s e a l s o
s i m p l e b u t p o w e r f u l f e a t u r e - d i s c o v e r y m o d e m s b y I M E I o r / a n d
I M S I n u m b e r s . F o r e x a m p l e :
[ d o n g l e 0 ]
i m e i = 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
[ d o n g l e 1 ]
i m s i = 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1
[ d o n g l e 2 ]
i m e i = 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9
i m s i = 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
E a c h t i m e b e f o r e d e v i c e o p e n i n g c h a n _ d o n g l e w i l l s e a r c h f o r
d e v i c e s w i t h p r e d e f i n e d V e n d o r I D : P r o d u c t I D p a i r s , d e t e c t p o r t s o r
t h i s d e v i c e s , a n d c h e c k i t s I M E I a n d I M S I .
m o d e m d e t a c h i n g f r o m s y s t e m w h e n t r y i n g t o c a l l
W h e n r e c e i v e d i n c o m i n g c a l l o r b e g i n i n g o u t g o i n g c a l l c h a n _ d o n g l e
l o s t c o n n e c t i o n t o d e v i c e a n d d e v i c e d i s a p p e a r s f r o m s y s t e m , b u t
a f t e r a w h i l e , i t c o m e s b a c k .
I n a s t e r i s k C L I a p p e a r s s o m e t h i n g l i k e t h a t
- - A t t e m p t i n g c a l l o n D o n g l e / d o n g l e 0 / 7 4 9 5 * * * * f o r a p p l i c a t i o n
P l a y b a c k ( s i l e n c e / 1 0 ) ( R e t r y 1 )
- - D o n g l e d o n g l e 0 h a s d i s c o n n e c t e d
[ D e c 3 0 1 6 : 1 2 : 0 9 ] N O T I C E [ 2 6 4 9 3 ] : p b x _ s p o o l . c : 3 3 9 a t t e m p t _ t h r e a d :
C a l l f a i l e d t o g o t h r o u g h , r e a s o n ( 1 ) H a n g u p
d e b i a n * C L I >
- - D o n g l e d o n g l e 0 t r y i n g t o c o n n e c t o n / d e v / t t y U S B 2 . . .
- - D o n g l e d o n g l e 0 h a s c o n n e c t e d , i n i t i a l i z i n g . . .
- - D o n g l e d o n g l e 0 i n i t i a l i z e d a n d r e a d y
I n k e r n e l l o g a n d d m e s g
D e c 3 0 1 5 : 1 4 : 1 0 V o i p G S M k e r n e l : [ 8 6 4 . 4 3 8 8 2 2 ] o p t i o n :
o p t i o n _ i n s t a t _ c a l l b a c k : e r r o r - 8 4
D e c 3 0 1 5 : 1 4 : 1 0 V o i p G S M k e r n e l : [ 8 6 4 . 4 4 8 0 6 0 ] u s b 5 - 1 : U S B
d i s c o n n e c t , a d d r e s s 3
D e c 3 0 1 5 : 1 4 : 1 0 V o i p G S M k e r n e l : [ 8 6 4 . 4 4 8 8 1 7 ] o p t i o n :
o p t i o n _ i n s t a t _ c a l l b a c k : e r r o r - 1 0 8
A p o s s i b l e r e a s o n i s b a d f i r m w a r e 1 1 . 6 0 8 . 1 2 . 1 0 . 2 0 9 i n H u a w e i
E 1 5 5 0 . T h i s v e r s i o n o f f i r m w a r e a l l o w v o i c e c a l l s i n W i n d o w s w i t h
M o b i l e P a r t n e r , b u t s e e m s n o t t o w o r k i n L i n u x : )
A n o t h e r r e a s o n i s t h e l a c k o f p o w e r f o r d e v i c e a t p e a k l o a d w h e n
c a l l i s s t a r t i n g .
S M S a n d U S S D t r u n c a t e d t o f i r s t \ n s y m b o l
F o r e x a m p l e y o u s e n d “ H e l l o ! \ n H o w a r e y o u ? ” b u t a s t e r i s k s h o w
o n l y “ H e l l o ! ”
T h e r e a s o n f o r t h i s h i d d e n i n a s t e r i s k v a r i a b l e s u b s i t u t i o n , a n d
c a n b e s o l v e d b y u s e B A S E 6 4 _ D E C O D E f u n c t i o n :
$ { B A S E 6 4 _ D E C O D E ( $ { S M S _ B A S E 6 4 } ) }
$ { B A S E 6 4 _ D E C O D E ( $ { U S S D _ B A S E 6 4 } ) }
C a l l e r p a r t y n o t h e a r i n g r i n g b a c k t o n e
W h e n f o r w a r d c a l l f r o m G S M → S I P c a l l e r p a r t y d o e s n o t h e a r
r i n g b a c k t o n e .
T o s o l v e t h i s p r o b l e m y o u c a n u s e a d d o p t i o n s ' m ' ( m u s i c o n h o l d )
o r ' r ' f o r D i a l ( ) a p p l i c a t i o n
e x t e n = > s , n , D i a l ( S I P / 1 1 1 @ s i p , 3 0 , m )
e x t e n = > s , n , D i a l ( S I P / 1 1 1 @ s i p , 3 0 , r )
D T M F s y m b o l s A , B , C , D n o t s e n t b y c h a n _ d o n g l e
S o r r y , b u t H u a w e i m o d e m s n o t s u p p o r t s e n d i n g t h i s s y m b o l s , a n d
a s t e r i s k t r y t o s e n d t h e s e s y m b o l s i n b a n d .
D T M F s y m b o l s n o t r e c e i v e d f r o m d o n g l e
A t f i r s t , D T M F i n G S M n e t w o r k a r e s e n t o v e r a v o i c e c h a n n e l , t h i s
m e a n y o u m u s t f i r s t a n s w e r t o i n c o m i n g c a l l o r e s t a b l i s h o u t g o i n g
f o r r e c e i v e D T M F .
O t h e r p o s s i b l e r e a s o n i s u s a g e o f a s t e r i s k v e r s i o n 1 . 6 . 2 . 1 6 - r c 1 ,
r e t u r n b a c k t o 1 . 6 . 2 . 1 3 s o l v e t h i s t r o u b l e .
C h e c k s e t t i n g o f d o n g l e . c o n f
d t m f = i n b a n d
o r
d t m f = r e l a x
I n c a s e o f p r o b l e m s w i t h D T M F w e r e c o m m e n d e n a b l e d t m f l o g g i n g i n
l o g g e r . c o n f
d t m f = > d t m f
D T M F s y m b o l s n o t s e n t t o d o n g l e
A t f i r s t , D T M F i n G S M n e t w o r k a r e s e n t o v e r a v o i c e c h a n n e l , t h i s
m e a n y o u m u s t f i r s t a n s w e r t o i n c o m i n g c a l l o r e s t a b l i s h o u t g o i n g
f o r s e n d D T M F .
D u p l i c a t e o f r e c e i v e d D T M F s y m b o l s
H a s s e v e r a l r e a s o n s o f d u p l i c a t i o n o f D T M F :
w h e n a s t e r i s k r e c e i v e D T M F s y m b o l f r o m c h a n _ d o n g l e i t p a s s e d
s y m b o l t o o t h e r l e g o f c a l l b u t D T M F t o n e s a l s o p a s s e d i n b a n d .
I . e . o t h e r s i d e r e c e i v e d u p l i c a t e d D T M F s y m b o l
G S M n e t w o r k v u l n e r a b l e f o r e c h o
G S M p h o n e o f p a r t y a l s o p r o d u c e e c h o
F o r t h e s e r e a s o n s D T M F s y m b o l c a n w a l k i n f i n i t e l y f r o m p h o n e t o
p h o n e i f a s t e r i s k b r i d g e G S M a n d G S M .
O n e w a y v o i c e o n H u a w e i E 1 5 0
B y d e f a u l t w i t h E 1 5 0 l o c a l p a r t y c a n l i s t e n w h a t t a l k i n g G S M
p a r t y , b u t G S M p a r t y l i s t e n s i l e n c e .
E 1 5 0 r e q u i r e w r i t e z e r o l e n g t h f r a m e a f t e r e a c h 3 2 0 b y t e s 2 0 m s o f
v o i c e d a t a w r i t t e n . B u t l i n u x d r i v e r n a m e d o p t i o n , n o t h i n g k n o w
a b o u t t h i s E 1 5 0 ' f e a t u r e ' .
S o l u t i o n i s b u i l d s p e c i a l v e r s i o n s o f o p t i o n d r i v e r a n d d r i v e r
f o r o n l y d i a g n o s t i c p o r t o f E 1 5 0 . T h e s o u r c e s o f t h e s e c a n b e
f o u n d o n h t t p s : / / g i t h u b . c o m / N o v a x / k m o d - h u a w e i - v o i c e
B r i e f i n s t r u c t i o n f o r d e b i a n a n d u b u n t u : I n s t a l l g i t
s u d o a p t - g e t i n s t a l l g i t
I n s t a l l l i n u x k e r n e l h e a d e r s f o r v e r s i o n o f y o u r k e r n e l
s u d o a p t - g e t i n s t a l l l i n u x - h e a d e r s - 2 . 6 . 3 5 - 2 2
I n s t a l l s o u r c e s o f k m o d - h u a w e i - v o i c e
c d / u s r / s r c
g i t c l o n e g i t : / / g i t h u b . c o m / N o v a x / k m o d - h u a w e i - v o i c e . g i t
B u i l d k e r n e l m o d u l e
c d k m o d - h u a w e i - v o i c e
m a k e
I n s t a l l m o d u l e ( n o t f u l l y y e t )
/ e t c / i n i t . d / a s t e r i s k s t o p
r m m o d o p t i o n
i n s m o d . / o p t i o n . k o
i n s m o d . / h u a w e i _ v o i c e . k o
/ e t c / i n i t . d / a s t e r i s k s t a r t
R u n n i n g a s t e r i s k a s n o n - r o o t
A l o t o f p e o p l e i s r u n n i n g A s t e r i s k a s “ a s t e r i s k ” u s e r . T h i s m a y
c a u s e c h a n _ d o n g l e n o t d e t e c t i n g U S B m o d e m s . I n t h a t c a s e , y o u
n e e d t o g i v e p e r m i s s i o n s f o r t t y U S B p o r t s . Y o u c a n d o t h a t
a u t o m a t i c a l l y b y c r e a t i n g f i l e / e t c / u d e v / r u l e s . d / 9 2 - d o n g l e . r u l e s
a n d a d d i n g :
K E R N E L = = " t t y U S B * " , M O D E = " 0 6 6 6 " , O W N E R = " a s t e r i s k " , G R O U P = " u u c p "
O t h e r s o l u t i o n s e t r u n u s e r / r u n g r o u p s e t t i n g s i n a s t e r i s k . c o n f
f i l e .
r u n g r o u p = d i a l o u t
I n o t h e r w o r d s o w n e r , g r o u p , p e r m i s s i o n s o n / d e v / t t y U S B x f i l e s
m u s t a l l o w r e a d a n d w r i t e o p e r a t i o n s f o r a s t e r i s k ' s E U I D , E G I D
m u s t a l l o w r e a d a n d w r i t e o p e r a t i o n s f o r a s t e r i s k ' s E U I D , E G I D
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
H e l p a n d S u p p o r t
F o r a n y o t h e r q u e s t i o n o r s u p p o r t , y o u c a n f i n d m o r e h e l p o n
h t t p : / / g r o u p s . g o o g l e . c o m / g r o u p / c h a n _ d o n g l e
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
P o r t i n g i n s t r u c t i o n s f r o m c h a n _ d a t a c a r d t o c h a n _ d o n g l e
M o d u l e c o n f i g u r a t i o n c h a n g e s
c h a n g e c o n f i g f i l e n a m e f r o m d a t a c a r d . c o n f t o d o n g l e . c o n f
c h a n g e p a r a m e t e r f r o m ' r e s e t d a t a c a r d ' t o ' r e s e t d o n g l e '
r e s e t d a t a c a r d = y e s
r e s e t d o n g l e = y e s
D i a l p l a n c h a n g e s
c h a n g e c h a n n e l t e c h n o l o g y f r o m ' D a t a c a r d ' t o ' D o n g l e '
D i a l ( D a t a c a r d / d 1 / + 7 9 1 3 9 1 3 1 2 3 4 )
D i a l ( D o n g l e / d 1 / + 7 9 1 3 9 1 3 1 2 3 4 )
c h a n g e d e v i c e s t a t u s f u n c t i o n f r o m ' D a t a c a r d S t a t u s ' t o
' D o n g l e S t a t u s '
D a t a c a r d S t a t u s ( d 1 , V A R )
D o n g l e S t a t u s ( d 1 , V A R )
c h a n g e S M S s e n d f u n c t i o n f r o m ' D a t a c a r d S e n d S M S ' t o
' D o n g l e S e n d S M S '
D a t a c a r d S e n d S M S ( d 1 , + 7 9 1 3 9 1 3 1 2 3 4 , " H e l l o h o w a r e y o u ,
D a n i l a ? " , 1 4 4 0 , y e s )
D o n g l e S e n d S M S ( d 1 , + 7 9 1 3 9 1 3 1 2 3 4 , " H e l l o h o w a r e y o u ,
D a n i l a ? " , 1 4 4 0 , y e s )
c h a n g e c h a n n e l v a r i a b l e s
D A T A C A R D t o D O N G L E N A M E
P R O V I D E R t o D O N G L E P R O V I D E R
I M E I t o D O N G L E I M E I
I M S I t o D O N G L E I M S I
C N U M B E R t o D O N G L E N U M B E R
C L I c h a n g e s
a l l c o m m a n d s o f d a t a c a r d c h a n g e d t o d o n g l e l i k e
d a t a c a r d s h o w d e v i c e s
d o n g l e s h o w d e v i c e s
M a n a g e r ' s c h a n g e s
M a n a g e r ' s c h a n g e s
A c t i o n s a n d e v e n t s b e g i n i n g f r o m “ D a t a c a r d ” c h a n g e d t o b e g i n i n g
f r o m “ D o n g l e ” f o r e x a m p l e
D a t a c a r d S h o w D e v i c e s
D o n g l e S h o w D e v i c e s
o r
D a t a c a r d N e w U S S D
D o n g l e N e w U S S D
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
R E F : h t t p : / / w i k i . e 1 5 5 0 . m o b i / d o k u . p h p
Posted 6th September 2011 by leonil sune
Comment as:� Select profile...
Publish � Preview
E n t e r y o u r c o m m e n t . . .
0 A d d a c o m m e n t