Compare commits

..

No commits in common. "ce81a1a3d8a7223b8c2eee165704e9f008b23d5a" and "a82a3697da26cbae86c0a565bf20d904c96fdaa1" have entirely different histories.

3 changed files with 4 additions and 15 deletions

View file

@ -365,10 +365,8 @@ class BeaconProvisioner: NSObject, ObservableObject {
isTerminating = true
DebugLog.shared.log("BLE: Provisioning success!")
state = .success
// Signal completion BEFORE disconnecting the disconnect delegate fires
// synchronously and ScanView needs writesCompleted=true before it sees it
completion?(.success(macAddress: nil))
disconnectPeripheral()
completion?(.success(macAddress: nil))
cleanup()
}

View file

@ -173,15 +173,6 @@ final class DXSmartProvisioner: NSObject, BeaconProvisioner {
for (index, (name, packet)) in commands.enumerated() {
await diagnosticLog?.log("write", "[\(index + 1)/\(commands.count)] \(name) (\(packet.count) bytes)")
// SaveConfig (last command) causes beacon MCU to reboot it never sends an ACK.
// Fire the BLE write and return immediately; the disconnect is expected.
if name == "SaveConfig" {
peripheral.writeValue(packet, for: writeChar, type: .withResponse)
await diagnosticLog?.log("write", "✅ [\(index + 1)/\(commands.count)] SaveConfig sent — beacon will reboot")
await diagnosticLog?.log("write", "✅ All commands written successfully")
return
}
// Retry each command up to 2 times beacon BLE stack can be flaky
var lastError: Error?
for writeAttempt in 1...2 {
@ -202,8 +193,8 @@ final class DXSmartProvisioner: NSObject, BeaconProvisioner {
throw lastError
}
// 150ms between commands aggressive speedup (was 300ms, originally 500ms)
try await Task.sleep(nanoseconds: 150_000_000)
// 500ms between commands beacon needs time to process
try await Task.sleep(nanoseconds: 500_000_000)
}
}

View file

@ -698,7 +698,7 @@ struct ScanView: View {
try await provisioner.writeConfig(config)
writesCompleted = true
// No explicit disconnect needed succeed() already disconnects
provisioner.disconnect()
try await APIClient.shared.registerBeaconHardware(
businessId: business.id,