Compare commits
No commits in common. "ce81a1a3d8a7223b8c2eee165704e9f008b23d5a" and "a82a3697da26cbae86c0a565bf20d904c96fdaa1" have entirely different histories.
ce81a1a3d8
...
a82a3697da
3 changed files with 4 additions and 15 deletions
|
|
@ -365,10 +365,8 @@ class BeaconProvisioner: NSObject, ObservableObject {
|
||||||
isTerminating = true
|
isTerminating = true
|
||||||
DebugLog.shared.log("BLE: Provisioning success!")
|
DebugLog.shared.log("BLE: Provisioning success!")
|
||||||
state = .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()
|
disconnectPeripheral()
|
||||||
|
completion?(.success(macAddress: nil))
|
||||||
cleanup()
|
cleanup()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -173,15 +173,6 @@ final class DXSmartProvisioner: NSObject, BeaconProvisioner {
|
||||||
for (index, (name, packet)) in commands.enumerated() {
|
for (index, (name, packet)) in commands.enumerated() {
|
||||||
await diagnosticLog?.log("write", "[\(index + 1)/\(commands.count)] \(name) (\(packet.count) bytes)")
|
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
|
// Retry each command up to 2 times — beacon BLE stack can be flaky
|
||||||
var lastError: Error?
|
var lastError: Error?
|
||||||
for writeAttempt in 1...2 {
|
for writeAttempt in 1...2 {
|
||||||
|
|
@ -202,8 +193,8 @@ final class DXSmartProvisioner: NSObject, BeaconProvisioner {
|
||||||
throw lastError
|
throw lastError
|
||||||
}
|
}
|
||||||
|
|
||||||
// 150ms between commands — aggressive speedup (was 300ms, originally 500ms)
|
// 500ms between commands — beacon needs time to process
|
||||||
try await Task.sleep(nanoseconds: 150_000_000)
|
try await Task.sleep(nanoseconds: 500_000_000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -698,7 +698,7 @@ struct ScanView: View {
|
||||||
|
|
||||||
try await provisioner.writeConfig(config)
|
try await provisioner.writeConfig(config)
|
||||||
writesCompleted = true
|
writesCompleted = true
|
||||||
// No explicit disconnect needed — succeed() already disconnects
|
provisioner.disconnect()
|
||||||
|
|
||||||
try await APIClient.shared.registerBeaconHardware(
|
try await APIClient.shared.registerBeaconHardware(
|
||||||
businessId: business.id,
|
businessId: business.id,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue