Reputation: 167
I've got a device that is operated by Windows Phone 8.1 and Android phones. Since only one of these phones can use the device at any time, we need to disconnect from the device as soon as we finished the use.
On Android, the library we use is able to connect and disconnect, but on Windows Phone 8.1 I can only seem to connect, I can't find a way to tell the phone to disconnect from the device. I have to manually unpair the phone from the device,
has anyone been able to disconnect a paired Bluetooth device? If yes, how?
Thank you!
Upvotes: 6
Views: 3278
Reputation: 889
This may not help with win8 apps, but for anyone working on UWP apps this article is helpful for pairing and unpairing: https://msdn.microsoft.com/en-us/windows/uwp/devices-sensors/pair-devices
The gist of it is you call DeviceInformation.Pairing.UnpairAsync method. https://msdn.microsoft.com/library/windows/apps/windows.devices.enumeration.deviceinformationpairing.unpairasync
Calling that method pops up the windows dialog asking the user for permission to unpair the device.
Upvotes: 0
Reputation: 340
Call Dispose() on the GattDeviceService, ensure that all GattCharacteristic objects are null and DON'T unregister ValueChanged event handlers from GattCharacteristic. Finally call GC.Collect() (Microsoft told that this is a bug in WP8.1 and should be fixed in Win10)
Upvotes: 3
Reputation: 17278
If you are communicating through a StreamSocket, a Dispose() call will disconnect.
Depending on your code, a using() statement might be the most elegant way to do so.
Upvotes: 0