小编j.w*_*aty的帖子

蓝牙低功耗 - notifyCharacteristicChanged()不更新描述符值

我有以下问题 - 我必须在我的应用程序工作时动态更改我的特性(BluetoothGattCharacteristic)中的描述符(BluetoothGattDescriptor).

不幸的是,来自BluetoothGattServer的函数notifyCharacteristicChanged()只更新了特性的值(在Andoird源代码中查找了这个函数 - https://github.com/android/platform_frameworks_base/blob/master/core/java/android/bluetooth/BluetoothGattServer.java),它忽略了描述符.

我的描述符只读一次 - 建立连接时.但是我想动态地改变它,每次重新连接都不是一个选择.

添加具有相同UUID但描述符不同的两个服务或特征并不能解决问题 - 区分它们是不可能的.

有人遇到类似问题吗?

这是代码:

BluetoothGattCharacteristic bc = mBluetoothGattServer.getService(service).getCharacteristic(characteristic);
bc.setValue(data);
bc.getDescriptor(descriptor).setValue(new byte[]{0, 0});      <- no effect here
mBluetoothGattServer.notifyCharacteristicChanged(connectedDevice, bc, false);
Run Code Online (Sandbox Code Playgroud)

谢谢你的建议!

android bluetooth descriptor bluetooth-lowenergy gatt

1
推荐指数
1
解决办法
1389
查看次数