Calling on GSM/3G Networks

The Asterisk for Raspberry Pi project is continuously improving with new features and enhancements. The latest feature is particularly interesting, it allows direct calling on GSM/3G networks with USB modems from Huawei and the chan_dongle channel driver. A highly affordable GSM VoIP gateway can be built, using the USB modem as trunk in Asterisk.
You can find complete setup instructions in the documentation section.

A number of interesting applications are possible with this: Least cost routing of course (use the GSM network when it’s cheaper). In remote areas with weak cell phone reception, install the RPi in a location where reception is possible and connect the SIP phones in your house with the RPi. High-gain directional antennas can be connected to some of the USB modems and pointed towards the next cell phone tower, in order to receive weak signals that can’t be received by regular phones anymore. Finally the RPi also makes a good extension to an already existing PBX, enhancing it with GSM gateway capability. With a total power consumption of around 5W for both RPi and the modem, your electricity bill is not streched at all, even if you are only occasionally calling over GSM.

P.S.: If you are interested in this application, you may want to read about this RPi GSM gateway implementation.

83 thoughts on “Calling on GSM/3G Networks

  1. I’m planning to use Raspberry Pi, Asterisk and Huawei 3G USB modem to do this:

    1 Receive a call – no need to answer it
    2. If the call if from a configured caller ID then use GPIO to trigger a relay switch

    How do I go about configuring #2?

  2. Have been having some real issues the last few months with the dongle seem to keep disappearing giving an “all circuits busy now” recording.

    I have pasted the details from CLI below – if anyone could help that’d be great!

    == Using SIP RTP TOS bits 184
    == Using SIP RTP CoS mark 5
    -- Executing [01473123456@from-internal:1] Macro("SIP/1001-0000000a", "user-callerid,LIMIT,") in new stack
    -- Executing [s@macro-user-callerid:1] Set("SIP/1001-0000000a", "AMPUSER=1001") in new stack
    -- Executing [s@macro-user-callerid:2] GotoIf("SIP/1001-0000000a", "0?report") in new stack
    -- Executing [s@macro-user-callerid:3] ExecIf("SIP/1001-0000000a", "1?Set(REALCALLERIDNUM=1001)") in new stack
    -- Executing [s@macro-user-callerid:4] Set("SIP/1001-0000000a", "AMPUSER=1001") in new stack
    -- Executing [s@macro-user-callerid:5] Set("SIP/1001-0000000a", "AMPUSERCIDNAME=1001") in new stack
    -- Executing [s@macro-user-callerid:6] GotoIf("SIP/1001-0000000a", "0?report") in new stack
    -- Executing [s@macro-user-callerid:7] Set("SIP/1001-0000000a", "AMPUSERCID=1001") in new stack
    -- Executing [s@macro-user-callerid:8] Set("SIP/1001-0000000a", "CALLERID(all)="1001" ") in new stack
    -- Executing [s@macro-user-callerid:9] GotoIf("SIP/1001-0000000a", "0?limit") in new stack
    -- Executing [s@macro-user-callerid:10] ExecIf("SIP/1001-0000000a", "1?Set(GROUP(concurrency_limit)=1001)") in new stack
    -- Executing [s@macro-user-callerid:11] GotoIf("SIP/1001-0000000a", "1?continue") in new stack
    -- Goto (macro-user-callerid,s,24)
    -- Executing [s@macro-user-callerid:24] Set("SIP/1001-0000000a", "CALLERID(number)=1001") in new stack
    -- Executing [s@macro-user-callerid:25] Set("SIP/1001-0000000a", "CALLERID(name)=1001") in new stack
    -- Executing [s@macro-user-callerid:26] Set("SIP/1001-0000000a", "CHANNEL(language)=en") in new stack
    -- Executing [01473123456@from-internal:2] Set("SIP/1001-0000000a", "MOHCLASS=default") in new stack
    -- Executing [01473123456@from-internal:3] ExecIf("SIP/1001-0000000a", "1?Set(TRUNKCIDOVERRIDE=07867952292)") in new stack
    -- Executing [01473123456@from-internal:4] Set("SIP/1001-0000000a", "_NODEST=") in new stack
    -- Executing [01473123456@from-internal:5] Gosub("SIP/1001-0000000a", "sub-record-check,s,1(out,01473123456,)") in new stack
    -- Executing [s@sub-record-check:1] GotoIf("SIP/1001-0000000a", "1?check") in new stack
    -- Goto (sub-record-check,s,6)
    -- Executing [s@sub-record-check:6] Set("SIP/1001-0000000a", "__MON_FMT=wav") in new stack
    -- Executing [s@sub-record-check:7] GotoIf("SIP/1001-0000000a", "1?next") in new stack
    -- Goto (sub-record-check,s,10)
    -- Executing [s@sub-record-check:10] ExecIf("SIP/1001-0000000a", "0?Return()") in new stack
    -- Executing [s@sub-record-check:11] GotoIf("SIP/1001-0000000a", "0?out,1") in new stack
    -- Executing [s@sub-record-check:12] Set("SIP/1001-0000000a", "__REC_STATUS=INITIALIZED") in new stack
    -- Executing [s@sub-record-check:13] ExecIf("SIP/1001-0000000a", "0?Set(__REC_POLICY_MODE=)") in new stack
    -- Executing [s@sub-record-check:14] Set("SIP/1001-0000000a", "NOW=1382176632") in new stack
    -- Executing [s@sub-record-check:15] Set("SIP/1001-0000000a", "__DAY=19") in new stack
    -- Executing [s@sub-record-check:16] Set("SIP/1001-0000000a", "__MONTH=10") in new stack
    -- Executing [s@sub-record-check:17] Set("SIP/1001-0000000a", "__YEAR=2013") in new stack
    -- Executing [s@sub-record-check:18] Set("SIP/1001-0000000a", "__TIMESTR=20131019-105712") in new stack
    -- Executing [s@sub-record-check:19] Set("SIP/1001-0000000a", "__FROMEXTEN=1001") in new stack
    -- Executing [s@sub-record-check:20] Set("SIP/1001-0000000a", "__CALLFILENAME=out-01473123456-1001-20131019-105712-1382176632.10") in new stack
    -- Executing [s@sub-record-check:21] Goto("SIP/1001-0000000a", "out,1") in new stack
    -- Goto (sub-record-check,out,1)
    -- Executing [out@sub-record-check:1] ExecIf("SIP/1001-0000000a", "1?Set(__REC_POLICY_MODE=always)") in new stack
    -- Executing [out@sub-record-check:2] GosubIf("SIP/1001-0000000a", "1?record,1(exten,01473123456,1001)") in new stack
    -- Executing [record@sub-record-check:1] Set("SIP/1001-0000000a", "AUDIOHOOK_INHERIT(MixMonitor)=yes") in new stack
    -- Executing [record@sub-record-check:2] MixMonitor("SIP/1001-0000000a", "2013/10/19/out-01473123456-1001-20131019-105712-1382176632.10.wav,,") in new stack
    -- Executing [record@sub-record-check:3] Set("SIP/1001-0000000a", "__REC_STATUS=RECORDING") in new stack
    -- Executing [record@sub-record-check:4] Set("SIP/1001-0000000a", "CDR(recordingfile)=out-01473123456-1001-20131019-105712-1382176632.10.wav") in new stack
    -- Executing [record@sub-record-check:5] Return("SIP/1001-0000000a", "") in new stack
    == Begin MixMonitor Recording SIP/1001-0000000a
    -- Executing [out@sub-record-check:3] Return("SIP/1001-0000000a", "") in new stack
    -- Executing [01473123456@from-internal:6] Macro("SIP/1001-0000000a", "dialout-trunk,6,01473123456,") in new stack
    -- Executing [s@macro-dialout-trunk:1] Set("SIP/1001-0000000a", "DIAL_TRUNK=6") in new stack
    -- Executing [s@macro-dialout-trunk:2] GosubIf("SIP/1001-0000000a", "0?sub-pincheck,s,1()") in new stack
    -- Executing [s@macro-dialout-trunk:3] GotoIf("SIP/1001-0000000a", "0?disabletrunk,1") in new stack
    -- Executing [s@macro-dialout-trunk:4] Set("SIP/1001-0000000a", "DIAL_NUMBER=01473123456") in new stack
    -- Executing [s@macro-dialout-trunk:5] Set("SIP/1001-0000000a", "DIAL_TRUNK_OPTIONS=tm") in new stack
    -- Executing [s@macro-dialout-trunk:6] Set("SIP/1001-0000000a", "OUTBOUND_GROUP=OUT_6") in new stack
    -- Executing [s@macro-dialout-trunk:7] GotoIf("SIP/1001-0000000a", "0?nomax") in new stack
    -- Executing [s@macro-dialout-trunk:8] GotoIf("SIP/1001-0000000a", "0?chanfull") in new stack
    -- Executing [s@macro-dialout-trunk:9] GotoIf("SIP/1001-0000000a", "0?skipoutcid") in new stack
    -- Executing [s@macro-dialout-trunk:10] Set("SIP/1001-0000000a", "DIAL_TRUNK_OPTIONS=") in new stack
    -- Executing [s@macro-dialout-trunk:11] Macro("SIP/1001-0000000a", "outbound-callerid,6") in new stack
    -- Executing [s@macro-outbound-callerid:1] ExecIf("SIP/1001-0000000a", "0?Set(CALLERPRES()=)") in new stack
    -- Executing [s@macro-outbound-callerid:2] ExecIf("SIP/1001-0000000a", "0?Set(REALCALLERIDNUM=1001)") in new stack
    -- Executing [s@macro-outbound-callerid:3] GotoIf("SIP/1001-0000000a", "1?normcid") in new stack
    -- Goto (macro-outbound-callerid,s,6)
    -- Executing [s@macro-outbound-callerid:6] Set("SIP/1001-0000000a", "USEROUTCID=") in new stack
    -- Executing [s@macro-outbound-callerid:7] Set("SIP/1001-0000000a", "EMERGENCYCID=") in new stack
    -- Executing [s@macro-outbound-callerid:8] Set("SIP/1001-0000000a", "TRUNKOUTCID=") in new stack
    -- Executing [s@macro-outbound-callerid:9] GotoIf("SIP/1001-0000000a", "1?trunkcid") in new stack
    -- Goto (macro-outbound-callerid,s,12)
    -- Executing [s@macro-outbound-callerid:12] ExecIf("SIP/1001-0000000a", "0?Set(CALLERID(all)=)") in new stack
    -- Executing [s@macro-outbound-callerid:13] ExecIf("SIP/1001-0000000a", "0?Set(CALLERID(all)=)") in new stack
    -- Executing [s@macro-outbound-callerid:14] ExecIf("SIP/1001-0000000a", "1?Set(CALLERID(all)=07867952292)") in new stack
    -- Executing [s@macro-outbound-callerid:15] ExecIf("SIP/1001-0000000a", "0?Set(CALLERPRES()=prohib_passed_screen)") in new stack
    -- Executing [s@macro-dialout-trunk:12] GosubIf("SIP/1001-0000000a", "0?sub-flp-6,s,1()") in new stack
    -- Executing [s@macro-dialout-trunk:13] Set("SIP/1001-0000000a", "OUTNUM=01473123456") in new stack
    -- Executing [s@macro-dialout-trunk:14] Set("SIP/1001-0000000a", "custom=AMP") in new stack
    -- Executing [s@macro-dialout-trunk:15] ExecIf("SIP/1001-0000000a", "0?Set(DIAL_TRUNK_OPTIONS=M(setmusic^default))") in new stack
    -- Executing [s@macro-dialout-trunk:16] ExecIf("SIP/1001-0000000a", "0?Set(DIAL_TRUNK_OPTIONS=M(confirm))") in new stack
    -- Executing [s@macro-dialout-trunk:17] Macro("SIP/1001-0000000a", "dialout-trunk-predial-hook,") in new stack
    -- Executing [s@macro-dialout-trunk-predial-hook:1] MacroExit("SIP/1001-0000000a", "") in new stack
    -- Executing [s@macro-dialout-trunk:18] GotoIf("SIP/1001-0000000a", "0?bypass,1") in new stack
    -- Executing [s@macro-dialout-trunk:19] ExecIf("SIP/1001-0000000a", "1?Set(CONNECTEDLINE(num,i)=01473123456)") in new stack
    -- Executing [s@macro-dialout-trunk:20] ExecIf("SIP/1001-0000000a", "1?Set(CONNECTEDLINE(name,i)=CID:07867952292)") in new stack
    -- Executing [s@macro-dialout-trunk:21] GotoIf("SIP/1001-0000000a", "1?customtrunk") in new stack
    -- Goto (macro-dialout-trunk,s,25)
    -- Executing [s@macro-dialout-trunk:25] Set("SIP/1001-0000000a", "pre_num=AMP:dongle/dongle0/") in new stack
    -- Executing [s@macro-dialout-trunk:26] Set("SIP/1001-0000000a", "the_num=OUTNUM") in new stack
    -- Executing [s@macro-dialout-trunk:27] Set("SIP/1001-0000000a", "post_num=") in new stack
    -- Executing [s@macro-dialout-trunk:28] GotoIf("SIP/1001-0000000a", "1?outnum:skipoutnum") in new stack
    -- Goto (macro-dialout-trunk,s,29)
    -- Executing [s@macro-dialout-trunk:29] Set("SIP/1001-0000000a", "the_num=01473123456") in new stack
    -- Executing [s@macro-dialout-trunk:30] Dial("SIP/1001-0000000a", "dongle/dongle0/01473123456,300,") in new stack
    [2013-10-19 10:57:13] WARNING[3567][C-00000021]: channel.c:180 channel_request: [dongle0] Request to call on device which can not make call at this moment
    [2013-10-19 10:57:13] WARNING[3567][C-00000021]: app_dial.c:2437 dial_exec_full: Unable to create channel of type 'dongle' (cause 44 - Requested channel not available)
    == Everyone is busy/congested at this time (1:0/0/1)
    -- Executing [s@macro-dialout-trunk:31] NoOp("SIP/1001-0000000a", "Dial failed for some reason with DIALSTATUS = CHANUNAVAIL and HANGUPCAUSE = 44") in new stack
    -- Executing [s@macro-dialout-trunk:32] Goto("SIP/1001-0000000a", "s-CHANUNAVAIL,1") in new stack
    -- Goto (macro-dialout-trunk,s-CHANUNAVAIL,1)
    -- Executing [s-CHANUNAVAIL@macro-dialout-trunk:1] Set("SIP/1001-0000000a", "RC=44") in new stack
    -- Executing [s-CHANUNAVAIL@macro-dialout-trunk:2] Goto("SIP/1001-0000000a", "44,1") in new stack
    -- Goto (macro-dialout-trunk,44,1)
    -- Executing [44@macro-dialout-trunk:1] Goto("SIP/1001-0000000a", "continue,1") in new stack
    -- Goto (macro-dialout-trunk,continue,1)
    -- Executing [continue@macro-dialout-trunk:1] GotoIf("SIP/1001-0000000a", "1?noreport") in new stack
    -- Goto (macro-dialout-trunk,continue,3)
    -- Executing [continue@macro-dialout-trunk:3] NoOp("SIP/1001-0000000a", "TRUNK Dial failed due to CHANUNAVAIL HANGUPCAUSE: 44 - failing through to other trunks") in new stack
    -- Executing [continue@macro-dialout-trunk:4] Set("SIP/1001-0000000a", "CALLERID(number)=1001") in new stack
    -- Executing [01473123456@from-internal:7] Macro("SIP/1001-0000000a", "outisbusy,") in new stack
    -- Executing [s@macro-outisbusy:1] Progress("SIP/1001-0000000a", "") in new stack
    -- Executing [s@macro-outisbusy:2] Playback("SIP/1001-0000000a", "all-circuits-busy-now,noanswer") in new stack
    -- Playing 'all-circuits-busy-now.ulaw' (language 'en')
    == Spawn extension (macro-outisbusy, s, 2) exited non-zero on 'SIP/1001-0000000a' in macro 'outisbusy'
    == Spawn extension (from-internal, 01473123456, 7) exited non-zero on 'SIP/1001-0000000a'
    -- Executing [h@from-internal:1] Hangup("SIP/1001-0000000a", "") in new stack
    == Spawn extension (from-internal, h, 1) exited non-zero on 'SIP/1001-0000000a'
    == MixMonitor close filestream (mixed)
    == End MixMonitor Recording SIP/1001-0000000a
    [2013-10-19 10:57:27] WARNING[2924]: chan_sip.c:4169 retrans_pkt: Retransmission timeout reached on transmission 0009b781-3ebd000a-62559e5d-6d206cff@192.168.0.5 for seqno 102 (Critical Response) -- See https://wiki.asterisk.org/wiki/display/AST/SIP+Retransmissions
    Packet timed out after 13121ms with no response

    • When issuing

      dongle show devices

      on the Asterisk CLI, does it show the dongle is registered properly?

  3. can you please help me with the dongle installation.
    i was using the following guide:
    http://www.andrius.mobi/2013/03/asterisk-on-raspberry-pi-as-gsm-gateway.html
    in the following step:
    # download and install chan_dongle
    wget https://github.com/jstasiak/asterisk-chan-dongle/archive/asterisk11.zip
    unzip asterisk11.zip
    cd asterisk-chan-dongle-asterisk11/
    aclocal
    autoconf
    automake -a
    ./configure
    make all
    make install
    cp etc/dongle.conf /etc/asterisk/

    not able to move forward because of the make install command

  4. Hi everybody.
    I have a little problem with my 3G dongle Huawei E171.
    It work’s fine with asterrisk 1.6 + chan_dongle in my ASUS WL-500Gp v2 router but now I try to configure my RaspberryPi for Asterisk.
    So here is a problem – My RaspberryPi reboots when an incoming call. And I can’t see any problem in logs because it reboots (((((
    Could somebody help with this?

    • This is a power problem. Please read the documentation here, section troubleshooting power problems. Your modem draws too much power during a call and the RPi’s voltage drops below a critical level.

      • Thank you! It’s really was a problem in USB-hub. I’m changed it to new one and now 3G-dongle working fine.

  5. I have this running now from my Pi using an E160 dongle that I re-flashed with the current firmware and then enabled voice on.

    As part of our PBX, all calls need to go out as withheld (blocked, etc…). At the moment the call goes out with the mobile number. I have tried using calledid and it still shows the mobile number. I’ve also tried various combinations of blocked, unavailable, withheld, none, etc…

    Any suggestions as I cannot use this fully until this has been sorted.

    Cheers!

    • Have a look at this comment. You should also be able to set anonymous calling directly in the network.

        • I don’t suppose it is possible to use a did number as the caller id for the dongle? We have a few different did’s that come in. I’d like to set it so certain extensions call out with the outbound called id as 1 did and other extensions use another did number.

          • This is unfortunately not possible. The cell phone providers only allow sending the own phone number as caller id or blocking it (calling anonymously).

  6. Can someone please help make head and tails of this error:

    [2013-06-23 10:34:37] WARNING[7185][C-0000003a] pbx.c: Channel ‘Dongle/dongle0-0100000008’ sent to invalid extension but no invalid handler: context,exten,priority=from-trunk-dongle,+XXXXXXXXXXXX,1

    I’ve checked the incoming routes and all extensions/misc destinations but I can’t seem to find the one that’s creating the error.

    • Got it…

      Been wondering what’s the purpose of these two lines…

      exten => _.,1,Set(CALLERID(name)=${CALLERID(num)})
      exten => _.,n,Goto(from-trunk,${EXTEN},1)

      Logs report a warning:

      [2013-06-23 17:36:28] WARNING[3646] pbx_config.c: The use of ‘_.’ for an extension is strongly discouraged and can have unexpected behavior. Please use ‘_X.’ instead at line 10 of /etc/asterisk/extensions_custom.conf
      [2013-06-23 17:36:28] VERBOSE[3646] pbx.c: — Added extension ‘_.’ priority 1 to from-trunk-dongle
      [2013-06-23 17:36:28] WARNING[3646] pbx_config.c: The use of ‘_.’ for an extension is strongly discouraged and can have unexpected behavior. Please use ‘_X.’ instead at line 11 of /etc/asterisk/extensions_custom.conf

      so I changed it accordingly… that was the source of the error.

      Remind me not to follow blindly all warnings… 🙂

      Thanks

      • This is a feature requested by another user some time ago. 🙂 Seems like it doesn’t work when using _X. instead…

  7. Can someone help me with installing 2 GSM dongles?

    this is what my dongle.conf looks like
    ; dongle required settings
    [dongle0]
    audio=/dev/ttyUSB1 ; tty port for audio connection; no default value
    data=/dev/ttyUSB2 ; tty port for AT commands; no default value

    [dongle3]
    audio=/dev/ttyUSB4 ; tty port for audio connection; no default value
    data=/dev/ttyUSB5 ; tty port for AT commands; no default value

    dongle3 seems to work fine, however dongle0 wont receive inbound calls,

    • Also here, please have a look at the logs as soon as the call comes in. You can also post your log in the forums.

      • Gernot,
        Nevermind, I got myself another dongle that works just fine, i dont think that the E180 supports voice calls.
        Thanks

  8. I found this script to another pbx, altered to make it work in rasppbx honestly do not know if opensource

    • Thank you very much for your script, it works perfect! Is this script open source, and if yes can it be included in RasPBX?

      • I found this script to another pbx, altered to make it work in raspbx honestly do not know if opensource.
        For me it should be included in raspbx.

        • * This product is solely a private production of the above named
          * author, and is neither endorsed nor supported by Eternal Works.
          * Although this product has been thuroughly tested, it is
          * distributed AS IS, and the author assumes no liability for any
          * damages this script may cause to your system. The author
          * has provided full source code and encourages you to review the
          * source code to determine any effects it may have on your system.
          *
          * (c) Copyright 2011, Troy A Nahrwold, Eternal Works, LLC.
          * All Rights Reserved.

        • Ok great! I do want to include this with RasPBX, but I think some sort of password protection should be in there, otherwise everyone on the local network can reach it.

          • yes just put this folder inside the “modules” and put script from password protection

  9. I have a problem with DISA callthrough service. I can call the mobile inbound number, than i get dial tone, dial the destination number, it rings on the other side, and if the called phone just wants to decline the call, it is impossible, it will ring and ring, if i end the call on the calling mobile, the call will be ended. What is wrong?

  10. Pingback: Calling on GSM/3G Networks | Asterisk for Raspb...

  11. hi, with hawei dongle i used raspbx and followed instruction and it works out box, only have to run dongle install, now i want to transfer all incoming call to skype account, can anyone help me with step by step instruction for skype to work.

  12. Hi there,

    Does anyone already forge an SMS by replacing sender phone number by another number ? I would like to use this to do a “forward” of incoming SMS to my another mobile phone and display the original sender phone number and not my SIM number inside the dongle.

    Is that possible ?

    Thanks in advance,
    Benjamin

    • This is not possible as the carrier is forcing the sender CID to the number of your SIM. You cannot override this number. The only possible way is to add the sender CID inside the SMS text. As long as the SMS text is shorter than 160-sendercid characters this should work. Requires some tweaking however in the SMS processing dialplan…

      • That’s a really bad news for me.

        I just wonder how some companies find a way to provide such a service : a web interface with in particular a field to fill with the sender phone number.

        Thank you anyway for your answer.

    • Thanks for letting us know! I’ve read your blog before, you are probably one of the first who made chan_dongle work on the RPi. Congratulations! 🙂

  13. Hi all! i have Hackberry (https://www.miniand.com/products/Hackberry%20A10%20Developer%20Board) and i want do the same (install asterisk+dongle). I was install Asterisk 1.8.13.1~dfsg-3 from repo and compile dongle from source. compiling had several mistakes, but i am ignore that and when load module chan_dongle have warning WARNING[26056]: chan_dongle.c:232 opentty: tcgetattr() failed for /dev/usbdev1.1: Inappropriate ioctl for device.
    who have any idea please write, thanks a lot.
    P.S. sory, if i take mistakes in my post 😉

    • I’ve not been using Asterisk from the Raspbian repository, instead compiled it myself. On top, I’m using Asterisk 11 and a modified chan_dongle for Asterisk 11.
      Maybe you can get more help on the original chan_dongle forum.”

  14. Do I need apt-utils for any reason?
    Can I install more applications of my own choice without disrupt the default settings for Astrisk?

    • Apt-utils is not really required. You can use apt-get to install additional software in the same way as on the official Raspbian image. Installing additional software does not disrupt the Asterisk settings.

  15. There is a fix who i want to talk about. Looking at the guides to make 3g dongles working on linux, most of times is suggest, and required, to push an AT Command who disable CDRom automated mount to get dongle recognized correctly and working on asterisk. Now, this is not so true, there is another less risky way.
    I wrote a guide to make it possible:
    # apt-get install usb-modeswitch usbutils
    #nano /etc/usb_modeswitch.d/12d1:1446
    and copy this configuration in: (i have an E1692, if u have another key get correct configuration here: )
    # Huawei E1692
    DefaultVendor= 0x12d1
    DefaultProduct= 0x1446

    TargetVendor= 0x12d1
    TargetProduct= 0x140c

    MessageContent=”55534243000000000000000000000011060000000000000000000000000000″

    CheckSuccess=5

    Now you have to add a rule in /etc/udev/rules.d/ creating 50-huawei-e1552.rules filename. Now add these text into that file:

    SUBSYSTEM==”usb”,
    ATTR{idVendor}==”12d1″,
    ATTR{idProduct}==”1446″,
    RUN+=”usb_modeswitch ‘%b/%k”

    NOW,REBOOT THE WHOLE SYSTEM!!!!!
    # reboot

    On next reboot you can see by lsusb changing in a product ID, in fact, all Huawei keys are recognized as 12d1:1446 and now mine is recognized because of usb-modeswitch as 12d1:144c where 144c wich is modem ability, not CDRom issue anymore!! 😉

    • Known issue:
      Using that guide all ttyUSB are enabled
      ls -l /dev/ttyUSB*
      but asterisk have no rights to use that devices.

      Fix:
      execute a chmod 777 /dev/ttyUSB* and asterisk starts to working like a charm.
      But i have to run chmod for every reboot on a system.
      If someone know how to solve that, is welcome 😀

    • Are you absolutely sure it doesn’t work without usb_modeswitch? Most modems (like the E169) are working perfectly fine also without usb_modeswitch. If yours is an exception I can add this to the instructions.

      • Abt 1° Comment:
        Yes, i used install-dongle script and asterisk have rights only with chmod 777 but as i said, logically, rights were lost on every reboots.
        i’ll try to add asterisk user to a right group, because as i saw (i’m not with rpi now) ttyUSB* are owned by another user (not root).

        I used install-dongle script either before or after my guide, in both cases results is the same!

        Abt 2° Comment:
        Yes, i’m absolutly sure, i don’t know if my dongle model is an exeption or not, anyway its common that kind of “trick” to switch usb dongles to get working as modem in *nixes distros.
        Gernot, feel free to use what i said there, if you want extend it to others dongles by parameters in the install-dongle script 🙂

        • Thank you very much for all the detailed information! I will add this to the install-dongle script and the documentation soon. I will also have a look at the permission issue.

        • The permissions issue can be solved by renaming the file /etc/udev/rules.d/99-permissions.rules to /etc/udev/rules.d/30-permissions.rules
          Installing usb_modeswitch disabled this file, that’s why you had the permissions problem.

          I also had a closer look at usb_modeswitch: From what I’ve learned it is not required to manually create the files /etc/usb_modeswitch.d/12d1:1446 and 50-huawei-e1552.rules because the right configuration is already contained in usb_modeswitch by default. Could you remove those 2 files, reboot and report if it is still working?

          • Thank you for the tip
            I’ll try ASAP (give me 2 days) both cases and i will let u know here 🙂

  16. Hi guys,
    i have managed to establish successfull calls (both originating and terminating) with the above setup. Can you please guide me on what needs to be administered for USSD/SMS to work. Currently, an SMS or USSD reply are being received by my SIP soft client as voice calls.

    • To receive SMS make the following changes:
      Edit /etc/asterisk/dongle.conf and change the line context=from-trunk to

      context=from-trunk-dongle

      Then edit the file /etc/asterisk/extensions_custom.conf and add these lines

      [from-trunk-dongle]
      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 => _.,1,Set(CALLERID(name)=${CALLERID(num)})
      exten => _.,n,Goto(from-trunk,${EXTEN},1)

      Received SMSes will be stored in /var/log/asterisk/sms.txt
      It is of course also possible to forward the sms by email or to send it to a text message capable SIP phone.

      • Hi Gernot… would it not be too much to ask if I’ll request for you to post a sample dialplan on how to forward received sms to another mobile? Seems that features such as this were being developed for chan_datacard before (zMessage, if I remember correctly) but there’s very few documentation and most links are now defunct.Thank you very much in advance.

        • I will have a look at this and let you know. It will require a bit of time…

          • Thanks as always, anyway, here’s what I’ve done so far….
            I added this as a second line to your dial plan as above…

            exten => sms,n,System(dongle sms dongle0 +XXXXXXXXXXXX From:${CALLERID(num)} Msg:${BASE64_DECODE(${SMS_BASE64})})

            but I get error saying:

            [2013-06-14 12:31:23] WARNING[31860][C-00000041] app_system.c: Unable to execute ‘dongle sms dongle0 +XXXXXXXXXX From:+XXXXXXXXXX Msg:testing 123’

            however, when I try to send:

            CLI > dongle sms dongle0 +XXXXXXXXXX From:+XXXXXXXXXX Msg:testing 123

            I receive the message…

          • Just after posting I realized a mistake…

            the call to dongle sms has to be

            exten => sms,n,System(asterisk -rx “dongle sms dongle0 +XXXXXXXXXXXX From:${CALLERID(num)} Msg:${BASE64_DECODE(${SMS_BASE64})})”

            no errors but sms still not sent.

      • sorry if this can be construed as flooding… just being excited… after further reading, I realized that the command to send sms within the dial plan is different… so I changed it to:

        exten => sms,n,DongleSendSMS(dongle0, destination #, message.

        changed it accordingly and received the message.

        will update what would be the result with long messages and what happens when a call on the same dongle is in progress…

        again, my apologies for flooding..

        • No problem, you’re not flooding! 🙂 Great you’ve found it. I still didn’t get a chance to look at this myself, but hopefully will be able to do so soon.

        • I’ve check this myself and it works perfectly fine, exactly as you wrote it! Thanks a lot for your hint. You need to add this line

          exten => sms,n,DongleSendSMS(dongle0,+123456789,${BASE64_DECODE(${SMS_BASE64})} - from ${CALLERID(num)})

          To /etc/asterisk/extensions_custom.conf directly before the line

          exten => sms,n,Hangup()

          Replace +123456789 with your destination mobile number. Incoming SMSs will be forwarded to this number.

          • Glad you’ve verified it… the following caveat applies though:

            1. Messages longer than 160 characters are cut-off.
            2. When the dongle is being used, i.e. during a call, and sms comes in, it sending would still commence but would result in error. Dunno if it’s a protocol, telco or design limitation.

          • Im trying to set this up so the dongle can forward any received msg to my number, this is what i have in the extentions_custom.conf:
            exten => sms,n,DongleSendSMS(dongle0,+29391241030,${BASE64_DECODE(${SMS_BASE64}$
            exten => sms,n,Hangup()
            exten => _.,1,Set(CALLERID(name)=${CALLERID(num)})
            exten => _.,n,Goto(from-trunk,${EXTEN},1)

            I’ve sent a couple of msgs to my dongle but didnt receive anything. what am i doning wrong?

          • Can you have a look at the logs to see what’s happening there? You can also post your log at pastebin or in the forums.

          • /var/log/asterisk/full or run asterisk -rvvvvv
            But please don’t spill the comments, use pastebin or move over to the forums.

      • Hi,
        Would like to request your assistance on how to forward Received SMSes stored in /var/log/asterisk/sms.txt
        to a text message capable SIP phone.

        thanks in advance

  17. Hi

    Does the image have iptables and things for security, i wouldnt mind changing our tower system over to a Pi but has we have been hacked once with our old system..

    • Iptables are installed of course. Fail2ban is available as well to effectively block intruders, see the documentation here. Besides this, the RPi should be kept behind a router with all ports closed. Port forwarding should only be used for RTP ports. An exception can be made for the SIP ports if remote extensions are required.
      If you follow the general security tips (see Razvan’s tutorial) you should be pretty safe.

  18. Is possible to do something like to this, but instead of redirecting directly the call, you call gsm gateway and make calls via sip? like using a local cellphone number to call the world using cheap voip calls

    • Yes this is possible. You can call the SIM card number, get a dialtone on the other side, and dial your destination with DTMF tones. The call can then be placed through any sip provider. (Check for the DISA module in FreePBX)

  19. An alternative to uploading through the web GUI is to just copy the files over to the rPi using scp. WinSCP is reported to be a good client for Windows, or you can use scp at the command line on Mac or *nix. Once you’ve got the files on the Pi, copy them to /var/lib/asterisk/moh/ and you’ll be set.

  20. Hi there,

    I’m having problems uploading Hold music through freepbx. The error says that the filesize has exceeded the maximum file size in etc/php.ini. There isn’t any php.ini there but there is on at /etc/php5/apache2/php.ini and also in another in another folder in /etc/php5. I changed it from 2M to 20M but I can’t upload a file more than 2M.

    Any ideas?

    Thanks.

    • You have already found the right place. Edit the file /etc/php5/apache2/php.ini and set

      upload_max_filesize = 20M

      and also

      post_max_size = 20M

      After this you need to restart Apache:

      service apache2 restart

      This has worked perfectly for me.

      • Hi,

        I changed the file size in /etc/php5/apache2/php.ini and /etc/php5/cli/php.ini to 20M but it still shows error: PHP Error Processing World Mix.wav! Check upload_max_filesize in /etc/php.ini

        Any ideas?

        Thanks

        • Did you also set post_max_size to 20M? I have tried this and it definitely worked for me. Have a look at the Apache log file /var/log/apache2/error.log, maybe you can find a more detailed error message there.

          • Seem to have gotten it now. Changed it to 2000M, file was larger than 20M.

            Thanks again 🙂