蓝牙Bluepy没有找到所有特征

时间:2016-06-17 11:29:14

标签: python bluetooth bluetooth-lowenergy characteristics

我正在使用bluepy library与蓝牙设备进行通信,但它没有向我显示所有特征。

当我使用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返回的句柄不匹配?

由于

1 个答案:

答案 0 :(得分:0)

你误解了这些附加特征是什么。以000028xx开头的uuids是特征&#34;声明&#34;如下所示:gatt declaration spec,以000029xx开头的uuids是描述符,如下所示:gatt descriptor spec。它们不是特征本身,而是描述其中一个特征的细节。