Thursday, December 18, 2014

We done VoIP GSM the gateway of Tp-link mr-3020 and Huawei E-171 — a part second — we added Siemens Gigaset c470IP and SMS

We done VoIP GSM the gateway of Tp-link mr-3020 and Huawei E-171 — a part second — we added Siemens Gigaset c470IP and SMS
There are such standard of ETSI of 201 912 SMS for «terrestrial lines» (landline sms zap. sources) as it appearing it support by Gigaset c470IP and sms can send us VoIP, ha learn it wanting to make «a rearrangement of sms» i.e. all that came in dongl are sen on Gigaset C470 IP and on the contrary — that there were a possibility to send to sms with C470IP in an external world through dongl, all it will happen as well as in the first part on tp-link mr-3020 under openwrt, the final configuration and a few pictures also will be show.
For those who passing the first part, in it I telling about basic setting of openwrt and asterisk on tp-link 3020 with usage of pivotroot on exterior flesh of storage of the kard-reader of dongl of Huawei E-171. 



The essence of the decision simple enough, are the special supplement for asterisk app_sms and with it binarnik of smsq for sending of "landline" sms, for operation of dongl with sms besides chan-dongle function of BASE64_DECODE are required to us.
But unfortunately neither binarnik nor function that as a matter of fact the unit of an asterisk was not install in openwrt to collect and install, priydetsya to compile from source codes, in this case more simply at once to collect all system (c) droidman. I for convenience collecting all that are necessary at once and making the repository, ha correct then opkg.conf, imkho are more best for collect superfluous, than nedosobrat. The list of packets and important in my opinion options I will result in the end of article. Now we will stop on the most important. All that are wr further at least actually for openwrt BARRIER BREAKER (Bleeding Edge, r35905).

Let's mark the unit all packets connect with asterisk18 as speaking above more simply to collect superfluous and not to put, than nedosobrat and to trace dependences.

To collect smsq we added patch before the assembly
cat ./trunk/feeds/packages/net/asterisk-1.8.x/patches/011-smsq_fix.patch 
--- a/utils/utils.xml
+++ b/utils/utils.xml
@@ -41,7 +41,7 @@
  <support_level>extended</support_level>
   </member>
   <member name="smsq">
- <defaultenabled>no</defaultenabled>
+ <defaultenabled>yes</defaultenabled>
  <depend>popt</depend>
  <support_level>extended</support_level>
   </member>


After the assembly we need to transfer ./trunk/build_dir/target-mips_r2_uClibc-0.9.33.2/asterisk-1.8.10.1/utils/smsq on a router in / usr/sbin/. For certain smsq at start will produce «smsq: cannot load library 'libstdc ++. so.6'» — are treat with the help:
cd /lib/
ln -s libuClibc-0.9.33.2.so libstdc++.so.6  


Also it will be necessary to transfer from the build directory ./trunk/build_dir/target-mips_r2_uClibc-0.9.33.2/asterisk-1.8.10.1/funcs/func_base64.so on a router in / usr/lib/asterisk/modules/

Since in the first part doing not result configs, here I will show all, the vocal part are ma on motives of links in the end of the first part, on sms I will stop more in detail.

dongle.conf 
[dongle0]
audio=/dev/ttyUSB1  ; tty port for audio connection;  no default value
data=/dev/ttyUSB2  ; tty port for AT commands;   no default value
context=dongle-incoming
group=0
rxgain=4;
txgain=5;
resetdongle=yes
u2diag=-1
usecallingpres=yes
callingpres=allowed_passed_screen
imei=Тутимейдонгла ; не забудьте сменить


root@OpenWrt:/lib# cat/etc/asterisk/sip.conf 
[general]
externip=10.10.10.10;       Эти поля у меня на самом деле не используются
externaddr=10.10.10.10;
localnet=192.168.5.0/255.255.255.0; Это локалка, gigaset тоже в этой сети
context=private;
allowguest=no;
context=default                 ; Default context for incoming calls
udpbindaddr=0.0.0.0   
tcpenable=yes                    ; Enable server for incoming TCP connections (default is no)
tcpbindaddr=0.0.0.0             ; IP address for TCP server to bind to (0.0.0.0 binds to all interfaces)
srvlookup=yes                   ; Enable DNS SRV lookups on outbound calls

