[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.
philmccluskey.com codestream » Blog Archive » symbian python 5:41 am on November 29, 2005 Permalink |
[...] (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”.) [...]
Guido van Rossum 1:36 pm on February 13, 2006 Permalink |
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.)
erik 2:32 pm on February 13, 2006 Permalink |
Thanks Guido! I’ve updated the post to reflect the changes in OS X 10.4 and the newer build of Python for S60.
Konrad Hinsen 11:32 am on February 4, 2007 Permalink |
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”.
imhorst.net » Mobiles Python 1:04 pm on August 13, 2007 Permalink |
[...] 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 [...]
Peter Tripp 1:56 pm on September 13, 2007 Permalink |
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.
erik 10:54 pm on September 13, 2007 Permalink |
Very nice Peter!
Kielbasa 5:00 am on November 29, 2007 Permalink |
Does anyone know how to generate a bluetooth database in Python for blender?
tim 5:49 pm on November 29, 2007 Permalink |
import audio
audio.say(“thank you erik”)
:-)
erik 9:50 am on November 30, 2007 Permalink |
:-)
Bertil 2:11 am on January 21, 2008 Permalink |
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)
Vids 3:28 am on April 9, 2008 Permalink |
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?
Vids 3:44 am on April 9, 2008 Permalink |
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.
Takashi Yoshida’s Blog » Blog Archive » Connect to Python S60 Bluetooth Console from Mac OS X 10.5 Leopard 12:02 pm on May 16, 2008 Permalink |
[...] can also find other online guide for older Mac OS X. – eriksartt.com/blog – [...]
Hooriye 5:19 am on June 11, 2009 Permalink |
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?
erik 2:05 pm on June 11, 2009 Permalink |
Sounds like a fun project! What you may want to do is post on the official PyS60 discussion board http://discussion.forum.nokia.com/forum/forumdisplay.php?forumid=102 so you can get the attention of a wider audience of PyS60 hackers.
Unfortunately, I’m no longer working on PyS60, so there may be specifics about your device or desired functionality that the PyS60 developers will be better able to respond to.
Good luck!
Connect Your Mac to Python S60 Bluetooth Console « Takashi Yoshida's Blog 10:33 am on December 17, 2009 Permalink |
[...] eriksartt.com/blog [...]