低功耗蓝牙连接 [英] Bluetooth Low Energy connection
问题描述
我正在尝试为Win 8.1 PC开发一个与我的BLE设备通信的应用程序.我读到Win 8中没有类似BLE扫描功能的内容,因此我从MS阅读了一些示例,并尝试使用UUID简单连接到我的设备:"A9DA45B4-34F8-C660-591D-F6918B5B988C"
I'm trying to develop an app for Win 8.1 PC to communicate with my BLE device. I read that in Win 8 there is no something like scanning functionality for BLE so I read some examples from MS and try to simple connect to my device with UUID: "A9DA45B4-34F8-C660-591D-F6918B5B988C"
所以我根据ms示例编写一些代码:
So I write some code based on ms examples:
var devices = await DeviceInformation.FindAllAsync(
GattDeviceService.GetDeviceSelectorFromUuid(new Guid("A9DA45B4-34F8-C660-591D-F6918B5B988C")), new string[] { "System.Devices.ContainerId" });
if (devices.Count > 0){
//Do something
}
但是此代码始终向我返回空设备列表.而且,我仍然可以通过Android或iOS应用程序连接设备.
But this code always return me empty devices list. More over I am still able to connect my device by Android or iOS app.
有人可以告诉我连接BLE的好方法吗?
Can someone told me if it is good way to connect BLE?
推荐答案
转到设置->更改PC设置->-> PC和设备->蓝牙.
Go to Settings --> Change PC Settings --> --> PC and devices --> Bluetooth.
确保您的设备可被发现,然后建立连接.
Make sure that your device is discoverable, then establish a connection.
完成后再试一次,如果仍然不起作用,请尝试以下代码:
Try again when you're done, if it still doesn't work, try with following code:
var devices = await DeviceInformation.FindAllAsync(
GattDeviceService.GetDeviceSelectorFromUuid(GattServiceUuids.GenericAccess));
devices.Count应该至少返回1.
devices.Count should return at least 1.
这篇关于低功耗蓝牙连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!