Rename solar integration types to VotronicSolarESP
Renames every type and identifier we built for the solar charge controller bridge from generic "Solar" naming to the product name VotronicSolarESP: VanAlignSolarProtocol -> VotronicSolarESPProtocol, SolarSession -> VotronicSolarESPSession, SolarState -> VotronicSolarESPState, plus the dependent properties, parameters, and user-facing discovery/empty-state strings. Purely a Swift-side rename - the underlying BLE service/characteristic UUIDs are untouched, so it has no effect on communicating with the actual firmware. DeviceRole.solar's case name, and DemoData's device instance variables, are left as-is since they describe the role/demo device rather than this specific integration code. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
7fc9442aeb
commit
644c4c7767
@@ -18,7 +18,7 @@ struct Discovery: Identifiable, Hashable {
|
||||
/// Der Neigungsmesser bewirbt seinen Dienst, ist also sicher erkennbar.
|
||||
var isLevelSensor = false
|
||||
/// Der Solarladeregler bewirbt seinen Dienst ebenso.
|
||||
var isSolarSensor = false
|
||||
var isVotronicSolarESPSensor = false
|
||||
|
||||
//var isVictron: Bool { victronRecordType != nil }
|
||||
|
||||
@@ -33,7 +33,7 @@ struct Discovery: Identifiable, Hashable {
|
||||
|
||||
var subtitle: String {
|
||||
if isLevelSensor { return "VanAlign Neigungsmesser" }
|
||||
if isSolarSensor { return "VanAlign Solarladeregler" }
|
||||
if isVotronicSolarESPSensor { return "VotronicSolarESP" }
|
||||
return "Bluetooth-Gerät"
|
||||
}
|
||||
/*var subtitle: String {
|
||||
@@ -164,7 +164,7 @@ final class BluetoothManager: NSObject {
|
||||
//private(set) var bmsDiagnostics: [UUID: BMSDiagnostics] = [:]
|
||||
//private(set) var fridgeStates: [UUID: AlpicoolState] = [:]
|
||||
private(set) var levelStates: [UUID: LevelState] = [:]
|
||||
private(set) var solarStates: [UUID: SolarState] = [:]
|
||||
private(set) var votronicSolarESPStates: [UUID: VotronicSolarESPState] = [:]
|
||||
private(set) var isBluetoothReady = false
|
||||
private(set) var bluetoothStatusText = "Bluetooth wird gestartet…"
|
||||
|
||||
@@ -201,7 +201,7 @@ final class BluetoothManager: NSObject {
|
||||
|
||||
//private var bmsSessions: [UUID: BMSSession] = [:]
|
||||
private var levelSessions: [UUID: LevelSession] = [:]
|
||||
private var solarSessions: [UUID: SolarSession] = [:]
|
||||
private var votronicSolarESPSessions: [UUID: VotronicSolarESPSession] = [:]
|
||||
private var connectedPeripherals: [UUID: CBPeripheral] = [:]
|
||||
private var reconnectTimer: DispatchSourceTimer?
|
||||
|
||||
@@ -285,10 +285,10 @@ final class BluetoothManager: NSObject {
|
||||
// voraussetzen.
|
||||
linkStates[DemoData.level.id] = .live
|
||||
|
||||
solarStates[DemoData.solar.id] = DemoData.solarState
|
||||
votronicSolarESPStates[DemoData.solar.id] = DemoData.votronicSolarESPState
|
||||
linkStates[DemoData.solar.id] = .live
|
||||
record(DemoData.solarState.snapshot(deviceID: DemoData.solar.id, rssi: -58))
|
||||
history[DemoData.solar.id] = DemoData.solarHistory()
|
||||
record(DemoData.votronicSolarESPState.snapshot(deviceID: DemoData.solar.id, rssi: -58))
|
||||
history[DemoData.solar.id] = DemoData.votronicSolarESPHistory()
|
||||
/* for snapshot in DemoData.snapshots() {
|
||||
snapshots[snapshot.deviceID] = snapshot
|
||||
linkStates[snapshot.deviceID] = .live
|
||||
@@ -346,7 +346,7 @@ final class BluetoothManager: NSObject {
|
||||
//bmsDiagnostics = bmsDiagnostics.filter { known.contains($0.key) }
|
||||
//fridgeStates = fridgeStates.filter { known.contains($0.key) }
|
||||
levelStates = levelStates.filter { known.contains($0.key) }
|
||||
solarStates = solarStates.filter { known.contains($0.key) }
|
||||
votronicSolarESPStates = votronicSolarESPStates.filter { known.contains($0.key) }
|
||||
|
||||
// Geräte, die nur auf Anforderung verbunden werden, zeigen bis dahin
|
||||
// ihren zuletzt gestellten Stand.
|
||||
@@ -556,9 +556,9 @@ final class BluetoothManager: NSObject {
|
||||
levelSessions[peripheralID] = nil
|
||||
disconnect(peripheralID)
|
||||
}
|
||||
for (peripheralID, session) in solarSessions where !wanted.contains(peripheralID) {
|
||||
for (peripheralID, session) in votronicSolarESPSessions where !wanted.contains(peripheralID) {
|
||||
session.stop()
|
||||
solarSessions[peripheralID] = nil
|
||||
votronicSolarESPSessions[peripheralID] = nil
|
||||
disconnect(peripheralID)
|
||||
}
|
||||
// Einstellungen an bestehende Sitzungen weiterreichen.
|
||||
@@ -606,11 +606,11 @@ final class BluetoothManager: NSObject {
|
||||
discoveryFlushTimer?.cancel(); discoveryFlushTimer = nil
|
||||
//for (_, session) in bmsSessions { session.stop() }
|
||||
for (_, session) in levelSessions { session.stop() }
|
||||
for (_, session) in solarSessions { session.stop() }
|
||||
for (_, session) in votronicSolarESPSessions { session.stop() }
|
||||
for (_, peripheral) in connectedPeripherals { central?.cancelPeripheralConnection(peripheral) }
|
||||
//bmsSessions.removeAll()
|
||||
levelSessions.removeAll()
|
||||
solarSessions.removeAll()
|
||||
votronicSolarESPSessions.removeAll()
|
||||
connectedPeripherals.removeAll()
|
||||
connectedSince.removeAll()
|
||||
//pendingControls.removeAll()
|
||||
@@ -806,8 +806,8 @@ final class BluetoothManager: NSObject {
|
||||
if let name, !name.isEmpty { entry.name = name }
|
||||
let services = advertisementData[CBAdvertisementDataServiceUUIDsKey] as? [CBUUID] ?? []
|
||||
entry.isLevelSensor = services.contains(LevelSession.serviceUUID)
|
||||
entry.isSolarSensor = services.contains(SolarSession.serviceUUID)
|
||||
entry.looksLikeSupported = entry.isLevelSensor || entry.isSolarSensor
|
||||
entry.isVotronicSolarESPSensor = services.contains(VotronicSolarESPSession.serviceUUID)
|
||||
entry.looksLikeSupported = entry.isLevelSensor || entry.isVotronicSolarESPSensor
|
||||
pendingDiscoveries[peripheral.identifier] = entry
|
||||
}
|
||||
/*private func updateDiscovery(peripheral: CBPeripheral,
|
||||
@@ -965,7 +965,7 @@ extension BluetoothManager: CBCentralManagerDelegate {
|
||||
// Bewusst kein Draht zu `activityManager`: Der Solarertrag soll
|
||||
// nicht in der Live Activity/CarPlay auftauchen, die ist dem
|
||||
// Neigungsmesser vorbehalten.
|
||||
let session = SolarSession(
|
||||
let session = VotronicSolarESPSession(
|
||||
deviceID: device.id,
|
||||
peripheral: peripheral,
|
||||
queue: queue,
|
||||
@@ -973,11 +973,11 @@ extension BluetoothManager: CBCentralManagerDelegate {
|
||||
onStateChange: { [weak self] state in
|
||||
self?.publish { self?.linkStates[device.id] = state }
|
||||
},
|
||||
onSolarState: { [weak self] state in
|
||||
self?.publish { self?.solarStates[device.id] = state }
|
||||
onVotronicSolarESPState: { [weak self] state in
|
||||
self?.publish { self?.votronicSolarESPStates[device.id] = state }
|
||||
}
|
||||
)
|
||||
solarSessions[peripheral.identifier] = session
|
||||
votronicSolarESPSessions[peripheral.identifier] = session
|
||||
session.start()
|
||||
return
|
||||
}
|
||||
@@ -1029,8 +1029,8 @@ extension BluetoothManager: CBCentralManagerDelegate {
|
||||
//bmsSessions[peripheral.identifier] = nil
|
||||
levelSessions[peripheral.identifier]?.handleDisconnect()
|
||||
levelSessions[peripheral.identifier] = nil
|
||||
solarSessions[peripheral.identifier]?.handleDisconnect()
|
||||
solarSessions[peripheral.identifier] = nil
|
||||
votronicSolarESPSessions[peripheral.identifier]?.handleDisconnect()
|
||||
votronicSolarESPSessions[peripheral.identifier] = nil
|
||||
connectedPeripherals[peripheral.identifier] = nil
|
||||
|
||||
let lifetime = connectedSince.removeValue(forKey: peripheral.identifier)
|
||||
|
||||
@@ -81,8 +81,8 @@ enum DemoData {
|
||||
}
|
||||
|
||||
/// Mittags, gute Sonne.
|
||||
static var solarState: SolarState {
|
||||
var state = SolarState()
|
||||
static var votronicSolarESPState: VotronicSolarESPState {
|
||||
var state = VotronicSolarESPState()
|
||||
state.batteryVoltage = 13.9
|
||||
state.pvVoltage = 19.4
|
||||
state.pvCurrent = 6.2
|
||||
@@ -96,7 +96,7 @@ enum DemoData {
|
||||
|
||||
/// Ein paar Stunden Verlauf je Kanal, damit die Grafik im Demo-Modus
|
||||
/// sofort etwas zeigt statt erst nach ein paar Minuten Laufzeit.
|
||||
static func solarHistory() -> DeviceHistory {
|
||||
static func votronicSolarESPHistory() -> DeviceHistory {
|
||||
let now = Date()
|
||||
func series(around value: Double, noise: Double) -> [HistorySample] {
|
||||
(0..<120).reversed().map { step in
|
||||
|
||||
@@ -195,7 +195,7 @@ private struct ConfigureDeviceView: View {
|
||||
}
|
||||
} else*/ if discovery.isLevelSensor {
|
||||
role = .leveling
|
||||
} else if discovery.isSolarSensor {
|
||||
} else if discovery.isVotronicSolarESPSensor {
|
||||
role = .solar
|
||||
} /*else if let name = discovery.name?.lowercased(),
|
||||
["alpicool", "icecube", "ice cube", "fridge", "cool"].contains(where: name.contains) {
|
||||
@@ -208,8 +208,8 @@ private struct ConfigureDeviceView: View {
|
||||
// ohnehin darüber unter "Gefunden als".
|
||||
if discovery.isLevelSensor {
|
||||
name = "Nivellierung"
|
||||
} else if discovery.isSolarSensor {
|
||||
name = "Solarladeregler"
|
||||
} else if discovery.isVotronicSolarESPSensor {
|
||||
name = role.title
|
||||
} else if let advertised = discovery.name, advertised.count <= 20,
|
||||
advertised.contains(" ") || advertised.rangeOfCharacter(from: .decimalDigits) == nil {
|
||||
name = advertised
|
||||
|
||||
@@ -106,7 +106,7 @@ struct DashboardView: View {
|
||||
Label("Noch keine Geräte", systemImage: "antenna.radiowaves.left.and.right")
|
||||
} description: {
|
||||
Text("Füge \(store.activeProfile.map { "„\($0.name)“" } ?? "diesem Fahrzeug") "
|
||||
+ "den Ladebooster, den Solarladeregler und das BMS hinzu.")
|
||||
+ "den Ladebooster, den VotronicSolarESP und das BMS hinzu.")
|
||||
} actions: {
|
||||
Button("Gerät suchen") { isAddingDevice = true }
|
||||
.buttonStyle(.borderedProminent)
|
||||
|
||||
Reference in New Issue
Block a user