Search code examples
uwpbluetoothbluetooth-lowenergywindows-10-universalgatt

BluetoothLEAdvertisementWatcher when device turn off BLE - UWP


What I have done:

  1. I have an observable collection Display.

  2. When I get BluetoothLEAdvertisementWatcher.Received event, I check the RSSI.

  3. If RSSI > -65DBm, I add the device in Display.

    (RSSI goes like -60 > -127 > -57 > -127 > -63 > -127 >...... I'm bit curious if this normal)


Question:

Can I 'catch' when the user turns off BT/BLE of the device?

  • so I can remove the corresponding device from Display.

The only events are Received and Stopped that I don't think it's possible like devicewatcher does, but still...

If this is not possible, that's fine too; please just comment/answer "This can't be done" so I don't dig in for nothing :)

Any help appreciated!


Solution

  • RSSI goes like -60 > -127 > -57 > -127 > -63 > -127 >...... I'm bit curious if this normal

    This is normal and it base on your bluetooth device sensitivity. if you have set the following, He will filter out mismatched data. But for my testing -127 will be capture with watcher.

    watcher.SignalStrengthFilter.InRangeThresholdInDBm = -70;
    watcher.SignalStrengthFilter.OutOfRangeThresholdInDBm = -75;
    

    If RSSI > -65DBm, I add the device in Display

    You could get RSSI value in OnAdvertisementReceived event handler with eventArgs.RawSignalStrengthInDBm. And then do secondary filtering.

    Int16 rssi = eventArgs.RawSignalStrengthInDBm;
    if (rssi >= -65)
    {
     // add to collection.
    }
    

    Is there a way I can catch whether a specific device is considered to be out of range?

    Currently, there is no such api to detect the specific device is out of range.