Kannel and GSM modems

During this past weekend I tested Kannel with my old GSM modem, it's a Free Works ED6000 (or WOO ED6000), also tried it on my Huawei K3565. I got the Kannel development version from SVN svn co kannel-gateway, this contains the smsbox, bearerbox and sqlbox (currently unused).

I then changed to my Kannel source directory (kannel-gateway) and compiled the source to /opt/kannel15. After compiling I started the bearerbox and smsbox, but obviously failed because both expect to be passed a configuration file which is not auto-generated during compilation. I had a lot of issues getting a working config file, most of the problems were due to not having an smsc group in my configuration which caused some weird behaviour, Kannel expects the core, smsbox, smsc and sendsms-user configured in order to do anything useful, that is if your interested in sending SMSs. There is an example config file in the docs package (/doc/examples/) but is hard to notice, I'm going to share my modified version below and explain some sections.

group = core
admin-port = 13000
admin-password = bar
log-file = "/tmp/kannel.log"
access-log = "/tmp/access.log"
# Smsbox related
smsbox-port = 13001

The admin-port and admin-password are used to run Kannel commands like shut-down, adding smscs, removing smscs, etc. I think smsbox-port is the port used by the smsbox to connect to the bearerbox.

group = smsbox
bearerbox-host = localhost
sendsms-port = 13013
log-file = "/tmp/smsbox.log"

The sendsms-port is the port used by the sendsms section, this is accessible from localhost:13013/cgi-bin/sendsms?username=foo&password=bar

group = sendsms-user
username = foo
password = bar

The sendsms user.

To configure the modems, I needed their init-string, device (the device location) and modemtype, and I used wvdial to get all this information (install it sudo apt-get install wvdial). Then insert the modem and run wvdialconf, it will generate a wall of text, mine contained the following lines.

ttyUSB1<*1>: Modem Identifier: ATI -- Manufacturer: huawei 
Found a modem on /dev/ttyUSB0. 
ttyUSB0<Info>: Speed 9600; init "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"

# WOO ED6000
ttyACM0<*1>: Modem Identifierr: ATI -- 5209.T406.00.A4
Found an USB modem on /dev/ttyACM0. 
ttyACM0<Info>: Speed 460800; init "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"

The first line has the modemtype ("huawei" and "5209.T406.00.A4"), the second has the device location (/dev/ttyUSB0 and /dev/ttyACM0) and the third has the init-string. My config for both modems look like this:

group = smsc
smsc = at
smsc-id = myhuawei
allowed-smsc-id = myhuawei
modemtype = huawei
device = /dev/ttyUSB0

group = smsc
smsc = at
smsc-id = ed6000
allowed-smsc-id = ed6000
modemtype = "5209.T406.00.A4"
device = /dev/ttyACM0

group = modems
id = huawei
name = myhuawei
init-string = "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"

group = modems
id = "5209.T406.00.A4"
name = ed6000
init-string = "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"

I struggled with SMSs being sent via an incorrect modem even while specifying the modem I wanted to handle the SMS, this was due to not having the allowed-smsc-id configuration option.

After this, I added my config to the Kannel directory /opt/kannel15/ and ran it using the following commands: /opt/kannel15/sbin/bearerbox /opt/kannel15/kannel.conf & /opt/kannel15/sbin/smsbox /opt/kannel15/kannel.conf

To wrap things up, I went to:
http://localhost:13013/cgi-bin/sendsms?username=foo&password=bar&smsc=ed6000&text=hello-world&from=277241234567&to=277241234567 and didn't receive anything:( Tried a couple of things and even assumed that my modem is not supported.
Then tried:
http://localhost:13013/cgi-bin/sendsms?username=foo&password=bar&smsc=ed6000&text=hello-world&from=00277241234567&to=00277241234567 and it worked:) This set-up expects the number to either not have a country code or have the country code with the + (written as 00) before it.
I will now attempt to get the inbound messages working and also make use of the SQLBox and hopefully write a post about it.

16 October, 2012 at 17:12PM

Auto-compile Twitter Bootstrap (C++)

I'm moving from Blueprint CSS to Twitter Bootstrap. I initially tried using less.js but it was too slow for my dev machine (I'm using an old low-spec laptop). I ended up installing node.js to get the less.css compiler, but manually recompiling the files is frustrating.

So, I have written a small auto compiler in C++ :) It polls for changes in the directory with the .less files and runs the lessc command.

// Auto reloads/compiles Twitter Bootstrap's .less files.
#include <iostream>
#include <unistd.h>
#include <sys/stat.h>
#include <ctime>
#include <cstdlib>

const std::string BOOTSTRAP_DIRECTORY = "zabalaza/static/less/",
    BOOTSTRAP_MAIN = "zabalaza/static/less/bootstrap.less",
    BOOTSTRAP_CSS = "zabalaza/static/css/bootstrap.css";

int main()
    using namespace std;

    struct tm* modified;
    struct stat file_stats;
    int modified_time, current_time = 0;
    // $ lessc input.less > output.css
    string cmd = "lessc " + BOOTSTRAP_MAIN + " > " + BOOTSTRAP_CSS;


    while (true) {
        stat(BOOTSTRAP_DIRECTORY.c_str(), &file_stats);
        modified = gmtime(&(file_stats.st_mtime));
        modified_time = mktime(modified);

        if (current_time == 0) {
            current_time = modified_time;
        if (modified_time > current_time) {
            current_time = modified_time;
            cout << "Recompiling .less files..." << endl;
            cout << "Done." << endl;

        cout << "Polling directory..." << endl;

    return 0;
08 August, 2012 at 21:17PM - a webpy blog running on Google App Engine

I started working on this blog code last year at the beginning of December 2010. I know about the popular options out there, I just prefer running my own custom blog software.

I also love webpy and GAE.

Some facts about

  • It's entirely written in :)
  • Runs on Google App Engine
  • Uses Markdown and Pygments
  • Jinja2
  • Blueprint CSS framework

Point number three simply implies that I get to write readable beautiful rich text with full code syntax highlighting:) Let me put this to the test.


$truth = 'I love Python';
$other = ' and PHP.';

echo vsprintf('%s%s', array($truth, $other));

?> has an RSS feed, and can create static pages. I have released teh codez under the GPL 3, and it's available in my GitHub profile.

04 January, 2011 at 11:09AM

© Copyright 2012 by Jose Sibande.