更新时间:2023-01-24 10:13:33
所以,我终于明白了我的错误 :)正如您在上面看到的,我使用的 UUID 与我的描述符具有相同的基础(以 3f54XXXX-....
开头)
So, I finnally figured out my mistake :)
As you can see above, I'm usinng a UUID with the same base for my descriptor as my characteristics (starting with 3f54XXXX-....
)
我将其更改为 public static final UUID X_ACCEL_DESCRIPTOR_UUID = UUID.fromString("00002902-0000-1000-8000-00805f9b34fb");
现在一切都按预期工作.
I changed it to public static final UUID X_ACCEL_DESCRIPTOR_UUID = UUID.fromString("00002902-0000-1000-8000-00805f9b34fb");
and now everything is working as expected.
我之前没有这样做,因为我认为每个特征都应该有一个描述符.但实际上,根据客户端特性配置 ...
I did not do this before as i thought that there should be a descriptor for each characteristic. But in fact, according to the Client Characteristic Configuration the ...
[...] 描述符应跨绑定设备的连接保持不变.客户端特征配置描述符对于每个客户端都是唯一的.
[...] descriptor shall be persistent across connections for bonded devices. The Client Characteristic Configuration descriptor is unique for each client.
因此,我检查了 RedBearLab Android 应用示例,发现描述符的 UUID 与其他 SO 答案中发布的 UUID 相同.
So I checked the RedBearLab Android App example and saw that the descriptor's UUID equals the ones posted on other SO answers.
这也解释了为什么我的应用程序在 BLE 扫描仪应用程序中启用它们后收到通知:由于描述符应在绑定设备的连接之间保持不变,BLE 扫描仪应用程序也使用此 UUID 作为描述符,因此启用了通知客户(=我的手机).
This also explains why my App received Notifications after I enabled them in the BLE Scanner App: As the descriptor shall be persistent across connections for bonded devices, the BLE Scanner App used also this UUID for the descriptor and thus enabled notifications for the client (= my phone).