HOWTO: Use PyS60’s Bluetooth Console on Fedora/Ubuntu/Debian Linux
While developing PyS60 apps is one of the most fun things you could do with your Nokia phone, debugging them isn’t as zippy as one would hope for in a Py development environment. To make up for that, PyS60 gives the developers an option for directly connecting to the interpreter through Bluetooth. Doesn’t sound very appealing? How about this: You connect your laptop with the cellphone, jump in at some place in the code while your app is executing and then use lappy’s big keyboard for exploiting different code and values in the interpreter. Sounds better?
To accomplish this on a Linux distro, you will need the following packages installed on your system:
Name | Links |
---|---|
gnome-bluetooth |
|
uucp /cu |
After making sure that both are present on your system, install PyS60 on your phone if you haven’t already done so.
Now the fun part:
- Switch on Bluetooth in the cellphone.
- Launch
bluetooth-properties
and click on “Setup New Device”. - Select your cellphone.
- You will be shown a pin.
- Enter the pin when queried on the cellphone.
- The phone should be successfully paired.
- Authorize your Linux system to make automatic connections to the phone.
- As
root
, run this shell script:[root@orthanc ~]# ./rfcomm-listen.sh
Serial Port service registered
Waiting for connection on channel 2 - Launch PyS60 interpreter and select “Bluetooth Console” from the application menu.
- Select your Linux machine.
The command you ran in previous step should have new output:
[root@orthanc ~]# ./rfcomm-listen.sh
Serial Port service registered
Waiting for connection on channel 2
Connection from 00:17:4B:B6:35:31 to /dev/rfcomm0
Press CTRL-C for hangupThe cellphone screen should be showing something like this:
- As
root
again, open a new terminal and run:[root@orthanc ~]# cu -l /dev/rfcomm0
Connected.
- Hit Enter till prompt (
>>>
) appears, then type:
>>> import appuifw
>>> appuifw.query(u'Hello World', 'text') - Viola, you should have an input box on the mobile screen:
- Enter any text and press the OK key. It should be show up in the terminal you were using to type in code:
>>> import appuifw
>>> appuifw.query(u'Hello World', 'text')
u’Finally’ - Exit the interpreter by typing
CTRL+D
on an empty line:
>>> import appuifw
>>> appuifw.query(u'Hello World', 'text')
u’Finally’
>>>
Interactive interpreter finished.
cu: Got hangup signalDisconnected.
Pat yourself on the back. Now, you can use your Bluetooth console to import
your modules, execute some stuff and then jump in the middle to test some extra lines or values. In fact, I found it to be a pretty darned good way of learning about PyS60’s API. Res secundae!