GSM VoIP Gateway with Chan_dongle | Asterisk for Raspberry Pi

Building:

If you run a different version of Asterisk, you’ll need to update the
13.7 as appropriate, obviously.

If you did not make install Asterisk in the usual location and configure
cannot find the asterisk header files in /usr/include/asterisk, you may
optionally pass –with-asterisk=PATH/TO/INCLUDE.

Dialplan example

To set JITTERBUFFER and AGC in the dialplan on the appropriate channel
regardless of who is initiating the call we will have to use
the “b” option of Dial:

b( context^exten^priority )

Before initiating an outgoing call, Gosub to the specified
location using the newly created channel.

The Gosub will be executed for each destination channel.”

[from-dongle]
; This will be executed by an indbound Dongle channel ( call initiated on the dongle side )
exten => _[ 0-9].,1,Dial(SIP/bob,b(from-dongle^outbound^1)) ;

; This will be executed by an outbound SIP channel ( channel generated by dial )
exten => outbound,1,Set(JITTERBUFFER(adaptive)=default)
same => n,Set(AGC(rx)=4000)
same => n,Return()

[from-sip]
; This will be executed by an inbound SIP channel ( call initiated on the SIP side )
exten => _[ 0-9].,1,Set(JITTERBUFFER(adaptive)=2000,1600,120)
same => n,Set(AGC(rx)=4000)
same => n,Dial(Dongle/i:${IMEI_OF_MY_DONGLE}/${NUMBER_OF_BOB}) 

Note: To use automatic gain control dialplan function (AGC) you will need
to compile Asterisk with func_speex ( see in menuselect ).
On raspberry Pi you will need to compile and install speex and speexdsp yourself,
the version of speex provided by the depos does not support AGC.
(because compiled with fixed point instead of floating point)
see: HOWTO

Gain control and jitter buffer

In order to perform good quality calls you will need to take care of:

chan_dongle does not control the gain of the audio stream it receive.
This result of Alice hearing Bob’s voice loud and noisy.
It is possible to manually manage the gain in dongle.conf but
the better option is by far to apply automatic gain control with
the dialplan function AGC.

Since asterisk 12 it is no longer possible to enable Jitter buffer
in dongle.conf it has to be applied in the dialplan.
The lack of Jitter buffer result in severe loss in the transport
of the voice from Bob to Alice.

Here is an example for the dialplan:

WARNING: This example uses the raw SMS message passed to System() directly.
No sane person would do that with untrusted data without escaping/removing the
single quotes.

[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 => s,1,Dial(SIP/[email protected])
exten => s,n,Hangup()

[othersipserver-incoming]

exten => _X.,1,Dial(Dongle/r1/${EXTEN})
exten => _X.,n,Hangup

exten => *#123#,1,DongleSendUSSD(dongle0,${EXTEN})
exten => *#123#,n,Answer()
exten => *#123#,n,Wait(2)
exten => *#123#,n,Playback(vm-goodbye)
exten => *#123#,n,Hangup()

exten => _#X.,1,DongleSendSMS(dongle0,${EXTEN:1},"Please call me",1440,yes,"magicID")
exten => _#X.,n,Answer()
exten => _#X.,n,Wait(2)
exten => _#X.,n,Playback(vm-goodbye)
exten => _#X.,n,Hangup()

Other cli commands:

For reading installation notes please look to INSTALL file.

Setup and configuration

Once your modem has PIN deactivated, latest firmware and voice enabled, run this command:

 install-dongle

This installer script installs chan_dongle.so, and creates an initial configuration. The script is provided with upgrade #11 (and improved further with upgrade #12). Once the installer has finished, connect your modem to the RPi. If it was connected already before, unplug it now and plug it in again.

Then log into FreePBX, in Connectivity – Trunks click Add Custom Trunk. Provide a trunk name, set Outbound CallerID to the number of your SIM, and enter in the field Custom Dial String:

dongle/dongle0/$OUTNUM$

Add an outbound route to use this trunk, as well as an incoming route. On the incoming route set DID Number to your SIM number, precisely matching the number you entered when running the install-dongle script.

More details on how to setup inbound and outbound routes can be found in the forum.

Troubleshooting

If it doesn’t work at this point, at first check if the interfaces of your modem match the configuration:

ls -l /dev/tty*

2 devices, ttyUSB1 and ttyUSB2 should show up. If the numbers are different, something like ttyUSB0 and ttyUSB1, edit /etc/asterisk/dongle.conf and change the values below [dongle0] accordingly.Many modems require the usb_modeswitch program to switch over from CD-drive mode (for installing Windows drivers) to modem mode.

The /dev/ttyUSB devices will not appear before the switch-over was done. Make sure to have all the latest upgrades on recent Debian Jessie based images to fix some initial bugs with usb_modeswitch. If your modem is still not switching it might be necessary to add a custom rule for usb_modeswitch.

You can also use this:

Call using a specific group:

Call using a specific group in round robin:

Call using a specific dongle:

Call using a specific provider name:

Call using a specific IMEI:

Call using a specific IMSI prefix:

How to store your own number:

Оцените статью
Huawei Devices
Добавить комментарий