fix(ble): restore peripheral state and keep advertising

This commit is contained in:
2026-01-08 22:27:11 +00:00
parent d89aedd5af
commit 214af08625
2 changed files with 45 additions and 7 deletions

View File

@@ -9,11 +9,13 @@ import SwiftUI
@main
struct irisApp: App {
@Environment(\.scenePhase) private var scenePhase
@StateObject private var ble: BlePeripheralManager
@StateObject private var orchestrator: ContextOrchestrator
init() {
let bleManager = BlePeripheralManager()
bleManager.start()
_ble = StateObject(wrappedValue: bleManager)
_orchestrator = StateObject(wrappedValue: ContextOrchestrator(ble: bleManager))
}
@@ -23,6 +25,11 @@ struct irisApp: App {
ContentView()
.environmentObject(ble)
.environmentObject(orchestrator)
.onChange(of: scenePhase) { phase in
if phase == .active || phase == .background {
ble.start()
}
}
}
}
}