0
我正在开发一个包含Bluegiga BLE113模块和Android应用程序的项目。在Bluegiga模块上,我设置了几个特性。对于一个特性,我定义了一个描述符来激活clie(在我的情况下,客户端是Android应用程序)。在BLE113模块的特征定义是这样的:Android BLE onCharacteristicChanged()未调用
<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>
在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
但是,如果我使用Bluegiga模块的串行接口更改DATAFLOW_OUT_CHARACT特性UUID的值,则在我的Android应用程序上不会触发onCharacteristicChanged(...)的预期回调。
我是否正确设置了描述符,还是在我的Android代码中失败?