Forum Xamarin.Forms

BLE notifications on Android some packages get lost

BaseCrusherBaseCrusher Member ✭✭
edited April 27 in Xamarin.Forms

Hello there,

I'm developing an App that connects via bluetooth LE to a peripheral using the Bluetooth LE by xabre plugin(sadly I'm not allowed to use links in my post).
As soon as the connection is established, I start listening to notifications of the peripheral, which is sending data in a 50Hz frequency.

Now using the App in iOS I have no problem and I receive all the packages. But when I run the app on Android I don't receive all the packages. It wouldnt be crucial to loose some packages, but I sometimes lose 50 packages in a row.

I'd like to know, if some of you know if thats an Android issue or my code implementation. Here the code:

    async Task GetCharacteristicsAsync(IService service)
        {
            Console.WriteLine($"Getting characteristics");
            try
            {
                controlCharacteristics = await service.GetCharacteristicAsync(Guid.Parse("***"));
                dataCharacteristics = await service.GetCharacteristicAsync(Guid.Parse("***"));

                dataCharacteristics.ValueUpdated += (o, args) =>
                {
                    ProcessData(args.Characteristic.Value);
                    CalculateData();
                };
            }
            catch (DeviceConnectionException e)
            {
                Console.WriteLine($"Exeption at GetCharacteristics: {e.Message}");
            }
        }
    private void ProcessData(Byte[] bytes) 
    {
    // Translate bytes into data types
    }

    private void CalculateData(Byte[] bytes) 
    {
    // Do Calculation
    }

Thank you for all the help in advance. :smile:

Best Answer

  • BaseCrusherBaseCrusher ✭✭
    Accepted Answer

    Well, I've run now a test with an Android native app in java.
    The issue persist even in the native app. Just wanted to let people in future know.

Answers

  • BaseCrusherBaseCrusher Member ✭✭
    Accepted Answer

    Well, I've run now a test with an Android native app in java.
    The issue persist even in the native app. Just wanted to let people in future know.

Sign In or Register to comment.