def __init__(self,
descriptor_id,
uuid,
characteristic_obj,
value,
flags):
"""Default initialiser.
1. Registers the descriptor on the D-Bus.
2. Sets up the service UUID and primary flags.
:param descriptor_id: A unique identifier for this descriptor
:param uuid: descriptor BLE UUID
:param characteristic_obj: The characteristic that this descriptor
is related to
:param value: The initial value of the descriptor
:param flags: Flags specifying access permissions
"""
# Setup D-Bus object paths and register service
PATH_BASE = characteristic_obj.get_path() + '/desc'
self.path = PATH_BASE + str('{0:04d}'.format(descriptor_id))
self.bus = dbus.SystemBus()
dbus.service.Object.__init__(self, self.bus, self.path)
self.props = {
constants.GATT_DESC_IFACE: {
'UUID': uuid,
'Characteristic': characteristic_obj.get_path(),
'Value': value,
'Flags': flags}
}
for prop in self.props[constants.GATT_DESC_IFACE].keys():
self.Set(constants.GATT_DESC_IFACE,
prop,
self.props[constants.GATT_DESC_IFACE][prop])
评论列表
文章目录