使用 FromBluetoothAddressAsync 获取 ble 设备服务时出错

Error getting ble device services using FromBluetoothAddressAsync

编辑

这是一些微软安全问题的已知问题 https://social.msdn.microsoft.com/Forums/en-US/58da3fdb-a0e1-4161-8af3-778b6839f4e1/bluetooth-bluetoothledevicefromidasync-does-not-complete-on-10015063?forum=wdk

如前所述添加注册的 CoInitializeSecurity 值解决了问题!

我正在尝试使用广告观察器读取 BLE 设备服务。 我已经在监听器中实现了服务读取,代码:

   private async void OnAdvertisementReceived(BluetoothLEAdvertisementWatcher watcher, BluetoothLEAdvertisementReceivedEventArgs args)
    {

        if (!gotSignal)
        {
            gotSignal = true;
            device = await Windows.Devices.Bluetooth.BluetoothLEDevice.FromBluetoothAddressAsync(args.BluetoothAddress);
            service = await GattDeviceService.FromIdAsync(device.DeviceId);

        }
          ...
     }

问题是我无法获取 BluetoothLEDevice 对象,当我到达这一行时,它没有返回任何值,它会跳过侦听器中的下一行。 注意:我已经安装了 windows creators update 并且在安装之前,功能 BluetoothLEDevice.FromBluetoothAddressAsync 已经工作。

解决方案

这是 Microsoft 某些安全问题的已知问题 https://social.msdn.microsoft.com/Forums/en-US/58da3fdb-a0e1-4161-8af3-778b6839f4e1/bluetooth-bluetoothledevicefromidasync-does-not-complete-on-10015063?forum=wdk

如前所述添加注册的 CoInitializeSecurity 值解决了问题!