OpenWrt Forum Archive

Topic: [How To] Asterisk 11+GSM/SMS channel+Google Voice+OpenWRT SIP Client

The content of this topic has been archived between 25 Apr 2018 and 5 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

nague wrote:

I'm trying to use chan_dongle on Barrier Breaker, my chipset’s router is AR71xx so I hope the one way issue is not present… but I have some doubts.

My dongle is Huawei E180. Voice is enable. And I’m using a powered USB Hub.

At time this time, I’m having two issues with outgoing calls (incoming not tested yet):

-    The dongle stuck on Dialing state each time I want to make a call… until a dongle reset
-    I can hear from the GSM => VoIP (even if the dongle is in the Dialing state), but not in the other side

Any idea to help me?

-    I can hear from the GSM => VoIP (even if the dongle is in the Dialing state), but not in the other side

this is the one-way audio issue I mention before.

As far as I know E180 is compatible with chan_dongle but it seems that chan_dongle module has been recently changed in Openwrt, the one-way audio issue is now always present in all B.B. versions, same with C.C.

(Last edited by pilovis on 21 Feb 2015, 17:13)

It should be the same issue. I am still trying to find out what is causing this, but I have not been succesfull in fixing it yet. If anyone will find out what is causing this issue, please, let me know. I will immediately merge the patch.

Thanks pilovis for all the work you've put into writing this guide!
As you mention, the official Asterisk guide on the wiki is still for 1.8 and your guide covers version 11. What's your impression after doing all the stuff you did - is version 11 working all fine in OpenWRT or is 1.8 better for some use cases?
Also, did you try out any admin GUIs?

mikewse wrote:

Thanks pilovis for all the work you've put into writing this guide!
As you mention, the official Asterisk guide on the wiki is still for 1.8 and your guide covers version 11. What's your impression after doing all the stuff you did - is version 11 working all fine in OpenWRT or is 1.8 better for some use cases?
Also, did you try out any admin GUIs?

Honestly I don't know which of the two versions is better, I tested both and both have worked very well on my OpenWRT routers.
My main PBX instead uses a real PC with Ubuntu server 10.04 32 bits and Asterisk 1.6.2.4 + FreePBX 2.8.1.5.

I tried Asterisk Gui but I don't like it at all, I prefere using FreePBX, but unfortunately it doesn't work on Openwrt, it is too heavy.

(Last edited by pilovis on 2 Apr 2015, 13:08)

slachta wrote:

It should be the same issue. I am still trying to find out what is causing this, but I have not been succesfull in fixing it yet. If anyone will find out what is causing this issue, please, let me know. I will immediately merge the patch.

It seems that some USB2 ports on some routers do not really handle 500 mA as required on USB2 specifications, some dongles need 500 mA or a little bit more current, this might cause the 'one way audio' problem.
I tested a GSM dongle on a PC with USB1.1 port (100 mA max) and I had the same issue.

(Last edited by pilovis on 2 Apr 2015, 13:20)

Did you have good experience with the QoS setup? I'm getting a Cisco SPA3102 for the FXS/FXO ports and it seems this device has QoS capabilities as well. I'd like to lose as little bandwidth as possible while not in a call and if this throttling works fine in OpenWRT I prefer to use that (I also notice there is a Network > SQM QoS module with more settings).

My SIP and Google Voice accounts were hacked because of this thread, I forgot to remove login data of my accounts when I put the configuration files available as examples (my fault).

The configuration files examples are not more avaible, for safety I removed all files.

I have all the numbers called from my hacked acconts and the originating IP addresses , I informed the Police.

(Last edited by pilovis on 13 Apr 2015, 05:49)

slachta wrote:

It should be the same issue. I am still trying to find out what is causing this, but I have not been succesfull in fixing it yet. If anyone will find out what is causing this issue, please, let me know. I will immediately merge the patch.

Today I've tried again the chan_dongle module, and surprisingly, without doing any modification it is working now!
I am sure it didn't work a month ago on the same hardware with the same configuration, I had the one way audio issue described here: https://code.google.com/p/asterisk-chan … ail?id=112 yikes

