Fix device signing/companion ID, duplicate-device crash, background updates, and add level bubble to Live Activity
- Assign the shared development team to the widget extension and watch complication targets, and correct the watch app's companion bundle identifier so on-device installs succeed after the bundle ID rename to de.s0.fototeddy.VanAligneiOS. - Guard against two ConfiguredDevices sharing a peripheralID (e.g. a double-tapped "Sichern"), which crashed BluetoothManager's Dictionary(uniqueKeysWithValues:) on launch. - Keep Bluetooth running in the background while a Live Activity is active, so lock screen/CarPlay keep receiving fresh readings instead of freezing at the last value before backgrounding. - Render the actual bubble-level graphic (not just a static icon) in the Live Activity's lock screen view and expanded Dynamic Island. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
bfe2b00a5c
commit
9a3b5cb472
@@ -517,7 +517,11 @@ final class BluetoothManager: NSObject {
|
||||
// MARK: - Ablauf auf der Funk-Queue
|
||||
|
||||
private func applyConfiguration(_ devices: [ManagedDevice]) {
|
||||
managed = Dictionary(uniqueKeysWithValues: devices.map { ($0.peripheralID, $0) })
|
||||
// Mit `uniqueKeysWithValues` stürzt das bei doppelt eingerichteten
|
||||
// Geräten (gleiches Peripheral, aus Versehen zweimal hinzugefügt) ab.
|
||||
// Der letzte Eintrag gewinnt – besser eine überschriebene Dublette als
|
||||
// ein Absturz der ganzen Funk-Schicht.
|
||||
managed = Dictionary(devices.map { ($0.peripheralID, $0) }, uniquingKeysWith: { _, latest in latest })
|
||||
|
||||
// Verbindungen zu Geräten lösen, die nicht mehr dazugehören.
|
||||
let wanted = Set(devices.filter { shouldStayConnected($0) }.map(\.peripheralID))
|
||||
|
||||
@@ -43,7 +43,11 @@ struct CamperMonitorApp: App {
|
||||
case .active:
|
||||
bluetooth.start()
|
||||
case .background:
|
||||
if !watch.wantsLiveUpdates { bluetooth.stop() }
|
||||
// Läuft gerade eine Live Activity, muss der Neigungsmesser
|
||||
// auch mit dunklem Bildschirm weiter Werte liefern – sonst
|
||||
// friert die Anzeige auf Sperrbildschirm und CarPlay beim
|
||||
// ersten Wegdrücken der App ein.
|
||||
if !watch.wantsLiveUpdates && !levelActivity.isActive { bluetooth.stop() }
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
@@ -13,6 +13,11 @@ final class LevelActivityManager {
|
||||
private(set) var trackedDeviceID: UUID?
|
||||
@ObservationIgnored private var activity: Activity<LevelActivityAttributes>?
|
||||
|
||||
/// Ob gerade irgendeine Aktivität läuft – die App muss dafür im
|
||||
/// Hintergrund weiter nach dem Neigungsmesser funken, sonst friert die
|
||||
/// Anzeige beim ersten Sperren des Bildschirms ein.
|
||||
var isActive: Bool { trackedDeviceID != nil }
|
||||
|
||||
func isActive(for deviceID: UUID) -> Bool {
|
||||
trackedDeviceID == deviceID && activity != nil
|
||||
}
|
||||
|
||||
@@ -94,7 +94,14 @@ final class DeviceStore {
|
||||
// MARK: - Geräte
|
||||
|
||||
/// Legt ein Gerät im gerade gewählten Profil an.
|
||||
///
|
||||
/// Dasselbe Peripheral doppelt im selben Profil anzulegen, würde später
|
||||
/// beim Aufbau der Funk-Konfiguration abstürzen (die dortige Zuordnung
|
||||
/// nach Peripheral-ID verlangt Eindeutigkeit) – etwa bei einem
|
||||
/// Doppel-Tipp auf „Sichern“. Ein zweiter Eintrag ersetzt darum den
|
||||
/// ersten, statt sich danebenzustellen.
|
||||
func add(_ device: ConfiguredDevice, victronKey: String? = nil) {
|
||||
devices.removeAll { $0.profileID == device.profileID && $0.peripheralID == device.peripheralID }
|
||||
devices.append(device)
|
||||
if let victronKey {
|
||||
setVictronKey(victronKey, for: device.id)
|
||||
|
||||
Reference in New Issue
Block a user