def __init__(self, characteristic_id,
uuid,
service_obj,
value,
notifying,
flags):
"""Default initialiser.
1. Registers the characteristc on the D-Bus.
2. Sets up the service UUID and primary flags.
:param service_id:
:param uuid: service BLE UUID
:param service_obj: the service that this characteristic is part of
:param value: the initial value of this characteristic
:param notifying: boolean representing the state of notification
:param flags:
"""
# Setup D-Bus object paths and register service
PATH_BASE = service_obj.get_path() + '/char'
self.path = PATH_BASE + str('{0:04d}'.format(characteristic_id))
self.bus = dbus.SystemBus()
dbus.service.Object.__init__(self, self.bus, self.path)
self.props = {
constants.GATT_CHRC_IFACE: {
'UUID': uuid,
'Service': service_obj.get_path(),
'Value': value,
'Notifying': notifying,
'Flags': flags}
}
for prop in self.props[constants.GATT_CHRC_IFACE].keys():
self.Set(constants.GATT_CHRC_IFACE,
prop,
self.props[constants.GATT_CHRC_IFACE][prop])
评论列表
文章目录