如何从Windows Phone 8.1中发现蓝牙低功耗设备

本文关键字:发现 低功耗 Windows Phone | 更新日期: 2023-09-27 18:14:46

我正在编写一个Silverlight Windows Phone 8.1应用程序,我正在尝试从Windows Phone 8.1连接蓝牙低功耗(BLE)设备,该设备是"心率",但我没有得到结果。请看下面的代码

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

我还在appmanifest文件中添加了功能。

<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>

一切看起来都很好,但是我没有得到输出。出了什么问题?

如何从Windows Phone 8.1中发现蓝牙低功耗设备

心率传感器必须先在手机的"设置->蓝牙"中配对。