Nokia Lifeblog Posting Protocol Update

Nokia seem to have updated their Atom upload protocol in recent versions of their phones.

I’ve just got hold of a Nokia N93 and tried posting to this blog using Lifeblog and the new Web Upload functionality in the Gallery with use the Atom protocol.

These postings were failing with a bad password error. I know my username and password are correct and they worked using my old phone.

As I had written my own blogging software, and it’s Atom upload functionality I was able to debug the messages being sent from the phone to the server.

It turns out that newer versions of Nokia Lifeblog encrypt their passwords differently to older versions.

They use a method called WSSE. See my previous article on how to use WSSE with Perl for more details on how this works, plus example code.

Very quickly, the password isn’t sent, but a digest of the password and the values to generate the digest yourself are. These are then encoded using base64 for transmission over the internet.

Older versions (pre Lifeblog 2.0) expect a value called the nonce to be used as sent while the password digest is generated. Newer versions (Lifeblog 2.0+) expect the nonce to be decoded from base64 before the digest is generated.

Once I had worked out what was going on, it was simple to modify my code to check against both possible versions of the password digest. This means I can now post using old and new versions of Lifeblog, or the web upload functionality.

Here’s a very quick bit of example Perl code. Assume $my_digest is the digest with the original nonce left in place and $my_alternative_digest is the digest with the nonce decoded first. $digest is the digest sent my incoming Atom request.

## example perl code to check digests)
if (($digest eq $my_digest) || ($digest eq $my_alternative_digest)) {
## one of the digests has validated, so continue here
} else {
## neither digests has validated, so return invalid password responses here.

I don’t think this change has been communicated very well amongst the development community. It has probably come about due to changes in the Atom spec, but (admittedly only quickly) checking the documentation I’ve not found it.

I will be updating my WSSE validation example accordingly, and a new version of that allows posting from Lifeblog 2.0 to Movable Type shortly.

Using Series 60 Python To Talk To A Webserver

I’ve been continuing my journey into Python by modifying my earlier location script to now post details to my website when run.

I’m using the standard urllib now and moving to slightly more advanced Python language features such as dictionaries (basically the equivalent of a Perl hash).

The code gets the location, calls a CGI script on my website and prints the returned message from that script to the console.

Here’s the code…

# we need access to the location and urllib modules so have to
#import them.
import location
import urllib
# get the mmc, mnc, lac and cellid by calling the gsm_location
# method from the location module.
(mmc, mnc, lac, cellid) = location.gsm_location()
# add the location to a python dictionary called params.
params = urllib.urlencode({'mmc': mmc, 'mnc': mnc, 'lac': lac, 'cellid': cellid})
# open a filehandle to a cgi tracking script that takes
# the contents of dictionary params as parameters.
f = urllib.urlopen("" % params)
# get the results, hopefully a message saying OK.

All the CGI script on my website does is to record the parameters passed to it and return a simple text string saying it ran OK.

As you can see it’s really simple to Series 60 Python to communicate over the phone’s network connection. I have to say, this language is turning out to be better than I had expected, and far easier than J2ME.

My First Python Script

It’s a full day since I started to try to teach myself Python for my Nokia 3230 phone.

My first script is running, and though it isn’t anything impressive, I’m still very pleased with the results.

So what is this amazing script? Well it just gets the current location of the phone by CellID, using the location module supplied with Python, and displays it on the console.

Here’s the code…

# we need access to the location module so have to import it.
import location
# get the mmc, mnc, lac and cellid by calling the gsm_location
# method from the location module.
(mmc, mnc, lac, cellid) = location.gsm_location()
# print out the retrieved details to the console.
print "mmc %sn" % mmc
print "mnc %sn" % mnc
print "lac %sn" % lac
print "cellid %sn" % cellid

screenshot of the python location script results
As you can see it’s not going to win any prizes at PyCon, but it does provide some very practical information for me, namely my location.

But what are those 4 variables returned?

  • MCC = Mobile Country Code
  • MNC = Mobile Network Code
  • LAC = Location Area Code
  • Cell ID = The Cell’s ID 🙂

Stay tuned for more Python adventures over the coming weeks.