Compare commits
2 commits
a82a3697da
...
f082eeadad
| Author | SHA1 | Date | |
|---|---|---|---|
| f082eeadad | |||
| 3720f496bd |
1 changed files with 12 additions and 2 deletions
|
|
@ -173,6 +173,15 @@ 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 {
|
||||||
|
|
@ -193,8 +202,9 @@ final class DXSmartProvisioner: NSObject, BeaconProvisioner {
|
||||||
throw lastError
|
throw lastError
|
||||||
}
|
}
|
||||||
|
|
||||||
// 500ms between commands — beacon needs time to process
|
// 300ms between commands — conservative speedup (was 500ms)
|
||||||
try await Task.sleep(nanoseconds: 500_000_000)
|
// Beacon needs time to process each GATT write; 300ms tested safe
|
||||||
|
try await Task.sleep(nanoseconds: 300_000_000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue