Are you looking for my non-technical blog?

This is now my technical-only blog, my non-technical blog is here.

03 December 2005

Python Mobile Bluetooth Console

So, now you wanna write Python scripts on your phone, but you are sick of the phone keyboard. Then it is time for BTConsole (Bluetooth Console), where you can have a console connection to the Mobile Phone from your PC using the Bluetooth connection as a Serial Port Emulator. This can be done on both Windows or Linux, but I am going to describe the Linux part as I don't like Windows and also I failed to set it up on it. First of all you have to have the Bluetooth Protocol Stack (BlueZ) installed on your machine. You may also use an "ipconfig" or "ifconfig" like command on you Computer to get information about your Computer's Bluetooth Address (It looks like the MAC Address) and so ... this command is called "hciconfig" Also to discover the Bluetooth devices near you, use "hcitool scan" Now create a Virtual Port (/dev/rfcomm0) on your Linux Machine for the Bluetoot connection and start listening on that port ... Type the following two commands on you computer:
"sdptool add-channel=2 SP" (It shall tell you someting like "Serial Port service registered" now) "rfcomm listen /dev/rfcomm0 2" (It shall tell you something like "Waiting for connection on Channel2")
Then on you Mobile Phone, go to Python (You have Python for Series60 installed on your phone, don't you !?). And choose Bluetooth Console from the Options menu. It should connect to the computer now. And the following will be shown on you computer "Connection from AA:BB:CC:DD:EE:FF to /dev/rfcomm0" then "Press CTRL-C for hangup", where AA:BB:CC:DD:EE:FF is your Mobile's Bluetoot Address The Linux equivalent to HyperTerminal is called minicom, so it's time to use it to open a console connection to the mobile phone. To run minicom type "minicom -s -m" then choose "Serial Port Setup" and set the Serial Device to "/dev/rfcomm0" and leave the rest as it is. Now press escape and exit the Serial Port Setup Menu. Here we go, you are now connected to the Python Shell on your Mobile Phone. If you'd like you may use this to send an SMS from your PC:
>>> import messaging
>>> messaging.sms_send("+20101234567",u"Hello World")
Where +20101234567 is the phone number you want to send your SMS to. Resources:
By the way if this doesn't work, try the following howto by Dankoozy: HOWTO: Use the Bluetooth console in PyS60

Tags: , , , , ,