question

CezarWagenheimer avatar image
0 Votes"
CezarWagenheimer asked

Android BluetoothLE Nightmare with Notifications

Hello, I am developing a Xamarin Forms application to display data from scale platforms via communication with BluetoothLE and it is being a nightmare due to the number of different problems that I have had to face.

I'm using Shiny.BluetoothLE for the Comunication and I think that it's very good, the problems don't seem to be with it, but with the Android Implementation of BluetoothLE itself.

The nightmare that I'm facing now is the following!
I need to connect to 4 distinct BlueetoothLE Scales at the same time and subscribe to 10 notifications for characteristics on each device.

Ok! On each device I do use for each notification :

 GattCharacteristic.EnableNotifications(true);
 GattCharacteristic.WhenNotificationReceived().Subscribe(
                     async result =>
                     {
                         //Use the Result Data
                     }


Ok! It does work on Some Android Devices, but on others, it does not work..... let me explain what happens! this is the sequence :

  • Device 1 connects and Notifications Subscribed. === NOTIFICATION for 1 is working

  • Device 2 connects and Notifications Subscribed. === NOTIFICATION for 1 and 2 are working

  • Device 3 connects and Notifications Subscribed. === NOTIFICATION for 2 and 3 are working, notification for 1 stopped working.

  • Device 4 connects and Notifications Subscribed. === NOTIFICATION for 4 is working, notification for 1, 2, and 3 stopped working.

This sequence changes sometimes, sometimes notifications for 2 different devices continue to work, or just 1. This "Bug" happens only on some Android devices (Galaxy J5 by example) and there is a variation in the problem.

On some devices (ex. Samsung Galaxy A71), all notifications always work for all Bluetooth devices without a problem.

It doesn't show any error messages or anything. It Simply stops receiving notifications for some of the GattCharacteristic that I had subscribed to with no visible reason.

Has anyone been through something similar or had an idea of how to solve it?

Ps. As a workaround, instead of subscribing for notification, I do read all values every 0.01 seconds. It works as a workaround, but it's way slower and I can only read data from one device per time (I cannot use a thread and then read from the 4 at the same time) and this makes a noticeable lag on the information shown on the UI.





dotnet-xamarin
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

0 Answers