Professional Documents
Culture Documents
http://rapidsms.readthedocs.org/en/latest/conguration/...
Installing Kannel
A kannel package is included with Ubuntu, so installation is very easy:
sudo apt-get install kannel
By default in Ubuntu, Kannel starts a WAP gateway but does not start the SMS gateway. To change this behavior, first stop Kannel:
sudo service kannel stop
Now, edit /etc/default/kannel and uncomment the line starting with START_SMSBOX. If you wont be using the WAP gateway (if you dont know what that is you probably wont be), you can also disable it by commenting out START_WAPBOX=1. Note: Simply setting START_WAPBOX=0 will not disable it; you must comment out the line:
sudo vim /etc/default/kannel # or use your favorite editor
Finally, start Kannel again (note it will say Starting WAP gateway even if its only starting the SMS gateway):
sudo service kannel start
You can check that its running by looking at ps ax | grep kannel. You should see something like this:
2446 ? Ss
1 of 7
06/07/2012 10:24 PM
http://rapidsms.readthedocs.org/en/latest/conguration/...
2447 ? 2460 ?
Sl Ss
To make things simpler, well first setup Kannel and RapidSMS to work with a Fake SMSC, and then attempt to connect it to a USB modem.
include = "/etc/kannel/modems.conf" #--------------------------------------------# CORE # # There is only one core group and it sets all basic settings # of the bearerbox (and system). You should take extra notes on # configuration variables like 'store-file' (or 'store-dir'), # 'admin-allow-ip' and 'access.log' group = core admin-port = 13000 smsbox-port = 13001 admin-password = CHANGE-ME status-password = CHANGE-ME admin-deny-ip = "*.*.*.*"
2 of 7
06/07/2012 10:24 PM
http://rapidsms.readthedocs.org/en/latest/conguration/...
admin-allow-ip = "127.0.0.1" box-deny-ip = "*.*.*.*" box-allow-ip = "127.0.0.1" log-file = "/var/log/kannel/bearerbox.log" log-level = 0 #--------------------------------------------# SMSC CONNECTIONS # # SMSC connections are created in bearerbox and they handle SMSC specific # protocol and message relying. You need these to actually receive and send # messages to handset, but can use GSM modems as virtual SMSCs
# Here is a sample SMSC for use with the /usr/lib/kannel/test/fakesmsc comma group = smsc smsc = fake smsc-id = FAKE port = 10000 connect-allow-ip = 127.0.0.1
#--------------------------------------------# SMSBOX SETUP # # Smsbox(es) do higher-level SMS handling after they have been received from # SMS centers by bearerbox, or before they are given to bearerbox for delive
group = smsbox bearerbox-host = 127.0.0.1 sendsms-port = 13013 sendsms-chars = "0123456789 +-" log-file = "/var/log/kannel/smsbox.log" log-level = 0 access-log = "/var/log/kannel/smsbox-access.log" reply-couldnotfetch = "Your message could not be processed at this time. Pl reply-requestfailed = "Your message could not be processed at this time. Pl reply-couldnotrepresent = "Your message could not be processed at this time. http-request-retry = 3 http-queue-delay = 10 # # # # # SEND-SMS USERS
These users are used when Kannel smsbox sendsms interface is used to send PUSH sms messages, i.e. calling URL like http://kannel.machine:13013/cgi-bin/sendsms?username=tester&password=fooba
# This is the username and password that RapidSMS uses to deliver SMSes to # Kannel. It must also set the 'smsc' variable in the query string, so that # Kannel knows which SMSC to use to route the message. group = sendsms-user username = rapidsms
3 of 7
06/07/2012 10:24 PM
http://rapidsms.readthedocs.org/en/latest/conguration/...
#--------------------------------------------# SERVICES # # These are 'responses' to sms PULL messages, i.e. messages arriving from # handsets. The response is based on message content. Only one sms-service i # applied, using the first one to match. # The 'ping-kannel' service let's you check to see if Kannel is running, # even if RapidSMS is offline for some reason. group = sms-service keyword = ping-kannel text = "Kannel is online and responding to messages." # # # # # There should be always a 'default' service. This service is used when no other 'sms-service' is applied. These relay incoming messages from any configured SMSCs to the appropriate HTTP backend URLs in RapidSMS. By setting 'accepted-smsc', we are assured that messages are routed to the appropriate backend in RapidSMS.
group = sms-service keyword = default catch-all = yes accepted-smsc = FAKE # don't send a reply here (it'll come through sendsms): max-messages = 0 get-url = http://127.0.0.1:8080/?id=%p&text=%a&charset=%C&coding=%c
Youll notice the file includes a file called modems.conf at the top. You can copy this file from where Ubuntu installed it as follows:
sudo cp /usr/share/doc/kannel/examples/modems.conf /etc/kannel/
When you look at the process list (ps ax | grep kannel), you should see a 4th process for the smsbox now started, like so:
3231 3232 3243 3245 ? ? ? ? Ss Sl Ss Sl 0:00 0:00 0:00 0:00 /usr/sbin/run_kannel_box /usr/sbin/bearerbox -v 4 /usr/sbin/run_kannel_box /usr/sbin/smsbox -v 4 --
4 of 7
06/07/2012 10:24 PM
http://rapidsms.readthedocs.org/en/latest/conguration/...
You can further test that Kannel is running by using the fake SMSC (used only for testing) to use the ping-kannel service that we included in the Kannel configuration above:
/usr/lib/kannel/test/fakesmsc -m 1 "123 789 text ping-kannel"
On the last line of the output you should see the message that was sent by the ping-kannel service, e.g.:
INFO: Got message 1: <789 123 text Kannel is online and responding to messag
Press Control-C to kill the fakesmsc command and return to the prompt.
INSTALLED_BACKENDS = { "message_tester": { "ENGINE": "rapidsms.backends.bucket", }, # other backends, if any "kannel-fake-smsc" : { "ENGINE": "rapidsms.backends.kannel", "host": "127.0.0.1", "port": 8080, "sendsms_url": "http://127.0.0.1:13013/cgi-bin/sendsms", "sendsms_params": {"smsc": "FAKE", "from": "123", # not set automatically by SMSC "username": "rapidsms", "password": "CHANGE-ME"}, # or set in localsettin "coding": 0, "charset": "ascii", "encode_errors": "ignore", # strip out unknown (unicode) characters }, }
And test connection using the echo app in RapidSMS (if installed in your project):
/usr/lib/kannel/test/fakesmsc -m 1 "123 789 text echo hi"
5 of 7
06/07/2012 10:24 PM
http://rapidsms.readthedocs.org/en/latest/conguration/...
You should see the message get echoed back to you on the last line:
INFO: Got message 1: <123 123 text hi>
Next, add the following sms-service at the end of the file, which will send incoming messages from the modem to RapidSMS via HTTP:
group = sms-service keyword = default catch-all = yes accepted-smsc = usb0-modem # don't send a reply here (it'll come through sendsms): max-messages = 0 get-url = http://127.0.0.1:8081/?id=%p&text=%a&charset=%C&coding=%c
6 of 7
06/07/2012 10:24 PM
http://rapidsms.readthedocs.org/en/latest/conguration/...
router infrastructure to send and receive messages via the USB modem you configured above in Kannel:
INSTALLED_BACKENDS = { # ... "kannel-usb0-smsc" : { "ENGINE": "rapidsms.backends.kannel", "host": "127.0.0.1", "port": 8081, "sendsms_url": "http://127.0.0.1:13013/cgi-bin/sendsms", "sendsms_params": {"smsc": "usb0-modem", "from": "+SIMphonenumber", # not set automaticall "username": "rapidsms", "password": "CHANGE-ME"}, # or set in localsettin "coding": 0, "charset": "ascii", "encode_errors": "ignore", # strip out unknown (unicode) characters }, }
Now, the next time you call ./manage.py runrouter, you should see two Kannel backends get created (one for the fake SMSC and one for the GSM modem).
Troubleshooting
For help troubleshooting, please carefully review the relevant log files in /var/log/kannel as well as the output of the ./manage.py runrouter command. For additional help configuring Kannel, review the Kannel user guide or subscribe to the Kannel users mailing list.
7 of 7
06/07/2012 10:24 PM