I upgraded to Windows 10, version 1703 build 15063 (Creators Update) official release. When I run the following code in a WPF desktop application, BluetoothLEDevice.FromBlue
Interestingly, it does work on desktop applications using cppwinrt:
Advertisement::BluetoothLEAdvertisementWatcher watcher;
void Start() {
watcher.ScanningMode(Advertisement::BluetoothLEScanningMode::Active);
Windows::Foundation::TimeSpan timeout = std::chrono::seconds(2);
watcher.SignalStrengthFilter().OutOfRangeTimeout(timeout);
watcher.SignalStrengthFilter().OutOfRangeThresholdInDBm(-90);
watcher.Received([&](Advertisement::BluetoothLEAdvertisementWatcher watcher, Advertisement::BluetoothLEAdvertisementReceivedEventArgs eventArgs) {
connect(eventArgs.BluetoothAddress());
});
watcher.Start();
}
Windows::Foundation::IAsyncAction connect(uint64_t uuid) {
co_await resume_background();
BluetoothLEDevice device = co_await BluetoothLEDevice::FromBluetoothAddressAsync(uuid);
GenericAttributeProfile::GattDeviceServicesResult gatt = co_await device.GetGattServicesForUuidAsync(myServiceUUID);
// works fine!
}
However, notifications for GATT characteristics don't work for me after that. I have filed a bug report with the cppwinrt project, but the devs don't seem to be particularly inclined to look into it.
I have no idea what that API is doing differently than the desktop C# version.