bluez-python

This is the page for bluez-python, High level/convenient python component on top of dbus-python
git repo is  http://gitorious.org/projects/bluez-python
tarball hosts at  http://code.google.com/p/bluez-python
If you have questions, suggestions, feedbacks, please contact: Jerry87905@…, or LiDongyang at irc.freenode.org

Implementation details

All other methods are same as the BlueZ 4 API.
__init__.py
module init
BlueZInterface.py
class BlueZInterface - base class of other interface classes.

GetObjectPath()
    Returns the dbus object path.
GetInterface()
    Returns the dbus interface.
GetInterfaceName()
    Returns the dbus interface name like 'org.bluez.Manager'
HandleSignal(handler, signal)
    The handler function will be called when specific signal is emitted.
    For available signals of each interface, check BlueZ4 documents.

easy way to get properties: just call the property name after the interface object, e.g. adapter.Name
BaseInterface.py
class BaseInterface(inherit from BlueZInterface)
abstraction of BlueZ base interfaces.

ListServiceInterfaces()
    Returns a list of available service interfaces under current object path,
    for available methods for each interface, check BlueZ4 documents.

ServiceInterface.py
class ServiceInterface(inherit from BlueZInterface)
interface for BlueZ service plugins
Manager.py
class Manager(inherit from BaseInterface)
represents org.bluez.Manager Interface

ListAdapters()
    Returns a list of Adapter instances.
CreateAgent(cls=Agent.Agent, obj_path='/org/bluez/Agent')
    Paramater cls should be a custom sub-class of Agent.
    Paramater obj_path is the dbus object path for the agent, should start with '/'.
    Returns an instance of specified cls.

Adapter.py
class Adapter(inherit from BaseInterface)
represents org.bluez.Adapter Interface

ListDevices()
    Returns list of Device instances.
RequestMode(mode, reply_handler=None, error_handler=None)
    Use reply_handler and error_handler to make asynchronous call.
    reply_handler will not receive any parameters,
    error_handler will receive an exception as the parameter.
CreateDevice(address)
    Creates a new dbus object path for a remote device,
    then returns Device instance.
CreatePairedDevice(address, agent, capability='', reply_handler=None, error_handler=None)
    Creates a new object path for a remote device and then
    returns Device instance. This method will connect to
    the remote device and retrieve all SDP records and then
    initiate the pairing.
    The agent parameter should be an instance of Agent, or
    customized sub-class of Agent.
    Use reply_handler and error_handler to make asynchronous call,
    and this method will return None.
    reply_handler will receive an instance of Device as the parameter,
    error_handler will receive an exception as the parameter.
RemoveDevice(device)
    parameter device should be an instance of Device.
RegisterAgent(agent, capability='')
    parameter agent is the same as for the method CreatePairedDevice.
UnregisterAgent(agent)
    parameter agent is the same as for the method CreatePairedDevice.

Device.py
class Device(inherit from BaseInterface)
represents org.bluez.Device Interface
Agent.py
decorator AgentMethod

The decorator for customizing the agent methods.
To use async callbacks, add two extra parameters for
success callback and error callback in the def of the agent method.

class Agent(inherit from dbus.service.Object)

Represents the BlueZ dbus API on interface "org.bluez.Agent".
Inherit from this class and use AgentMethod decorator
to customize the methods.
The simple-agent is provided by default.

errors.py
Custom BlueZ dbus exceptions
utils.py
decorator raise_dbus_error
method raise_type_error