Windows 10 物联网蓝牙 LE [英] Windows 10 IoT Bluetooth LE

查看:15
本文介绍了Windows 10 物联网蓝牙 LE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在重新连接到我的 BLE 设备时遇到了问题.

I got an issue with reconnection to my BLE device.

有效的 Senario- BLE 设备未配对- Pi 启动并启动我的应用程序,找到 BLE 设备,配对并连接,接收数据- 启动 Pi 并启动我的应用程序,它不会像已经配对的那样配对,它连接正常并接收数据.

Senario that works - BLE Device is not paired - Pi boots and start my App, find's the BLE device, pair and connect, receiving data - Boot Pi and start my App, it will not pair as its already paired, it connects fine and receiving data.

不起作用的场景- BLE 设备不配对或配对,无所谓- 如果我的 BLE 设备由于断电或超出范围而断开连接,然后通电或回到范围内,Pi 将重新连接并抛出:mscorlib.ni.dll 中的System.Exception"指定的登录会话没有用户会话密钥.(来自 HRESULT 的异常:0x80070572)

Senario that does not work - BLE Device is not pair or pair, does not matter - If my BLE device disconnect due to power loss or out of range and gets powered up or back in range the Pi will reconnect and throw: 'System.Exception' in mscorlib.ni.dll There is no user session key for the specified logon session. (Exception from HRESULT: 0x80070572)

如果我尝试重新启动 Pi,当我尝试执行时会抛出相同的消息: await _readCharacteristic.WriteClientCharacteristicConfigurationDescriptorAsync(GattClientCharacteristicConfigurationDescriptorValue.Notify);

If I try to reboot the Pi, the same message is thrown when I try to execute: await _readCharacteristic.WriteClientCharacteristicConfigurationDescriptorAsync(GattClientCharacteristicConfigurationDescriptorValue.Notify);

唯一有效的方法是每次断开连接时我都取消配对.

The only thing that works is if I unpair the device every time it disconnect.

这和这家伙有同样的问题:https://social.msdn.microsoft.com/Forums/sqlserver/en-US/b98d77f2-bf5e-45fc-9495-1c444b54450e/uwpreconnecting-to-a-ble-csac-device-causes-exception?forum=wpdevelop

This is the same issue that this guy has: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/b98d77f2-bf5e-45fc-9495-1c444b54450e/uwpreconnecting-to-a-ble-csac-device-causes-exception?forum=wpdevelop

也许这里有人见过同样的问题并解决了它?

Maybe there is anyone here that has seen the same issue and solved it ?

谢谢

推荐答案

您收到此特定错误的原因几乎可以肯定是 BLE 设备本身没有存储在配对过程中协商的绑定信息.要重新使用现有的 BLE 配对,设备必须保留与其合作伙伴的绑定,以便将来进行通信会话.

The reason for this particular error you are receiving is almost certainly that the BLE device itself is not storing the bonding information that is negotiated during the pairing process. For an existing BLE pairing to be re-used, the device must retain the bonding with its partner for future communication sessions.

开发人员有时可以通过让 PC 或移动应用程序删除与已保留设备的任何先前配对,并在每次看到蓝牙时协商新的配对,从而解决其(非 Windows)PC 或手机应用程序中的此设备缺陷设备.这是可能的,因为许多蓝牙设备具有静态 PIN,无需交互即可配对,并保持开放配对模式.因此,该应用程序会在每次通信时创建一个新设备配对.Mac BLE API 也不需要用户交互来配对和取消配对.

Developers can sometimes work around this device shortcoming in their (non-Windows) PC or phone application by having the PC or Mobile app delete any previous pairings with the device already retained, and negotiate a new pairing each time it sees the Bluetooth device. This is possible because many Bluetooth devices have a static PIN, require no interaction for pairing, and remain in open pairing mode. So the app creates a new device pairing upon each communication. The Mac BLE API requires no user interaction for pairing and un-pairing as well.

但是这个解决方案在 Windows BLE API 下是行不通的,因为与常规蓝牙不同,低功耗蓝牙 API 需要用户在配对和取消配对仪式"期间进行交互.用户必须同意每次配对,并且必须同意每次取消配对.从 Windows 上的 UX 角度来看,这使得此变通解决方案不适合入门.我的猜测是 BLE 设备制造商没有存储绑定.

But this solution is unworkable under Windows BLE API, because unlike regular Bluetooth, the Bluetooth Low Energy API requires user interaction during both the pairing, and un-pairing "ceremonies". The user must agree to every pairing, and must agree to every un-pairing. This makes this workaround solution a non-starter from a UX standpoint on Windows. My guess is the BLE device manufacturer isn't storing the bonding.

我们自己开发了自己的 BLE 驱动程序来与我们自己的 BLE 板通信时遇到了这样的情况;我们不得不重新编写运行 BLE 设备的固件,因为虽然它可以使用上述方法在 Mac OS 和 Android 下运行,但 Microsoft UWP 上可用的 BLE API 需要用户在配对仪式期间进行交互.无论如何,这似乎是正确的做事方式.

We ran into such a situation ourselves developing our own BLE driver to speak with our own BLE board; we had to re-do the firmware running our BLE device because while it would work under Mac OS and Android with the method described above, the BLE API available on the Microsoft UWP requires user interaction during the pairing ceremony. This seems the right way to do things, anyway.

这篇关于Windows 10 物联网蓝牙 LE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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