RaPi GSM gateway

I gotta put these notes somewhere in case I need them again oneday.
Meanwhile, somebuddy else might find 'em useful. Enjoy.

RaPBX on Raspberry Pi 3 Model B+

Download the image and read the documentation at

wget http://download.raspberry-asterisk.org/raspbx-04-04-2018.zip
sha1sum raspbx-04-04-2018.zip
unzip raspbx-04-04-2018.zip
Determine SD card usb device, ie /dev/sdk

Details for how to setup the SD card at

Using any Linux host, write the image to the micro SD card
dd bs=4M if=raspbx-04-04-2018.img of=/dev/sdk
Before removing the micro SD card :

Put the micro SD card into the RaPi, connect ethernet and power it up.
Scan the network for the ip address.
nmap -sP

Find the Raspberry Pi device, and ssh to it.
ssh root@10.0.0.xx
password = raspberry

uname -a
Linux raspbx 4.14.30-v7+ #1102 SMP Mon Mar 26 16:45:49 BST 2018 armv7l GNU/Linux

Get all latest updates

Confirm kernel updated to latest
uname -a
Linux raspbx 4.14.34-v7+ #1110 SMP Mon Apr 16 15:18:51 BST 2018 armv7l GNU/Linux

I like some extra handy tools
apt-get install nmap inxi lshw locate

Confirm hardwares
lshw -short | grep system
system Raspberry Pi 3 Model B Plus Rev 1.3

inxi -Fimd -c 17
Lotsa useful hardware details

Yes it running 32 bit OS on 64 bit processor.
RaPBX thinks its an ARMv7 processor (v7l) 32 bit
Actually it should be a Broadcom BCM2837B0, Cortex-A53 64-bit SoC @ 1.4GHz

Connect the GSM dongle and install the chan dongle packages

Check the dongle is working :

asterisk -r
raspbx*CLI> dongle show devices
dongle0 0 Free 5 0 0 xxxx E160X 11.609.10.02.432 xxxxxxxxxx

raspbx*CLI> dongle show device state dongle0
-------------- Status -------------
Device : dongle0
State : Free
Audio : /dev/ttyUSB1
Data : /dev/ttyUSB2
Voice : Yes
SMS : Yes
Manufacturer : huawei
Model : E160X
Firmware : 11.609.10.02.432
IMEI : xxxxxxxxxxxxxxx
IMSI : xxxxxxxxxxxxxxx
GSM Registration Status : Registered, home network
RSSI : 13, -87 dBm
Mode : No Service
Submode : No service
Provider Name : xxxxxxx
etc, yadda, yadda

Make sure the Audio and Data devices are same as settings in /etc/asterisk/dongle.conf
Notice the RSSI dBm value for GSM signal strength

Use the web interface to RaPBX

Setup an administrator as prompted.
Setup language and timezone as prompted
Be patient while it sets up locale files

Add Trunk as per instructions
Custom dial string
Add Outbound route using the GSM trunk, use dial pattern X[dot] to accept ALL numbers
Add extension/s
I use pjsip and Linphone on Android handphone for testing.
Add Inbound route
Phones ring, inbound and outbound. Seems to work. Real-world testing to follow.


Is GSM still operational in Australia?

I just use the term “GSM” in its non-technical meaning, referring to cellphone services generally.
Sorry if this causes confusion.
Since the dongle is solely for voice, (not any data) it doesn’t matter whether its 3G or 4G or another G.


This sounds like a really cool project David! You should put it up on our Projects page for everyone to see, and you can even get store credit when you do.

Can’t wait to see it!


Are you familiar with Lenny?

Best use of PBX I’ve ever seen.

1 Like

Yes, we’ve been using Lenny for many years.
Lenny is an important member of our team.
We have our own collection of private recordings that always bring laughter and amusement.
Lenny is worth more money, but wait, he’s open source.

Hi, thanks for your post. I have just installed Raspbx-10-10-2020 on RaspberryPi 3 and set up Huawei E1752C modem. Modem is supposed to be unlocked, and actually I tried with the enclosed software called Mobile Partner, and I can call and talk just fine. So I assume it is unlocked.

So, after installing everything, setting trunks, extensions, outbound and inbound routes, i went to http://IP_of_my_Raspberry/sms and sending SMS messages works just fine. Receiving also - I get them on my mail.

However, I have a problems with voice calling.

First about SIP extension. I went to Applications - Extensions and selected chan_pjsip extension. I set up extension number 1000.

then I went to my phone set up Linphone and SIP account. It says it is connected. Please note, I am doing this in my local network.

So far, so good.

However, when someone tries to call me, line is busy. And - I am also not able to call. Or maybe I do not know how to call? I am trying to enter a phone number in a format +38640123456 (Slovenian number). Is that correct, or should I enter some “outgoing” code?

Did you
Check the dongle is working ?

Whats in your
dongle show devices ?
dongle show device state dongleX (probably dongle0) ?

Edit. We’re still using the original RaPi, same dongle, and same original software installed 3.5 years ago.
IMHO if something works, often best to leave it alone until it breaks.
The little RaPi very cheaply handles lotsa calls in each direction, each day.
AFAIK the only mod I’ve added is an autoresponder for incoming SMS messages.
It replies and informs the sender that this is an unmonitored phone service and messages are NOT delivered.
This suits our use case.

Yes, I have installed dongle, and I can also list dongle devices.

In fact, I can enter the command (in ssh session) channel originate dongle/dongle0/031123456 application MusicOnHold and the target number actually gets called (I can see state Dialing and Outgoing when target number picks up the phone (on hold music is then heard), but it seems there is a problem dialing via SIP and trunk…

I guess USB dongle is completely OK, probably I just misconfigured trunk or some outgoing rule…?

OK, I figured it out. Trunk was OK, bot for Outbound Routes I had the wrong dial pattern. I live in Europe and I needed to correct the pattern. However, now I can call out!

But unfortunately incoming calls are not working. I have created two extensions (1000 and 2000) and they can call themselves. I also have created Inbound route, but incoming call is not directed to extension 1000.

When I am trying to call my number (SIM card in a dongle), it rings three times and after that, call is not routed to extension 1000, and after three rings, call is just terminated.

Maybe some other idea how to solve this?

Definitely yes.
Check the asterisk logs and see what step in the inbound call process is failing.
BTW, your “likes” for my posts will be appreciated.
Enjoy !

1 Like

Hi, thanks, I figure it out.

The problem was the firewall on my device running SIP client. And Linphone on iPhone just sucks. :grinning:

Now everything is working.

I also gave a like to your post.

1 Like

Hi, I’m back. :slight_smile:

I have tested the connection between a friend, located in Chicago, USA, and me, located in Slovenia, Europe.

Unfortunately the call quality was quite bad, when I called through dongle trunk. But directly, between two extensions, it was really good.

Can you tell me which codecs do you use or would you recommend?

1 Like

AFAIK, different codecs are used by different telco carriers in different regions.
You’ll need to research and test to find the best codec for your environment.
Lots to choose from including g722, g729, g726, alaw, ulaw, gsm
For a cellphone network, try gsm.

Edit. You should also try making a local call within Slovenia using your cellphone dongle.

1 Like

We’ve been using this “old” RaPi powered cellphone gateway with Huawei dongle for past 5+ years.
Now, it looks like there’s an opportunity to significantly update this ageing project.

With the imminent shutdown of 3G networks in AU, my trusty old Huawei E160X will need to be replaced with something newer.
This old modem was purchased so many years ago for circa ~ $20. It’s been great value. :wink: