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
+2
-2
@@ -1,13 +1,13 @@
|
||||
import Foundation
|
||||
|
||||
/// Solarladeregler „VanAlign Solar" – zweiter ESP32 im Fahrzeug, liest einen
|
||||
/// VotronicSolarESP – zweiter ESP32 im Fahrzeug, liest einen
|
||||
/// Votronic-Solarladeregler aus und stellt die Werte über einen eigenen
|
||||
/// BLE-Dienst bereit. Siehe `firmware/vanalign/esp32_ble_solar.yaml`.
|
||||
///
|
||||
/// Wie beim Neigungsmesser: kein Rahmenprotokoll, jede Messgrösse liegt in
|
||||
/// einer eigenen Charakteristik, alle sind reine Lesewerte, der Client fragt
|
||||
/// sie im Takt ab.
|
||||
enum VanAlignSolarProtocol {
|
||||
enum VotronicSolarESPProtocol {
|
||||
|
||||
/// Wird vom Gerät beworben, das Gerät ist darüber auffindbar.
|
||||
static let serviceUUID = "05C9A349-2B8E-4B1D-9C9D-C247E9A6A001"
|
||||
+20
-20
@@ -6,25 +6,25 @@ import Foundation
|
||||
/// Einfacher noch als `LevelSession`: die Firmware bietet für keine
|
||||
/// Charakteristik `notify` an (siehe `esp32_ble_solar.yaml`), es wird also
|
||||
/// immer im Takt abgefragt statt abonniert.
|
||||
final class SolarSession: NSObject {
|
||||
final class VotronicSolarESPSession: NSObject {
|
||||
|
||||
static let serviceUUID = CBUUID(string: VanAlignSolarProtocol.serviceUUID)
|
||||
private static let batteryVoltageUUID = CBUUID(string: VanAlignSolarProtocol.batteryVoltageUUID)
|
||||
private static let pvVoltageUUID = CBUUID(string: VanAlignSolarProtocol.pvVoltageUUID)
|
||||
private static let pvCurrentUUID = CBUUID(string: VanAlignSolarProtocol.pvCurrentUUID)
|
||||
private static let pvPowerUUID = CBUUID(string: VanAlignSolarProtocol.pvPowerUUID)
|
||||
private static let controllerTempUUID = CBUUID(string: VanAlignSolarProtocol.controllerTempUUID)
|
||||
private static let statusFlagsUUID = CBUUID(string: VanAlignSolarProtocol.statusFlagsUUID)
|
||||
static let serviceUUID = CBUUID(string: VotronicSolarESPProtocol.serviceUUID)
|
||||
private static let batteryVoltageUUID = CBUUID(string: VotronicSolarESPProtocol.batteryVoltageUUID)
|
||||
private static let pvVoltageUUID = CBUUID(string: VotronicSolarESPProtocol.pvVoltageUUID)
|
||||
private static let pvCurrentUUID = CBUUID(string: VotronicSolarESPProtocol.pvCurrentUUID)
|
||||
private static let pvPowerUUID = CBUUID(string: VotronicSolarESPProtocol.pvPowerUUID)
|
||||
private static let controllerTempUUID = CBUUID(string: VotronicSolarESPProtocol.controllerTempUUID)
|
||||
private static let statusFlagsUUID = CBUUID(string: VotronicSolarESPProtocol.statusFlagsUUID)
|
||||
|
||||
let deviceID: UUID
|
||||
private let queue: DispatchQueue
|
||||
private let peripheral: CBPeripheral
|
||||
private let onUpdate: (DeviceSnapshot) -> Void
|
||||
private let onStateChange: (DeviceLinkState) -> Void
|
||||
private let onSolarState: (SolarState) -> Void
|
||||
private let onVotronicSolarESPState: (VotronicSolarESPState) -> Void
|
||||
|
||||
private var characteristics: [CBUUID: CBCharacteristic] = [:]
|
||||
private var state = SolarState()
|
||||
private var state = VotronicSolarESPState()
|
||||
private var pollTimer: DispatchSourceTimer?
|
||||
|
||||
/// Reicht für einen Solarregler, dessen Werte sich über Sekunden ändern –
|
||||
@@ -36,13 +36,13 @@ final class SolarSession: NSObject {
|
||||
queue: DispatchQueue,
|
||||
onUpdate: @escaping (DeviceSnapshot) -> Void,
|
||||
onStateChange: @escaping (DeviceLinkState) -> Void,
|
||||
onSolarState: @escaping (SolarState) -> Void) {
|
||||
onVotronicSolarESPState: @escaping (VotronicSolarESPState) -> Void) {
|
||||
self.deviceID = deviceID
|
||||
self.queue = queue
|
||||
self.peripheral = peripheral
|
||||
self.onUpdate = onUpdate
|
||||
self.onStateChange = onStateChange
|
||||
self.onSolarState = onSolarState
|
||||
self.onVotronicSolarESPState = onVotronicSolarESPState
|
||||
super.init()
|
||||
peripheral.delegate = self
|
||||
}
|
||||
@@ -87,14 +87,14 @@ final class SolarSession: NSObject {
|
||||
private func publish() {
|
||||
guard state.hasReading else { return }
|
||||
onStateChange(.live)
|
||||
onSolarState(state)
|
||||
onVotronicSolarESPState(state)
|
||||
onUpdate(state.snapshot(deviceID: deviceID, rssi: nil))
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - CBPeripheralDelegate
|
||||
|
||||
extension SolarSession: CBPeripheralDelegate {
|
||||
extension VotronicSolarESPSession: CBPeripheralDelegate {
|
||||
|
||||
func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?) {
|
||||
if let error {
|
||||
@@ -137,17 +137,17 @@ extension SolarSession: CBPeripheralDelegate {
|
||||
|
||||
switch characteristic.uuid {
|
||||
case Self.batteryVoltageUUID:
|
||||
state.batteryVoltage = VanAlignSolarProtocol.float(from: value)
|
||||
state.batteryVoltage = VotronicSolarESPProtocol.float(from: value)
|
||||
case Self.pvVoltageUUID:
|
||||
state.pvVoltage = VanAlignSolarProtocol.float(from: value)
|
||||
state.pvVoltage = VotronicSolarESPProtocol.float(from: value)
|
||||
case Self.pvCurrentUUID:
|
||||
state.pvCurrent = VanAlignSolarProtocol.float(from: value)
|
||||
state.pvCurrent = VotronicSolarESPProtocol.float(from: value)
|
||||
case Self.pvPowerUUID:
|
||||
state.pvPower = VanAlignSolarProtocol.float(from: value)
|
||||
state.pvPower = VotronicSolarESPProtocol.float(from: value)
|
||||
case Self.controllerTempUUID:
|
||||
state.controllerTemperature = VanAlignSolarProtocol.float(from: value)
|
||||
state.controllerTemperature = VotronicSolarESPProtocol.float(from: value)
|
||||
case Self.statusFlagsUUID:
|
||||
guard let flags = VanAlignSolarProtocol.statusFlags(from: value) else { return }
|
||||
guard let flags = VotronicSolarESPProtocol.statusFlags(from: value) else { return }
|
||||
state.isBatteryCharging = flags.isBatteryCharging
|
||||
state.isBatteryDischarging = flags.isBatteryDischarging
|
||||
state.isControllerActive = flags.isControllerActive
|
||||
@@ -19,7 +19,7 @@ enum DeviceRole: String, Codable, CaseIterable, Identifiable, Sendable {
|
||||
//case .bms: return "Batterie / BMS"
|
||||
//case .fridge: return "Kühlbox"
|
||||
case .leveling: return "Nivellierung"
|
||||
case .solar: return "Solarladeregler"
|
||||
case .solar: return "VotronicSolarESP"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import Foundation
|
||||
|
||||
/// Zustand des Solarladereglers.
|
||||
struct SolarState: Equatable, Codable, Sendable {
|
||||
struct VotronicSolarESPState: Equatable, Codable, Sendable {
|
||||
var batteryVoltage: Double?
|
||||
var pvVoltage: Double?
|
||||
var pvCurrent: Double?
|
||||
Reference in New Issue
Block a user