One of the nifties things I have on my cell phone is a bluetooth capability: the ability to communicate with other devices nearby at relatively high speeds over a wireless protocol. Bluetooth is a very useful tool for development: I don’t have to worry about USB cables or anything else, and I can talk equally well to my Linux desktop with an abicom BT adapter as I can to my Powerbook with its built-in bluetooth.
One thing that no one has mentioned yet about the new Python release is the Bluetooth console. It took some doing, but I finally got it connected to my Linux desktop, and found an app that will let me connect to the port. Now, I basically have a way to tell my phone what to do over Bluetooth:
[crschmidt@peanut ~]$ sudo cu -l /dev/rfcomm0 Connected. Python 2.2.2 (#0, Dec 2 2004, 18:12:32) [GCC 2.9-psion-98r2 (Symbian build 540)] on symbian_s60 Type 'copyright', 'credits' or 'license' for more information. Type 'commands' to see the commands available in this simple line editor. >>>
This has sped up my application development significantly: with this in place, I can start to experiment with different code at a rapid rate: without sending almost identical files to the phone several dozen times to test them, nor typing on the 3650’s keypad to enter my code. I just type into a normal tty, and it acts exactly like a local python interpreter.
This is also possible, and documented as such, using TCP/IP over GPRS instead of Bluetooth. However, the speed restrictions of that cause it to be much less practical. It’s like typing into ssh over bluetooth: sure, it’s okay, but you almost never want to do it if you can avoid it.
Here’s what I ended up doing to get it working:
- Get a working bluez install. Bluez is the standard Linux protocol stack, and is built in to most recent kernels.
- Test that you can talk to the phone, using hcitool scan, hcitool info.
- Register an “SP” (serial port) service with sdpd. sdptool add –channel=3 SP
- Ensure that sdpd is running
- Set up an rfcomm port to receive the communications: rfcomm listen /dev/rfcomm0 3
- (On Phone) Open Python, then bt_console.py
- On the computer, you should see:
[crschmidt@peanut ~]$ sudo rfcomm listen /dev/rfcomm0 3 Waiting for connection on channel 3 Connection from 00:60:57:41:86:C2 to /dev/rfcomm0 Press CTRL-C for hangup
- Using taylor-uucp, type cu -l /dev/rfcomm0
- Welcome to the phone!
If you want to test to make sure it’s working, you can do something simple like:
import appuifw appuifw.note(u'Howdy!', 'info')
from there, refer to the excellent Nokia documentation for more tips and tricks on what you can do. I think this is definitely a great example of what power the distribution has, and I’m surprised that more people haven’t been writing about it. Has anyone besides me (and Nokia employees) gotten this working?