【发布时间】:2016-04-15 23:46:47
【问题描述】:
我正在使用我的 linux 板上 bluez 附带的 example-gatt-server.py 脚本。我想向我的自定义特征之一添加通知。为此,我需要定义客户端特征配置描述符并将其添加到我的自定义特征中。这是我的做法 -
类 ClientCharacteristicConfigurationDescriptor(Descriptor):
CCCD_UUID = '2902'
def __init__(self, bus, index, characteristic):
self.value = array.array('B')
self.value = self.value.tolist()
#self.value = []
Descriptor.__init__(
self, bus, index,
self.CCCD_UUID,
['read', 'write'],
characteristic)
def ReadValue(self):
print("I am reading CCCD value")
print(self.value)
return self.value
def WriteValue(self, value):
print("I am writing CCCD value")
print type(value)
#self.value = value
print(value)
此代码的灵感来自已在 example-gatt-server 文件中定义的 CharacteristicUserDescriptionDescriptor 类。 上面的代码在阅读或写作时给了我错误。它甚至不打印“我正在读取 CCCD 值”语句。我在这里错过了什么?
谢谢!
【问题讨论】:
-
你的 bluez 版本是多少?对于 LE 的 python dbus 访问,必须至少为 5.37
-
感谢您的回复。我使用 5.34,它适用于除此通知之外的所有其他特性。所以我不确定这是否是问题所在。
标签: python linux notifications bluez