I'm working on a project which includes a Bluegiga BLE113 module and an Android app. On the Bluegiga module I've set up several characteristics. For one characteristic I defined a descriptor to activate the client notification (in My case, the client is the Android app.). The characteristic definition of the BLE113 module looks like this:
:
<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:
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.
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?