[sg470ip]
type=friend                                 
host=dynamic
secret=pass
context=from-sg470ip           ; Контекст для siemens 470 IP, он единственный клиент 
canreinvite=yes
dtmfmode=rfc2833
permit=192.168.5.200/255.255.255.255
qualify=yes



root@OpenWrt:/lib# cat/etc/asterisk/extensions.conf 

[general]
static=yes
writeprotect=no
clearglobalvars=no


[dongle-incoming]
include => dongle-incoming-sms-ussd
exten => s,1,Dial(SIP/sg470ip)
exten => h,n,Hangup()


[from-sg470ip]
exten => _7X.,1,Dial(Dongle/dongle0/holdother:+${FILTER(0-9,${EXTEN})})
exten => _+7X.,1,Dial(Dongle/dongle0/holdother:+${FILTER(0-9,${EXTEN})})
exten => _8X.,1,Dial(Dongle/dongle0/holdother:+7${FILTER(0-9,${EXTEN:1})})
exten => _007X.,1,Dial(Dongle/dongle0/holdother:+7${FILTER(0-9,${EXTEN:3})})

exten => 2000,1,NoOp(Receiving SMS from ${CALLERID(num)})
exten => 2000,n,Answer
exten => 2000,n,SMS(2000,as)
exten => 2000,n,System(/etc/asterisk/sms-out.sh)
exten => h,n,Hangup()


[dongle-incoming-sms-ussd]
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,System(/usr/sbin/smsq --mt --oa="${CALLERID(num)}" --mttx-callerid="2001" --mttx-channel="SIP/sg470ip" --ud="${BASE64_DECODE(${SMS_BASE64})}")
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,System(/usr/sbin/smsq --mt --oa="0" --mttx-callerid="2001" --mttx-channel="SIP/sg470ip" --ud="${DONGLENAME}: ${BASE64_DECODE(${USSD_BASE64})}")
exten => ussd,n,Hangup()


The last config concerning sms we will disassemble in more details. The matter is that when in 470IP ukazyvetsya sms the center when sending messages, on * they come on number and still 0 in the end, at me are register in C470IP number of the sms-center 200, thus all outbox of sms arrived on 2000 see [from-sg470ip] further an asterisk answered and SMS (2000, as) meant 2000 name of queue, a — to answer, s — to operate as sms center, i.e. the message are sav in / by var/spool/asterisk/sms/morx/2000.* where the asterisk are date time, on SMS () it are possible to address behind more detail information to links in the end of a post, the script whom parsit the sav file and sent through dongl further are fulfill.

/ etc/asterisk/sms-out.sh
#!/bin/sh

SPOOL='/var/spool/asterisk/sms/morx'

for SMS in `ls -1 "$SPOOL"`; do
  DST=`grep -e '^da=' "$SPOOL/$SMS" | sed 's/da=//'`
  MSG=`grep -e '^ud=' "$SPOOL/$SMS" | sed 's/ud=//'`
  valid="true"

    if [ ${#DST} -gt 1 ] ; then
 DSTPRFX=${DST:0:2}
 if [ $DSTPRFX = "89" ] ; then
 DST=`echo $DST | sed 's/8/\+7/'`
 asterisk -rx "dongle sms dongle0 $DST $MSG"  
 else valid="false"
        fi
    else 
 if [ $DST = "0" ] ; then
        asterisk -rx "dongle ussd dongle0 $MSG"
 else valid="false"
 fi
     fi

if [ $valid = "false"  ] ; then
 echo "unknown dest number $DST" >> /var/log/asterisk/sms-out.log
 smsq --mt --mttx-callerid="2001" --mttx-channel="SIP/sg470ip" --oa="200" --ud="ERR unknown dest $DST"
fi
  rm -f "$SPOOL/$SMS"

done


Here was select weed a coma and a body sms, further there are a check if number of assignment began on 89 8 it are replac on +7 (on mho it are impossible to type + in number) and the message through dongl if number of assignment 0 the body as are sen to ussd request, it are ma that could send USSD requests are sen, ha for example sen *100# on 0 Cs sgc470ip it are possible to check up balance on a sim card in dongle :) If conditions was not fulfill record in log and sending of the error report on phone by means of smsq, pay attention that at answer from sms center are already add 1 instead of 0 in number of sms-center (though on mho and with 0 too like worked) phone kn this number did not ring as usual, and silently tried to receive smska, briefly principle of a command of smsq from listing — to generate file in / var/spool/sms/mttx/0. *, to generate. call a file of any additional actions are not required, all necessary parameters was in command line, it are possible to esteem helps keys - help and - usage.

[dongle - incoming - are more SMS ussd] in extensions.conf I thinks it are already clear, it for sms enter on gsm to the channel «in dongl» — logirovaniye and transfer by means of smsq on 470ip, too most for enter answers to USSD with that only a difference that USSD in caller-id will have «ussd» gigaset such did not love, therefore there the parameter at transfer from (-oa) are expos in «0»

As it looked:
Sms it are sen with a mobile phone on number which number in dongle beginning with "+", coming 810
We done VoIP GSM the gateway of Tp-link mr-3020 and Huawei E-171 — a part second — we added Siemens Gigaset c470IP and SMS
sms
We done VoIP GSM the gateway of Tp-link mr-3020 and Huawei E-171 — a part second — we added Siemens Gigaset c470IP and SMS
Call if are in the note book of gigaset-a
We done VoIP GSM the gateway of Tp-link mr-3020 and Huawei E-171 — a part second — we added Siemens Gigaset c470IP and SMS
Call if is not present in the book of gigaset-a
We done VoIP GSM the gateway of Tp-link mr-3020 and Huawei E-171 — a part second — we added Siemens Gigaset c470IP and SMS
Adjustment of gigaset are trivial, apparently from pictures, the provider at me are nam GSM, the plan of a dial-up of gigaset-a sent all that began on 89 on this provider (mr-3020), adjustment sms center was ma with a dekta-tube, the center number 200 are more SMS, this center for sending are select and the provider that are interesting are select, could not coincide with dialplan in basis, all the same will depart to that are specif in adjustments sms, also could be expos some more sms centers, only on reception. 

The list of packets which at me was us, was necessary not all, but nevertheless I will more better result the complete
opkg list-installed

asterisk18 - 1.8.10.1-4
asterisk18-app-exec - 1.8.10.1-4
asterisk18-app-readexten - 1.8.10.1-4
asterisk18-app-senddtmf - 1.8.10.1-4
asterisk18-app-setcallerid - 1.8.10.1-4
asterisk18-app-sms - 1.8.10.1-4
asterisk18-app-system - 1.8.10.1-4
asterisk18-app-verbose - 1.8.10.1-4
asterisk18-chan-dongle - 1.1.r10-18
asterisk18-chan-local - 1.8.10.1-4
asterisk18-codec-alaw - 1.8.10.1-4
asterisk18-func-shell - 1.8.10.1-4
asterisk18-pbx-spool - 1.8.10.1-4
asterisk18-sounds - 1.8.10.1-4
base-files - 134-r35905
blkid - 2.21.2-1
block-mount - 0.2.0-10
busybox - 1.19.4-6
dnsmasq - 2.62-3
dropbear - 2012.55-2
e2fsprogs - 1.42.4-1
fdisk - 2.21.2-1
firewall3 - 2013-03-02
glib2 - 2.34.3-1
hotplug2 - 1.0-beta-4
httping - 1.5.2-1
iptables - 1.4.18-2
iw - 3.6-1
jshn - 2013-01-29-0bc317aa4d9af44806c28ca286d79a8b5a92b2b8
kernel - 3.8.2-1-f0811f6432963110cc6f2a1623174e3a
kmod-ath - 3.8.2+2013-02-22-1
kmod-ath9k - 3.8.2+2013-02-22-1
kmod-ath9k-common - 3.8.2+2013-02-22-1
kmod-cfg80211 - 3.8.2+2013-02-22-1
kmod-crypto-aes - 3.8.2-1
kmod-crypto-arc4 - 3.8.2-1
kmod-crypto-core - 3.8.2-1
kmod-crypto-hash - 3.8.2-1
kmod-crypto-manager - 3.8.2-1
kmod-fs-ext4 - 3.8.2-1
kmod-gpio-button-hotplug - 3.8.2-1
kmod-ipt-conntrack - 3.8.2-1
kmod-ipt-core - 3.8.2-1
kmod-ipt-nat - 3.8.2-1
kmod-ipt-nathelper - 3.8.2-1
kmod-leds-gpio - 3.8.2-1
kmod-ledtrig-default-on - 3.8.2-1
kmod-ledtrig-netdev - 3.8.2-1
kmod-ledtrig-timer - 3.8.2-1
kmod-ledtrig-usbdev - 3.8.2-1
kmod-lib-crc-ccitt - 3.8.2-1
kmod-lib-crc16 - 3.8.2-1
kmod-mac80211 - 3.8.2+2013-02-22-1
kmod-nls-base - 3.8.2-1
kmod-nls-utf8 - 3.8.2-1
kmod-ppp - 3.8.2-1
kmod-pppoe - 3.8.2-1
kmod-pppox - 3.8.2-1
kmod-scsi-core - 3.8.2-1
kmod-usb-core - 3.8.2-1
kmod-usb-ohci - 3.8.2-1
kmod-usb-serial - 3.8.2-1
kmod-usb-serial-option - 3.8.2-1
kmod-usb-serial-wwan - 3.8.2-1
kmod-usb-storage - 3.8.2-1
kmod-usb-uhci - 3.8.2-1
kmod-usb2 - 3.8.2-1
kmod-wdt-ath79 - 3.8.2-1
libblkid - 2.21.2-1
libblobmsg-json - 2013-01-29-0bc317aa4d9af44806c28ca286d79a8b5a92b2b8
libc - 0.9.33.2-1
libcom_err - 1.42.4-1
libcyassl - 1.6.5-2
libext2fs - 1.42.4-1
libffi - 3.0.11-1
libgcc - 4.6-linaro-1
libiconv-full - 1.11.1-1
libip4tc - 1.4.18-2
libip6tc - 1.4.18-2
libiwinfo - 39
libiwinfo-lua - 39
libjson - 0.9-2
liblua - 5.1.5-1
libncurses - 5.7-5
libnet1 - 1.1.2.1-2
libnl-tiny - 0.1-3
libopenssl - 1.0.1e-1
libpcap - 1.1.1-2
libpopt - 1.7-5
libpthread - 0.9.33.2-1
librpc - 0.9.32-rc2-0a2179bbc0844928f2a0ec01dba93d9b5d6d41a7
librt - 0.9.33.2-1
libubox - 2013-01-29-0bc317aa4d9af44806c28ca286d79a8b5a92b2b8
libubus - 2013-01-13-bf566871bd6a633e4504c60c6fc55b2a97305a50
libubus-lua - 2013-01-13-bf566871bd6a633e4504c60c6fc55b2a97305a50
libuci - 2013-01-04.1-1
libuci-lua - 2013-01-04.1-1
libusb-1.0 - 1.0.9-1
libusb-compat - 0.1.4-1
libustream-cyassl - 2013-01-22-da607e6272d789ed5dae3b0efff90912fda6f81f
libuuid - 2.21.2-1
libxtables - 1.4.18-2
lua - 5.1.5-1
luci - trunk+svn9678-1
luci-app-diag-core - trunk+svn9678-1
luci-app-diag-devinfo - trunk+svn9678-1
luci-app-firewall - trunk+svn9678-1
luci-i18n-english - trunk+svn9678-1
luci-i18n-russian - trunk+svn9678-1
luci-lib-core - trunk+svn9678-1
luci-lib-ipkg - trunk+svn9678-1
luci-lib-nixio - trunk+svn9678-1
luci-lib-sys - trunk+svn9678-1
luci-lib-web - trunk+svn9678-1
luci-mod-admin-core - trunk+svn9678-1
luci-mod-admin-full - trunk+svn9678-1
luci-proto-core - trunk+svn9678-1
luci-proto-ppp - trunk+svn9678-1
luci-sgi-cgi - trunk+svn9678-1
luci-ssl - trunk+svn9678-1
luci-theme-base - trunk+svn9678-1
luci-theme-openwrt - trunk+svn9678-1
mac-to-devinfo - 1.0.0-2
mc - 4.7.5.3-2
mtd - 20
nano - 2.2.6-1
netdiscover - 0.3-beta6-3
netdiscover-to-devinfo - 1.0.0-2
netifd - 2013-02-19-486aa750a164d41905beb61afec89268e3eb7f48
opkg - 618-3
ppp - 2.4.5-9
ppp-mod-pppoe - 2.4.5-9
procd - 2012-12-20-d343dd9e9a64d4ae7d225ea29169e97fa8d116a1
px5g - 1
smap - 0.6.0-2
smap-to-devinfo - 1.0.0-2
swap-utils - 2.21.2-1
swconfig - 10
terminfo - 5.7-5
uboot-envtools - 2012.04.01-1
ubus - 2013-01-13-bf566871bd6a633e4504c60c6fc55b2a97305a50
ubusd - 2013-01-13-bf566871bd6a633e4504c60c6fc55b2a97305a50
uci - 2013-01-04.1-1
uhttpd - 2013-01-22-14e3971c37e6feb0ec5eda0988e07d8a786ba9f9
uhttpd-mod-ubus - 2013-01-22-14e3971c37e6feb0ec5eda0988e07d8a786ba9f9
usb-modeswitch - 1.2.5-1
usb-modeswitch-data - 20121109
wpad-mini - 20130302-1
zlib - 1.2.7-1


Nuances:

It are not necessary to create folders of type/overlay/var at all or / differently they will start to be sav by overlay/tmp on flesh, it caused at once 2nd problems: speed of reversal and recovery of irrelevant files from last loading i.e. if you see for example in the console of an asterisk: WARNING [1751]: db.c:115 dbinit: Unable to open Asterisk database '/var/lib/asterisk/astdb': No such file or directory
The right decision will add mkdir - p/var/lib/asterisk in an appropriate place in / etc/init.d/boot 

Busybox in openwrt by default gathered without support of unicode, use an option of CONFIG_BUSYBOX_CONFIG_UNICODE_SUPPORT=y.

The Krivost of hands doing not allow to be solder to mini-USB, but similarity of POE were possible on distance about 15 meters, the simple injector, the power unit from d-link usb-hub 5V 3A and alter "butt" were us from a router
We done VoIP GSM the gateway of Tp-link mr-3020 and Huawei E-171 — a part second — we added Siemens Gigaset c470IP and SMS
We done VoIP GSM the gateway of Tp-link mr-3020 and Huawei E-171 — a part second — we added Siemens Gigaset c470IP and SMS

And at last a picture who should be the first :)
We done VoIP GSM the gateway of Tp-link mr-3020 and Huawei E-171 — a part second — we added Siemens Gigaset c470IP and SMS

UPD: do not forget do make dirclean after update of svn differently there could to be problems with the assembly.
UPD: that that gathering at me: www.dropbox.com/sh/xjldxibmzo6bdye/88eCAN2j9S 

The useful references on a subject:

www.voip-info.org/wiki/index.php?page=Asterisk+cmd+SMS
wiki.e1550.mobi/doku.php? id=usage
www.automated.it/asterisk/sms.html
forum.ixbt.com/topic.cgi?id=88:1699-26
forum.asterisk.ru/viewtopic.php?f=3&t;=1160&start;=10

Source : http://sysmagazine.com/posts/172345/

3 comments: