How to discover Bluetooth Low Energy Device(BLE) f

2019-04-15 02:07发布

I am writing a Silverlight Windows Phone 8.1 application, I am trying to connect with Bluetooth Low Energy(BLE) device from Windows Phone 8.1, the device is "HEART RATE", but I'm not getting the result. See my code below.

protected async override void OnNavigatedTo(NavigationEventArgs e)
{
var devices = await DeviceInformation.FindAllAsync(GattDeviceService.GetDeviceSelectorFromUuid
                           (GattServiceUuids.HeartRate));
   if (devices.Count > 0)
   {

   }
}

I have also added capability in appmanifest file.

<Capabilities>
 <Capability Name="internetClient"/>
    <m2:DeviceCapability Name="bluetooth.genericAttributeProfile">
      <m2:Device Id="any">
      <m2:Function Type="name:heartRate" />
       <m2:Function Type="serviceId:0000180d-0000-1000-8000-00805f9b34fb" />
     </m2:Device>
</m2:DeviceCapability>

Everything seems fine, but I don't get the output. What's going wrong?

1条回答
何必那么认真
2楼-- · 2019-04-15 02:09

The heart rate sensor has to be paired first in the "settings->Bluetooth" on your phone.

查看更多
登录 后发表回答