0

After connecting to BLE device and discovering its services, I check that a certain characteristic is readable, then, I call readCharacteristic. This call returns true, but the callback onCharacteristicRead is not called.
After merely 30 seconds, the onCharacteristicRead is called with characteristic == null and the onDeviceDisconnected is called with status code equal to 22.

I have tested nRF Connecte to read the same characteristic and it worked fine.

What could possibly be wrong ?

MMasmoudi
  • 508
  • 1
  • 5
  • 19

1 Answers1

0

The fact that it timeouts after 30 seconds and disconnects with error 22 (local device terminated the connection) indicates that the peripheral did not respond within 30 seconds, as required by the GATT standard. You should debug the peripheral to find the cause.

The reason it works in nRF Connect might be that the previous GATT sent / received put the peripheral in a different state.

You could check out the HCI log in Android to see all raw packets to maybe figure out what's going on.

Emil
  • 16,784
  • 2
  • 41
  • 52