As per web defines: Kannel (http://www.kannel.org/) is one of the most popular open source WAP/SMS Gateway, because its very good performance to handle a huge SMS. Kannel supports many modem’s brand even generic modem, also support multi modems (modem bank).
x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x
After some testing, I have found Kannel one of the best , fastest SMS and WAP gateway among other open source sms gateways , capable of handling several hundreds of requests per second.
Following is a guide on how you can configure your own Local SMS HTTP gateway using KANNEL
(The aim of configuring kannel on my Ubuntu box was that I required it to send sms via DMASOFTLAB RADIUS MANAGER which uses API to send sms via clickatell HTTP gateway for New Account / Expiry Warning / Password recovery via sms , verification code and many other cool functions. It comes with the clickatell HTTP gateway API which off course require you to buy sms bundle package and do require handsome amount of $$ if you have a huge number of users, Therefore to save $$ money , I created my own gateway)
O/S = Ubuntu 10.4
Hardware = Teltonika ModemUSB/E12 UM1400 / and Dlink dwm-156 , dlink is a problematic modem
Detecting MODEM
First thing you have to do is to search for working modem port , various methods are used, try to Use WVDIALCONF command to detect modem and see at which port its working (or not detected)
As showed below …
root@radius:/temp# wvdialconf Editing `/etc/wvdial.conf'. Scanning your serial ports for a modem. ttyS0<*1>: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud ttyS0<*1>: ATQ0 V1 E1 -- failed with 9600 baud, next try: 115200 baud ttyS0<*1>: ATQ0 V1 E1 -- and failed too at 115200, giving up. Modem Port Scan<*1>: S1 S2 S3 S4 S5 S6 S7 S8 Modem Port Scan<*1>: S9 S10 S11 S12 S13 S14 S15 S16 Modem Port Scan<*1>: S17 S18 S19 S20 S21 S22 S23 S24 Modem Port Scan<*1>: S25 S26 S27 S28 S29 S30 S31 ttyUSB0<Info>: Device or resource busy Modem Port Scan<*1>: USB0 ttyUSB1<*1>: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud ttyUSB1<*1>: ATQ0 V1 E1 -- OK ttyUSB1<*1>: ATQ0 V1 E1 Z -- OK ttyUSB1<*1>: ATQ0 V1 E1 S0=0 -- OK ttyUSB1<*1>: ATQ0 V1 E1 S0=0 &C1 -- OK ttyUSB1<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 -- OK ttyUSB1<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK ttyUSB1<*1>: Modem Identifier: ATI -- MTK2 ttyUSB1<*1>: Max speed is 9600; that should be safe. ttyUSB1<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK ttyUSB2<*1>: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud ttyUSB2<*1>: ATQ0 V1 E1 -- failed with 9600 baud, next try: 9600 baud ttyUSB2<*1>: ATQ0 V1 E1 -- and failed too at 115200, giving up. ttyUSB3<*1>: ATQ0 V1 E1 -- failed with 2400 baud, next try: 9600 baud ttyUSB3<*1>: ATQ0 V1 E1 -- failed with 9600 baud, next try: 9600 baud ttyUSB3<*1>: ATQ0 V1 E1 -- and failed too at 115200, giving up. Found a modem on /dev/ttyUSB1. Modem configuration written to /etc/wvdial.conf. ttyUSB1<Info>: Speed 9600; init "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"
As you can see the modem is detected on ttyUSB1 port.
INSTALL KANNEL in ubuntu
First install KANNEL using apt-get (configuring it on ubuntu is the easiest task ! that’s why i love ubuntu ,not all but in most cases 😉 )
apt-get install libxml2 apt-get install kannel
EDIT KANNEL CONFIGURATION FILE
Now open the kannel config file by
nano /etc/kannel/kannel.conf
Remove all the lines and paste the following config
! MAKE SURE YOU CHANGE THE USB PORT IN THE DEVICE SECTION ! Also pay attention to speed as some modems like serial may work on 115200 speed , zaib
# Syed Jahanzaib # https://aacable.wordpress.com # aacable [at] hotmail.com group = core admin-port = 13000 smsbox-port = 13001 admin-password = zaibadmin status-password = zaibstatus log-file = "/var/log/kannel/bearerbox.log" log-level = 0 box-deny-ip = "*.*.*.*" box-allow-ip = "127.0.0.1" #Send sms only once. No retry sms-resend-retry = 1 group = smsc smsc = at smsc-id = zaibgsmid modemtype = teltonika device = /dev/ttyACM0 # Change above port to match your port, it could ACM1 or USB0, if you dont set it correctly, it will not work and you will get error in logs that unable to connect to device) # Or use serial-by-id like # device = /dev/serial/by-id/usb-D-Link_Inc_D-Link_DWM-156-if03-port0 speed = 19200 my-number = 0333302100000 # (put your sim number, not necessary) # Following SMSC number is for zong # sms-center = 00923040000011 sim-buffering = true log-level = 0 # for teltonkia only, if you are using other brand you may need to get there INIT stribgs # But what I have seen that this string worked for dlink and huawei modem as well. group = modems id = teltonika name = "Teltonika E12" detect-string = "Undefined" enable-mms = true init-string = "AT+CNMI=2,2,0,1,1" # or i used this for dlink as well. #init-string = "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0" speed = 115200 message-storage = "SM" # for Huawei USB/GSM modem e155 i guess, remove hashes from below lines if u r using this model. #group = modems #id = huawei #name = "Huawei" #detect-string = "huawei" #enable-mms = true #init-string = "ATZ" #init-string = "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0" group = smsbox bearerbox-host = localhost sendsms-port = 13013 global-sender = 13013 sendsms-chars = "0123456789 +-" log-file = "/var/log/kannel/smsbox.log" log-level = 0 access-log = "/var/log/kannel/access.log" group = sendsms-user # MAKE VERY SURE that you change the PASSWORD for security reasons username = kannel password = kannel concatenation = true max-messages = 1000 group = sms-service keyword = default get-url = "http://localhost/kannel/receivesms.php?sender=%p&text=%b" # If you have playSMS installed to receive sms use below line instead #get-url = "http://localhost/playsms/index.php?app=call&cat=gateway&plugin=kannel&access=geturl&t=%t&q=%q&a=%a&Q=%Q" accept-x-kannel-headers = true max-messages = 99 concatenation = true catch-all = true text = "Galaxy ROBOT by Zaib" omit-empty = true
START KANNEL CONSOLE
Now start kannel (for test start with two terminals, one bearerbox and smsbox)
[ BEARER & SMSBOX ]
Open two terminal windows and issue below commands in each terminal box in the following order.
1. Start the Bearer Box
and leave it running as it will show you the debug logs)
bearerbox -v 0 /etc/kannel/kannel.conf
You may see the following screenshot if your config is ok
Now leave it running.
2. Start the SMSBOX in separate terminal
(in second terminal window and leave it running as it will show you the debug logs)
smsbox -v 0 /etc/kannel/kannel.conf
You may see the following screenshot if your config is OK
[If you receive error that the address is already in use, first issue the command service kannel stop]
CHECK KANNEL CONFIGURATION STATUS VIA CLI and WEB
First check kannel service status with
ps aux |grep kannel
and you should see something like this
root@radius:/temp# ps aux |grep kannel kannel 15448 0.0 0.0 2252 308 ? Ss 12:05 0:00 /usr/sbin/run_kannel_box --pidfile /var/run/kannel/kannel_bearerbox.pid --no-extra-args /usr/sbin/bearerbox -v 4 -- /etc/kannel/kannel.conf kannel 15450 1.5 0.1 94936 7780 ? Sl 12:05 0:10 /usr/sbin/bearerbox -v 4 -- /etc/kannel/kannel.conf kannel 15465 0.0 0.0 2252 368 ? Ss 12:05 0:00 /usr/sbin/run_kannel_box --pidfile /var/run/kannel/kannel_wapbox.pid --no-extra-args /usr/sbin/wapbox -v 4 -- /etc/kannel/kannel.conf kannel 15468 0.0 0.0 2252 312 ? Ss 12:05 0:00 /usr/sbin/run_kannel_box --pidfile /var/run/kannel/kannel_smsbox.pid --no-extra-args /usr/sbin/smsbox -v 4 -- /etc/kannel/kannel.conf kannel 15470 0.0 0.0 71192 2544 ? Sl 12:05 0:00 /usr/sbin/smsbox -v 4 -- /etc/kannel/kannel.conf root 23357 0.0 0.0 4388 820 pts/0 S+ 12:16 0:00 grep --color=auto kannel
CHECK via WEB
Now From your browse, type the following to make sure kannel is working fine 🙂
[change the ip and password to match your config]
and you may see the following screen , if your config is ok
How to Send SMS via HTTP command
Open your browser and paste the following command.
NOTE: Change the IP / ID + Password = and number to match your local configuration.
The result would be similar to the following . . .
and you shoudl receive sms on your cell as following …
Some Tips and reference.
Howto send SMS via GAMMU CLI
gammu sendsms TEXT 03333021909 -text "Test Msg from GAMMU .."
Howto send USSD CODES via GAMMU CLI
For balance check (below example is for zong balacne check)
gammu --getussd *222#
Howto send sms via CLI using KANNEL
curl "http://localhost:13013/cgi-bin/sendsms?username=kannel&password=KANNELPASS&to=03333021909&text=Welcome+Jahanzaib+Test+Message"
Sending mesage with new line using %0A code using KANNEL
curl "http://localhost:13013/cgi-bin/sendsms?username=kannel&password=KANNELPASS&to=03333021909&text=Welcome+Jahanzaib+Test+Message%0ANew+line"
Howto send sms using FILE via CLI using KANNEL
curl "http://127.0.0.1:13013/cgi-bin/sendsms?username=kannel&password=kannelpassword&to=03333333333" -G --data-urlencode text@/temp/message.txt
Howto send sms using any output via CLI using KANNEL
ls -l | curl "http://127.0.0.1:13013/cgi-bin/sendsms?username=kannel&password=kannelpassword&to=03333333333" -G --data-urlencode text@-
SEND SMS FROM MIKROTIK USING KANNEL AS GW
/tool fetch url="http://KANNEL_GW_IP:13013/cgi-bin/sendsms\?username=kannel&password=KANNELPASSWORD&to=03333021909&text=ALERT:+INTERNET+Link+DOWN+at+$date+$time+[YOURCOMPANY+Pvt+Ltd]"
Howto make KANNEL start on reboot
edit following file
/etc/default/kannel
and make sure it looks like following
START_WAPBOX=1 START_SMSBOX=1
If you receive some permission error in logs like below image
then follow this guide
Regard’s
Syed Jahanzaib