telematics

Basic Telematics using SMS and the Web » read article

posted by ian grant on March 24, 2006 at 10:00 pm | in digital art hacks, flickr, telematics, web 2.0 | Comments Off

Integrating Short Message Service (SMS) and the Web

Introduction

“Flickr Peep Show” connected mobile phone networks and a popular internet social photography network by means of SMS messaging and explored public display and projection. See Flickr Peep Show for more information. If you wish to do this style of creative telematic work, read on!

There are a number of ways to get going with SMS (Short Message Service) and web page integration. Some techniques are trickier and more expensive than others. Some rely on you having direct access and control over the web server – this may be possible when you are using web technologies to do installation / gallery work and are providing the infrastructure yourself (eg. degree shows).

The three options I write about here are:

(Option 1) Subscribe to an online SMS gateway
(Option 2) Use a GSM Modem
(Option 3) Using a Bluetooth-Enabled Mobile Phone, A Bluetooth-Enabled Mac/Linux Server and UltraSMS


(Option 1) Subscribe to an online SMS gateway for sending and receiving messages.

This option is the only one that does not require physical access to the web server.

(a) Find a service and sign up.
I use tm4b – bulk sms gateway. http://www.tm4b.com/

Signing up is free [true circa March 2005). You have many options for sending messages, via their web interface, via their simple Application Programming Interface (API) using scripting languages like php. The cost per message is slightly cheaper than mobile network operators charge.

(b) Sending a message using tm4b's SMS API and PHP
Here is a working php script. Download here (ctrl/right click): sms.php.txt.

<?php
//initialize the request variable
$request = "";
//this is the username of our TM4B account
$param["username"] = "[your TM4B username]";
//this is the password of our TM4B account
$param["password"] = "[your TM4B password]";
//this is the message that we want to send
$param["msg"] = "This is a sample SMS.";
//these are the recipients of the message
$param["to"] =
"[recipients phone # or multiple #s seperated by a pipe (|)]";
//this is our sender
$param["from"] = "Ian";
//we want to send the message via first class
$param["route"] = "frst";
//we are only simulating a broadcast
//$param["sim"] = "yes";
// un-comment this line to enter 'simulation' mode.
// It will test the script without sending a message (saving money)

//traverse through each member of the param array building
//the url query
foreach($param as $key=>$val){
//we have to urlencode the values
$request.= $key."=".urlencode($val);
//append the ampersand (&) sign after each
//parameter/value pair
$request.= "&amp;";
}
//remove the final ampersand sign from the request
$request = substr($request, 0, strlen($request)-1);
//echo $request;
//uncomment this line to view the URL that is constructed
//using the code above.
//this is the url of the gateway's interface
// method 1 — using CURL – this must be installed
$url = "http://www.tm4b.com/client/api/send.php";
//above: the url of the gateway's interface
$query = $url."?".$request;
$ch = curl_init($query); //initialize curl handle
//run the whole process and return the response
$response = curl_exec($ch);
<pre><code>curl_close($ch);//close the curl handle
// uncomment to show the result onscreen for debugging
//echo $response;

(c) Receiving messages

Receiving messages via a web page and handling that message within a script is slightly more involved. Some web based 'bulk sms' suppliers charge a packet (no network pun intended) for this facility - you normally need a dedicated number or short number and the set up costs are prohibitive - with monthly fees sometimes as high as £1000! I am have a 'keyword' and a dedicated short number from tm4b.com. I'll update this post / or post another entry when I have had a chance to evaluate this service properly. The API is flexible and well documented.

