General
Kannel for Windows – Some Cygwin Binaries
Apr 8th
A customer of mine recently asked me for a windows version of Kannel. Prior to this I had no experience with Cygwin/Windows development at all. It was actually extremely simple to build Kannel using Cygwin (thanks to the Kannel developers for being, well, pretty cool
).
Obviously it’s not the easiest thing in the world for non-developers so I thought I would make it easy for everyone to just simply download some binaries of Kannel and get going.
So with that said, I have built two installers for Kannel to run on windows. I have built against the stable release 1.4.3 and then I have done a CVS snapshot build against CVS dated 2009-04-07.
If you are interested in these, please navigate to my kannel for windows page which I will keep up to date as more stable releases get done.
Just a bit of background of how to build your own versions on Cygwin below:
- Download latest version of Cygwin
- Install, making sure you select the development packages (gcc, automake, libxml2-devel, openssl-devel, etc)
- Download and extract the source of Kannel from www.kannel.org
- Change directory to the extracted source
- Run ./configure
- Run make
- Then if you wish, run make install to install (need privileges unless alternative –prefix was specified)
Easy !
Just as a final note, Kannel on windows should NOT be treated as a production ready piece of software, so this should be used strictly for convenience, testing, development, etc.
As always, if you have any questions, leave a comment or mail me via blog@ddj.co.za
Technorati Tags: Kannel, Windows, Cygwin

Extracting meta-data from SMPP TLV’s with Kannel
Mar 15th
I have been relatively quiet the past few weeks with various operations going on, but seeing as I have a few minutes to spare I thought I would do a quick post explaining how to extract SMPP TLV’s using the new Kannel meta data features which are in the current CVS branch.
These are scheduled for the 1.5.0 stable release of Kannel, so for now you’ll need to do a CVS checkout of the main branch (as described in my previous posts).
I will be demonstrating how to set a test TLV and then extracting this data when a reply is received. Once you have setup your ’smpp-tlv’ group, you simply need to specify an additional parameter in your smsbox request. This parameter is named ‘meta-data’. The format for this variable is ‘?<bind_type>?<dataset>’ currently the only supported bind type is ’smpp’ but it was done this way to allow future support.
The dataset argument, is a URL encoded key/value pair string. So for these tests I have configured a smpp-tlv group called ‘my-custom-var’. In order to set this, I need to build a string like this for meta-data purposes.
?smpp?my-custom-var=This+is+a+cool+var
As you can see my-custom-var is set as a URL encoded variable, this will still need to be URL-encoded for submission in the meta-data parameter sent to smsbox.
So just to demonstrate, using PHP how you would build this string, you would use.
$bind_type = "smpp";
$my_custom_var = "This is a cool var";
$meta_data = "?".$bind_type."?my-custom-var=".urlencode($my_custom_var);
/* Now we need to urlencode this string */
$meta_data = urlencode($meta_data);
/* So URL would look like */
/* cgi-bin/sendsms?to=...&from=...&meta-data=$meta_data */
So now, when you set this to smsbox, it will be sent via the smpp bind as a TLV. Easy!
Now on the converse, if your smpp bind returns a TLV in a deliver_sm or other PDU, this will also passed to your URL (if you have configured it. Here below is a basic function for parsing the meta data out of this string.
/* This function will take the meta-data string and return an associative array */
function parse_metadata($var) {
$pos = strpos($var, "?", 1) + 1;
/* Simply stripping out bind type 'smpp', this can be modified if you need it
*/
$var = substr($var, $pos);
$data = parse_str($var, $out);
return $out;
}
/* Example: */
$meta_data = parse_metadata($_GET['meta-data']);
echo "My custom var = ".$meta_data['my-custom-var'];
I hope this helps you with your SMPP TLV requirements. Good luck, don’t forget to email me if you need any assistance with Kannel/SMS, etc and I will do my best to help you as best I can.
Technorati Tags: Kannel, SMPP, TLV, Kannel Support
Send SMS using Java Midlet/J2ME and Clickatell
Jan 23rd
I have had some time to experiment with J2ME which is something I’ve always wanted the time to do. So during the course of this week (maybe a few hours total) I have put together my first Midlet. It’s a simple piece of software which allows you to send an SMS via the Clickatell SMS gateway.
You’ll need a Clickatell HTTP API Account to do so, if you don’t already have one click here to get one.
I have posted the source code here or you can point your mobile device directly at:
Alternatively, download the jar file directly (I had to do this to get it working on my Windows Mobile 6.1 phone) at http://www.ddj.co.za/s.jar
I wrote it using a Mac with Eclipse (with ME add-on’s) using mpowerplayer as the emulator. It is *just* a prototype and by no means uses best practice programming so don’t judge me on this quick hack
Enjoy! If you like this app and you want me to modify it for you please get in touch via midlet@ddj.co.za
Technorati Tags: SMS, J2ME, Midlet, Clickatell

Midlet running in mpowerplayer
HOWTO: Connect Kannel to an SMPP Server
Dec 5th
Today I will be covering how to connect Kannel gateway to an SMPP Server.
Following on from my previous post, you should have a wapbox, smsbox and bearerbox binary now compiled on your machine. Just to put your minds at ease, I want to cover some basic architecture of Kannel, so you can understand how your messages flow through the system, and potentially give you an idea of where to start your troubleshooting.
What this diagram indicates is, the bearerbox is the binary with ‘the muscle’, it directs the flow of messaging traffic, and connects to all your upstream SMSC’s, GSM modems, etc. These upstream SMSC type’s include, by default in Kannel, just to name a few, CIMD2, EMI, SMPP, AT modems, HTTP SMSCs and a few others. Seeing as Kannel is open source with a really flexible license, its easy to write your own custom SMSC’s, but that is way out of the scope of this document
So today, we will be focusing on getting the bearerbox, to connect to an SMPP server, seems simple enough!
Before you connect to something, you’ll need some basic details which your SMPP service operator will give you. This will include a system-id (username), password, hostname / ip address. This is what is required at minimum. Some operators will also give you things like default character set, system type and so forth. For todays demo I am going to connect to an SMPP server I have setup on my machine (should be fast!
).
So my details for connection (yours to be provided by operator):
- IP address : internal.smpp.ddj.co.za
- System-id (username): donsmpp
- Password: strngpas
- Port: 9102
So, at this stage my ‘bearerbox’ configuration looks as follows:
group = core
admin-port = 13000
smsbox-port = 13001
admin-password = bar
log-file = "/tmp/kannel.log"
log-level = 0
box-deny-ip = "*.*.*.*"
box-allow-ip = "127.0.0.1"
group=smsc
smsc=smpp
smsc-id=internal
interface-version=34
host=internal.smpp.ddj.co.za
port=9102
system-id=donsmpp
smsc-password=strngpas
system-type=default
transceiver-mode=1
group = smsbox
bearerbox-host = 127.0.0.1
sendsms-port = 13013
log-level = 0
Now you’re probably wondering where those other config settings came from, I’ll attempt to give you a really quick explanation.
- group = core, all settings under this group, are related to the core bearerbox configuration, ie which ports to listen on, log level etc, as you can see I have put the log-level on 0 which will give me tons of debugging information which is pretty useful (not recommended for production servers though
) - group = smsbox, this group specifies on which port/ip address to allow inbound connections from smsbox/wapbox/sqlbox/smppbox (see architecture) and isn’t really covered in this post, maybe next time
- So that just leaves our smsc group, which is to connect to our smpp server. I’ll quickly try to explain the non trivial configuration directives.
- smsc-id – this is a name given to the smsc, which can be used later for routing etc
- interface-version – This is to tell us what version of SMPP to speak to the server with, I have specified 34 which indicates version 3.4
- system-type – This is required by Kannel, but its not always required by the server, I have just specified a ‘junk’ value to stop Kannel from complaining.
- trancseiver-mode – This indicates that I want to bind as a transceiver to the server (as opposed to transmitter / receiver) what this will allow me to do is send AND receive messages over the same connection. This is a SMPP 3.4 specific option.
I’m sure you’re tired of reading now and just want to see ! So let’s start this sucker up. I will start it up from command line, some of you (using Ubuntu, CentOS etc) will start it via init scripts, ie, /etc/init.d/kannel start, I will start it up simply by executing /usr/local/sbin/bearerbox /opt/kannel/etc/my_bbox.conf – this will of course only start the bearerbox, not the smsbox/wapbox, etc. Here we go!
2008-12-05 09:26:08 [28431] [6] DEBUG: Thread 6 (gw/smsc/smsc_smpp.c:io_thread) maps to pid 28431.
2008-12-05 09:26:08 [28431] [6] DEBUG: SMPP[internal]: Sending PDU:
2008-12-05 09:26:08 [28431] [6] DEBUG: SMPP PDU 0x50dab0 dump:
2008-12-05 09:26:08 [28431] [6] DEBUG: type_name: bind_transceiver
2008-12-05 09:26:08 [28431] [6] DEBUG: command_id: 9 = 0x00000009
2008-12-05 09:26:08 [28431] [6] DEBUG: command_status: 0 = 0x00000000
2008-12-05 09:26:08 [28431] [6] DEBUG: sequence_number: 1 = 0x00000001
2008-12-05 09:26:08 [28431] [6] DEBUG: system_id: "donsmpp"
2008-12-05 09:26:08 [28431] [6] DEBUG: password: "strngpas"
2008-12-05 09:26:08 [28431] [6] DEBUG: system_type: "default"
2008-12-05 09:26:08 [28431] [6] DEBUG: interface_version: 52 = 0x00000034
2008-12-05 09:26:08 [28431] [6] DEBUG: addr_ton: 0 = 0x00000000
2008-12-05 09:26:08 [28431] [6] DEBUG: addr_npi: 0 = 0x00000000
2008-12-05 09:26:08 [28431] [6] DEBUG: address_range: NULL
2008-12-05 09:26:08 [28431] [6] DEBUG: SMPP PDU dump ends.
2008-12-05 09:26:08 [28431] [6] DEBUG: SMPP[internal]: Got PDU:
2008-12-05 09:26:08 [28431] [6] DEBUG: SMPP PDU 0x50dab0 dump:
2008-12-05 09:26:08 [28431] [6] DEBUG: type_name: bind_transceiver_resp
2008-12-05 09:26:08 [28431] [6] DEBUG: command_id: 2147483657 = 0x80000009
2008-12-05 09:26:08 [28431] [6] DEBUG: command_status: 0 = 0x00000000
2008-12-05 09:26:08 [28431] [6] DEBUG: sequence_number: 1 = 0x00000001
2008-12-05 09:26:08 [28431] [6] DEBUG: system_id: "DDJSMPP"
2008-12-05 09:26:08 [28431] [6] DEBUG: SMPP PDU dump ends.
2008-12-05 09:26:12 [28431] [6] DEBUG: SMPP[internal]: Sending unbind:
2008-12-05 09:26:12 [28431] [6] DEBUG: SMPP PDU 0x50dab0 dump:
2008-12-05 09:26:12 [28431] [6] DEBUG: type_name: unbind
2008-12-05 09:26:12 [28431] [6] DEBUG: command_id: 6 = 0x00000006
2008-12-05 09:26:12 [28431] [6] DEBUG: command_status: 0 = 0x00000000
2008-12-05 09:26:12 [28431] [6] DEBUG: sequence_number: 2 = 0x00000002
2008-12-05 09:26:12 [28431] [6] DEBUG: SMPP PDU dump ends.
2008-12-05 09:26:12 [28431] [6] DEBUG: SMPP[internal]: io_thread: break and shutting down
2008-12-05 09:26:12 [28431] [6] DEBUG: Thread 6 (gw/smsc/smsc_smpp.c:io_thread) terminates.
Success! Due to the log level, being on debug, we can see almost too much info, but great because our bind was successful! Our bearerbox is now bound to the SMPP server and ready to start sending messages. The great thing about Kannel is, its built in status page, so even if you don’t see this output, you can browse to the local web status page, http://<host>:<port>/status (or http://localhost:13000/status in my case) which will give you an output like this:
Kannel bearerbox version `cvs-20080824′.
Build `Sep 7 2008 12:04:32′, compiler `4.0.1 (Apple Inc. build 5465)’.
System Darwin, release 9.5.0, version Darwin Kernel Version 9.5.0: Wed Sep 3 11:29:43 PDT 2008; root:xnu-1228.7.58~1/RELEASE_I386, machine i386.
Hostname donald-jacksons-macbook-pro-6.local, IP 192.168.1.82.
Libxml version 2.6.16.
Using OpenSSL 0.9.7l 28 Sep 2006.
Compiled with MySQL 5.0.67, using MySQL 5.0.67.
Using native malloc.Status: running, uptime 0d 0h 0m 55s
WDP: received 0 (0 queued), sent 0 (0 queued)
SMS: received 0 (0 queued), sent 0 (0 queued), store size -1
SMS: inbound 0.00 msg/sec, outbound 0.00 msg/sec
DLR: 0 queued, using internal storage
No boxes connected
SMSC connections:
internal SMPP:internal.smpp.ddj.co.za:9102/9102:donsmpp:default (online 55s, rcvd 0, sent 0, failed 0, queued 0 msgs)
As you can see by this status output, I have no smsbox’s connected and am just demonstrating the bearerbox part. I will probably do a part 3 tutorial which will cover configuring smsbox and sending a few messages.
If you have any questions for me I’ll be happy to answer, even via comments or email. I hope this helps some of you connect your Kannel instances!
Technorati Tags: Kannel, SMPP, Architecture, Smsbox, Bearerbox, SMS
HOWTO: Compile Kannel on Ubuntu / Kubuntu 8.04
Nov 3rd
Hey everyone, I am putting together a multi-part post on how to compile Kannel as well as connect it to an SMPP Server and send a few messages through it. I will be using Kubuntu 8.04 for the tutorial but it should apply to most Linux distro’s.
Step 1 – Satisfying requirements / dependencies
Install CVS client:
sudo apt-get install cvs
Build dependencies:
Install build tools (gcc, mac, g++, etc. Not all necessary but you should have them!)
- sudo apt-get install build-essential
Install required Kannel dependencies (there are obviously way more, but this is all required on Kubuntu 8.04)
- sudo apt-get install libxml2-dev
Install optional Kannel dependencies (These are only required if you would like to use SSL enabled servers, alternate DLR storage options etc. For the purposes of this example I will enable our Kannel build for SSL and PostgreSQL DLR storage)
- sudo apt-get install openssl-dev
- sudo apt-get install libpq-dev
Step 2 – Getting the source of Kannel.
Option a) Downloading latest stable
Visit the kannel download page and download the source as gzip tarball (or bzip2 tarball if you prefer). In the directory you downloaded execute:
tar zxvf gateway-X.X.X.tar.gz
Option b) Getting the latest CVS (my preferred method)
You will need a CVS client installed.
Log in using the following command (just press Enter when it asks for
a password):
- cvs -d:pserver:anonymous@cvs.kannel.org:/home/cvs login
Check out the current version of the Kannel gateway:
- cvs -d:pserver:anonymous@cvs.kannel.org:/home/cvs co -d gateway-cvs gateway
Once the gateway is checked out, it will be in the gateway-cvs directory (as specified above)
Step 3 – Building Kannel
Change directory to the directory you downloaded the source to (gateway-X.X.X or gateway-cvs)
Execute:
- ./configure –with-pgsql –enable-ssl
This should configure the build correctly with OpenSSL and PostgreSQL support.
Once that’s done, execute:
- make
This will build the binaries for Kannel, if you want to install them system wide at this point you can by executing:
- sudo make install
You now have the Kannel binaries built for your use. These include smsbox, wapbox and bearerbox. You can either consult the Kannel user guide for how to use these or wait for my next post where I will cover setting and starting up Kannel (and some architecture stuff
).
I want more HD
Oct 27th
Been a long time since a post, sorry to my massive audience
Being the nerd that I am I adopted Multichoice’s HD offering as it was released. There were/are numerous things that I hate(d) about the new HD decoder. It’s buggy, it’s slow, and so on. But most of all what I hate is the seriously limited content that is available on the DSTV bouquet.
I am absolutely in love with the picture quality of the HD broadcasts, but it seems to me as Multichoice was just not prepared when they launched this system. The decoder out the box was buggy with debugging messages all over the place. The Olympics was a good platform to launch from, after it was over, I got really excited to see M-Net in HD, to be disappointed, there was no Carte Blanche at the usual 7pm timeslot. What Multichoice failed to mention was that M-Net HD is not normal M-Net, its basically a new channel with the odd ‘Simulcast’ (eg: Show’s run concurrently on standard M-Net and M-Net HD). I was looking forward to was the Saturday sport, Carte Blanche and other shows in HD. Only recently (this weekend) did they show some rugby in HD. It was BRILLIANT (ok and the Shark’s won
).
All I ask now of Multichoice is to add some more HD content/channels to the bouquet, there is simply not enough available at the moment and the HD decoder is not worth the investment at this point. I would like to see a roadmap from Multichoice showing the plans of when they are going to add more HD channels, so people can plan when they want to buy and not be fooled as I was into believing that there is an abundance of HD programming.
With that said, HD is the future and is brilliant, I just want more now.
Technorati Tags: DSTV, Multichoice, HD, M-Net
My new chip credit card
Apr 21st
I recently got a new credit card from my bank with one of these ‘fantastic’ new smart chips on it.
Wow, all shiny and pretty this thing must be good!
Wrong.
I knew this card required a PIN as opposed to my previous one, seems simple enough, I can deal with that
I went to three, different shops this Saturday to spend my hard earned money and at the first shop, *swipe* *try to use chip* “Sorry its not working…”. Next shop, *swipe*, call the supervisor, supervisor manages to get the transaction through! And the final straw was when I simply went to the Spar, you would think a big retail chain would be fully ready to deal with these new cards. Nope. Supervisor again, enter passwords and all sorts of things.
So yes, the bank tells you all the things that are great with this card. Its secure, safe and shiny! What they don’t tell is that the shops are not ready to use it properly, and that it will completely inconvenience you and waste your time every time you shop!
My recommendation is to avoid getting one of these for now wherever possible!
http://www.chipandspin.co.uk/
The irony of the gym parking lot.
Apr 8th
I am writing this post because I am completely confused.
People go to gym to exercise right? Do weights, run on the treadmill, take classes, etc?
If they are there to exercise, why on earth do people have to park so close to the front door? Surely a few extra steps wouldn’t hurt, maybe it would be good for people to warm up a little.
I go to gym at the Virgin Active at Tygervalley and on a daily basis my mind is blown by people, who park on curbs, in bushes and all over the place, to avoid taking ten extra steps for a parking slightly further from the entrance. I’m not talking about there being no other parking available, just pure lazyness (or crazyness?).
Am I the only person who sees the irony?
C Programmers get away with murder
Mar 27th
I have been reading a lot of C source code lately and I have found that C programmers are lucky, in that, they can get away with pretty much whatever they like.
Why? Well firstly, there are few C programmers around to start picking apart other peoples code so the reviewing process usually gets ignored. Secondly, C is fast. It is so quick by design that there is often no need to write good code, because the language on its own is just extremely fast, hence you will see a lot of sloppy code around!
With that said… If you don’t fit into the “trying your luck” coder category, the company I work for is looking for an additional programmer well versed in C with *nix experience, so if thats you, email me
Gauteng’s traffic explained.
Feb 15th
If you are like me, a person not from Gauteng, you may have wondered why you always hear about these ‘accidents’ in the morning during the traffic report. Why are there so many in Gauteng, is it just purely mathematical (more cars?) or is it some other phenomenon?
Well, I have recently had the (un)fortunate experience of travelling to Pretoria thanks to my loving company (shameless punt), and I think I have figured out the problem. There are so many accidents in Gauteng, because the people in Gauteng, drive like complete idiots. I have no doubt, driving ability wise, they are probably on average better than most other cities drivers, but when it comes to common sense, they must be the lowest.
While driving back to the airport from Pretoria, I was simply horrified to see how these loons drive. Zigging and zagging through the traffic at high speeds in their small sports cars until reaching a ‘go slow’ and then simply going down the emergency lane/yellow line. The question was, why was there a go slow? Because some idiot, in his sports car, had an accident. Now, in my opinion, from what I have seen, this must be a daily occurrence on the highways in Gauteng causing a serious head ache for motorists.
Being a programmer, let me try and approach this logically, and explain it to the loons out there who insist this is the best way to drive. If you drive fast and badly, ultimately, you will be in an accident and cause a huge delay for everyone else (law of averages), and while it may be some other loons turn today, yours will come. Now, if you all (loons) decide to drive with some relative sense (no emergency lane, minimal zigging and zagging), you will probably decrease your odds of an accident quite significantly, and if you all play along, there will generally be less accidents. Hence on average, there will be less delays, and everyone will be happier!
If you are from Gauteng and own a Z3/Z4/SLK/Any other equally compensating for something type vehicle, ask yourself, is it really necessary to endanger yourself and everyone else, to save those few minutes?
I’m guessing the answer is probably yes, but at least I tried.
