flutter_reactive_ble icon indicating copy to clipboard operation
flutter_reactive_ble copied to clipboard

iOS scan returning devices that have recently stopped advertising

Open maBarabas opened this issue 1 year ago • 0 comments

Describe the bug

When our device starts an OTA upgrade, it will power down then reboot after a few seconds. During this time it stops advertising. However, if I start a scan on iOS just after the device disconnects, then the scan will show the device occasionally. It seems like there is some kind of race condition in the library where scan results can be from the past, and include devices that have recently stopped advertising.

Similar issue that was closed in the past: https://github.com/PhilipsHue/flutter_reactive_ble/issues/390

To Reproduce Steps to reproduce the behavior:

  1. Connect to device
  2. power down device
  3. when the device disconnects, start a scan
  4. Notice that rarely, the powered down device is in the results

Expected behavior The scan results do not include the powered down device

  • [ ] I tried doing the same with a general BLE scanner application (e.g. nRF Connect) and it exhibits the expected behavior as described above

Smartphone / tablet

  • Device: iPhone XR
  • OS: iOS 15.6.1
  • Package version: 5.0.3

Peripheral device

  • Vendor, model: custom
  • Does it run a custom firmware / software: yes

Additional context

Similar issue that was closed in the past: https://github.com/PhilipsHue/flutter_reactive_ble/issues/390

This happens rarely enough that I think maybe some cache invalidation logic was added to the library since that issue was closed. Could you confirm if there is a workaround in the library now, which seems to have a bug, or if I should add the work around in my application code?

maBarabas avatar Apr 26 '23 11:04 maBarabas