Files
SensorReader/EnvSensorReader/SensorReading.swift
2025-11-27 17:42:54 +09:00

29 lines
688 B
Swift

import Foundation
struct SensorReading: Identifiable, Equatable {
let id = UUID()
let timestamp: Date
let deviceAddress: String
let nonce: UInt16
let temperature: Double
let humidity: Double
let pressure: Double
let voltage: Double
let current: Double
let rssi: Int
var power: Double {
voltage * current
}
var timestampString: String {
let formatter = DateFormatter()
formatter.dateFormat = "HH:mm:ss"
return formatter.string(from: timestamp)
}
static func == (lhs: SensorReading, rhs: SensorReading) -> Bool {
lhs.deviceAddress == rhs.deviceAddress && lhs.nonce == rhs.nonce
}
}