
Hello dear habrovchane and lovers of solutions based on Asterisk. In this article I want to share the experience of solving an
interesting problem. It was necessary to ensure that when forwarding calls from one mobile / city number to another mobile, we would see the caller’s number, not our city number. But the fact is that telecom operators will not let us so easily substitute their numbers when they call through their networks (Indeed, this would be a real mess). But you can solve the problem by sending it via SMS message via a GSM modem.
What we have:
Server with FreePBX Distro FreePBX 2.11.0.0beta2.5 (Asterisk 1.8), Huawei E171 modem, several connected city lines, dialplan with redirection.
')
To begin with we will install the modem, we will transfer it to the necessary mode. It is important to transfer the modem to the modem only mode:
HUAWEII
http://huawei.mobzon.ru/instruktsii/25-instruktsiya-po-nastrojke-modemZTE
http://www.yccy.ru/category/raznoe/346.htmlConfigure the program to send SMS - Gnokii. Here and further I describe actions for CentOS.
1. Be sure to set dependencies:
yum install usbutils libusb1-devel tcl
2. Insert the modem and see how it is defined:
lsusb Bus 002 Device 007: ID 12d1:14fe Huawei Technologies Co., Ltd.
So at the beginning looks like a string.
3. In my distribution there was no package for building programs from sources. We put Development Tools.
yum groupinstall "Development Tools"
4. Download the program to switch the modem mode. Packages usb-modeswitch usb-modeswitch-data take
from here .
5. Unpack both archives and install in turn:
tar xvjf ... make install
6. We distort the modem and check:
lsusb Bus 002 Device 008: ID 12d1:1506 Huawei Technologies Co., Ltd. E398 LTE/UMTS/GSM Modem/Networkcard
So everything is OK and the modem will be determined every time as necessary. If the line is the same as at the beginning, then go
here .
The dmesg command will show us:
option 2-1.4:1.0: GSM modem (1-port) converter detected usb 2-1.4: GSM modem (1-port) converter now attached to ttyUSB0 option 2-1.4:1.1: GSM modem (1-port) converter detected usb 2-1.4: GSM modem (1-port) converter now attached to ttyUSB1 option 2-1.4:1.2: GSM modem (1-port) converter detected usb 2-1.4: GSM modem (1-port) converter now attached to ttyUSB2
7. Install the repository for EPEL CentOS
like this .
8. Install gnokii
yum --enablerepo=epel install gnokii gnokii-smsd
You can download the package:
http://rpm.pbone.net/index.php3/stat/4/idpl/27788385/dir/redhat_el_6/com/gnokii-0.6.30-2.el6.i686.rpm.htmland the dependency
http://rpm.pbone.net/index.php3/stat/4/idpl/16859934/dir/redhat_el_6/com/libpcsclite1-1.4.0-9.el6.i686.rpm.html9. Edit config / etc / gnokiirc
[global] port = /dev/ttyUSB0 model = AT initlength = default connection = serial use_locking = no serial_baudrate = 115200
there may be a different port for different modems;
10. Check SMS sending:
echo 'Bingo!' | gnokii --sendsms +79060000000
Now you need to allow the asterisk user to run gnokii from the dialplan. Since gnokii was installed under the root account, the asterisk user will not be able to start it. Edit the / etc / sudoers file using the visudo command (it is strongly recommended that you only use visudo to edit the sudoers file):
Add a line for the asterisk user:
asterisk ALL=NOPASSWD:/usr/bin/gnokii
Save the file and exit.
Next, we need to implement the System () command in our dialplan to send a CID to SMS. FreePBX, of course, will not allow us to edit extensions.conf and extensions_additional.conf, since it overwrites them all the time. But you can insert your edits into the plan using the extensions_override_freepbx.conf file, which we will do. You can simply find the necessary context in the extensions_additional.conf file, copy its fragment into extensions_override_freepbx.conf and make your changes. I have an internal number 203 which is redirected to a mobile phone number via SIP / trunk / telephone_number. We will edit this part of the dialplan:
[ext-local] exten => 203,1,Set(__RINGTIMER=${IF($[${DB(AMPUSER/203/ringtimer)} > 0]?${DB(AMPUSER/203/ringtimer)}:${RINGTIMER_DEFAULT})}) exten => 203,n,System(echo '8${CALLERID(num)}' | sudo gnokii --sendsms +79061234567) ; exten => 203,n,Macro(exten-vm,novm,203,0,0,0) exten => 203,n(dest),Set(__PICKUPMARK=) exten => 203,n,Goto(${IVR_CONTEXT},return,1) exten => 203,hint,SIP/10000/778899 exten => Narva778899,1,Goto(from-internal,203,1)
Now, when calling or forwarding to 203, an SMS with the caller's number, taken from the CALLERID variable (num), will be sent directly to the mobile phone.
In the next article I want to talk about setting up a bunch of Asterisk and SugarCRM to display the number of the caller on the monitor screen of the CRM operator, for later entry into the customer base. (
done )
Pls, throw karma if someone useful article.