pilovis wrote:
slachta wrote:

It should be the same issue. I am still trying to find out what is causing this, but I have not been succesfull in fixing it yet. If anyone will find out what is causing this issue, please, let me know. I will immediately merge the patch.

Today I've tried again the chan_dongle module, and surprisingly, without doing any modification it is working now!
I am sure it didn't work a month ago on the same hardware with the same configuration, I had the one way audio issue described here: https://code.google.com/p/asterisk-chan … ail?id=112 yikes

It seems that to solve this problem you have to insert the following two lines in /etc/asterisk/modules.conf:

noload => res_timing_pthread.so
noload => res_timing_timerfd.so

but by doing this the Music On Hold becomes jerky on SIP channels (MOH seems OK on dongle channel) hmm  sad

If you use "load => res_timing_pthread.so", SIP channels are OK but Chan_dongle has one way audio with high noise on the other channel,
with "load => res_timing_timerfd.so" SIP channels are OK but Chan_dongle has one way audio with no audio on the other channel.

(Last edited by pilovis on 23 May 2015, 17:12)

Since I was able to make chan_dongle working on OpenWRT B.B., I want to post some useful commands:

To send a SMS from shell:

/usr/sbin/asterisk -rx 'dongle sms dongle0 number message'

example:

/usr/sbin/asterisk -rx 'dongle sms dongle0 +393711734567 test message'


bash:
#!/bin/sh
asterisk -rx 'dongle sms dongle0 +393711734567 test message'

Perl:
#!/usr/bin/perl
system qq(asterisk -rx 'dongle sms dongle0 +393711734567 test message')


-----------------------------------------------------------------
Chan_dongle configuration example for Huawei E169
-----------------------------------------------------------------

/etc/asterisk/extensions.conf:

[from-internal]
; extension 100 - rings for 30 seconds
exten => 100,1,Dial(SIP/100,30)
exten => 100,2,Hangup()
; dial out
exten => _1NXXNXXXXXX,Dial(dongle/dongle0/${EXTEN})
[from-pstn]
; incoming
exten =>
+393711734567,1,Answer()
exten =>
+393711734567,2,Dial(SIP/100,30)
exten =>
+393711734567,3,Hangup()

/etc/asterisk/dongle.conf:

[general]
interval=15
[defaults]
context=from-pstn
group=1
rxgain=0
txgain=0
autodeletesms=yes
resetdongle=yes
u2diag=-1
usecallingpres=yes
callingpres=allowed_passed_screen
disablesms=no
language=it
smsaspdu=yes
mindtmfgap=45
mindtmfduration=80
mindtmfinterval=200
callwaiting=auto
disable=no
initstate=start
exten=
+393711734567
dtmf=relax
[dongle0]
audio=/dev/ttyUSB1
data=/dev/ttyUSB2
imei=123456789012345
imsi=123456789012345

/etc/asterisk/modules.conf:

[modules]
autoload=yes
noload => res_timing_pthread.so
noload => pbx_gtkconsole.so
noload => res_musiconhold.so
noload => chan_alsa.so
noload => chan_console.so
noload => pbx_ael.so
load => pbx_spool.so
noload => chan_motif.so
noload => res_timing_timerfd.so
load => chan_dongle.so
noload => chan_iax2.so

/etc/asterisk/sip.conf:

[general]
transport=udp
bindport=5060
bindaddr=0.0.0.0
nat=force_rport,comedia
language=en
allowguest=no
srvlookup=no
disallow=all
allow=ulaw
allow=alaw
allow=gsm
dateformat=%F %T
alwaysauthreject=yes
localnet=192.168.1.0/255.255.255.0
localnet=127.0.0.0/255.255.255.0
localnet=10.0.0.0/255.255.255.0
;tcpbindaddr=0.0.0.0
;tcpenable=yes

[100]
user=100
type=friend
secret=
Change_Me!
host=dynamic
qualify=yes
nat=force_rport,comedia
insecure=invite,port
context=from-internal