[update 18 July 2006 - I won a dedicated keyword on a long-number-service of my choice in a customer service survey for tm4b - I can highly recommend them as a web based SMS service - check out their current options here: http://www.tm4b.com/

The principle is: through your suppliers web interface you set up a "message receiver" and a "message responder". tm4b.com has 3 main channels for handling received messages: depicted here (read from bottom to top):

Tm4B Receiving Model Image

In the case of our artistic endeavors, the communication model may not immediately re-route the message to a user. It is likely the text message will be intercepted by a web script using the SMS API and processed in a creative and interesting way. For example: text process the message, stripping keywords and then flickr retrieving images, or store the message in a mysql database and processed later - maybe into a fragmented hypertext narrative.

(Option 2) GSM Modem with SMS capabilities with Built in SIM Card Reader

You need to buy a modem and have a spare SIM card with a phone number, dedicated only to receiving SMS and have physical access to a server.

Richard Colson (Digital Arts Pathway Leader) has a Falcom GSM modem for use in Digital Art modules. [Note: this post was originally written as a tutorial for students on the BA (Hons) in Digital Art at TVU, London. http://mercury.tvu.ac.uk/da/] The drivers are windows only and as yet, I have not tested it. It can send/receive SMS message to a dedicate phone number and relays the message to the PC it is connected to. Using cross platform open source SMS tools (http://smstools.meinemullemaus.de/), you can configure a server box to do near enough what you wish. Using it, Richard has created a shockwave movie that interfaces with a matrix display and outputs SMS content.

(Option 3) Instant SMS to MySQL Using a Bluetooth-Enabled Mobile Phone, A Bluetooth-Enabled Mac/Linux Server and an Open Source 'Daemon' Called UltraSMS

Requires: Physical access to a bluetooth enabled linux or Mac OS X Server, running MySQL and a supported phone

This option is very cool and relatively straight forward. Put simply: the server and the phone are 'paired' via bluetooth. A small piece of software (ultraSMS), called a daemon, runs continuously in the background and 'listens' for an incoming SMS. As soon as a SMS is received, the daemon pulls the SMS data off the phone, inserts it into a MySQL database and tidies up by deleting the received message from the phone. As soon as the SMS is in the database, any server side scripting language can access, process and output the data.

Step by step

(a) Download UltraSMS here: http://kinks.ultralab.ac.uk/ultrasms/
UltraSMS is an open source daemon for sending and recieving SMS messages. It will work on Mac OS X and Linux systems. It comes with full instructions for use.

(b) Use phpMyAdmin, or similar tool, to create a MySQL database on the webserver to contain the SMS Data - the SQL file (ultrasms.sql) to do this for you is included in the ultraSMS distribution.

01 Create Db-1

(c) 'Pair' the server via Bluetooth with a supported phone (luckily mine was on the short list!).

On a mac you do from the bluetooth preferences, detailed instructions are in the documentation of ultraSMS (click for larger images):

Bluetooth 01

Pair the phone, then click the button to edit the serial ports:

Bluetooth 02-1

Here are the settings: the port name will be needed in the configuration file in the next step, so copy it!

Bluetooth 03-1

(c) Edit the UltraSMS Configuration file (utlrasms.conf) to point to the newly created database, sample below your details may vary.


DEVICE = "/dev/tty.Torme-SerialPort-1"
DAEMON = "FALSE"
DEBUG = "FALSE"
MYSQL_HOST = "localhost"
MYSQL_DB = "ultrasms"
MYSQL_USER = "root"
MYSQL_PASS = "[insert your mysql password]"

You put this conf into the /etc/ directory.

(d) Start the daemon.

Start Daemon

(e) Wait for a text!

(f) Voila! Message Received

Daemon Receives Message

(g) The SMS data is automatically inserted the database.

Database Result

(h) The next step is to do something cool with the data!

Conclusions

I favour option (3). Physical access to a server is not always possible and so this solution is ideal for art installation scenarios where one has hands on access to a web-server setup.

Option (1) - is great but finding an inexpensive service, of an appropriate scale and that is reliable has so far eluded me. I will update this view when www.tm4b.com get back to me.

The next tutorial, Public Art and Interactivity using SMS: a prototype, will demonstrate how to integrate a flickr search with the ultraSMS and MySQL process elaborated in Option 3.

Ian Grant

Further Links

Flickr Peep Show
http://www.textually.org/

searching and returning images from flickr » read article

posted by ian grant on February 5, 2006 at 4:45 pm | in digital art hacks, telematics, web 2.0 | no comments

A number of people need to get searching flickr, returning and displaying images according to tag or full-text searches and handling associated tags. Although it seems a long process, this tutorial demonstrates one way to approach flickr that is simple and flexible. (more…)

(cc) ian grant some rights reserved