Bluetooth notify gatt characteristic losing data

Viewed 24

I am receiving a large amount of real-time data from a BTLE device using a notify GATT Characteristic. We're definitely reaching the bandwidth limits of the protocol, the device is capable of sending approx 1.2Mbps.

The problem: I am seeing a lot of data loss. The ValueChanged usually fires with 244 bytes of data, the MaxPdu is getting negotiated to 251, and some of those data buffers are missing data. If we send a smaller amount of data, at the same rate, there is no loss. Once the total amount of data grows intermittent data loss is more common.

The code is pretty standard and is using Windows.Devices.Bluetooth. A simplified example of hooking up the event is below. Standard connection, service discovery, etc is removed for brevity.

var descriptorWriteResult =
await charac.WriteClientCharacteristicConfigurationDescriptorAsync(descriptorValue);

if (descriptorWriteResult == GattCommunicationStatus.Success)
{
    int valCount = 0;
    charac.ValueChanged += (sender, args) =>
    {
        CryptographicBuffer.CopyToByteArray(args.CharacteristicValue, out byte[] data);
        Console.WriteLine($"{valCount++} | {data.Length} | {data.ToDataDebugString()}");
    };
}
  1. Is the size of the buffer configurable, or knowable?
  2. Is there a way to access the buffer directly?
  3. Is there a better way to receive large amounts of data?
0 Answers
Related