Using the Python for Series 60 Bluetooth Console from OS X

[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/, 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 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.


[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.

17 thoughts on “Using the Python for Series 60 Bluetooth Console from OS X”

  1. 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.)

  2. 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”.

  3. 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!


  4. 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?

  5. 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.

  6. Hi there

    I am studying communication and computer networks and for my project I am working with arduino Bluetooth.
    I wondered if you could help with my arduino and python code for the Bluetooth connection and message sending to the mobile phone?

Comments are closed.