fix: resolve false disconnect error at end of provisioning
succeed() was calling disconnectPeripheral() before completion(), so the disconnect delegate fired while writesCompleted was still false — causing the "Unexpected disconnect" error log even on successful provisions. Swapped order: signal completion first, then disconnect. Also removed the redundant provisioner.disconnect() in ScanView since succeed() already handles it. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
f082eeadad
commit
4bf4435feb
2 changed files with 4 additions and 2 deletions
|
|
@ -365,8 +365,10 @@ class BeaconProvisioner: NSObject, ObservableObject {
|
|||
isTerminating = true
|
||||
DebugLog.shared.log("BLE: Provisioning success!")
|
||||
state = .success
|
||||
disconnectPeripheral()
|
||||
// Signal completion BEFORE disconnecting — the disconnect delegate fires
|
||||
// synchronously and ScanView needs writesCompleted=true before it sees it
|
||||
completion?(.success(macAddress: nil))
|
||||
disconnectPeripheral()
|
||||
cleanup()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -698,7 +698,7 @@ struct ScanView: View {
|
|||
|
||||
try await provisioner.writeConfig(config)
|
||||
writesCompleted = true
|
||||
provisioner.disconnect()
|
||||
// No explicit disconnect needed — succeed() already disconnects
|
||||
|
||||
try await APIClient.shared.registerBeaconHardware(
|
||||
businessId: business.id,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue