- Show stable group health in a fixed 2x2 metric grid - Add link-chain state to fleet cards and parse hardware/control/SIM/cellular - Replace the wrapped icon with a full-bleed app icon - Bump the IPA build number
119 lines
4.1 KiB
Swift
119 lines
4.1 KiB
Swift
import Foundation
|
|
|
|
public struct DeviceSection: Equatable, Identifiable, Sendable {
|
|
public let id: String
|
|
public let title: String
|
|
public let values: [String: String]
|
|
}
|
|
|
|
public struct DeviceSnapshot: Equatable, Sendable {
|
|
public let sections: [DeviceSection]
|
|
}
|
|
|
|
public struct DeviceLinkState: Equatable, Sendable {
|
|
public init(
|
|
hardwareOnline: Bool? = nil,
|
|
controlOnline: Bool? = nil,
|
|
simPresent: Bool? = nil,
|
|
cellularOnline: Bool? = nil
|
|
) {
|
|
self.hardwareOnline = hardwareOnline
|
|
self.controlOnline = controlOnline
|
|
self.simPresent = simPresent
|
|
self.cellularOnline = cellularOnline
|
|
}
|
|
|
|
public var hardwareOnline: Bool?
|
|
public var controlOnline: Bool?
|
|
public var simPresent: Bool?
|
|
public var cellularOnline: Bool?
|
|
}
|
|
|
|
extension DeviceService {
|
|
static var placeholderSections: [DeviceSection] {
|
|
[
|
|
DeviceSection(id: "device", title: "设备", values: [:]),
|
|
DeviceSection(id: "sim", title: "SIM", values: [:]),
|
|
DeviceSection(id: "network", title: "蜂窝网络", values: [:]),
|
|
DeviceSection(id: "stats", title: "系统资源", values: [:]),
|
|
DeviceSection(id: "cpu", title: "CPU", values: [:]),
|
|
DeviceSection(id: "connectivity", title: "连接状态", values: [:])
|
|
]
|
|
}
|
|
}
|
|
|
|
public struct DeviceSummary: Equatable, Sendable {
|
|
public init(
|
|
deviceName: String? = nil,
|
|
phoneNumber: String? = nil,
|
|
operatorName: String? = nil,
|
|
networkTechnology: String? = nil,
|
|
signalPercent: Int? = nil,
|
|
cpuPercent: Double? = nil,
|
|
memoryPercent: Double? = nil,
|
|
cpuCount: Int? = nil,
|
|
temperatureCelsius: Double? = nil,
|
|
batteryPercent: Double? = nil,
|
|
ipAddress: String? = nil,
|
|
latencyMilliseconds: Int? = nil,
|
|
connectivity: String? = nil,
|
|
firmwareVersion: String? = nil,
|
|
totalStorageBytes: Int64? = nil,
|
|
availableStorageBytes: Int64? = nil,
|
|
downloadRateBytesPerSecond: Double? = nil,
|
|
uploadRateBytesPerSecond: Double? = nil,
|
|
messagesToday: Int? = nil,
|
|
uptimeSeconds: Double? = nil,
|
|
linkState: DeviceLinkState = DeviceLinkState()
|
|
) {
|
|
self.deviceName = deviceName
|
|
self.phoneNumber = phoneNumber
|
|
self.operatorName = operatorName
|
|
self.networkTechnology = networkTechnology
|
|
self.signalPercent = signalPercent
|
|
self.cpuPercent = cpuPercent
|
|
self.memoryPercent = memoryPercent
|
|
self.cpuCount = cpuCount
|
|
self.temperatureCelsius = temperatureCelsius
|
|
self.batteryPercent = batteryPercent
|
|
self.ipAddress = ipAddress
|
|
self.latencyMilliseconds = latencyMilliseconds
|
|
self.connectivity = connectivity
|
|
self.firmwareVersion = firmwareVersion
|
|
self.totalStorageBytes = totalStorageBytes
|
|
self.availableStorageBytes = availableStorageBytes
|
|
self.downloadRateBytesPerSecond = downloadRateBytesPerSecond
|
|
self.uploadRateBytesPerSecond = uploadRateBytesPerSecond
|
|
self.messagesToday = messagesToday
|
|
self.uptimeSeconds = uptimeSeconds
|
|
self.linkState = linkState
|
|
}
|
|
|
|
public var deviceName: String?
|
|
public var phoneNumber: String?
|
|
public var operatorName: String?
|
|
public var networkTechnology: String?
|
|
public var signalPercent: Int?
|
|
public var cpuPercent: Double?
|
|
public var memoryPercent: Double?
|
|
public var cpuCount: Int?
|
|
public var temperatureCelsius: Double?
|
|
public var batteryPercent: Double?
|
|
public var ipAddress: String?
|
|
public var latencyMilliseconds: Int?
|
|
public var connectivity: String?
|
|
public var firmwareVersion: String?
|
|
public var totalStorageBytes: Int64?
|
|
public var availableStorageBytes: Int64?
|
|
public var downloadRateBytesPerSecond: Double?
|
|
public var uploadRateBytesPerSecond: Double?
|
|
public var messagesToday: Int?
|
|
public var uptimeSeconds: Double?
|
|
public var linkState: DeviceLinkState
|
|
}
|
|
|
|
public enum DeviceServiceError: Error, Equatable {
|
|
case unauthorized
|
|
case invalidResponse
|
|
}
|