Bluetooth

Paul Boddie paul at boddie.org.uk
Fri Sep 23 17:58:57 EDT 2005


Tor Erik Sønvisen wrote:
> I'm making a server-side solution in Python and need to be able to
> communicate through bluetooth. Is there any bluetooth-packages out there for
> python?

At the lowest level, you should be able to create sockets for Bluetooth
communications (see the socket module's documentation and the source
code in Modules/socketmodule.c); for example:

from socket import *
s = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM)

On Linux, upon binding a device file to the Bluetooth device, you can
use things like pySerial to manage the communications; this works with
software like t616hack:

http://www.nelson.monkey.org/~nelson/weblog/tech/phone/
http://pyserial.sourceforge.net/

Various other tools exist which understand Bluetooth communications,
notably the OpenOBEX tools:

http://triq.net/obex/

I prefer to work with tools at the higher levels (obexftp to access
files, pySerial/t616hack to access messages), but provided your Python
distribution is set up correctly, you should be able to work at the
lowest levels too.

Paul




More information about the Python-list mailing list