OpenVox GSM-gateway as a full-fledged exchange of PBX

As you know, SIP is gaining more and more popularity and it’s not a secret to anyone that it is possible to optimize telephony costs by correctly choosing a SIP provider.
But, unfortunately, the above statement is true only for large cities in Russia and the CIS. But what to do in cases where SIP is not available? Use PRI? Quite expensive, especially for a small company with a small number of calls, and again, not always available. Use analog telephony the old fashioned way? Of course not. The answer seems pretty obvious: a GSM gateway will solve all your problems.
At first glance, everything is quite simple to implement, but with a more detailed thinking it will become clear that the gateway itself is not very functional and is only a kind of GSM to SIP converter, and for the implementation, albeit cloudless, it’s still necessary ATS (e.g. IVR, routing, queues). To minimize the cost process, let's say this is our favorite open-source Asterisk. If we are talking about a completely global economy, then we can immediately say: “Yeah, and the server for Asterisk? It is also not free! ”(Although, in my opinion, the thrifty admin will always have a piece of hardware for Aster :))
Now imagine that all of the above can be implemented only by means of one GSM gateway? Unbelievable? Well, please, under cat.
A couple of months ago, grigly wrote an article about the Openvox company’s new GSM gateways , which ended with a rather optimistic and encouraging phrase: “Colleagues, it has a full-fledged Asterisk, I won’t be surprised if I can configure IVR and queues on it and use it as full-fledged telephone exchange. ”
And really? Is it possible to realize the PBX functions by means of a gateway?
Colleagues, I’ll immediately make a reservation that this solution is suitable for a small company, say with a staff of 10 employees.
So, for starters, let's evaluate what features a PBX needs for a small company? In my opinion, these are queues, IVR, call transfer.
Create sip peers in the web interface of the gateway:
Go to the SIP tab → SIP Endpoints, click “Add New SIP Endpoint”
Name = 777
User Name = 777
Password = YourStrongPasssword123
Registration = Endpoint registers with this gateway
Hostname or IP Address = dynamic
Transport = UDP
NAT Traversal = Yes
Click “Save”

Next by analogy, create the required number of SIP peers.
Now in the web interface enable SSH access. To do this, go to the System → Login Settings tab and set SSH Login Settings to “Enable ON”.

It is worth noting that the port for SSH in the gateway is 12345, it cannot be changed, which is apparently done for security purposes.
By default, the admin user does not have root rights, in order to get root, you must change the user to super, the password is super.

So, we go to the gateway via SSH:
ssh -p 12345 admin@192.168.1.111
Password: admin
After you get to the gateway, edit the context of the extra-channels.conf configuration file:
vim /etc/asterisk/extra-channels.conf:
Edit the context for an incoming call with SIM1:
; Span 1: opvxg4xx/0/1 «OpenVox G400P GSM/CDMA PCI Card 0» AMI/CCS
group=1
context=ivr
signalling = gsm
vol=70
mic=1
dacgain=-15
adcgain=-3
debugat=off
smscodec=utf-8
;hwdtmfdet=1
anonymouscall=off
call_waiting=off
band=
dialprefix=
switchtype=SIMCOM_SIM840W
channel => 1
group=1
context=ivr
signalling = gsm
vol=70
mic=1
dacgain=-15
adcgain=-3
debugat=off
smscodec=utf-8
;hwdtmfdet=1
anonymouscall=off
call_waiting=off
band=
dialprefix=
switchtype=SIMCOM_SIM840W
channel => 1
Now create a new ivr context.
vim /etc/asterisk/extensions_custom.conf
Create a new ivr context:
[ivr]
exten => s,1,Answer()
same => n,Background(press-1&or&press-2)
same => n,WaitExten()
exten => 1,1,Playback(wait_connection)
same => n,Dial(SIP/777)
same => n,Hangup()
exten => 2,1,Playback(wait_connection)
same => n,Dial(SIP/888)
same => n,Hangup()
exten => s,1,Answer()
same => n,Background(press-1&or&press-2)
same => n,WaitExten()
exten => 1,1,Playback(wait_connection)
same => n,Dial(SIP/777)
same => n,Hangup()
exten => 2,1,Playback(wait_connection)
same => n,Dial(SIP/888)
same => n,Hangup()
The dialplan in the example is the most primitive, intended for demonstration, in the production, of course, protection against incorrectly entered numbers should be implemented.
It is worth noting that Openvox only supports sounds for IVR in GSM format. I had sounds in the .wav format, which I transcoded using the system:
sox input.wav -r 8000 -c1 output.gsm lowpass 4000 compand 0.02,0.05 -60,-60,-30,-10,-20,-8,-5,-8,-2,-8 -8 -7 0.05
By default, gsm modules are not loaded in Openvox, you must force them into the CLI:
Openvox-Wireless-Gateway*CLI> module load codec_gsm.so
Openvox-Wireless-Gateway*CLI> module load format_gsm.so
In order not to load gsm every time after rebooting the gateway, I recommend adding these two lines to the /etc/asterisk/modules.conf file
Now let's move on to configuring the queues:
We go into the gateway web interface, the tab Routing → Groups. Create a new group by clicking on the New Group button:
Group Name = YourGroupName
Type = SIP
Policy = select the appropriate calling strategy for
Members = check the boxes in front of the numbers that we want to include in the group:

Now go to the tab Routing → Call Routing Rules, click New Call Routing Rule:
Routing name = YourRoutingName
Call Comes in From = for example, gsm-2 (that is, all calls from sim 2 will be forwarded to our queue)
Send Call Through = from the drop-down list, select the group you just created.

Another important feature is the ability to transfer a call. To our great joy, this is already provided by the Openvox developers. Open feauteres.conf:
vim /etc/asterisk/features.conf
And we see the following line there:
blindxfer => #1 ; Blind transfer
That is, by pressing # 1 the call transfer will be made, in principle, you can select any prefix for translation, I changed it to * 1 for convenience.
Conclusion
Using the undocumented capabilities of this device, as a result we get the following costing for a typical small business:
1) 10 IP phones ~ 25 thousand rubles. (not the cheapest devices, but with support for HD codecs, headsets, and probably even PoE)
2) OpenVox VS-GW1200-4G ~ 15 thousand rubles
3) If you need to connect an external analog line and, say, a fax, you can purchase inexpensive FXO / FXS gateway, for example, Granstream HT-503 ~ 2.5 thousand rubles.
4) As mentioned above, the gateway can register the final SIP devices on itself and register on the PBX itself, so there will be no problems connecting the SIP provider.
Total, full-fledged VOIP in the office, with unlimited trunks, queues and blackjack less than for 45 000 rubles!
The gateway does not have hard drives, and uses only high-quality components (we could verify this in a previous article about OpenVox), therefore it is an extremely reliable solution.
Moreover, this decision does not require any additional. licenses, subscriptions to those. support and so on, so the total cost of ownership is quickly calculated and you can forget about all kinds of pitfalls with licensing.