Our own little SMS gateway
One of my favorite projects at Kielikeidas, and stories to tell from those days, was when we created our own home-grown SMS gateway. (Kielikeidas was a small Web agency I worked for 2004–2007.)
When a longtime client of our’s asked if we could set up a weblog in a hurry (to start in six days), I said “no problem.” What the client had neglected to tell me was that he wanted the weblog to be updatable via a mobile phone, and from anywhere in Russia.
Reporter Tuomas Karhu was taking the Trans-Siberian train to Vladivostok and back, and was to keep a blog of the journey. These days, setting up a weblog that can be updated from a mobile phone is trivial. In 2005, this wasn’t exactly the case.
First of all, mobile phones weren’t as advanced as they are today. More significantly, though, it was unlikely that there would be data network coverage on the train and for the entire trip.
My colleague Marko Samuli Kirves and I investigated several alternatives, but the easiest solution seemed to be to update the blog with SMS messages (this was way before Twitter or Jaiku, remember).
Our first choice was to contact commercial SMS gateway service providers. Unfortunately, it was the height of the Finnish summer vacation season, and none of the providers were able to set up a service for us on time. Also, there was the problem that the short code numbers used in Finland by commercial service providers don’t always work from abroad.
In addition to pursuing several alternatives, we started considering setting up our own makeshift SMS gateway. If we took a regular Nokia phone with a regular operator plan, we could hook it up to a laptop. Using the open source library Gammu to read the messages off the phone, we could parse the messages and send them on to the Wordpress weblog through its XML-RPC interface.
This would perfect, we thought — if we could get it to work. There was one big hitch: Gammu only knew how to read phones through a serial port interface. Older Nokia phones used to have USB cables with built in serial port emulators, but newer models used the USB interface natively. We did have an older model phone that Gammu supported. All we needed then was a cable.
I looked up a bunch of mobile phone shops, and started calling. The first place I called looked up the cable on their computer and said yes, they had one. So I went to the store and asked for the cable, and the guy gave me one. But it’s the wrong cable.
“This is the wrong cable,” I said.
“Oh. Well, that’s the only Nokia cable we have,” the clerk said.
So I called the next store. They had two, the guy said; but, of course, they didn’t. Losing faith in the inventory systems of the stores, I just started visiting the stores to look through their bins. I went to four more stores that day, and none of them had the type we needed. (I did learn a lot about the deficiencies of inventory software that day. Some shops label similar products under the same product code, while others share the inventories of multiple locations. How they’re able to keep their shelves stocked, I have no idea.)
In the end, it was over the phone that I finally found the cable we were looking for. It was in a store at a shopping mall, and I asked them to reserve it for me. The next day, when I went to pick it up, they sold me the cable for half price because it was a return. I didn’t tell them I would’ve paid ten times more.
We wrote some middleware PHP scripts to handle the messages, and the cobbled-together “SMS gateway” was in use. It understood multi-part SMS messages, which meant the message length wasn’t fixed. It also recognized the sender’s local time, and would fix the timestamp of the entry appropriately.
We ended up using the gateway for several years with multiple blogs (including this one) and other SMS-triggered applications. The only time the gateway went down was when a salesman from our company had unplugged the power source at our office to charge his own phone.
Later on, we built a system for posting videos shot with mobile phones and digital cameras to Wordpress blogs. It involved transferring the video files from the blog server to another server where they were transcoded into the FLV format (using the open source ffmpeg library), and moved back to the blog server and added to the media library. But that’s another story altogether.
---
There is 1 other entry posted on this day.