编辑
如上所述添加注册 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 已经工作。