(Last edited by pilovis on 23 May 2015, 15:50)

Forward any SMS received through "chan_dongle" to email:

edit "/etc/asterisk/extensions.conf" and add the following:

[from-pstn]
;
; SMS 2 email ; it needs mini_sendmail and asterisk11-func-base64 installed
;
exten => sms,1,Noop(Incoming SMS from ${CALLERID(num)} ${BASE64_DECODE(${SMS_BASE64})})

exten => sms,2,System(echo 'From: ${CALLERID(num)} <sender@domain.com>\nTo: <myself@domain.com>\nSubject:Received SMS\nfrom: ${CALLERID(num)}\n${BASE64_DECODE(${SMS_BASE64})}' >> /var/log/asterisk/sms.txt)
exten => sms,3,System(/usr/sbin/mini_sendmail -fsender@domain.com -ssmtp.server.com -p25 myself@domain.com < /var/log/asterisk/sms.txt)
exten => sms,4,System(rm -f /var/log/asterisk/sms.txt)
exten => sms,5,Hangup()

Notes:
the line in red is a single line!
-ssmtp.server.com is the SMTP server and need to be adapted to your parameters, -p25 is the SMTP port, example:
if your server is relay.post.com, then use: -srelay.post.com -p25

usage:
mini_sendmail -f(sender) -s(SMTP) -p(port) (recipient)

(Last edited by pilovis on 23 May 2015, 17:16)

Web page to send SMS from OpenWRT (B.B.) using Asterisk11+Chan_dongle:


1) Install PHP:
opkg update
opkg install php5 php5-cgi

2) create /www/sms directory
mkdir /www/sms

3) create index.php file
nano /www/sms/index.php
(or vi /www/sms/index.php if you don't have nano installed)

insert the following lines:

<?php
/************************************************** *******************
* Chan_Dongle SMS Script v.0.01
* for The Raspberry Asterisk
*
* Author: Troy Nahrwold
* Email: Troy(at)eternalworks(dot)com
* Company: Eternal Works
* Website: www.eternalworks.com
*
* Disclaimer:
* 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.
*
* ITALIAN/OPENWRT VERSION BY: pilovis
* EVENTUALLY EDIT THIS FILE TO CHANGE DESCRIPTIONS FROM ITALIAN TO YOUR LANGUAGE
************************************************** *******************/
$dongle = "dongle sms dongle0 ";
$ini = "'";
if(isset($_REQUEST['phonenumbers']) && !empty($_REQUEST['phonenumbers']) && !empty($_REQUEST['message']))
{
$message = substr($_REQUEST['message'],0,160);
$phonenumberarray1 = explode(' ',$_REQUEST['phonenumbers']);
foreach ($phonenumberarray1 as $phonenumber)
{
}
$output = "Testo: $message<br><br>\n";
{
$runcommand = '/usr/sbin/asterisk -rx' . $ini . $dongle . $phonenumber . " " . $message . $ini;
$output .= "Invio messaggio a: $phonenumber<br>\n";
exec($runcommand);
}
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>SMS Messaging for Asterisk</title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<script type="text/javascript">
/**
**/
function countChar() {
//
var count_char_textarea = document.getElementById("message");
// count_char_textarea.value = count_char_textarea.value.length;
var char_length = document.getElementById("char_length");
//
if ( count_char_textarea.value.length > 160 ) {
count_char_textarea.value = count_char_textarea.value.substr(0, 160);
}
char_length.innerHTML = count_char_textarea.value.length;
}
</script>
<hr>
<body bgcolor="#84b0fd" text="#030303" link="#9abcde">
<a href="./index.php"><h2 align="center"></h2></a>
<table border="0" cellspacing="0" cellpadding="1" width="600" bgcolor="#ffffff" align="center">
<tr>
<td>
<table border="0" cellspacing="0" cellpadding="3" width="100%" bgcolor="#ffffff" align="center">
<tr bgcolor="#abcdef">
<td><b><?php echo $output; ?></b></td>
</tr>
<tr><form action="index.php" method="post">
<p><b>Numero di cellulare:</b> <br><font size="-2">(Formato: +39XXXXXXXX)</font></p>
<textarea id="phonenumbers" name="phonenumbers"></textarea>
<p><b>Testo del messaggio:</b> <br> <font size="-2">(Massimo 160 caratteri, se superiore il messaggio verra' troncato) </font></p>
<textarea id="message" name="message" size="160" rows="6" cols="30" onchange="countChar()" onkeyup="countChar()"></textarea><br /><br/>
<font size="2">conteggio caratteri del messaggio: <span id="char_length"> 0 </span></font>
<p>
<button type="submit">Invia Messaggio</button><br /><br />
</form></tr>
</table>
</dd>
<p></td>
</tr>
<tr>
<td bgcolor="#ffffff"><a href="javascript:history.back()">Invia lo stesso messaggio ad altro numero</a></td>
</tr>
</table>
</td>
</tr>
</table>
<p>
</td>
</tr>
</table>
<hr>
</body>


4) test the page at http://your_IP_address/sms/


5) protect the page with a password

Basic Authentication on uhttpd, to add a password to uhttpd (global web page access) use the following commands:

uci set uhttpd.main.config=/etc/httpd.conf
uci commit uhttpd
echo "/:root:password" > $(uci get uhttpd.main.config)
/etc/init.d/uhttpd restart

change password as you desire, user is root (note that this is not the "root user" of OpenWRT)

(Last edited by pilovis on 23 May 2015, 17:04)

To improve a little bit the efficency of Asterisk11 + Chan_dongle on Openwrt there are some configuration modifications to do:

In "asterisk.conf" add the following line under [options]:

internal_timing = yes

the "modules.conf" file should be modified as per the following:

[modules]

; notes:
; noload => disable a module
; load => enable a module

autoload=yes

noload => res_timing_pthread.so ; never enable it when using chan_dongle
noload => pbx_gtkconsole.so
noload => res_musiconhold.so ; you shouldn't use music on hod with chan_dongle because of choppy audio
noload => chan_alsa.so
noload => chan_console.so
noload => pbx_ael.so
load => pbx_spool.so
noload => chan_motif.so ; enable it only if you have an active Google voice account
noload => res_timing_timerfd.so ; never enable it when using chan_dongle
load => chan_dongle.so ; if you don't use chan_dongle, disable this and enable res_timing_timerfd.so
noload => chan_iax2.so
noload => codec_ilbc.so
noload => codec_lpc10.so
noload => skipping codec_lpc10.so
noload => codec_speex.so
noload => app_adsiprog.so
noload => app_db.so
noload => chan_skinny.so
noload => cdr_csv.so
noload => res_adsi.so
noload => res_agi.so

(Last edited by pilovis on 9 Jun 2015, 16:35)

Say current date and time to the caller

install zoneinfo-core:

opkg update
opkg install zoneinfo-core
opkg install zoneinfo-europe

Insert the following lines in "extensions.conf":

[from-internal]

; say current Date & Time
exten => 161,1,SayUnixTime(,CET,AdbYkM)
exten => 161,2,Wait(2)
exten => 161,3,Hangup()

note: change CET with your timezone (ex.: GMT, EST, UTC, etc.).

Restart asterisk:

/etc/init.d/asterisk restart

To test it dial 161.

(Last edited by pilovis on 12 Nov 2015, 09:20)

Hi...
Great work done...Thx for sharing...
I have a question, why you are not using asterisk as sip client it supports same answering and dialling.
And did you ever tried video with baresip ? My audio is working fine but with video I always get problems or asterisk is telling me that video stream is ignored because port is zero or some other random errors .

Several issues about SMS...

What about merging long SMS? Each part of the message is sent as a single email.

${CALLERID(num)} displays literals sender name as a sequence like AC4#9#A*#410
Any idea how to show alphanumeric sender?

Hi pilovis!

Thank you for your hard work sharing your Asterisk knowledge!

I'd like tu use an old Fastweb router as PBX to make 1 (maximum 2) contemporary calls using a HT-503 as FXO trunk.

The router is a F226M FWB with 16 MB of flash memory and 64 MB of RAM, with a broadcom SoC 6358 (such as the first Vodafone Station you used for the old AA project).
https://www.ilpuntotecnicoeadsl.com/wik … -8-X-B-FWB

Is it capable to use a compressed codec such as ILBC? I'd like to use it to make calls from outside, trough my OpenVPN on the smartphone, using the PSTN line via the HT-503.

PS I know the are newer cheap routers, but I've plenty of Fastweb routers to use before to buy others...
PPS What about this project?
https://github.com/pgid69/bcm63xx-phone

(Last edited by varma on 4 Sep 2015, 17:25)

varma wrote:

Hi pilovis!

Thank you for your hard work sharing your Asterisk knowledge!

I'd like tu use an old Fastweb router as PBX to make 1 (maximum 2) contemporary calls using a HT-503 as FXO trunk.

The router is a F226M FWB with 16 MB of flash memory and 64 MB of RAM, with a broadcom SoC 6358 (such as the first Vodafone Station you used for the old AA project).
https://www.ilpuntotecnicoeadsl.com/wik … -8-X-B-FWB

Is it capable to use a compressed codec such as ILBC? I'd like to use it to make calls from outside, trough my OpenVPN on the smartphone, using the PSTN line via the HT-503.

PS I know the are newer cheap routers, but I've plenty of Fastweb routers to use before to buy others...
PPS What about this project?
https://github.com/pgid69/bcm63xx-phone

I think the F226M FWB should work well with Asterisk, Asterisk needs at least 32 Mbytes to work smoothly on OpenWRT.
About the ILBC codec, I've never tried it.
If you want to use a smartphone as a Voip client, I would suggest you use a IAX2 channel with gsm codec.
About the bcm63xx-phone project, I don't have time to compile the code, but honestly I don't understand why the author has not published the compiled driver yet.

(Last edited by pilovis on 7 Sep 2015, 10:33)

thank you!
I installed the 12.09 version because in the newer versions the package luci-app-pbx dependencies' couldn't resolve.
but in this version there are codec packages only for uLaw and aLaw...not big problem.

is possible to add a FXO gateway (with a SPA3000 or HT-503) using the "SIP Account" tab? Or I need to set it manually in conf files?

could you please send me a private message with the templates you removed for security reason?

PS. in PM you should reply in Italian, to better communicate wink

pilovis, thanks for your post about baresip in openwrt.
Have someone tried to configure video broadcasting with baresip?
Does it work?
Thanks.

DON'T USE CHAOS CALMER, asterisk11 is badly compiled, many modules are missing, use Barrier Breaker only.

(Last edited by pilovis on 5 Nov 2015, 17:33)

pilovis wrote:

DON'T USE CHAOS CALMER, asterisk11 is badly compiled, many modules are missing, use Barrier Breaker only.

And video broadcasting will work? Thanks.

On the contrary I can say that openwrt is the best ever image. I'm using BarrierBreaker 14.07 image
Im running bitminer, asterisk18, samba, iptv, motion with webcam, collecting interface statistics on my TPLINK3600. Also I have compiled
asterisk18-dongle module, up and running with E1550 and E173 voice enabled modems for
asterisk dialouts. these dongles are fantastic working SMS, USSD, both direction Voice.

router2*CLI> dongle show devices
ID           Group State      RSSI Mode Submode Provider Name  Model      Firmware          IMEI             IMSI             Number
dongle0      0     Free       3    0    0                      E1550      11.608.14.15.311  3XXXXXXXXXXXX37  2XXXXXXXXXX77  Unknown
dongle1      0     Free       8    0    0                     E173       11.126.85.00.209  8XXXXXXXXXX05  2XXXXXXXXXXXX2  Unknown

(Last edited by usavich on 13 Apr 2016, 22:33)