fix: prevent re-entrant disconnect callbacks #4
1 changed files with 5 additions and 4 deletions
|
|
@ -1013,12 +1013,13 @@ extension BeaconProvisioner: CBCentralManagerDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disconnect during device info read (post-auth, pre-write) — beacon may have
|
// Disconnect during device info read (post-auth, pre-write) — beacon may have
|
||||||
// dropped the connection during the MAC address query. This is recoverable:
|
// dropped the connection during the MAC address query. We authenticated but
|
||||||
// we already authenticated, so treat as success without MAC.
|
// lost connection before writing config, so this is a failure — but a known
|
||||||
|
// one with a clear retry path, not an unexplained "Unexpected disconnect".
|
||||||
if state == .authenticating && awaitingDeviceInfoForProvisioning && dxSmartAuthenticated {
|
if state == .authenticating && awaitingDeviceInfoForProvisioning && dxSmartAuthenticated {
|
||||||
DebugLog.shared.log("BLE: Disconnect during device info read (post-auth) — proceeding without MAC, treating as non-fatal")
|
DebugLog.shared.log("BLE: Disconnect during device info read (post-auth) — connection lost before config write, failing with retry prompt")
|
||||||
awaitingDeviceInfoForProvisioning = false
|
awaitingDeviceInfoForProvisioning = false
|
||||||
// Can't proceed without connection — fail gracefully with specific message
|
// Connection lost — can't write config without it, fail with specific message
|
||||||
fail("Disconnected after auth during device info read — please retry", code: .disconnected)
|
fail("Disconnected after auth during device info read — please retry", code: .disconnected)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue