[Note: This post was originally written for OS X 10.3, but now includes an "updated" section for OS X 10.4. The comments address the Bluetooth setting changes in OS X 10.5.]
The documentation shipping with Python for Series 60 doesn’t cover using the Bluetooth Console with Mac OS X; However, connecting is possible using just pre-installed Apple software. Step one is to make sure your machine has already been paired with your phone, that Bluetooth is turned on, and that you’re Mac is discoverable. Pairing is done using the “Bluetooth Setup Assistant” in /Applications/Utilities/; The other settings are done from the Bluetooth control panel in System Preferences. Next, fire up “Bluetooth Serial Utility” which is also hopefully in /Applications/Utilities/. Using the Serial Utility, you’ll setup an incoming RS-232 port. Give it a name you’ll remember. I ran into a little bit of trouble connecting when having multiple incoming ports like this, but I imagine it can be done. With just one port open, I had no trouble.
Once you create and name your new incoming Bluetooth port, you should have a matching device link at “/dev/tty.portname”. From a Terminal (ie., /Applications/Utilities/Terminal.app), you can then use the command “screen /dev/tty.portname” to redirect that port to the terminal. With this part ready, you can now fire up Python.app on the phone and run the “Bluetooth console” script. Use the BTConsole application to search for available Bluetooth devices and choose your Mac from the list. The BTConsole application will likely dump some address and port discovery info to the screen, but eventually you should see a “Connected” message in your Mac Terminal window followed shortly there after by some directions and a Python prompt.
From the Mac, “Control-d” will exit the BTConsole and shut down the process on the phone.
“Control-a Control-\” (or “Control-a K”) will shut down the ’screen’ process.
Enjoy!
[Update 2006-02-13]
“Bluetooth Serial Utility” is no longer installed with new versions of OS X. To set this up on OS X 10.4.x, go to “System Preferences :: Bluetooth” and open the “Sharing” tab. From there, click the “Add Serial Port Service” button in the lower-left corner of the dialog box. A new service should appear in the text area above. From there, you can change the name to something memorable, like “bt_console”. Make sure to change the “Type” from “Modem” to “RS-232″, and be sure that the “On” checkbox is checked. If you’re currently not listening for Bluetooth Series connections, you’ll need to activate it with the “Start Serial Port” button. If your machine is already listening, the button will read “Stop Serial Port”, which you won’t want to click.
Also new since this post, the Bluetooth Console is now built-in to Python for S60. It’s under the Options menu.
November 29th, 2005 at 5:41 am
[...] (If you want to use Terminal.app, I found a great tip for pointing the output of the RS-232 port to the screen: “screen /dev/cu.Bluetooth-PDA-Sync”.) [...]
February 13th, 2006 at 1:36 pm
I was interested in using this but couldn’t find the “Bluetooth Serial Utility” on either of my family’s Powerbooks — both running Mac OS 10.4.2. Eventually I figured out that the same functionality is now available in the Bluetooth Preferences panel. The Sharing tab has a button at the bottom saying “Add Serial Port Service”. After using this, and renaming the serial port PythonConsole, “screen /dev/tty.PythonConsole” worked.
(The other detail I missed was that you have to start Python on the phone, go to its Options menu, and select the Bluetooth console command.)
February 13th, 2006 at 2:32 pm
Thanks Guido! I’ve updated the post to reflect the changes in OS X 10.4 and the newer build of Python for S60.
February 4th, 2007 at 11:32 am
I followed the instructions, but got only “connection refused” from the Python on the phone. Then I noticed that there was already a serial port defined on the Mac, called “Bluetooth-PDA-Sync”, and presumably created by iSync. I tried using that port (”screen /dev/tty.Bluetooth-PDA-Sync”), and it worked. So if you have that port, no need to create a new one, even though it’s of type “modem”.
August 13th, 2007 at 1:04 pm
[...] um über die Bluetooth-Schnittstelle eine Konsolen-Sitzung zu erzeugen (das HowTo habe ich von eriksmartt.com). Die Geräte sollten via Blutooth miteinander verbunden sein und im “Bluetooth [...]
September 13th, 2007 at 1:56 pm
I just created a step-by-step instructables guide for doing this in 10.4 with my Nokia E70. Screenshots, pictures and all.
http://www.instructables.com/id/EBEXSILF6B7SY7Z/?ALLSTEPS
Feel free to republish/repurpose any of it. I realeased it into the public domain.
September 13th, 2007 at 10:54 pm
Very nice Peter!
November 29th, 2007 at 5:00 am
Does anyone know how to generate a bluetooth database in Python for blender?
November 29th, 2007 at 5:49 pm
import audio
audio.say(”thank you erik”)
:-)
November 30th, 2007 at 9:50 am
:-)
January 21st, 2008 at 2:11 am
Bluetooth options in OSX 10.5 (Leopard) were moved around. Serial port settings, including the crucial RS-232 one, are reachable via Bluetooth Preferences, tucked away under the “Advanced” button. It may be necessary to add a new serial device via the “Perform tasks with the selected device” — click the gear icon, select “Edit Serial Ports…”.
Should probably make a new instructable for Leopard. I believe this excellent post still holds othewise. Thanks Erik!
B)
April 9th, 2008 at 3:28 am
Im using Leapard. I tried this and it tries to connect but then I get a bluetooth error: “Failed to open an RFCOMM serial channel.”
and screen terminates and on the phone it says broken pipe.
any ideas?
April 9th, 2008 at 3:44 am
Okay I got it to work by using screen /dev/tty.Bluetooth-PDA-Sync which is set up as a Modem. I tried to add another bluetooth serial device and call it pyconsole with RS232 but that gave the error. But it works though the modem device.
May 16th, 2008 at 12:02 pm
[...] can also find other online guide for older Mac OS X. - eriksartt.com/blog - [...]