在Windows 10上连接到BLE外围设备 [英] Connect to BLE peripheral on Windows 10

查看:263
本文介绍了在Windows 10上连接到BLE外围设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I try to connect to BLE peripheral. First, I watch for advertisements:

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

,并且在WatcherOnReceived回调中,我尝试创建BluetoothLEDevice

and in the WatcherOnReceived callback I try to create BluetoothLEDevice

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

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

However, I always get bleDevice == null in WatcherOnReceived callback. Why and how to fix it? What is the proper way of creating BLE device in UWP application? I then need to connect to that device, discover its GATT services and characteristics, enable notifications on some of them and read/write some of them.

推荐答案

此问题的答案很简单-不要在Windows 10上使用BLE.该API无法正常工作或行为随机,并且完全没有文档说明.我喜欢每个人都在谈论物联网是下一次工业革命,而微软在存在六年的BLE后仍无法使用BLE API.

The answer to this question is simple - do not use BLE on Windows 10. The API doesn't work or behaves randomly and is totally undocumented. I like everyone talking about IoT being next industrial revolution and Microsoft not having working BLE API after 6 year BLE exists.

这篇关于在Windows 10上连接到BLE外围设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