Saturday, January 26, 2013

Configuring Kannel with GSM modem

These is sample config for Alcatel X200L(1bbb:0017) We assume that you have setup you modem(for example you have your modem at /dev/ttyUSB0-4)

1. Add kannel to dialout group (/etc/groups)
2. Config some stuff:
/etc/kannel/kannel.conf:
group = core
admin-port = 13000
admin-password =
admin-deny-ip = "*.*.*.*"
admin-allow-ip = "127.0.0.1"
smsbox-port = 13001
log-file = "/var/log/kannel/bearerbox.log"
#log-level = 3
box-deny-ip = "*.*.*.*"
box-allow-ip = "127.0.0.1"
dlr-storage = mysql
#--- mysql connection
group = mysql-connection
id = mydlr
host = localhost
username = kannel
password = jMYnv29rcScJEZsM
database = kannel
max-connections = 1
# ---- DLR table structure ----
group = dlr-db
id = mydlr
table = dlr
field-smsc = smsc
field-timestamp = timestamp
field-destination = destination
field-source = source
field-service = service
field-url = url
field-mask = mask
field-status = status
field-boxc-id = boxc_id
# device conf
group = smsc
smsc = at
smsc-id = usbmodem
modemtype = auto
device=/dev/ttyUSB3
my-number = +359888123456
log-level = 0
group = sms-service
keyword-regex = .*
catch-all = yes
max-messages = 0
get-url = "http://localhost/api/receive.php?sender_gsm=%p&receiever_gsm=%P&text=%a&dlr=%d&s=%n"
group = smsbox
bearerbox-host = 127.0.0.1
sendsms-port = 7048
global-sender = "sms"
#log-level = 3
log-file = "/var/log/kannel/smsbox.log"
group = sendsms-user
username = senduser
password = sendpass
max-messages = 3
concatenation = true
include = "/etc/kannel/modems.conf"
view raw kannel.conf hosted with ❤ by GitHub
/etc/kannel/modems.conf:
group = modems
id = generic
name = "Generic Modem"
speed = 9600
init-string = "AT+CNMI=1,2,2,2,1"
view raw modems.conf hosted with ❤ by GitHub

Important params:

* device - You should find out on what device you can access the modem with AT commands. So we try all of them from 0 to 4. This device works with 3 and 4.

* init-string - this one is extremely important. If it is not correct you even may not connect to the modem, can't send a message or can't receive DLRs. If you get "got +CMT but pdu_extract failed" message when receive a DLR it is highly possible that the init-string is not the correct one for your device.

No comments: