I have a windows 10 UWP app that is able to pair with a bluetooth LE device programmatically. Once the pairing is successful, a connection to the device is also established.
If at some point, the device gets disconnected, I am not able to read any of the GattCharacteristics from the LE device. I'm able to check if the connection is present or not but I'm unable to re-establish the connection.
DeviceInformation deviceInfo = await DeviceInformation.CreateFromIdAsync("deviceId", "additionalProperties", "DeviceInformationKind");
if(deviceInfo.ConnectionStatus != BluetoothConnectionStatus.Connected) { // re-establish the connection }
Thanks.
Select Remotes & Accessories — Bluetooth device name — Connect. (Android 10) Select Remotes & Accessories — Bluetooth settings — Registered devices — Bluetooth device name — Connect.
A headset or a speaker doesn't reconnect automaticallyReturn to Settings, search for Bluetooth auto-connect and enable this feature. Make sure that the other device is within the effective Bluetooth range from your smartphone and restart it. Re-enable Bluetooth on the phone and check if the issue is fixed*.
Make sure the Bluetooth function on the both devices to pair. In the PC, right-click on the Bluetooth icon and select the option to add a new connection or device, which will make the computer search for available Bluetooth devices. When another device appears, select it to connect/pair it to your laptop.
The Problem
The Bluetooth LE device is not storing the bonding information created during the pairing process. Bonding information allows two previously paired devices to initiate new connections if they have become disconnected.
The Windows 10 Solution
Using the in-app pairing APIs, you can programmatically tell the system to pair with the Bluetooth LE device (it sounds like you are already doing this). To work around the bonding problem described above, the DevicePairingProtectionLevel
must be set to None
. So your in-app pairing code could look like:
var result = await someDevice.Pairing.PairAsync(DevicePairingProtectionLevel.None);
Setting the DevicePairingProtectionLevel
to None
tells the system to ignore bonding information and just look for a matching device.
The Peripheral Solution
Alternatively, if you have access to the peripheral's firmware, you can set it to remember the bonding information. Then your current pairing calls on Windows 10 should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With