Summary
Implement a 3g dongle voice channel on asterisk server that can be managed in FreePBX web interface.
Notes
- Its assumed that the 3g dongle is voice capable and voice is enabled, and it is also configured to work as modem on linux.
- It requires source compilation of chan_dongle.so.
Resources
- Host: Banana Pi M1 (bananian – debian jessie)
- Asterisk: 13.11.02
- FreePBX: 13.0.190.20
- 3g Dongle: Huawei E169
- Telecom: NOS Portugal
Required software
asterisk module chan_dongle.so
First task is found some working code. After try other chan_dongle sources namely:
- https://github.com/bg111/asterisk-chan-dongle
- https://github.com/jstasiak/asterisk-chan-dongle/
I found the one that i can compile in my setup (described above)
- https://github.com/wdoekes/asterisk-chan-dongle
This one works and i can do exactely what its wanted to do.
Get Required chan_dongle.so
Get the code from web, compile from the source, and pre configure it for asterisk.
wget https://github.com/wdoekes/asterisk-chan-dongle/archive/master.zip
unzip master.zip
cd asterisk-chan-dongle-master
aclocal && autoconf && automake -a
configure.ac:64: installing ‘./compile’
configure.ac:6: installing ‘./config.guess’
configure.ac:6: installing ‘./config.sub’
configure.ac:7: installing ‘./install-sh’
configure.ac:7: installing ‘./missing’
(ignore above errors)
./configure –with-astversion=13
make
make install (optional not done, files copied manualy bellow)
cp chan_dongle.so /usr/lib/asterisk/modules
chown asterisk:asterisk /usr/lib/asterisk/modules/chan_dongle.so
cp etc/dongle.conf /etc/asterisk/
To avoid some permission errors later
chmod 666 /dev/ttyUSB1
chmod 666 /dev/ttyUSB2
This permissions changes are not permanent and I need to apply this latter.
vi /etc/udev/rules.d/92-dongle.rules
KERNEL=="ttyUSB*", MODE="0666", OWNER="root", GROUP="dialout"
My original owner:group is root:dialout.
Its done, lets check on asterisk.
Test chan_dongle in Asterisk
Now its time to test the new channel in asterisk
asterisk -rvvvv
CLI> module load chan_dongle
CLI> dongle show devices
You may now try to call to your new number (the gsm number), if every thing is ok you found that the call is anwsered and hungup. this is because we need to do some more configurations in a text file, and in the freePBX web interface.
Configure chan_dongle in asterisk dongle.file
If you don want to receive incoming sms or ussd messages you could use: from-pstn or from-trunk for context configuration.
Edit the file /etc/asterisk/dongle.conf and change:
context=default to context=dongle-incoming
exten=+1234567890 to exten=YOURNUMBER
Save and reload the new configuration
CLI> dongle reload when convenient
Test again
Note (the exten is only used if Subscriber Number is not present)
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,\”+556191000000\”,145
Configure incoming SMS on Asterisk with FreePBX
if you use context=dongle-incoming you need to insert the context in dialplan.
Add the following code to the file: /etc/asterisk/extensions_custom.conf
[dongle-incoming]
exten => sms,1,Verbose(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()
exten => ussd,1,Verbose(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()
exten => 929203351,1,goto(from-pstn,${EXTEN},11)
exten => s,1,goto(from-pstn,${EXTEN},1)
CONFIGURE ASTERISK CHAN_DONGLE IN FreePBX
Login on FreePBX web interface for asterisk.
Create a trunk
Connectivity > Trunks > Add Custom Trunk
Create a Inbound Route
Connectivity > Inbound Routes > Add Inbound Route
Custom Dial String: dongle/dongle0/$OUTNUM$
Include it on some Outbond Route
Connectivity > Outbound Routes
Add the dongle trunk to one of the existing routes or create a new one.
Test the 3g dongle Asterisk FreePBX integration
Place an inbound call
Using some external phone
Place an outbund call
Using some internal phone (extension)
Send a SMS using CLI
dongle sms dongle0 +OUTNUMBER test1sms
Send a SMS to YOURNUMBER
The sms’s and ussd’s received are stored on the following files
- /var/log/asterisk/sms.txt
- /var/log/asterisk/ussd.txt
For me its all working ok now.
DONGLE ASTERISK CLI comands
dongle callwaiting — Enable/Disable Call-Waiting on the dongle
dongle cmd — Send commands to port for debugging
dongle discovery — Discovery devices and create config
dongle pdu — Send PDU of SMS from the dongle
dongle reload — Reload dongle
dongle remove — Remove dongle
dongle reset — Reset dongle now
dongle restart — Restart dongle
dongle show device settings — Show Dongle device settings
dongle show device state — Show Dongle device state
dongle show device statistics — Show Dongle device statistics
dongle show devices — Show Dongle devices state
dongle show version — Show module version
dongle sms — Send SMS from the dongle
dongle start — Start dongle
dongle stop — Stop dongle
dongle ussd — Send USSD commands to the dongle
Links
https://github.com/bg111/asterisk-chan-dongle/wiki/Preparation
History
Version: 1.0