Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notify not working on Android #96

Open
burnhamd opened this issue Jul 5, 2022 · 9 comments
Open

Notify not working on Android #96

burnhamd opened this issue Jul 5, 2022 · 9 comments
Labels
bug Something isn't working

Comments

@burnhamd
Copy link

burnhamd commented Jul 5, 2022

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
@Reedyuk
Copy link
Owner

Reedyuk commented Jul 5, 2022

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?

@burnhamd
Copy link
Author

burnhamd commented Jul 5, 2022

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
Copy link
Author

burnhamd commented Jul 5, 2022

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

@burnhamd
Copy link
Author

burnhamd commented Jul 5, 2022

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"

@Reedyuk Reedyuk added the bug Something isn't working label Nov 19, 2022
@leonardovallem
Copy link

Hello you all! Any updates on this?

I'm having the exact same issue. Works on iOS, but on Android it doesn't. It does works sometimes, but most of times it doesn't. onCharacteristicChanged is not being called.

Any ideas?

Thanks in advance.

@Reedyuk
Copy link
Owner

Reedyuk commented May 16, 2024

I havent had chance to look into it. I also don't have the exact devices and setup to reproduce so it would be difficult for me. I am happy for anyone to produce a solution in a PR and i can review it.

@Reedyuk
Copy link
Owner

Reedyuk commented Nov 24, 2024

i have found that when you do indicate and notify it seems to be working, @leonardovallem can you confirm the same?

@leonardovallem
Copy link

i have found that when you do indicate and notify it seems to be working, @leonardovallem can you confirm the same?

for me, that worked. i had issues when trying to notify multiple characteristics, but soon solved by better managing my coroutine scopes

@Reedyuk
Copy link
Owner

Reedyuk commented Nov 25, 2024

Hmm, i need to look into it further but it could be to do with the characteristic properties stuff we do when we notify

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants