Android 未使用BLE112调用onCharacteristicChanged()
我正在使用BLE112设备,我的回调方法onCharacteristicChanged。。。在我的Android应用程序上没有触发 在我的gatt.xml文件中,我定义了此服务:Android 未使用BLE112调用onCharacteristicChanged(),android,bluetooth,bluetooth-lowenergy,Android,Bluetooth,Bluetooth Lowenergy,我正在使用BLE112设备,我的回调方法onCharacteristicChanged。。。在我的Android应用程序上没有触发 在我的gatt.xml文件中,我定义了此服务: <service uuid="4300" advertise="true" id="entry_service"> <description>Entry_Service</description> <characteristic uuid
<service uuid="4300" advertise="true" id="entry_service">
<description>Entry_Service</description>
<characteristic uuid="4301" id="unlock_state">
<description>Unlock_State</description>
<properties read="true" write="true" notify="true"/>
<value length="1">0</value>
<descriptor uuid="4381">
<properties read="true" write="true"/>
<value length="1">0</value>
</descriptor>
</characteristic>
</service>ode here
在我的日志聊天中,我得到了写描述符等的确认,但是一旦特性改变。。。从来没有人打过电话。
有人能帮忙吗?在GATT.XML文件中更改属性的顺序
<properties notify="true" read="true" write="true" />
我解决了这个问题。
获取描述符时,必须使用UUID:0x2902
BluetoothGattDescriptor descriptor = characteristic.getDescriptor(uuidDescr); //uuidDescr must be 0x2902
您不必在gatt.xml中编写自己的描述符。
只需获取并编写UUID为0x2902的描述符,描述您希望得到通知的特征
在此之后,onCharacteristicChanged正确启动
UUID为2902的描述符被称为什么意思?像这样:`Entry\u Service Unlock\u State 0`我尝试了这个,但没有效果。我认为顺序无关紧要。在Blugigas文档中,没有提到属性的特定顺序。我使用的是上面提到的相同的BLE112。还将执行设置通知所指定的所有操作。但我的onCharacteristicChanged从未调用。如何将2902转换为UUID?
BluetoothGattDescriptor descriptor = characteristic.getDescriptor(uuidDescr); //uuidDescr must be 0x2902