S60 Surveillance Camera and PyS60 instability
Monday, August 2, 2010
During my 4-week summer vacation I had some time to work on one of those projects that I’ve been meaning to do for ages. The task at hand seems simple: I have an old Nokia E70 device and I want to use it as a surveillance camera so that I can go to joker.iki.fi and see the pictures taken from our house when I’m travelling with my family.
I decided to implement first quick-and-dirty version of this in such way that the phone takes pictures every 10 seconds and sends them, one-by-one, using the wifi interface, to joker.iki.fi as a POST request. On the server side, there would be simple server component, which saves the image and tags it with the time it’s taken.
Since I made a holy promise not to touch Symbian C++ ever again, I implemented the component which takes the pictures and sends them using python for S60. I already had some good experiences of this from the SMS forwarder script, so I decided to take a deliberate risk on developing something for a Symbian device on my free time. On vacation time, I like to avoid any frustrating projects and doing something on Symbian is always frustrating, maybe excluding shooting the thing with a shotgun.
At first, everything seemed to work very nicely. Then I got *AGAIN* into the hell that is development on the S60 platform. Even using Python, you can feel the shaky yet rigid bubblegum patchwork that is Symbian underneath. Nothing works like you expect, error messages are about as informative as sudden kick to groin and documentation is outdated, crap or it doesn’t exist.
The script is under hundred lines and doing basic things, yet it took me close to 12 hours to get it working (well kinda). Here’s the most annoying things I found:
1. PyS60 Socket library madness. I can’t understand (or really care) why there are two socket libraries in PyS60. There’s the normal python “socket” module and then there’s something called “btsocket”. These look mostly the same and BT in the beginning refers to “Bluetooth”, but then you can use it like you would use sockets for anything else. The thing is, it seems like pys60 libs use the socket library, so if you give python libs instances of btsocket, you get unexpected behavior. Nothing in the documentation tells you this.
2. The “default access point” behavior on S60. This is related to the socket annoyance but is a nice extension to this. You see, when an application tries to use network in Symbian, the os pops up a dialog for the user to select which access point (can be 3G packet data or Wifi for example) you want to use. At times this dialog randomly refuses to show you the Wifi access option and best of all: If you do “send(data, server)” in a loop for example, 10 times over, the default behavior is to … yes you guessed it: Ask the question 10 times, each time for each loop! How cool and secure is that!
So I ended up doing my own access point selection dialog which prevents also the problem of constantly selecting the access point. Why oh why did I need to code this myself?
3. Fail eventually, silently, horribly -style behavior. This is really notorious thing and seems to happen always on this platform. My application is essentially like this:
initialize()
ap = select_access_point()
while(True):
image = camera.take_photo()
send_image(ap, image)
Everything worked nicely so I decided to leave the script running and went to golf course. When driving back, I checked the camera output from my trusty HTC Hero. Surprise, the image hadn’t updated for hours.
I spend a lot of time trying to find why it’s crashing (and it was crashing the OS, not the python runtime) and managed to isolate the problem.
Probably most annoying thing was this:
4. When the app crashed the first time I first checked through the code and found no problems. Then I checked my pyS60 version, which was quite old, and decided to upgrade to the latest 2.0.0. I spend hours trying to do this and found out that no, it seems that for some reason the installation is just not working. Grr.
While every annoyance is probably not related to Symbian but some can be attributed to the pyS60 project, this is yet-another negative development experience on top of Symbian. It really is a waste-of-time-kinda-platform. I do realize that I’m in S60 3rd edition still and newer versions exist, but still I wonder when there will be a brave leader of Symbian who has the balls to say: Look guys, this OS is no more. It was nice in 2000, but we actually need to develop something that works nowadays and Symbian only gets in the way.
Please let there be such hero really soon.
I’ll probably release the surveillance camera as soon as I get the code cleaned up and hopefully the bugs get fixed sooner than later by PyS60 team.