j.w*_*aty 1 android bluetooth descriptor bluetooth-lowenergy gatt
我有以下问题 - 我必须在我的应用程序工作时动态更改我的特性(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)
谢谢你的建议!
你想做什么表明你的系统设计不好.
特征描述符通常不应由服务器主机随时间更改.无论哪种方式,在BLE的精神中,只有特征的价值可以通知客户.
你想"动态地"改变它的事实是不对的.你为什么?
如果它为您的整个应用程序提供了一些重要的,有意义的数据,那么请创建一个新特性
特征描述符的唯一目的是"解释"特征值的使用方式,格式,单位等.
| 归档时间: |
|
| 查看次数: |
1389 次 |
| 最近记录: |