[英]Android BLE onCharacteristicChanged not called
I'm working on a project which includes a Bluegiga BLE113 module and an Android app. 我正在研究一个包含Bluegiga BLE113模块和Android应用程序的项目。 On the Bluegiga module I've set up several characteristics.
在Bluegiga模块上,我设置了几个特征。 For one characteristic I defined a descriptor to activate the client notification (in My case, the client is the Android app.).
对于一个特征,我定义了一个描述符来激活客户端通知(在我的情况下,客户端是Android应用程序。)。 The characteristic definition of the BLE113 module looks like this:
BLE113模块的特征定义如下所示:
:
<characteristic uuid="dcfa2671-974d-4e4a-96cd-6221afeabb62" id="ez1_flow_data_out">
<!-- org.bluetooth.descriptor.gatt.characteristic_user_description -->
<description>Data to transmit to Android device</description>
<properties write="true" read="true" />
<value variable_length="true" length="255" type="hex" />
<!-- org.bluetooth.descriptor.gatt.client_characteristic_configuration -->
<descriptor uuid="2902">
<properties write="true" read="true" const="false" />
<!-- Bit 0 = 1: Notifications enabled -->
<value type="hex">0001</value>
</descriptor>
:
:
</characteristic>
On the Android side I've set up the notification inside the onServicesDiscovered(...)
callback according to the Android Bluetooth Low Energy guide: 在Android方面,我已根据Android蓝牙低功耗指南在
onServicesDiscovered(...)
回调中设置了通知:
characteristic = gatt.getService(BLEuuids.DATAFLOW_SERVICE).getCharacteristic(BLEuuids.DATAFLOW_OUT_CHARACT);
//Enable local notifications
gatt.setCharacteristicNotification(characteristic, true);
//Enabled remote notifications
BluetoothGattDescriptor desc = characteristic.getDescriptor(BLEuuids.DATAFLOW_OUT_DESCRIPT);
boolean test;
test = desc.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE); // return value = true
test = gatt.readDescriptor(desc); // return value = true
test = gatt.writeDescriptor(desc); // return value = true
However, if I change the Value of the DATAFLOW_OUT_CHARACT characteristics UUID, using the serial interface of the Bluegiga Module, the intended callback onCharacteristicChanged(...)
isn't triggered on My Android app. 但是,如果使用Bluegiga模块的串行接口更改DATAFLOW_OUT_CHARACT特征UUID的值,则MyAndroid应用程序不会触发预期的
onCharacteristicChanged(...)
回调。
Try not to READ descriptor. 尽量不要读取描述符。 Do write descriptor right after set.
设置后立即写描述符。 Properly the read will overwrite your set and you write the same value back?
正确的读取将覆盖您的集合,而您又写回相同的值?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.