Filename Size Date modified Message
34.3 KB
159 B
10.2 KB
6.3 KB
440 B

PyOBEX Python Package

Author: David Boddie
Date: 2009-01-18
Version: 0.10

Note: This text is marked up using reStructuredText formatting. It should be readable in a text editor but can be processed to produce versions of this document in other formats.


The Object Exchange (OBEX) protocol is a widely used protocol for network communication between Bluetooth and infra-red devices that provides the foundation for a number of common tasks, such as file transfer and data synchronization via the use of "profiles".

Although Bluetooth communication is well-supported on the most popular operating systems, support for OBEX is limited by the restricted amount of information freely available on the protocol. The specification of the protocol is published by the Infrared Data Association (IrDA). Non-members of this association must pay a fee to obtain a copy of the specification document.

Most applications and libraries that provide connectivity between, for example, desktop computers and mobile phones use the OpenOBEX library to communicate using the OBEX protocol.

This package provides a simple Python implementation of aspects of the OBEX protocol based on the information available in freely available Bluetooth specifications and other openly accessible online resources. It is not intended to be a complete, accurate, or fully functioning implementation of the protocol.

This package depends on Bluetooth support in the standard Python socket module. Users of Linux and Windows XP systems may also find the PyBluez package useful; this provides the bluetooth module described below.


To install the package alongside other packages and modules in your Python installation, unpack the contents of the archive. At the command line, enter the directory containing the script and install it by typing the following:

python install

You may need to become the root user or administrator to do this.

Locating the Bluetooth device

Low level discovery of Bluetooth devices and services is provided by the bluetooth module, distributed as part of the PyBluez package. You need to use the following calls to determine the address of the device you wish to connect to.

Discover the devices available by calling:

devices = bluetooth.discover_devices()

Look up names by calling:


on each device in the devices list.

Find out about the services provided by a device by calling:


The file transfer service has the service ID, "E006", so we can find out the port on the device that we need to connect to when using the BrowserClient from the PyOBEX.client module:

services = bluetooth.find_service(uuid="E006", address=device_address)

The list returned contains dictionaries corresponding to each service. The port used by a service can be obtained from the "port" dictionary entry. Assuming that the previous line of code returned a list containing a single item, we can obtain the port using the following code:

port = services[0]["port"]

This integer value will be required when connecting to the service.

Using the PyOBEX package

The PyOBEX package contains the following modules:
Package file for the PyOBEX Python package.
Classes providing common facilities for other modules.
Client classes for sending OBEX requests and handling responses.
Classes encapsulating OBEX headers.
Classes encapsulating OBEX requests.
Classes encapsulating OBEX responses.

For most people, the client module is the most useful module because it provides a reasonably high level API that can be used to interact with a Bluetooth device.

Using appropriate values for device_address and port obtained using the bluetooth module, or alternative tools on your system, the following code can be used to list the files in the root directory on a device:

from PyOBEX.client import BrowserClient
client = BrowserClient(device_address, port)

Other methods of the BrowserClient object can be used to get and put files, set the current directory and delete files. Use the interactive help facilities to find out more or read the docstrings in the source code.


Listing services under Linux:

sdptool browse <device address>

A list of services is available in the OpenOBEX Trac site:

Notes on the Sony Ericsson K750i

In file browsing mode, you may be able to obtain low level information about the directory structure on the phone by calling the client's get() method with an empty string.


The contents of this package are licensed under the GNU General Public License (version 3 or later):

PyOBEX, a Python package implementing aspects of the Object Exchange (OBEX) protocol.
Copyright (C) 2007 David Boddie <>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <>.