From 66cf65f803ed1b7fbb7a079ea309f866b65f92de Mon Sep 17 00:00:00 2001 From: Schwifty Date: Mon, 23 Mar 2026 04:18:18 +0000 Subject: [PATCH] fix: trim auth and post-write delays from 600ms down to 100ms total MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Auth trigger settle: 100ms → 50ms - Auth password settle: 500ms → 50ms - Post-write reboot settle: 200ms → 50ms Beacon handles 50ms inter-command just fine, no reason for the beginning and end to be slower. Co-Authored-By: Claude Opus 4.6 (1M context) --- PayfritBeacon/Provisioners/DXSmartProvisioner.swift | 6 ++---- PayfritBeacon/Views/ScanView.swift | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/PayfritBeacon/Provisioners/DXSmartProvisioner.swift b/PayfritBeacon/Provisioners/DXSmartProvisioner.swift index d3f6963..ff9b0c8 100644 --- a/PayfritBeacon/Provisioners/DXSmartProvisioner.swift +++ b/PayfritBeacon/Provisioners/DXSmartProvisioner.swift @@ -384,15 +384,13 @@ final class DXSmartProvisioner: NSObject, BeaconProvisioner { // Step 1: Trigger — fire and forget (matches Android's WRITE_TYPE_NO_RESPONSE) if let triggerData = Self.triggerPassword.data(using: .utf8) { peripheral.writeValue(triggerData, for: ffe3, type: .withoutResponse) - try await Task.sleep(nanoseconds: 100_000_000) // 100ms (matches Android SDK timer) + try await Task.sleep(nanoseconds: 50_000_000) // 50ms settle } // Step 2: Auth password — fire and forget if let authData = Self.defaultPassword.data(using: .utf8) { peripheral.writeValue(authData, for: ffe3, type: .withoutResponse) - // 500ms settle after auth — beacon needs time to enter config mode, - // especially if BLE stack was stressed by prior provisioner attempts - try await Task.sleep(nanoseconds: 500_000_000) + try await Task.sleep(nanoseconds: 50_000_000) // 50ms settle } } diff --git a/PayfritBeacon/Views/ScanView.swift b/PayfritBeacon/Views/ScanView.swift index 4e7c55c..c214493 100644 --- a/PayfritBeacon/Views/ScanView.swift +++ b/PayfritBeacon/Views/ScanView.swift @@ -620,8 +620,8 @@ struct ScanView: View { try await provisioner.writeConfig(config) writesCompleted = true - // Give the beacon 200ms to process SaveConfig before dropping the BLE link. - try? await Task.sleep(nanoseconds: 200_000_000) + // Brief settle after SaveConfig before dropping the BLE link. + try? await Task.sleep(nanoseconds: 50_000_000) provisioner.disconnect() try await APIClient.shared.registerBeaconHardware(