Linux

Extracting meta-data from SMPP TLV’s with Kannel

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: , , ,

Mac OS X on a PC Update + Ubuntu 7

Some of you may have read my initial, extremely short and uninformative post about installing Mac OS X on my PC. Well I got a little bit ahead of myself after installing that, soon realizing that I couldn’t actually do much with the PC as I was having a lot of incompatibility problems, drivers, and so on. Enjoying the challenge, I decided to keep looking around and I eventually found another, considerably better ISO image for Mac OS X (x86), running a later version (10.4.8) and patched for SSE2 and SSE3 CPU’s.

So, if you’re up for it google for ‘mac jas 10.4.8 sse2 sse3′ and download the image from your favourite torrent site. Burn the image and at the boot screen push F8 and the enter ‘-v’ to get verbose output during the install so you can see if something goes screwy. Make sure to uncheck printer drivers and only install what you need, also use the disk utility from the Utilities menu and make a Mac partition for yourself. I decided to leave some free space and not use the entire partition as I was going to try and run a dual boot configuration, but a bit more on that later.

Once installed I was faced with the driverless config of old, this time I was not installing it on my PC but on my older notebook, which is a HP Compaq NX7000 (Pentium M 1.5GHz [SSE2], 1.25 GB RAM, Bluetooth, ATI Mobility Radeon 9200, Built in 802.11b, etc) I managed to source some drivers for the Radeon 9200 which worked pretty well and allowed me to change the resolution to the native 1680×1050 offered by my laptop. I installed Microsoft Office Mac 2004 successfully, firefox and some other apps with no problem. Having such a crummy graphics card in the laptop does limit the performance some what because it does not offer something called “Quartz Extreme” or QE so the GUI is not as quick as a native mac or SSE3 machine, but it is still very useable, just don’t try and watch any videos in full screen or use OpenGL applications.

Once I had my laptop working pretty well I decided I would try the install on my more suited PC which I described in my last post (Pentium 4, SSE3, Geforce 6600). This time it was much more successful as I managed to find some drivers by the name of ‘Titan’ I suggest you check these out if you have an Nvidia card, otherwise, visit this site to check your hardware compatibility and possible driver links for what you need. The Osx86 Project has some awesome resources so browse around their site, you are almost certain to find what you need. After all my pain my PC runs Mac OS X extremely well with full video acceleration, and I have had no compatibility problems as yet so I think I have a winner there, but its just not as convenient as a laptop :]

OK, Jumping around a bit here, but after installing Mac OS X on my laptop, using the ‘free space’ I had allocated during the install, I tried to go ahead and install Ubuntu 7 on that partition, at first it wiped my boot loader for Mac, but after reading some guides I found that editing /boot/grub/menu.lst and adding in my Mac partition to the boot list, this problem was solved, and, I was seriously impressed with Ubuntu, it still boggles my mind that such great software is available for free. I think I have found my new home development environment, I installed all my development tools (Eclipse / XAMPP), hardware and personal items with such ease, the Ubuntu developers are definately on to something good hopefully they’ll get the community support they need (or enough of shuttleworth’s $$$) ;]

If anyone has any questions about my configuration of these operating systems don’t hesitate to ask, I will see what I can do to assist you, although I know very little on the subject :]

Good luck!

Technorati Tags: , , ,