我正在使用bluepy 库与蓝牙设备进行通信,但它没有向我展示所有特征。
当我使用 gatttool 运行以下命令时,我得到:
[EE:50:F0:F8:3C:FF][LE]> char-desc 0x0019 0xffff
handle: 0x0019, uuid: 00002800-0000-1000-8000-00805f9b34fb
handle: 0x001a, uuid: 00002803-0000-1000-8000-00805f9b34fb
handle: 0x001b, uuid: 00001532-1212-efde-1523-785feabcd123
handle: 0x001c, uuid: 00002803-0000-1000-8000-00805f9b34fb
handle: 0x001d, uuid: 00001531-1212-efde-1523-785feabcd123
handle: 0x001e, uuid: 00002902-0000-1000-8000-00805f9b34fb
handle: 0x001f, uuid: 00002803-0000-1000-8000-00805f9b34fb
handle: 0x0020, uuid: 00001534-1212-efde-1523-785feabcd123
但是当我使用 Bluepy 运行以下命令时,我得到:
characteristics = self.peripheral.getCharacteristics(startHnd=0x0019, endHnd=0xFFFF, uuid=None)
for characteristic in characteristics:
print("{}, hnd={}, supports {}".format(characteristic, hex(characteristic.handle), characteristic.propertiesToString()))
Characteristic <00001532-1212-efde-1523-785feabcd123>, hnd=0x1a, supports WRITE NO RESPONSE
Characteristic <00001531-1212-efde-1523-785feabcd123>, hnd=0x1c, supports NOTIFY WRITE
Characteristic <00001534-1212-efde-1523-785feabcd123>, hnd=0x1f, supports READ
我需要能够将 '\x01\x00' 写入特征:
handle: 0x001e, uuid: 00002902-0000-1000-8000-00805f9b34fb
然后将 '\x01\x04' 写入特征:
handle: 0x001d, uuid: 00001531-1212-efde-1523-785feabcd123
但我不能,因为 Bluepy 没有找到特征:
handle: 0x001e, uuid: 00002902-0000-1000-8000-00805f9b34fb
为什么是这样?
当 Bluepy 找不到该特征时,如何写入该特征?
为什么 Bluepy 返回的句柄与 gatttool 返回的句柄不匹配?
谢谢