100% fresh codebase — no legacy code carried over. Built against the Android beacon app as the behavioral spec. Architecture: - App: SwiftUI @main, AppState-driven navigation, Keychain storage - Views: LoginView (OTP + biometric), BusinessListView, ScanView (provisioning hub) - Models: Business, ServicePoint, BeaconConfig, BeaconType, DiscoveredBeacon - Services: APIClient (actor, async/await), BLEManager (CoreBluetooth scanner) - Provisioners: KBeacon, DXSmart (2-step auth + flashing), BlueCharm - Utils: UUIDFormatting, BeaconBanList, BeaconShardPool (64 shards) Matches Android feature parity: - 4-screen flow: Login → Business Select → Scan/Provision - 3 beacon types with correct GATT protocols and timeouts - Namespace allocation via beacon-sharding API - Smart service point naming (Table N auto-increment) - DXSmart special flow (connect → flash → user confirms → write) - Biometric auth, dev/prod build configs, DEV banner overlay Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
40 lines
1.4 KiB
Swift
40 lines
1.4 KiB
Swift
import Foundation
|
|
import CoreBluetooth
|
|
|
|
/// Common protocol for all beacon provisioners
|
|
protocol BeaconProvisioner {
|
|
/// Connect to the beacon and authenticate
|
|
func connect() async throws
|
|
|
|
/// Write the full beacon configuration
|
|
func writeConfig(_ config: BeaconConfig) async throws
|
|
|
|
/// Disconnect from the beacon
|
|
func disconnect()
|
|
|
|
/// Whether we're currently connected
|
|
var isConnected: Bool { get }
|
|
}
|
|
|
|
/// GATT UUIDs shared across provisioner types
|
|
enum GATTConstants {
|
|
// FFE0 service (KBeacon, DXSmart)
|
|
static let ffe0Service = CBUUID(string: "0000FFE0-0000-1000-8000-00805F9B34FB")
|
|
static let ffe1Char = CBUUID(string: "0000FFE1-0000-1000-8000-00805F9B34FB")
|
|
static let ffe2Char = CBUUID(string: "0000FFE2-0000-1000-8000-00805F9B34FB")
|
|
static let ffe3Char = CBUUID(string: "0000FFE3-0000-1000-8000-00805F9B34FB")
|
|
|
|
// FFF0 service (BlueCharm)
|
|
static let fff0Service = CBUUID(string: "0000FFF0-0000-1000-8000-00805F9B34FB")
|
|
static let fea0Service = CBUUID(string: "0000FEA0-0000-1000-8000-00805F9B34FB")
|
|
|
|
// CCCD for enabling notifications
|
|
static let cccd = CBUUID(string: "00002902-0000-1000-8000-00805F9B34FB")
|
|
|
|
// Timeouts (matching Android)
|
|
static let connectionTimeout: TimeInterval = 5.0
|
|
static let operationTimeout: TimeInterval = 5.0
|
|
static let maxRetries = 3
|
|
static let retryDelay: TimeInterval = 1.0
|
|
static let postFlashDelay: TimeInterval = 3.0
|
|
}
|