Windows 10 IoT Bluetooth LE
Asked Answered
T

1

6

I got an issue with reconnection to my BLE device.

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.

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)

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.

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 ?

Thanks

Tartar answered 8/1, 2016 at 22:4 Comment(0)
W
10

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.

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.

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.

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.

Workhouse answered 21/4, 2016 at 21:32 Comment(7)
Great thanks, really usefull answer. I had a problem with sending data to HM11 ble module (cc2540 based) and was receiving exception "from HRESULT 0x80650003".Your post solve my issue, i changed setup from "Not need PIN Code" to "Auth and bond" This is the only useful answer from all the web.Hiroshima
@VladimirTsykunov I am also running into this problem, did you change the setup from "Not need PIN Code" to "Auth and bond" on your PC or on your Bluetooth device? ThanksBengali
Yes, i switched bluetooth on device to Auth and Bond and this helped a lot. But win10 still has many bugs and disconnects. Usage of external BT dongle may help, also there are some changes in BT core in Win10 August update @danielmetlitskiHiroshima
@VladimirTsykunov Thanks! Also, it's strange that on Windows 8.1 everything works - I only need to pair once and it will work after. But on Windows 8.1 I'm getting the exception when trying to connect the second time. Why would this be a problem on Windows 10 and not on 8.1?Bengali
@VladimirTsykunov wouldn't setting the bluetooth device to "Paired and Authenticated" cause problems? The device will think that it's always connected, could that be a problem when connecting to iOS or Android?Bengali
@danielmetlitski Yes it can be a problem. I am not really expert here, but seems pairing and bonding increase data size that is transferred between devices, it may cause problems for BLE chips with bad performance - most of Qualcom. And it will NOT cause problems connecting to devices, you will just need reenter password once and this is all.Hiroshima
This is not correct user must give his consent and forget about this nightmare. And if necessary, take your consent. We live in the age of automation, not the age of monkeys that push buttons.Pros

© 2022 - 2024 — McMap. All rights reserved.