Search:

eriksmartt.com/blog

 

 

Using the Python for Series 60 Bluetooth Console from OS X

Filed under: mobile, python — January 2, 2005

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



14 Responses to “Using the Python for Series 60 Bluetooth Console from OS X”

  1. Avatar philmccluskey.com codestream » Blog Archive » symbian python Says:

    [...] (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”.) [...]

  2. Avatar Guido van Rossum Says:

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

  3. Avatar erik Says:

    Thanks Guido! I’ve updated the post to reflect the changes in OS X 10.4 and the newer build of Python for S60.

  4. Avatar Konrad Hinsen Says:

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

  5. Avatar imhorst.net » Mobiles Python Says:

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

  6. Avatar Peter Tripp Says:

    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.

  7. Avatar erik Says:

    Very nice Peter!

  8. Avatar Kielbasa Says:

    Does anyone know how to generate a bluetooth database in Python for blender?

  9. Avatar tim Says:

    import audio
    audio.say(”thank you erik”)

    :-)

  10. Avatar erik Says:

    :-)

  11. Avatar Bertil Says:

    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)

  12. Avatar Vids Says:

    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?

  13. Avatar Vids Says:

    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.

  14. Avatar Takashi Yoshida’s Blog » Blog Archive » Connect to Python S60 Bluetooth Console from Mac OS X 10.5 Leopard Says:

    [...] can also find other online guide for older Mac OS X. - eriksartt.com/blog - [...]

Leave a Reply


 

A few books I'm reading now:

A few books I'd recommend: