blue-falcon icon indicating copy to clipboard operation
blue-falcon copied to clipboard

Notify not working on Android

Open burnhamd opened this issue 2 years ago • 6 comments

Describe the bug When calling the notifyCharacteristic, the onCharacteristicChanged never firing. I am getting a value for the read. And I have checked that the device indeed does support notifications using the LightBlue Application on IOS.

To Reproduce Steps to reproduce the behavior:

  1. Connect to the device using blueFalcon.connect(bluetoothPeripheral, true)
  2. Wait until didDiscoverServices Returns
  3. Search through service to find the characteristic I want to nofify4.
  4. Call notifyCharacteristic on the returned characteristic

char = service.characteristics.first { it.name == TESS5600_DATA_CHAR.lowercase() } bluetoothService.characteristicDelegate = this bluetoothService.notifyCharacteristic(bluetoothPeripheral, char!!, true)

Expected behavior Expecting the onCharacteristicChanged to fire

Smartphone

  • Device: Samsung Tablet
  • OS: Android API 31

burnhamd avatar Jul 05 '22 13:07 burnhamd

Can you try the same thing using lightblue on Android(as you did for ios)? this rules out any reason it could be an android thing.

I would also suggest, after you request 'notify characteristic', can you then perform a single read after this, then wait to see if it updates?

Reedyuk avatar Jul 05 '22 13:07 Reedyuk

For some reason light blue is crashing on this device on startup. Will see if I can fix that and test.

If I do a read after notify, then I get no read result either.

burnhamd avatar Jul 05 '22 14:07 burnhamd

Just confirmed that when I subscribe using the light blue app the notifications are received from the peripheral.

burnhamd avatar Jul 05 '22 18:07 burnhamd

I think the issue is here: it.characteristic.descriptors.forEach { descriptor -> descriptor.value = descriptorValue gatt.writeDescriptor(descriptor) }

Here it is iterating through all descriptors and attempting to write an enable notification to it. But I have additional descriptor. Instead I think it should just set the notify descriptor "00002902-0000-1000-8000-00805f9b34fb"

burnhamd avatar Jul 05 '22 23:07 burnhamd