Bluetooth Low Energy (BLE) cache is not updating with data sent from a BLE device RRS feed

  • Question

  • I am developing a BLE interface in C# to display "real-time" data received at a frequency rate of 100 Hz from a custom-built BLE device.

    My program can connect to the device and to the desired Service and Characteristics UUIDs.

    However, when I try to read the BLE device raw data from the cache, a same value is displayed.

    When I try to read the data but with the BluetoothCacheMode.Uncached option, updated data are read but at a very low frequency (lower than 1 Hz).

    Therefore, my problem is to figure out why the Bluetooth cache is not updating correctly while new data are being sent by the BLE device. 

    My BLE device is working because data are received in real-time when testing with iOS LightBLue and Android BLE Device Monitor mobile apps.


    using System;
    using System.Threading;
    using System.Threading.Tasks;
    using Windows.Storage.Streams;
    /*** Specific Namespaces for BLE Interface ***/
    using Windows.Devices.Bluetooth;
    using Windows.Devices.Bluetooth.GenericAttributeProfile;
    using Windows.Devices.Enumeration;
    namespace TDS_BLE_Console
       class TdsBleMain
          static void Main()
             eTdsDevice eTds = new eTdsDevice();
          }//end Main
       }//end class TdsBleMain
       public class eTdsDevice
          /* Instance variable */
          public int count = 0;
          /* Method */
          public async void InitializeDevice()
             /*** Get a list of devices that match desired service UUID  ***/
             Guid selectedService = new Guid("0000AA10-0000-1000-8000-00805F9B34FB");
             var devices = await DeviceInformation.FindAllAsync(GattDeviceService.GetDeviceSelectorFromUuid(selectedService));
             /*** Create an instance of the eTDS device ***/
             DeviceInformation eTdsDevice = devices[0];         // Only one device should be matching the eTDS-specific service UUID
             Console.WriteLine("Device Name: {0}", eTdsDevice.Name);  // Display the name of the device
             /*** Create an instance of the specified eTDS service ***/
             GattDeviceService myService = await GattDeviceService.FromIdAsync(eTdsDevice.Id);
             Console.WriteLine("Service UUID: {0}", myService.Uuid.ToString());
             /*** Create an instance of the characteristic of the specified service ***/
             Guid selectedCharacteristic = new Guid("0000AA11-0000-1000-8000-00805F9B34FB");
             const int CHARACTERISTIC_INDEX = 0;
             GattCharacteristic myCharacteristic = myService.GetCharacteristics(selectedCharacteristic)[CHARACTERISTIC_INDEX];
             myCharacteristic.ProtectionLevel = GattProtectionLevel.Plain;     // Set security level to "No encryption" 
             /*** Reading 1000 data samples ***/
             GattReadResult bleData;
             byte[] bleDataArray = new byte[6];
             for (int i = 0; i < 10000; i++)
                /* Read data from a buffer */
                bleData = null;
                bleData = await myCharacteristic.ReadValueAsync(BluetoothCacheMode.Cached);
                /* Display each element of raw data */
                Console.WriteLine("Value {0}: {1} {2} {3} {4} {5} {6}", count, bleDataArray[0], bleDataArray[1], bleDataArray[2], bleDataArray[3], bleDataArray[4], bleDataArray[5]);
                /* Pause thread execution */
             }//end for
          }//end method InitializeDevice
       }//end class eTdsDevice


    Device Name: TDS_BLE

    Service UUID: 0000AA10-0000-1000-8000-00805F9B34FB

    Value 1: 41 1 104 253 129 1

    Value 2: 41 1 104 253 129 1

    Value 3: 41 1 104 253 129 1


    Value 1000: 41 1 104 253 129 1

    • Edited by sebnor31 Friday, February 20, 2015 7:50 PM Added code block
    • Moved by Caillen Monday, February 23, 2015 9:03 AM
    Friday, February 20, 2015 7:38 PM


All replies

  • Hi sebnor31,

    This is Visual C# forum, but your question seems not related to Visual C# language itself. It most likely related to the bluetooth message transaction protocal or with the device itself.

    I'll move your question to [where is this forum for...] forum where the morderator may direct you to the correct forum.

    Thanks for your understanding.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, February 23, 2015 9:03 AM
  • Might try them over here.





    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

    • Proposed as answer by Mike Laughlin Tuesday, February 24, 2015 1:02 AM
    • Marked as answer by Just Karl Wednesday, March 4, 2015 9:47 PM
    Tuesday, February 24, 2015 12:55 AM