In order not to waste your and your time: in this topic there is no
- chan_datacard setup guides
- SIP configuration guides in Asterisk
- guides for setting up VoIP-gateways and SIP-clients.
All this is perfectly googled, and with experience, it is remembered and not forgotten.
Recently, the task arose to raise in a small office PBX.
One of the requirements was to optimally spend the funds allocated for mobile communication: from MTS to call only to MTS, from Beeline to Beeline, and so on. It was decided to use a bundle of Asterisk and several unlocked 3G modems: there were already SIM cards with optimal tariffs. As subscriber devices, both softphones at the employees' workplaces and ordinary wired phones connected to the VoIP-gateway were used.
The first thing that was done - the DEF-codes of domestic cellular operators were found and rewritten. Of course, not all, but only the big three: for all other calls it was planned to use TELE2.
Then an internal numbering plan was created: it was decided that the internal numbers would be four-digit, and would start with 5.
Calls from SIP to the outside world were assigned a sip-incoming context, external calls coming from modems were datacard-incoming, respectively. The required modem was determined using the MCC / MNC (Mobile Country Code / Mobile Network Code) prefix from the IMSI SIM card. The code of Russia is 250. Accordingly, MTS MNC 25001, MegaFon 25002, Beeline 25099, Tele2 25020.
')
Ubuntu Linux 11.10 x86-64 was used as a software platform, and there, if memory serves me correctly - Asterisk 1.8. To control the modems, the chan_datacard of the 310th assembly was used.
Actually, an example of extensions.conf.
[datacard-incoming]
exten => sms, 1, Verbose (Incoming SMS from $ {CALLERID (num)} $ {SMS})
exten => sms, n, System (echo '$ {STRFTIME ($ {EPOCH} ,,% Y-% m-% d% H:% M:% S)} - $ {DATACARD} - $ {CALLERID (num )}: $ {SMS} '>> /var/log/asterisk/sms.txt)
exten => sms, n, hangup ()
exten => ussd, 1, Verbose (Incoming USSD: $ {USSD})
exten => ussd, n, System (echo '$ {STRFTIME ($ {EPOCH} ,,% Y-% m-% d% H:% M:% S)} - $ {DATACARD}: $ {USSD}' >> /var/log/asterisk/ussd.txt)
exten => ussd, n, hangup ()
exten => s, 1, Dial (SIP / 5001 ,,)
exten => s, n, hangup ()
[sip-incoming]
; mobile operators
exten => _8913XXXXXXX, 1, Dial (Datacard / s: 25001 / $ {EXTEN})
exten => _8913XXXXXXX, n, Hangup
exten => _8983XXXXXXX, 1, Dial (Datacard / s: 25001 / $ {EXTEN})
exten => _8983XXXXXXX, n, Hangup
exten => _8923XXXXXXX, 1, Dial (Datacard / s: 25002 / $ {EXTEN})
exten => _8923XXXXXXX, n, Hangup
exten => _8903XXXXXXX, 1, Dial (Datacard / s: 25099 / $ {EXTEN})
exten => _8903XXXXXXX, n, Hangup
exten => _8905XXXXXXX, 1, Dial (Datacard / s: 25099 / $ {EXTEN})
exten => _8905XXXXXXX, n, Hangup
exten => _89XXXXXXXXX, 1, Dial (Datacard / s: 25020 / $ {EXTEN})
exten => _89XXXXXXXXX, n, Hangup
; local numbers
exten => _5XXX, 1, Dial (SIP / $ {EXTEN})
exten => _5XXX, n, Hangup
A little about setting up chan_datacard. The 310th assembly is able to get rid of specific ports by specifying which IMEI / IMSI is expected for a specific logical device. Out of habit, I tuned in to USB pseudo terminals.
datacard.conf example
[datacard0]
audio = / dev / ttyUSB1; tty port for audio connection; no default value
data = / dev / ttyUSB2; tty port for AT commands; no default value
context = datacard-incoming
autodeletesms = yes; auto delete incoming sms
resetdatacard = yes; reset datacard during initialization
u2diag = 0; set U2DIAG parameter (0 = disable everything except modem function)
usecallingpres = yes; use the caller ID presentation or not
callingpres = allowed_passed_screen; set caller ID presentation
That's all folks!
Nuances of setup and operation
What is achieved by this setting? Subscribers do not need to think about which prefix to exit to where. In fact, Asterisk itself determines through which interface to redirect the call, guided by the number, and its length. With a sufficient number of modems and other lines, there is always a free channel in the direction.
Regarding specifically 3G modems - Asterisk on modern AMD and Core processors holds even 50-60 modems well. True, this requires the fulfillment of several conditions:
- Modems are removed from the enclosures and placed in USB hubs, also released from the enclosures
- Hubs are supplied with additional power from independent power supplies.
- "Combs" of the hubs and modems are placed in a housing with good flow-air cooling - case fan for the system unit is quite suitable
- Hubs are recommended to connect to individual host controllers installed on the bus PCI-E
All this is due to the fact that when voice traffic goes through the modem, its chips heat up intensively and consume electricity. Sometimes, not very well assembled E1550 overheated and "fell off" - Asterisk stopped seeing them for a while.
But the E173 is generally poorly adapted to work "naked": in contrast to the E1550, their SIM-card slot is not a slot card, but an invoice. I had to press the card to the contacts of the reader with a clothespin.
On this for sure.