xmedeko
xmedeko

Reputation: 7820

Windows UWP BluetoothLEDevice reconnect

I use BluetoothLEDevice in a Desktop app without pairing, according to the Microsoft videos and source codes. I subscribe to notify a characteristics and receive it's values, so far so good.

However, if the device goes off/on or is to out of signal for a moment, then it's ConnectionStatus is Disconnected and does not reconnect again (does not change to Connected). How to reconnect device if it's signal is within the range again?

The only way which come to my mind it to keep DeviceWatcher running and listen to the Added event. Or may it be done in a simpler way?

Upvotes: 2

Views: 720

Answers (1)

Vincent
Vincent

Reputation: 3746

There is no other way. The DeviceWatcher is responsible of the devices detection. You will have to monitor the DeviceAdded event to redetect your device.

According to the documentation, you should monitor all the events to keep receiving added notification after the initial enumeration.

An app must subscribe to all of the added, removed, and updated events to be notified when there are device additions, removals or updates. If an app handles only the added event, it will not receive an update if a device is added to the system after the initial device enumeration completes.

Upvotes: 3

Related Questions