Bluetooth Generic Attribute Profile - Heart Rate Service

Demonstrates use of the Bluetooth Generic Attribute Profile (Gatt) Windows Runtime API to interact with a Bluetooth Gatt device, which contains a Heart Rate Service.

 
 
 
 
 
4 Star
(7)
32,915 times
Add to favorites
9/3/2014
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • GattDeviceService::FromIdAsync won't create the service
    2 Posts | Last post January 15, 2018
    • I'm working from the HR example here presented. 
      
      I only have changed the UUID so it connects to the generic access (0x1800) on my own BLE device. The device does appear but when I click on it, the service is not created.
      
      As far as I understand, the GattDeviceService::FromIdAsync(device->Id) doesn't work, so the verification 
      
      if (service != nullptr) is false and the program notifies that the access was not granted. 
      
      I managed to get the Device ID  returned by windows, which is this:
      
      \\?\BTHLEDevice#{00001800-0000-1000-8000-00805f9b34fb}_d2f28afd324a#&&1a50d254&9&001#{6e3bbb679-4372-40c8-9eaa-4509df2-60cd8}
      
      What am I doing wrong?
    • Was this ever resolved? I am running into the same issue.
  • non rt app
    1 Posts | Last post November 08, 2017
    • Hi everybody,
      
      i need to write a procedure (non store app) in vb to read data from heart rate monitor.
      Can someone publish an example in vb or c for a desktop app?
      
  • non rt app
    1 Posts | Last post November 08, 2017
    • Hi everybody,
      
      i need to write a procedure (non store app) in vb to read data from heart rate monitor.
      Can someone publish an example in vb or c for a desktop app?
      
  • WinRT originate error on first call to GattDeviceService::FromIdAsync
    1 Posts | Last post March 11, 2016
    • Has anyone encountered a WinRT originate error when calling GattDeviceService::FromIdAsyn?
      "Exception thrown @ 0x745F3FC8 (kernelBase.dll) in xx.exe: 0x40080201: WinRT originate error (parameter: 0x80028CA), 0x00000010, 0x0EA8F570)"
      
      0x80028CA means it is a TYPE_E_MISMATCh, but I don't see anything that is mismatching.
      My code is based on the one from the HRM app, i.e., based on the following code:
      IAsyncAction^ HeartRateService::InitializeHeartRateServicesAsync(DeviceInformation^ device)
      {
          return create_async([this, device]()
          {
              auto containerId = device->Properties->Lookup("System.Devices.ContainerId");
              this->deviceContainerId = containerId->ToString();
      
              return create_task(GattDeviceService::FromIdAsync(device->Id))
                  .then([this, device] (GattDeviceService^ service) //when hit this breakpoint, the WinRT 
                                                                    //originate appears in the debugger (VS 2015)
              {
      
  • GattDeviceService Dispose method - does it close connection with BLE device
    2 Posts | Last post March 11, 2016
    • I started with the C# version of the Bluetooth GATT Windows App, and modified it to work with a BLE device (via UUID).  I noticed that calling ReadValueAsync and also FromIDAsync (in different places in my code) automatically connects to the device.  But when I call the Dispose method on the GattDeviceService object, the connection isn't terminated.  
      
      How long do I need to wait to see the disconnection?  (In the device I'm using, a flashing green means the device is connected and a flashing red tells me the device is disconnected.)
      
      Does the C# version of GattDeviceService.Dispose release the connection to the BLE device?  Would the C++ version (GattDeviceService::Close() work better to release the connection 'on demand'?
    • This was answered by me in a different forum back in Oct 2015:
      https://social.msdn.microsoft.com/Forums/en-US/b0851ea1-0d2b-4000-8c0d-05ead09b47a7/gattdeviceservice-dispose-method-does-it-close-connection-with-ble-device?forum=csharpgeneral
  • Show Device while receive value of heartrate
    1 Posts | Last post February 04, 2016
    • Function: Instance_ValueChangeCompleted(HeartRateMeasurement heartRateMeasurementValue);
      File: Scenario1_DeviceEvents
      Command: Debug.WriteLine(heartRateMeasurementValue.HeartRateValue); // Can show value HeartRate in realtime.
      
      The Question is:
      - How can I show both device of HeartRate and value of HeartRate in realtime or like this one???
      
      Example: [Run]
      heartrate = 75 device = A
      heartrate = 80 device = A
      heartrate = 82 device = A
      heartrate = 91 device = A
      heartrate = 89 device = A
      
      Many thanks a lot!
      Parietal Lobe
  • BLE status from Connected to Paired
    1 Posts | Last post November 18, 2015
    • Hello everyone,
      
      I've working on an application under this example by using VS2015 community and Windows 10. I do notice a condition which my BLE device will change it's status from "Connected" to "Paired" once the application closed. This will really bother the users if they have to reconnect the device using default Bluetooth Manager every time they reopen the app. 
      
      The questions are brought here:
      1. How can I connect the BLE device by coding once the default Bluetooth Manager  showing "Paired"?
      2. How can I avoid the my application to disconnect the device if it is closed?
      
      Many thanks!
      Hugo
  • ERROR: There is no user session key for the specified logon session. (HRESULT: 0x80070572)
    3 Posts | Last post November 12, 2015
    • Hi everyone,
      
      I've been trying to run this example under VS2015 community and Windows 10. Using an external USB BLE dongle to communicate my Heart Rate sensor with the computer. I am able to pair the device, but every time I select the device from this application, it throws the following error:
      
      ERROR: Accessing your device failed. There is no user session key for the specified logon session. (Exception from HRESULT: 0x80070572)
      
      The device works fine if I read the data from an Android/iOS phone, but it seems not to work with Win10/VS2015.
      
      My only guess is that might be the dongle, but I'm not sure yet. I'm using a "KINOVO BTD-400" I think it's based on a Broadcom chip.
      
      Any ideas on this?
      
      Thanks a lot!
    • Hi EmbeddedEngineer2015,
      
      I'm having the same issue. Did you manage to find a solution?
      
      Regards,
      José.
    • If you look at the Bluetooth settings in Control Panel, is the device listed as 'paired' or as 'connected'? When it says it's just 'paired' it means it's NOT connected. In that case the device would still show up in the device list in the app. However if you select it it goes wrong for obvious reasons (it's not actually connected).
      
      I too have a hard time connecting my GATT devices to Windows 8.1 or 10, while it works fine in OSX/iOS/Android. More often than not it just doesn't work. GATT in Windows is very immature and I'm not the only one complaining about this...
  • Is this code really correct?
    2 Posts | Last post October 19, 2015
    • So I'm connecting to Wahoo BlueHR HRM. Here's what I notice. In this part of the code:
      
            var currentDescriptorValue = await characteristic.ReadClientCharacteristicConfigurationDescriptorAsync();
      
                      if ((currentDescriptorValue.Status != GattCommunicationStatus.Success) ||
                          (currentDescriptorValue.ClientCharacteristicConfigurationDescriptor != CHARACTERISTIC_NOTIFICATION_TYPE))
                      {
                          // Set the Client Characteristic Configuration Descriptor to enable the device to send notifications
                          // when the Characteristic value changes
                          GattCommunicationStatus status =
                              await characteristic.WriteClientCharacteristicConfigurationDescriptorAsync(
                              CHARACTERISTIC_NOTIFICATION_TYPE);
      
                          if (status == GattCommunicationStatus.Unreachable)
                          {
                              // Register a PnpObjectWatcher to detect when a connection to the device is established,
                              // such that the application can retry device configuration.
                              StartDeviceConnectionWatcher();
                          }
                      }
      
      currentDescriptorValue is Notify, but the ValueChanged event is never fired. However, if I always write the Notify descriptor (i.e. always execute the body of the if) then it works fine. 
      
      Second issue: every second time I run the app, upon trying to connect I get back HR 0x80000013 -- the object has been closed. Is the cleanup code wrong?
    • Hi, Eugene. I have the same problem. Did you solve it?
  • Incorrect Funktion(Exception from HRESULT: 0x80070001)
    2 Posts | Last post May 28, 2015
    • Hey.
      If i want to connect my Device to the App, it comes to an Error.
      (Incorrect Funktion(Exception from HRESULT: 0x80070001)
      
      Im trying it with the TICKR RUN heart rate belt. Isnt that possible?
    • In Shared/HeartRateService.cs/ConfigureServiceForNotificationsAsync(), change
      
           characteristic.ProtectionLevel = GattProtectionLevel.EncryptionRequired;
      
      to:
      
           characteristic.ProtectionLevel = GattProtectionLevel.Plain;
      
      Worked for my CooSpo H6.
      
1 - 10 of 22 Items