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
If you have questions, suggestions, feedbacks, please contact: Jerry87905@gmail.com, or missed at irc.freenode.org
Implementation details
__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 emmited.
For available signals of each interface, check BlueZ4 documents.
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
GetAdapter(pattern=None)
Returns an instance of Adaper for specified adapter,
valid patterns are "hci0" or "00:11:22:33:44:55".
Or returns default BlueZ if pattern is None.
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.
RequestAuthorization(address, handle, 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.
Device.py
class Device(inherit from BaseInterface)
represents org.bluez.Device Interface
GetObjectPath()
Returns the dbus object path of the device.
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
All other methods are same as the BlueZ 4 API.
Logs
2008-08-20:
add class BaseInterface with method ListServiceInterfaces
make Manager, Adapter and Device inherit from BaseInterface
remove ListInterfaces from Device
release 0.1.1
2008-08-14:
release 0.1
2008-08-11:
add class ServiceInterface
2008-08-09:
add ListInterfaces() for !Device
2008-08-07:
use follow_name_owner_changes parameter when get dbus proxy object
2008-08-04:
add GetObjectPath(), GetInterface() and GetInterfaceName() for BlueZInterface
fix to make async method call with RequestMode() and RequestAuthorization()
2008-08-02:
add base class BlueZInterface
make other classes inherit from BlueZInterface
2008-08-01:
fix to make async method call with CreatePairedDevice()
add license headers
add setup script
add AUTHORS COPYING README ChangeLog file
2008-07-11:
add doctrings
2008-06-29:
at home, implemented class Agent and decorator AgentMethod
add CreateAgent() for Manager, add some exceptions for Agent
2008-06-17 to 2008-06-27:
away for the exams
2008-06-03:
adjusted current components to the latest API
2008-06-02 to 2008-06-08:
a full week time for a class, low productivity
2008-05-25:
added raise_type_error to handle TypeError
removed exception DBusSignalDoesNotExist since dbus-python doesn't check if signal exists or not
use raise_type_error to handle TypeError in HandleSignal()
implemented methods for Adapter
implemented methods for Device
2008-05-24:
change object path of Manager to "/"
ListAdapters() in Manager now returns a list of Adapter instances
added utils.py with decorator raise_dbus_error()
use decorator raise_dbus_error to handle dbus exceptions
fix import usage
2008-05-20:
added exception: DBusSignalDoesNotExistError
added GetAdapter(pattern) for Manager, pattern could be "hci0" or "00:11:22:33:44:55" or None
if pattern is None, GetAdapter() will return default adapter, otherwise will find adapter and return
added ListAdapters() for Manager, returning a list contains string like "hci0", "hci1"
added HandelSignal(signal, handler) for Manager, user need to define his own handler and this method will raise DBusSignalDoesNotExistError if the signal is not defined
project git: http://gitorious.org/projects/bluez-python
2008-05-17:
added two exceptions: DBusMainLoopNotSupportedError and DBusMainLoopModuleNotFoundError for mainloop usage
added setup_event_loop() for Manager, user will pass a string to Manager's init to get a dbus connection with mainloop support
supported mainloops are gobject, pyqt4 and ecore currently
2008-05-14:
__init__ now does nothing, user should call Manager to get Manager instance explicitly,
Manager now is singleton, by overriding __new__(),
Manager will have a __bus = dbus.SystemBus() temporarily
added exception DBusServiceUnknownError in case of org.bluez not available
