Hi, I was trying to send notification from nRF51822 to an android central when notification is enabled on the nordic uart rx characteristic and I discovered that if I enable notification on the characteristic once it has been discovered by the android app, nothing is received by the app but when I enable notification more than once, for example each time, the battery level characteristic is read, then I would start receiving data. I found out that in the source code of nrftoolbox, precisely in the hrs code, notification is enabled on the hrm characteristic each time the battery level characteristic is read:
public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
if (characteristic.getUuid().equals(HR_SENSOR_LOCATION_CHARACTERISTIC_UUID)) {
final String sensorPosition = getBodySensorPosition(characteristic.getValue()[0]);
//This will send callback to HRSActicity when HR sensor position on body is found in HR device
mCallbacks.onHRSensorPositionFound(sensorPosition);
if (mBatteryCharacteritsic != null) {
readBatteryLevel();
} else {
enableHRNotification();
}
}
if (characteristic.getUuid().equals(BATTERY_LEVEL_CHARACTERISTIC)) {
int batteryValue = characteristic.getValue()[0];
//This will send callback to HRSActicity when Battery value is received from HR device
mCallbacks.onBatteryValueReceived(batteryValue);
enableHRNotification();
}
} else {
mCallbacks.onError(ERROR_READ_CHARACTERISTIC, status);
}
}
So why wont notification be sent when it is enable just once?