Python for Series 60

To give myself a break from my studies, I’ve been exploring writing code for my mobile phone. I bought a Series 60 phone at Christmas from a high-street store planning to learn how to program it. Instead I ended up wasting most of the holidays dealing with Carphone Warehouse’s appalling customer service.

(It’s a long story. In brief, the salesman lied to me and sold me the phone on a tariff that was unusable with the handset meaning I couldn’t get network access on it. His manager, an unhelpful thug, refused to accept the return of the phone. It took close to 40 hours of phone calls, letters, emails and visits to stores to cancel the contract and get my money back. The experience left a very bitter taste in my mouth. I will never use Carphone Warehouse again.)

I’ve only scratched the surface of developing C++ apps for Symbian so far but while searching for a way to read GSM cell info (according to the forum posts it looks as if the API is restricted to registered developers who pay) I found that it was simplicity itself to get this data using Python for Series 60.

Learning Python is (yet another) thing on my todo list and after installing it on the phone and trying out a few sample scripts from the web I’m eager to do so.

Although it’s easy to code on your pc and send the finished script to your phone via bluetooth, there is also a way to code directly on the phone from your machine by using the bluetooth console that is included with Nokia’s python installer.

Assuming you have bluetooth up and running already on your Debian box:

$ sdptool add --channel=2 SP
Serial Port service registered
$ rfcomm listen /dev/rfcomm0 2
Waiting for connection on channel 2

Now start python on the phone and select bluetooth console from the options.

Connection from 00:16:4E:CD:09:06 to /dev/rfcomm0
Press CTRL-C for hangup

In a new terminal on the machine start minicom with the following flags

$minicom -s -m

then choose “Serial Port Setup” and set the Serial Device to “/dev/rfcomm0″ and you’re ready to run.

Test with:

import appuifw
appuifw.note(u'Hello world!', 'info')

You should get a “Hello world!” info box popping up on your phone screen.

Now for something more interesting, print the gsm location details of your nearest cell (see how simple this is):

import location
print(location.gsm_location())

Finally to send a text message (replacing 0000000000 below with the real destination number) :

import messaging
messaging.sms_send("0000000000", u"Hello there")

I can see Python coming in very handy for creating rapid prototypes of applications and/or simple applications for private use only. Although I find the low level details you need to know for C++ development fascinating, there’s something undeniably satisfying about being able to write an application that does something powerful in only two or three lines of code.

Leave a Reply