Monkey.BluetoothLE icon indicating copy to clipboard operation
Monkey.BluetoothLE copied to clipboard

Notifications issue on Android

Open marcojak opened this issue 9 years ago • 1 comments

I noticed that notifications under Android are not working correctly (under iOS are working correctly).

In the following code, I write a value inside a characteristic (c) that enable the notifications. if (c.CanWrite) { c.Write(new byte[] { 0x01 }); AddLog("Notif enabled"); valueUpdatedHandler = (s, ea) => { Device.BeginInvokeOnMainThread(() => { AddLog("NOTIFICATION"); }); }; c.ValueUpdated += valueUpdatedHandler;
c.StartUpdates(); }

Once enabled the notifications, every time i write a value inside a second characteristic, I should receive a notification from the first (c). Under iOS all is working with no problem but under Android i don't receive notification.

The strange thing is that on Android, with the notifications enabled, when I read a value from the first characteristic (c.ReadAsync();), the method return the correct value and I also receive a notification!

If you need other informations, I'll provide it

Thank you very much

Marco

marcojak avatar Apr 10 '15 08:04 marcojak

I encountered notify issues as well on Android.

https://github.com/xamarin/Monkey.Robotics/issues/33

I wrote a Gatt call Queue and queued all of my calls on it. Issue on Android side it that you need to have one active Gatt call at a time. Older versions seem to like those calls on the GUI thread. As for now, the BLE changes I have are working fine. I tested this with two different BLE devices on Samsung Galaxy S4 and Nexus 7.

KeyvanPouyan avatar May 13 '15 02:05 KeyvanPouyan