fix: resolve write ACK on didWriteValueFor instead of waiting for notification

Frame1_DevInfo (cmd 0x61) and potentially other commands don't send a
separate FFE1 notification after being written. The code was waiting for
didUpdateValueFor (notification) to resolve responseContinuation, but it
never came — causing a 5s timeout on every such command.

The .withResponse write type already guarantees the BLE stack confirmed
delivery. Now didWriteValueFor resolves responseContinuation on success,
so commands that don't trigger notifications still complete immediately.

If a notification also arrives later, responseContinuation is already nil
so it's harmlessly ignored.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Schwifty 2026-03-23 02:16:24 +00:00
parent 37c7c72052
commit b88dded928

View file

@ -448,10 +448,18 @@ extension DXSmartProvisioner: CBPeripheralDelegate {
return
}
// Handle write errors for command writes
if let error, let cont = responseContinuation {
// For command writes (FFE1/FFE2): the .withResponse write confirmation
// IS the ACK. Some commands (e.g. 0x61 Frame1_DevInfo) don't send a
// separate FFE1 notification, so we must resolve here on success too.
// If a notification also arrives later, responseContinuation will already
// be nil harmless.
if let cont = responseContinuation {
responseContinuation = nil
cont.resume(throwing: error)
if let error {
cont.resume(throwing: error)
} else {
cont.resume(returning: Data())
}
}
}
}