gpt4 book ai didi

windows - 在 Windows 10 上连接到 BLE 外设

转载 作者:可可西里 更新时间:2023-11-01 11:16:39 27 4
gpt4 key购买 nike

我尝试连接到 BLE 外围设备。首先,我看广告:

watcher = new BluetoothLEAdvertisementWatcher { ScanningMode = BluetoothLEScanningMode.Active };
watcher.Received += WatcherOnReceived;
watcher.Start();

在 WatcherOnReceived 回调中我尝试创建 BluetoothLEDevice

public async void WatcherOnReceived(BluetoothLEAdvertisementWatcher sender, BluetoothLEAdvertisementReceivedEventArgs btAdv)
{
BluetoothLEDevice bleDevice = await BluetoothLEDevice.FromBluetoothAddressAsync(btAdv.BluetoothAddress);
}

但是,我总是在 WatcherOnReceived 回调中得到 bleDevice == null。为什么以及如何解决它?在 UWP 应用程序中创建 BLE 设备的正确方法是什么?然后我需要连接到该设备,发现它的 GATT 服务和特征,启用其中一些的通知并读取/写入其中的一些。

最佳答案

这个问题的答案很简单——不要在 Windows 10 上使用 BLE。API 不起作用或行为随机,并且完全没有记录。我喜欢每个人都在谈论物联网是下一次工业革命,而微软在 BLE 存在 6 年后没有可用的 BLE API。

关于windows - 在 Windows 10 上连接到 BLE 外设,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38703701/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com