【发布时间】:2015-02-20 13:37:08
【问题描述】:
我有以下问题 - 我必须在我的应用程序工作时动态更改我的特征 (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);
感谢您的建议!
【问题讨论】:
标签: android bluetooth bluetooth-lowenergy descriptor gatt