How to discover Bluetooth Low Energy Device(BLE) from Windows Phone 8.1

久未见 提交于 2019-12-09 20:59:18

问题


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:


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



来源:https://stackoverflow.com/questions/24928264/how-to-discover-bluetooth-low-energy-deviceble-from-windows-phone-8-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!