Mittwoch, 24. September 2008

Python via bluetooth console with Nokia S60 and openSUSE 11.0

If you have a Nokia S60 smartphone, you can install python on it and mess about with it. There is quite a bit of documentation on the Nokia developers site on this and there are lots of applications already hosted on the python for S60 wiki. What I found was lacking, was a good description of how to get a bluetooth console set up so that you can type commands on your linux pc and have them executed on the phone and the results displayed on the PC (quasi ssh-like). The official wiki has a howto at http://wiki.opensource.nokia.com/projects/PyS60_Bluetooth_console but even that seems to lack self-confidence and points to a 'better description' at http://crschmidt.net/blog/11/bluetooth-console/ (it really is better).

After trying out a number of tools and making tonnes of mistakes, here's what I did to finally get it working on openSUSE 11.0 (make sure that hcitool, sdptool, rfcomm, screen are installed - and I take it for granted that you have already installed and setup python on the phone itself - if not, go to http://sourceforge.net/projects/pys60/ )

  • hciconfig reset
  • hcitool dev
  • sdptool add --channel=2 SP
  • rfcomm listen rfcomm2 2
The last command Waiting for connection on channel 2
should output something like:
Waiting for connection on channel 2
Now open python on the phone. One of the options from the start 'options' is 'bluetooth console'. Choose the bluetooth console and follow the instructions (it will basically only ask you to select the bluetooth connection to use - typically your PC/Laptop. You can save the choice as 'default' if you like.) Once this is done, in the console where you typed the last command (rfcomm listen rfcomm2 2), you should now see:
Connection from 00:14:A7:8B:6A:A0 to /dev/rfcomm2
Press CTRL-C for hangup
Now open up another console and type:
screen /dev/rfcomm2
If everything went right, you should now have a python console. This python console is actually running on your phone - anything you type in will be executed on the phone. This makes developing python for Nokia S60 a cinch.

Keine Kommentare: