Add flag to only stop device scan if it as started at least once before - #37
Add flag to only stop device scan if it as started at least once before#37ebariaux wants to merge 2 commits into
Conversation
MartinaeyNL
left a comment
There was a problem hiding this comment.
Does this work? Won't searchedAtLeastOnce be incorrect after a 2nd device provisioning?
There was a problem hiding this comment.
Pull request overview
This pull request adds state to the ESP provisioning wrapper so stopESPDevicesSearch() is only invoked after at least one device search has been started, aiming to avoid a known crash in the underlying ESPProvision library.
Changes:
- Convert
EspressifProvisionManagerfrom astructto aclassto retain state across calls. - Track whether a search has ever been started and guard
stopESPDevicesSearch()accordingly. - Add an initializer to support injecting an
ESPProvisionManagerinstance.
Suppressed comments (3)
ORLib/ConsoleProviders/ESPProvision/DeviceRegistry.swift:45
- This assignment should be updated to match the renamed/encapsulated flag (e.g.,
hasSearchedAtLeastOnce) so it stays consistent with the guard instopESPDevicesSearch().
searchedAtLeastOnce = true
ORLib/ConsoleProviders/ESPProvision/DeviceRegistry.swift:63
- Guarding
stopESPDevicesSearch()with a local "has searched" flag avoids the known crash, but it can also makestopDevicesScan()a no-op if it’s called before the async scan task reachessearchESPDevices()(the task will still start a search later). Consider preventing searches from starting afterbleScanningis set to false (e.g., checkbleScanningbefore initiatingsearchESPDevicesinDeviceRegistry.devicesScan) and/or introducing an explicit cancellable scan task instead of relying on this flag alone.
// ESPProvisionManager.stopESPDevicesSearch crashes by force unwrapping nil if it did not perform a search before
guard searchedAtLeastOnce else { return }
provisionManager.stopESPDevicesSearch()
ORLib/ConsoleProviders/ESPProvision/DeviceRegistry.swift:62
- Update the guard to match the renamed flag so the code compiles and the intent stays clear.
guard searchedAtLeastOnce else { return }
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@MartinaeyNL Issue is with Espressif code, some object is nil if not initialised by a search, but when done once that object stays around forever |
|



No description provided.