4

Does anyone know how Android handles the service changed indication sent by peer device?

I found out even if the Android app has subscribed the Service Changed Characteristic in Generic GATT service, the onCharacteristicChanged callback will not be invoked.

It seems like Android BT stack will invalidate all the subscribed GATT services hosted by peer and do the service discovery internally and silently. After that, mobile app will not be able to receive any notification from existing GATT services hosted by tracker.

Have anyone experienced this issue? How can the App do the re-subscription/recovery if we don't receive the onCharacteristicChanged callback?

ShawnW
  • 41
  • 1
  • I don't have an answer yet, but I hope to. I am writing a peripheral on a Nordic chip but I cannot get their service changed method to work. Once that happens, I should see what Android does with it. I, like you, expect to see an onCharacteristicChanged signaled. BUT i have found that Android enables indications on the service changed characteristic under the hood. Does it handle service changed indications under the hood as well? Don't know yet! – Brian Reinhold Nov 06 '19 at 10:39

1 Answers1

0

Android 12 (api 31) added the following api that is called on Service Changed indication

public void onServiceChanged (BluetoothGatt gatt)

The documentation says:

Callback indicating service changed event is received Receiving this event means that the GATT database is out of sync with the remote device. BluetoothGatt#discoverServices should be called to re-discover the services.