Configuration of gateway can be divided into two parts.
Bearerbox : bearerbox is a gateway, interface towards the phones. Its work is to keeping an eye on the gateway while it is running and use http interface to control the gateway.
smsbox : It handles sms gateway functionality. It contain sms-services, sendsms-user group which helps sms center to build.
sqlbox : (optional) sqlbox is used for DLR(delivery report) storage. Use to store logs of incoming and outgoing SMS in database.
Purpose of Using kannel : To send and receive sms for your application.
Requirements : GSM phone or modem (link to compatible.shtml)
Attach your phone or modem to the computer through USB cable.
Enter the following command in your terminal.
$ wvdialconf Note : run command with sudo user
If it display : No modem was detected.
Then your phone is not compatible with kannel.
If it display : Found an USB modem.
Then your phone is compatible with kannel.
Your connected device configuration written to /etc/wvdial.conf
Open wvdial.conf file in your favourite editor.
$ vim /etc/wvdial.conf
Value of Init1 ,Init2, Modem Type, Modem use in gateway configuration
Lets write configuration file for kannel.
Edit kannel.conf file on your desktop or anywhere you want in your file system.
core group is used for general bearerbox configuration. dlr-storage value is depend on which DBMS is used.
group = core admin-port = 13003 admin-password = admin-allow-ip = "127.0.0.1" dlr-storage = mysql //where to store the logs of sms smsbox-port = 13016 log-file = "/var/log/kannel/bearerbox.log" access-log = "/var/log/kannel/access.log" box-allow-ip = "127.0.0.1" log-level = 0
smsc group include all variables which used to set SMS center in kannel. smsc-id value is name of device which is connected. modemtype and device change according to Modem value in wvdial.conf file
group = smsc smsc-id = Nokia smsc = at modemtype = USB Modem device= /dev/ttyACM0 my-number = +919888888887 connect-allow-ip = 127.0.0.1 sim-buffering = false log-level = 0
mysql-connection group is used when mysql database is used to store data values. database,username,password variables values are database name,database username and password respectively.
group = mysql-connection id = mydlr host = localhost username = boot password = abc database = key
group = dlr-db id = mydlr table = dlr field-smsc = smsc field-timestamp = ts field-source=source field-destination = destination field-service = service field-url = url field-mask = mask field-status = status field-boxc-id = boxc
Modem group is used to define Modem configuration. init- string variable value change according to Init value in wvdial.conf file
group = modems id = Nokia name = Nokia detect-string = "Nokia" init-string = "ATZ" init-string = "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0" message-storage = SM message-start = 0
smsbox group must define to use SMS Kannel
group = smsbox smsbox-id = mysmsbox bearerbox-host = localhost //hostname bearerbox-port = 13020 sendsms-port = 13013 global-sender = +919888888887 //your modem number access-log = "/var/log/kannel/smsbox-access.log" log-file = "/var/log/kannel/smsbox.log" log-level = 0 mo-recode = true
smsbox route group is develop an interface between smsbox and bearerbox.
group = smsbox-route smsbox-id = mysmsbox smsc-id = Nokia
sendsms-user group is used to push SMS through browser. Variables username and password are used for authentication purpose.
group = sendsms-user username = password = concatenation= true max-messages = 10000
sms-service group is provide services to incoming SMS. Accepted-smsc variable means which SMS center used to accept as incoming SMS.
group = sms-service keyword-regex = .* catch-all = true accepted-smsc = Nokia max-messages = 99 get-url = "http://localhost/api/sms.php?phone=%p&text=%a"
Edit sqlbox.conf file where your kannel.conf file is placed.
sqlbox group used to tell kannel about sms log table and insert table. The sql-insert-table is used to store SMS which we want to send and sql-log-table is show logs of sms which are send through kannel and log of delivery reports.
group = sqlbox id = sqlbox-db global-sender = "+919888888887" bearerbox-host = localhost bearerbox-port = 13016 smsbox-port = 13020 smsbox-port-ssl = false sql-log-table = sent_sms sql-insert-table = send_sms log-file = "/var/log/kannel/kannel-sqlbox.log" log-level = 0
mysql-connection group explained before
group = mysql-connection id = sqlbox-db host = localhost username = boot password = abc database = key
Lets send SMS through kannel through http(browser) and application. Excited 😉
Start kannel service: Run these commands on seperate Terminals sequentially with sudo user.
$ bearerbox -v 1 kannel.conf
$ sqlbox -v 1 sqlbox.conf
$ smsbox -v 1 kannel.conf
Set verbosity level
0 is ‘debug’.
1 is ‘info.
Send SMS through browser : Open your favorite browser and type below given on address bar.
13001 is an admin-port number which is defined in core group.
username and password value which is define in sendsms-user group.
to value contain phone number to whom we want to send SMS.
text value contain content of SMS.
Send SMS through application : To send through application is just do one entry in send_sms table of defined database in config files.
Method : Write sql query which insert sender, receive number and message data in send_sms table. kannel automatically check send_sms table and send SMS.
sql code of tables
All the Best!