From a274d6fcf8f03e6ef0ebb6d31dd24d0c3bfd4ed6 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Thu, 8 Aug 2024 10:39:45 -0700 Subject: [PATCH] Update protos --- Meshtastic/Helpers/BLEManager.swift | 2 +- .../contents | 2 +- Meshtastic/Persistence/UpdateCoreData.swift | 4 +- .../Settings/Config/SecurityConfig.swift | 6 +- .../Sources/meshtastic/admin.pb.swift | 54 +- .../Sources/meshtastic/config.pb.swift | 40 +- .../Sources/meshtastic/mesh.pb.swift | 277 +++++-- .../Sources/meshtastic/telemetry.pb.swift | 717 ++++++++++++------ protobufs | 2 +- 9 files changed, 799 insertions(+), 305 deletions(-) diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index 13941ec9..ec03b2f8 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -1388,7 +1388,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate public func sendFactoryReset(fromUser: UserEntity, toUser: UserEntity) -> Bool { var adminPacket = AdminMessage() - adminPacket.factoryReset = 5 + adminPacket.factoryResetConfig = 5 var meshPacket: MeshPacket = MeshPacket() meshPacket.to = UInt32(toUser.num) meshPacket.from = UInt32(fromUser.num) diff --git a/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 42.xcdatamodel/contents b/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 42.xcdatamodel/contents index a04f71ea..432be802 100644 --- a/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 42.xcdatamodel/contents +++ b/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModelV 42.xcdatamodel/contents @@ -341,7 +341,7 @@ - + diff --git a/Meshtastic/Persistence/UpdateCoreData.swift b/Meshtastic/Persistence/UpdateCoreData.swift index 843554b2..304c6a77 100644 --- a/Meshtastic/Persistence/UpdateCoreData.swift +++ b/Meshtastic/Persistence/UpdateCoreData.swift @@ -785,7 +785,7 @@ func upsertSecurityConfigPacket(config: Config.SecurityConfig, nodeNum: Int64, c newSecurityConfig.adminKey = config.adminKey newSecurityConfig.isManaged = config.isManaged newSecurityConfig.serialEnabled = config.serialEnabled - newSecurityConfig.debugLogEnabled = config.debugLogEnabled + newSecurityConfig.debugLogApiEnabled = config.debugLogApiEnabled newSecurityConfig.bluetoothLoggingEnabled = config.bluetoothLoggingEnabled } else { fetchedNode[0].securityConfig?.publicKey = config.publicKey @@ -793,7 +793,7 @@ func upsertSecurityConfigPacket(config: Config.SecurityConfig, nodeNum: Int64, c fetchedNode[0].securityConfig?.adminKey = config.adminKey fetchedNode[0].securityConfig?.isManaged = config.isManaged fetchedNode[0].securityConfig?.serialEnabled = config.serialEnabled - fetchedNode[0].securityConfig?.debugLogEnabled = config.debugLogEnabled + fetchedNode[0].securityConfig?.debugLogApiEnabled = config.debugLogApiEnabled fetchedNode[0].securityConfig?.bluetoothLoggingEnabled = config.bluetoothLoggingEnabled } diff --git a/Meshtastic/Views/Settings/Config/SecurityConfig.swift b/Meshtastic/Views/Settings/Config/SecurityConfig.swift index 47e56b18..4c8bd85a 100644 --- a/Meshtastic/Views/Settings/Config/SecurityConfig.swift +++ b/Meshtastic/Views/Settings/Config/SecurityConfig.swift @@ -25,7 +25,7 @@ struct SecurityConfig: View { @State var adminKey = "" @State var isManaged = false @State var serialEnabled = false - @State var debugLogEnabled = false + @State var debugLogApiEnabled = false @State var bluetoothLoggingEnabled = false @State var adminChannelEnabled = false @@ -132,7 +132,7 @@ struct SecurityConfig: View { } .toggleStyle(SwitchToggleStyle(tint: .accentColor)) if serialEnabled { - Toggle(isOn: $debugLogEnabled) { + Toggle(isOn: $debugLogApiEnabled) { Label("Serial Debug Logs", systemImage: "ant.fill") Text("Output live debug logging over serial.") } @@ -153,7 +153,7 @@ struct SecurityConfig: View { self.adminKey = node?.securityConfig?.adminKey?.base64EncodedString() ?? "" self.isManaged = node?.securityConfig?.isManaged ?? false self.serialEnabled = node?.securityConfig?.serialEnabled ?? false - self.debugLogEnabled = node?.securityConfig?.debugLogEnabled ?? false + self.debugLogApiEnabled = node?.securityConfig?.debugLogApiEnabled ?? false self.bluetoothLoggingEnabled = node?.securityConfig?.bluetoothLoggingEnabled ?? false self.adminChannelEnabled = node?.securityConfig?.adminChannelEnabled ?? false self.hasChanges = false diff --git a/MeshtasticProtobufs/Sources/meshtastic/admin.pb.swift b/MeshtasticProtobufs/Sources/meshtastic/admin.pb.swift index ba263709..f526f4ca 100644 --- a/MeshtasticProtobufs/Sources/meshtastic/admin.pb.swift +++ b/MeshtasticProtobufs/Sources/meshtastic/admin.pb.swift @@ -390,6 +390,16 @@ public struct AdminMessage { set {payloadVariant = .commitEditSettings(newValue)} } + /// + /// Tell the node to factory reset config everything; all device state and configuration will be returned to factory defaults and BLE bonds will be cleared. + public var factoryResetDevice: Int32 { + get { + if case .factoryResetDevice(let v)? = payloadVariant {return v} + return 0 + } + set {payloadVariant = .factoryResetDevice(newValue)} + } + /// /// Tell the node to reboot into the OTA Firmware in this many seconds (or <0 to cancel reboot) /// Only Implemented for ESP32 Devices. This needs to be issued to send a new main firmware via bluetooth. @@ -433,13 +443,13 @@ public struct AdminMessage { } /// - /// Tell the node to factory reset, all device settings will be returned to factory defaults. - public var factoryReset: Int32 { + /// Tell the node to factory reset config; all device state and configuration will be returned to factory defaults; BLE bonds will be preserved. + public var factoryResetConfig: Int32 { get { - if case .factoryReset(let v)? = payloadVariant {return v} + if case .factoryResetConfig(let v)? = payloadVariant {return v} return 0 } - set {payloadVariant = .factoryReset(newValue)} + set {payloadVariant = .factoryResetConfig(newValue)} } /// @@ -570,6 +580,9 @@ public struct AdminMessage { /// Commits an open transaction for any edits made to config, module config, owner, and channel settings case commitEditSettings(Bool) /// + /// Tell the node to factory reset config everything; all device state and configuration will be returned to factory defaults and BLE bonds will be cleared. + case factoryResetDevice(Int32) + /// /// Tell the node to reboot into the OTA Firmware in this many seconds (or <0 to cancel reboot) /// Only Implemented for ESP32 Devices. This needs to be issued to send a new main firmware via bluetooth. case rebootOtaSeconds(Int32) @@ -584,8 +597,8 @@ public struct AdminMessage { /// Tell the node to shutdown in this many seconds (or <0 to cancel shutdown) case shutdownSeconds(Int32) /// - /// Tell the node to factory reset, all device settings will be returned to factory defaults. - case factoryReset(Int32) + /// Tell the node to factory reset config; all device state and configuration will be returned to factory defaults; BLE bonds will be preserved. + case factoryResetConfig(Int32) /// /// Tell the node to reset the nodedb. case nodedbReset(Int32) @@ -736,6 +749,10 @@ public struct AdminMessage { guard case .commitEditSettings(let l) = lhs, case .commitEditSettings(let r) = rhs else { preconditionFailure() } return l == r }() + case (.factoryResetDevice, .factoryResetDevice): return { + guard case .factoryResetDevice(let l) = lhs, case .factoryResetDevice(let r) = rhs else { preconditionFailure() } + return l == r + }() case (.rebootOtaSeconds, .rebootOtaSeconds): return { guard case .rebootOtaSeconds(let l) = lhs, case .rebootOtaSeconds(let r) = rhs else { preconditionFailure() } return l == r @@ -752,8 +769,8 @@ public struct AdminMessage { guard case .shutdownSeconds(let l) = lhs, case .shutdownSeconds(let r) = rhs else { preconditionFailure() } return l == r }() - case (.factoryReset, .factoryReset): return { - guard case .factoryReset(let l) = lhs, case .factoryReset(let r) = rhs else { preconditionFailure() } + case (.factoryResetConfig, .factoryResetConfig): return { + guard case .factoryResetConfig(let l) = lhs, case .factoryResetConfig(let r) = rhs else { preconditionFailure() } return l == r }() case (.nodedbReset, .nodedbReset): return { @@ -1070,11 +1087,12 @@ extension AdminMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat 42: .standard(proto: "remove_fixed_position"), 64: .standard(proto: "begin_edit_settings"), 65: .standard(proto: "commit_edit_settings"), + 94: .standard(proto: "factory_reset_device"), 95: .standard(proto: "reboot_ota_seconds"), 96: .standard(proto: "exit_simulator"), 97: .standard(proto: "reboot_seconds"), 98: .standard(proto: "shutdown_seconds"), - 99: .standard(proto: "factory_reset"), + 99: .standard(proto: "factory_reset_config"), 100: .standard(proto: "nodedb_reset"), ] @@ -1429,6 +1447,14 @@ extension AdminMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat self.payloadVariant = .commitEditSettings(v) } }() + case 94: try { + var v: Int32? + try decoder.decodeSingularInt32Field(value: &v) + if let v = v { + if self.payloadVariant != nil {try decoder.handleConflictingOneOf()} + self.payloadVariant = .factoryResetDevice(v) + } + }() case 95: try { var v: Int32? try decoder.decodeSingularInt32Field(value: &v) @@ -1466,7 +1492,7 @@ extension AdminMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat try decoder.decodeSingularInt32Field(value: &v) if let v = v { if self.payloadVariant != nil {try decoder.handleConflictingOneOf()} - self.payloadVariant = .factoryReset(v) + self.payloadVariant = .factoryResetConfig(v) } }() case 100: try { @@ -1628,6 +1654,10 @@ extension AdminMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat guard case .commitEditSettings(let v)? = self.payloadVariant else { preconditionFailure() } try visitor.visitSingularBoolField(value: v, fieldNumber: 65) }() + case .factoryResetDevice?: try { + guard case .factoryResetDevice(let v)? = self.payloadVariant else { preconditionFailure() } + try visitor.visitSingularInt32Field(value: v, fieldNumber: 94) + }() case .rebootOtaSeconds?: try { guard case .rebootOtaSeconds(let v)? = self.payloadVariant else { preconditionFailure() } try visitor.visitSingularInt32Field(value: v, fieldNumber: 95) @@ -1644,8 +1674,8 @@ extension AdminMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat guard case .shutdownSeconds(let v)? = self.payloadVariant else { preconditionFailure() } try visitor.visitSingularInt32Field(value: v, fieldNumber: 98) }() - case .factoryReset?: try { - guard case .factoryReset(let v)? = self.payloadVariant else { preconditionFailure() } + case .factoryResetConfig?: try { + guard case .factoryResetConfig(let v)? = self.payloadVariant else { preconditionFailure() } try visitor.visitSingularInt32Field(value: v, fieldNumber: 99) }() case .nodedbReset?: try { diff --git a/MeshtasticProtobufs/Sources/meshtastic/config.pb.swift b/MeshtasticProtobufs/Sources/meshtastic/config.pb.swift index 01e74689..4b953470 100644 --- a/MeshtasticProtobufs/Sources/meshtastic/config.pb.swift +++ b/MeshtasticProtobufs/Sources/meshtastic/config.pb.swift @@ -1404,6 +1404,7 @@ public struct Config { /// /// Very Long Range - Slow + /// Deprecated in 2.5: Works only with txco and is unusably slow case veryLongSlow // = 2 /// @@ -1425,6 +1426,12 @@ public struct Config { /// /// Long Range - Moderately Fast case longModerate // = 7 + + /// + /// Short Range - Turbo + /// This is the fastest preset and the only one with 500kHz bandwidth. + /// It is not legal to use in all regions due to this wider bandwidth. + case shortTurbo // = 8 case UNRECOGNIZED(Int) public init() { @@ -1441,6 +1448,7 @@ public struct Config { case 5: self = .shortSlow case 6: self = .shortFast case 7: self = .longModerate + case 8: self = .shortTurbo default: self = .UNRECOGNIZED(rawValue) } } @@ -1455,6 +1463,7 @@ public struct Config { case .shortSlow: return 5 case .shortFast: return 6 case .longModerate: return 7 + case .shortTurbo: return 8 case .UNRECOGNIZED(let i): return i } } @@ -1540,39 +1549,38 @@ public struct Config { /// /// The public key of the user's device. - /// This is sent out to other nodes on the mesh to allow them to compute a shared secret key. + /// Sent out to other nodes on the mesh to allow them to compute a shared secret key. public var publicKey: Data = Data() /// /// The private key of the device. - /// This is used to create a shared key with a remote device. + /// Used to create a shared key with a remote device. public var privateKey: Data = Data() /// - /// This is the public key authorized to send admin messages to this node + /// The public key authorized to send admin messages to this node. public var adminKey: Data = Data() /// - /// If true, device is considered to be "managed" by a mesh administrator - /// Clients should then limit available configuration and administrative options inside the user interface + /// If true, device is considered to be "managed" by a mesh administrator via admin messages + /// Device is managed by a mesh administrator. public var isManaged: Bool = false /// - /// Disabling this will disable the SerialConsole by not initilizing the StreamAPI + /// Serial Console over the Stream API." public var serialEnabled: Bool = false /// /// By default we turn off logging as soon as an API client connects (to keep shared serial link quiet). - /// Set this to true to leave the debug log outputting even when API is active. - public var debugLogEnabled: Bool = false + /// Output live debug logging over serial. + public var debugLogApiEnabled: Bool = false /// /// Enables device (serial style logs) over Bluetooth - /// Moved to SecurityConfig public var bluetoothLoggingEnabled: Bool = false /// - /// Enables incoming admin control over the "admin" channel + /// Allow incoming device control over the insecure legacy admin channel. public var adminChannelEnabled: Bool = false public var unknownFields = SwiftProtobuf.UnknownStorage() @@ -1736,6 +1744,7 @@ extension Config.LoRaConfig.ModemPreset: CaseIterable { .shortSlow, .shortFast, .longModerate, + .shortTurbo, ] } @@ -2800,6 +2809,7 @@ extension Config.LoRaConfig.ModemPreset: SwiftProtobuf._ProtoNameProviding { 5: .same(proto: "SHORT_SLOW"), 6: .same(proto: "SHORT_FAST"), 7: .same(proto: "LONG_MODERATE"), + 8: .same(proto: "SHORT_TURBO"), ] } @@ -2869,7 +2879,7 @@ extension Config.SecurityConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageIm 3: .standard(proto: "admin_key"), 4: .standard(proto: "is_managed"), 5: .standard(proto: "serial_enabled"), - 6: .standard(proto: "debug_log_enabled"), + 6: .standard(proto: "debug_log_api_enabled"), 7: .standard(proto: "bluetooth_logging_enabled"), 8: .standard(proto: "admin_channel_enabled"), ] @@ -2885,7 +2895,7 @@ extension Config.SecurityConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageIm case 3: try { try decoder.decodeSingularBytesField(value: &self.adminKey) }() case 4: try { try decoder.decodeSingularBoolField(value: &self.isManaged) }() case 5: try { try decoder.decodeSingularBoolField(value: &self.serialEnabled) }() - case 6: try { try decoder.decodeSingularBoolField(value: &self.debugLogEnabled) }() + case 6: try { try decoder.decodeSingularBoolField(value: &self.debugLogApiEnabled) }() case 7: try { try decoder.decodeSingularBoolField(value: &self.bluetoothLoggingEnabled) }() case 8: try { try decoder.decodeSingularBoolField(value: &self.adminChannelEnabled) }() default: break @@ -2909,8 +2919,8 @@ extension Config.SecurityConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageIm if self.serialEnabled != false { try visitor.visitSingularBoolField(value: self.serialEnabled, fieldNumber: 5) } - if self.debugLogEnabled != false { - try visitor.visitSingularBoolField(value: self.debugLogEnabled, fieldNumber: 6) + if self.debugLogApiEnabled != false { + try visitor.visitSingularBoolField(value: self.debugLogApiEnabled, fieldNumber: 6) } if self.bluetoothLoggingEnabled != false { try visitor.visitSingularBoolField(value: self.bluetoothLoggingEnabled, fieldNumber: 7) @@ -2927,7 +2937,7 @@ extension Config.SecurityConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageIm if lhs.adminKey != rhs.adminKey {return false} if lhs.isManaged != rhs.isManaged {return false} if lhs.serialEnabled != rhs.serialEnabled {return false} - if lhs.debugLogEnabled != rhs.debugLogEnabled {return false} + if lhs.debugLogApiEnabled != rhs.debugLogApiEnabled {return false} if lhs.bluetoothLoggingEnabled != rhs.bluetoothLoggingEnabled {return false} if lhs.adminChannelEnabled != rhs.adminChannelEnabled {return false} if lhs.unknownFields != rhs.unknownFields {return false} diff --git a/MeshtasticProtobufs/Sources/meshtastic/mesh.pb.swift b/MeshtasticProtobufs/Sources/meshtastic/mesh.pb.swift index f0a7c55c..489cd8e3 100644 --- a/MeshtasticProtobufs/Sources/meshtastic/mesh.pb.swift +++ b/MeshtasticProtobufs/Sources/meshtastic/mesh.pb.swift @@ -782,23 +782,35 @@ public struct Position { /// The new preferred location encoding, multiply by 1e-7 to get degrees /// in floating point public var latitudeI: Int32 { - get {return _storage._latitudeI} + get {return _storage._latitudeI ?? 0} set {_uniqueStorage()._latitudeI = newValue} } + /// Returns true if `latitudeI` has been explicitly set. + public var hasLatitudeI: Bool {return _storage._latitudeI != nil} + /// Clears the value of `latitudeI`. Subsequent reads from it will return its default value. + public mutating func clearLatitudeI() {_uniqueStorage()._latitudeI = nil} /// /// TODO: REPLACE public var longitudeI: Int32 { - get {return _storage._longitudeI} + get {return _storage._longitudeI ?? 0} set {_uniqueStorage()._longitudeI = newValue} } + /// Returns true if `longitudeI` has been explicitly set. + public var hasLongitudeI: Bool {return _storage._longitudeI != nil} + /// Clears the value of `longitudeI`. Subsequent reads from it will return its default value. + public mutating func clearLongitudeI() {_uniqueStorage()._longitudeI = nil} /// /// In meters above MSL (but see issue #359) public var altitude: Int32 { - get {return _storage._altitude} + get {return _storage._altitude ?? 0} set {_uniqueStorage()._altitude = newValue} } + /// Returns true if `altitude` has been explicitly set. + public var hasAltitude: Bool {return _storage._altitude != nil} + /// Clears the value of `altitude`. Subsequent reads from it will return its default value. + public mutating func clearAltitude() {_uniqueStorage()._altitude = nil} /// /// This is usually not sent over the mesh (to save space), but it is sent @@ -841,16 +853,24 @@ public struct Position { /// /// HAE altitude in meters - can be used instead of MSL altitude public var altitudeHae: Int32 { - get {return _storage._altitudeHae} + get {return _storage._altitudeHae ?? 0} set {_uniqueStorage()._altitudeHae = newValue} } + /// Returns true if `altitudeHae` has been explicitly set. + public var hasAltitudeHae: Bool {return _storage._altitudeHae != nil} + /// Clears the value of `altitudeHae`. Subsequent reads from it will return its default value. + public mutating func clearAltitudeHae() {_uniqueStorage()._altitudeHae = nil} /// /// Geoidal separation in meters public var altitudeGeoidalSeparation: Int32 { - get {return _storage._altitudeGeoidalSeparation} + get {return _storage._altitudeGeoidalSeparation ?? 0} set {_uniqueStorage()._altitudeGeoidalSeparation = newValue} } + /// Returns true if `altitudeGeoidalSeparation` has been explicitly set. + public var hasAltitudeGeoidalSeparation: Bool {return _storage._altitudeGeoidalSeparation != nil} + /// Clears the value of `altitudeGeoidalSeparation`. Subsequent reads from it will return its default value. + public mutating func clearAltitudeGeoidalSeparation() {_uniqueStorage()._altitudeGeoidalSeparation = nil} /// /// Horizontal, Vertical and Position Dilution of Precision, in 1/100 units @@ -894,16 +914,24 @@ public struct Position { /// - "yaw" indicates a relative rotation about the vertical axis /// TODO: REMOVE/INTEGRATE public var groundSpeed: UInt32 { - get {return _storage._groundSpeed} + get {return _storage._groundSpeed ?? 0} set {_uniqueStorage()._groundSpeed = newValue} } + /// Returns true if `groundSpeed` has been explicitly set. + public var hasGroundSpeed: Bool {return _storage._groundSpeed != nil} + /// Clears the value of `groundSpeed`. Subsequent reads from it will return its default value. + public mutating func clearGroundSpeed() {_uniqueStorage()._groundSpeed = nil} /// /// TODO: REPLACE public var groundTrack: UInt32 { - get {return _storage._groundTrack} + get {return _storage._groundTrack ?? 0} set {_uniqueStorage()._groundTrack = newValue} } + /// Returns true if `groundTrack` has been explicitly set. + public var hasGroundTrack: Bool {return _storage._groundTrack != nil} + /// Clears the value of `groundTrack`. Subsequent reads from it will return its default value. + public mutating func clearGroundTrack() {_uniqueStorage()._groundTrack = nil} /// /// GPS fix quality (from NMEA GxGGA statement or similar) @@ -1455,11 +1483,25 @@ public struct Waypoint { /// /// latitude_i - public var latitudeI: Int32 = 0 + public var latitudeI: Int32 { + get {return _latitudeI ?? 0} + set {_latitudeI = newValue} + } + /// Returns true if `latitudeI` has been explicitly set. + public var hasLatitudeI: Bool {return self._latitudeI != nil} + /// Clears the value of `latitudeI`. Subsequent reads from it will return its default value. + public mutating func clearLatitudeI() {self._latitudeI = nil} /// /// longitude_i - public var longitudeI: Int32 = 0 + public var longitudeI: Int32 { + get {return _longitudeI ?? 0} + set {_longitudeI = newValue} + } + /// Returns true if `longitudeI` has been explicitly set. + public var hasLongitudeI: Bool {return self._longitudeI != nil} + /// Clears the value of `longitudeI`. Subsequent reads from it will return its default value. + public mutating func clearLongitudeI() {self._longitudeI = nil} /// /// Time the waypoint is to expire (epoch) @@ -1485,6 +1527,9 @@ public struct Waypoint { public var unknownFields = SwiftProtobuf.UnknownStorage() public init() {} + + fileprivate var _latitudeI: Int32? = nil + fileprivate var _longitudeI: Int32? = nil } /// @@ -2369,6 +2414,16 @@ public struct FromRadio { set {payloadVariant = .fileInfo(newValue)} } + /// + /// Notification message to the client + public var clientNotification: ClientNotification { + get { + if case .clientNotification(let v)? = payloadVariant {return v} + return ClientNotification() + } + set {payloadVariant = .clientNotification(newValue)} + } + public var unknownFields = SwiftProtobuf.UnknownStorage() /// @@ -2424,6 +2479,9 @@ public struct FromRadio { /// /// File system manifest messages case fileInfo(FileInfo) + /// + /// Notification message to the client + case clientNotification(ClientNotification) #if !swift(>=4.1) public static func ==(lhs: FromRadio.OneOf_PayloadVariant, rhs: FromRadio.OneOf_PayloadVariant) -> Bool { @@ -2487,6 +2545,10 @@ public struct FromRadio { guard case .fileInfo(let l) = lhs, case .fileInfo(let r) = rhs else { preconditionFailure() } return l == r }() + case (.clientNotification, .clientNotification): return { + guard case .clientNotification(let l) = lhs, case .clientNotification(let r) = rhs else { preconditionFailure() } + return l == r + }() default: return false } } @@ -2496,6 +2558,46 @@ public struct FromRadio { public init() {} } +/// +/// A notification message from the device to the client +/// To be used for important messages that should to be displayed to the user +/// in the form of push notifications or validation messages when saving +/// invalid configuration. +public struct ClientNotification { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + /// + /// The id of the packet we're notifying in response to + public var replyID: UInt32 { + get {return _replyID ?? 0} + set {_replyID = newValue} + } + /// Returns true if `replyID` has been explicitly set. + public var hasReplyID: Bool {return self._replyID != nil} + /// Clears the value of `replyID`. Subsequent reads from it will return its default value. + public mutating func clearReplyID() {self._replyID = nil} + + /// + /// Seconds since 1970 - or 0 for unknown/unset + public var time: UInt32 = 0 + + /// + /// The level type of notification + public var level: LogRecord.Level = .unset + + /// + /// The message body of the notification + public var message: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + + fileprivate var _replyID: UInt32? = nil +} + /// /// Individual File info for the device public struct FileInfo { @@ -2987,6 +3089,7 @@ extension LogRecord.Level: @unchecked Sendable {} extension QueueStatus: @unchecked Sendable {} extension FromRadio: @unchecked Sendable {} extension FromRadio.OneOf_PayloadVariant: @unchecked Sendable {} +extension ClientNotification: @unchecked Sendable {} extension FileInfo: @unchecked Sendable {} extension ToRadio: @unchecked Sendable {} extension ToRadio.OneOf_PayloadVariant: @unchecked Sendable {} @@ -3138,22 +3241,22 @@ extension Position: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationB ] fileprivate class _StorageClass { - var _latitudeI: Int32 = 0 - var _longitudeI: Int32 = 0 - var _altitude: Int32 = 0 + var _latitudeI: Int32? = nil + var _longitudeI: Int32? = nil + var _altitude: Int32? = nil var _time: UInt32 = 0 var _locationSource: Position.LocSource = .locUnset var _altitudeSource: Position.AltSource = .altUnset var _timestamp: UInt32 = 0 var _timestampMillisAdjust: Int32 = 0 - var _altitudeHae: Int32 = 0 - var _altitudeGeoidalSeparation: Int32 = 0 + var _altitudeHae: Int32? = nil + var _altitudeGeoidalSeparation: Int32? = nil var _pdop: UInt32 = 0 var _hdop: UInt32 = 0 var _vdop: UInt32 = 0 var _gpsAccuracy: UInt32 = 0 - var _groundSpeed: UInt32 = 0 - var _groundTrack: UInt32 = 0 + var _groundSpeed: UInt32? = nil + var _groundTrack: UInt32? = nil var _fixQuality: UInt32 = 0 var _fixType: UInt32 = 0 var _satsInView: UInt32 = 0 @@ -3247,15 +3350,19 @@ extension Position: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationB public func traverse(visitor: inout V) throws { try withExtendedLifetime(_storage) { (_storage: _StorageClass) in - if _storage._latitudeI != 0 { - try visitor.visitSingularSFixed32Field(value: _storage._latitudeI, fieldNumber: 1) - } - if _storage._longitudeI != 0 { - try visitor.visitSingularSFixed32Field(value: _storage._longitudeI, fieldNumber: 2) - } - if _storage._altitude != 0 { - try visitor.visitSingularInt32Field(value: _storage._altitude, fieldNumber: 3) - } + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = _storage._latitudeI { + try visitor.visitSingularSFixed32Field(value: v, fieldNumber: 1) + } }() + try { if let v = _storage._longitudeI { + try visitor.visitSingularSFixed32Field(value: v, fieldNumber: 2) + } }() + try { if let v = _storage._altitude { + try visitor.visitSingularInt32Field(value: v, fieldNumber: 3) + } }() if _storage._time != 0 { try visitor.visitSingularFixed32Field(value: _storage._time, fieldNumber: 4) } @@ -3271,12 +3378,12 @@ extension Position: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationB if _storage._timestampMillisAdjust != 0 { try visitor.visitSingularInt32Field(value: _storage._timestampMillisAdjust, fieldNumber: 8) } - if _storage._altitudeHae != 0 { - try visitor.visitSingularSInt32Field(value: _storage._altitudeHae, fieldNumber: 9) - } - if _storage._altitudeGeoidalSeparation != 0 { - try visitor.visitSingularSInt32Field(value: _storage._altitudeGeoidalSeparation, fieldNumber: 10) - } + try { if let v = _storage._altitudeHae { + try visitor.visitSingularSInt32Field(value: v, fieldNumber: 9) + } }() + try { if let v = _storage._altitudeGeoidalSeparation { + try visitor.visitSingularSInt32Field(value: v, fieldNumber: 10) + } }() if _storage._pdop != 0 { try visitor.visitSingularUInt32Field(value: _storage._pdop, fieldNumber: 11) } @@ -3289,12 +3396,12 @@ extension Position: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationB if _storage._gpsAccuracy != 0 { try visitor.visitSingularUInt32Field(value: _storage._gpsAccuracy, fieldNumber: 14) } - if _storage._groundSpeed != 0 { - try visitor.visitSingularUInt32Field(value: _storage._groundSpeed, fieldNumber: 15) - } - if _storage._groundTrack != 0 { - try visitor.visitSingularUInt32Field(value: _storage._groundTrack, fieldNumber: 16) - } + try { if let v = _storage._groundSpeed { + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 15) + } }() + try { if let v = _storage._groundTrack { + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 16) + } }() if _storage._fixQuality != 0 { try visitor.visitSingularUInt32Field(value: _storage._fixQuality, fieldNumber: 17) } @@ -3676,8 +3783,8 @@ extension Waypoint: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationB // enabled. https://github.com/apple/swift-protobuf/issues/1034 switch fieldNumber { case 1: try { try decoder.decodeSingularUInt32Field(value: &self.id) }() - case 2: try { try decoder.decodeSingularSFixed32Field(value: &self.latitudeI) }() - case 3: try { try decoder.decodeSingularSFixed32Field(value: &self.longitudeI) }() + case 2: try { try decoder.decodeSingularSFixed32Field(value: &self._latitudeI) }() + case 3: try { try decoder.decodeSingularSFixed32Field(value: &self._longitudeI) }() case 4: try { try decoder.decodeSingularUInt32Field(value: &self.expire) }() case 5: try { try decoder.decodeSingularUInt32Field(value: &self.lockedTo) }() case 6: try { try decoder.decodeSingularStringField(value: &self.name) }() @@ -3689,15 +3796,19 @@ extension Waypoint: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationB } public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 if self.id != 0 { try visitor.visitSingularUInt32Field(value: self.id, fieldNumber: 1) } - if self.latitudeI != 0 { - try visitor.visitSingularSFixed32Field(value: self.latitudeI, fieldNumber: 2) - } - if self.longitudeI != 0 { - try visitor.visitSingularSFixed32Field(value: self.longitudeI, fieldNumber: 3) - } + try { if let v = self._latitudeI { + try visitor.visitSingularSFixed32Field(value: v, fieldNumber: 2) + } }() + try { if let v = self._longitudeI { + try visitor.visitSingularSFixed32Field(value: v, fieldNumber: 3) + } }() if self.expire != 0 { try visitor.visitSingularUInt32Field(value: self.expire, fieldNumber: 4) } @@ -3718,8 +3829,8 @@ extension Waypoint: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationB public static func ==(lhs: Waypoint, rhs: Waypoint) -> Bool { if lhs.id != rhs.id {return false} - if lhs.latitudeI != rhs.latitudeI {return false} - if lhs.longitudeI != rhs.longitudeI {return false} + if lhs._latitudeI != rhs._latitudeI {return false} + if lhs._longitudeI != rhs._longitudeI {return false} if lhs.expire != rhs.expire {return false} if lhs.lockedTo != rhs.lockedTo {return false} if lhs.name != rhs.name {return false} @@ -4369,6 +4480,7 @@ extension FromRadio: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementation 13: .same(proto: "metadata"), 14: .same(proto: "mqttClientProxyMessage"), 15: .same(proto: "fileInfo"), + 16: .same(proto: "clientNotification"), ] public mutating func decodeMessage(decoder: inout D) throws { @@ -4550,6 +4662,19 @@ extension FromRadio: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementation self.payloadVariant = .fileInfo(v) } }() + case 16: try { + var v: ClientNotification? + var hadOneofValue = false + if let current = self.payloadVariant { + hadOneofValue = true + if case .clientNotification(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payloadVariant = .clientNotification(v) + } + }() default: break } } @@ -4620,6 +4745,10 @@ extension FromRadio: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementation guard case .fileInfo(let v)? = self.payloadVariant else { preconditionFailure() } try visitor.visitSingularMessageField(value: v, fieldNumber: 15) }() + case .clientNotification?: try { + guard case .clientNotification(let v)? = self.payloadVariant else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 16) + }() case nil: break } try unknownFields.traverse(visitor: &visitor) @@ -4633,6 +4762,60 @@ extension FromRadio: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementation } } +extension ClientNotification: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = _protobuf_package + ".ClientNotification" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "reply_id"), + 2: .same(proto: "time"), + 3: .same(proto: "level"), + 4: .same(proto: "message"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularUInt32Field(value: &self._replyID) }() + case 2: try { try decoder.decodeSingularFixed32Field(value: &self.time) }() + case 3: try { try decoder.decodeSingularEnumField(value: &self.level) }() + case 4: try { try decoder.decodeSingularStringField(value: &self.message) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._replyID { + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 1) + } }() + if self.time != 0 { + try visitor.visitSingularFixed32Field(value: self.time, fieldNumber: 2) + } + if self.level != .unset { + try visitor.visitSingularEnumField(value: self.level, fieldNumber: 3) + } + if !self.message.isEmpty { + try visitor.visitSingularStringField(value: self.message, fieldNumber: 4) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: ClientNotification, rhs: ClientNotification) -> Bool { + if lhs._replyID != rhs._replyID {return false} + if lhs.time != rhs.time {return false} + if lhs.level != rhs.level {return false} + if lhs.message != rhs.message {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + extension FileInfo: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { public static let protoMessageName: String = _protobuf_package + ".FileInfo" public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ diff --git a/MeshtasticProtobufs/Sources/meshtastic/telemetry.pb.swift b/MeshtasticProtobufs/Sources/meshtastic/telemetry.pb.swift index ec627e3d..de4e550c 100644 --- a/MeshtasticProtobufs/Sources/meshtastic/telemetry.pb.swift +++ b/MeshtasticProtobufs/Sources/meshtastic/telemetry.pb.swift @@ -245,27 +245,68 @@ public struct DeviceMetrics { /// /// 0-100 (>100 means powered) - public var batteryLevel: UInt32 = 0 + public var batteryLevel: UInt32 { + get {return _batteryLevel ?? 0} + set {_batteryLevel = newValue} + } + /// Returns true if `batteryLevel` has been explicitly set. + public var hasBatteryLevel: Bool {return self._batteryLevel != nil} + /// Clears the value of `batteryLevel`. Subsequent reads from it will return its default value. + public mutating func clearBatteryLevel() {self._batteryLevel = nil} /// /// Voltage measured - public var voltage: Float = 0 + public var voltage: Float { + get {return _voltage ?? 0} + set {_voltage = newValue} + } + /// Returns true if `voltage` has been explicitly set. + public var hasVoltage: Bool {return self._voltage != nil} + /// Clears the value of `voltage`. Subsequent reads from it will return its default value. + public mutating func clearVoltage() {self._voltage = nil} /// /// Utilization for the current channel, including well formed TX, RX and malformed RX (aka noise). - public var channelUtilization: Float = 0 + public var channelUtilization: Float { + get {return _channelUtilization ?? 0} + set {_channelUtilization = newValue} + } + /// Returns true if `channelUtilization` has been explicitly set. + public var hasChannelUtilization: Bool {return self._channelUtilization != nil} + /// Clears the value of `channelUtilization`. Subsequent reads from it will return its default value. + public mutating func clearChannelUtilization() {self._channelUtilization = nil} /// /// Percent of airtime for transmission used within the last hour. - public var airUtilTx: Float = 0 + public var airUtilTx: Float { + get {return _airUtilTx ?? 0} + set {_airUtilTx = newValue} + } + /// Returns true if `airUtilTx` has been explicitly set. + public var hasAirUtilTx: Bool {return self._airUtilTx != nil} + /// Clears the value of `airUtilTx`. Subsequent reads from it will return its default value. + public mutating func clearAirUtilTx() {self._airUtilTx = nil} /// /// How long the device has been running since the last reboot (in seconds) - public var uptimeSeconds: UInt32 = 0 + public var uptimeSeconds: UInt32 { + get {return _uptimeSeconds ?? 0} + set {_uptimeSeconds = newValue} + } + /// Returns true if `uptimeSeconds` has been explicitly set. + public var hasUptimeSeconds: Bool {return self._uptimeSeconds != nil} + /// Clears the value of `uptimeSeconds`. Subsequent reads from it will return its default value. + public mutating func clearUptimeSeconds() {self._uptimeSeconds = nil} public var unknownFields = SwiftProtobuf.UnknownStorage() public init() {} + + fileprivate var _batteryLevel: UInt32? = nil + fileprivate var _voltage: Float? = nil + fileprivate var _channelUtilization: Float? = nil + fileprivate var _airUtilTx: Float? = nil + fileprivate var _uptimeSeconds: UInt32? = nil } /// @@ -278,123 +319,191 @@ public struct EnvironmentMetrics { /// /// Temperature measured public var temperature: Float { - get {return _storage._temperature} + get {return _storage._temperature ?? 0} set {_uniqueStorage()._temperature = newValue} } + /// Returns true if `temperature` has been explicitly set. + public var hasTemperature: Bool {return _storage._temperature != nil} + /// Clears the value of `temperature`. Subsequent reads from it will return its default value. + public mutating func clearTemperature() {_uniqueStorage()._temperature = nil} /// /// Relative humidity percent measured public var relativeHumidity: Float { - get {return _storage._relativeHumidity} + get {return _storage._relativeHumidity ?? 0} set {_uniqueStorage()._relativeHumidity = newValue} } + /// Returns true if `relativeHumidity` has been explicitly set. + public var hasRelativeHumidity: Bool {return _storage._relativeHumidity != nil} + /// Clears the value of `relativeHumidity`. Subsequent reads from it will return its default value. + public mutating func clearRelativeHumidity() {_uniqueStorage()._relativeHumidity = nil} /// /// Barometric pressure in hPA measured public var barometricPressure: Float { - get {return _storage._barometricPressure} + get {return _storage._barometricPressure ?? 0} set {_uniqueStorage()._barometricPressure = newValue} } + /// Returns true if `barometricPressure` has been explicitly set. + public var hasBarometricPressure: Bool {return _storage._barometricPressure != nil} + /// Clears the value of `barometricPressure`. Subsequent reads from it will return its default value. + public mutating func clearBarometricPressure() {_uniqueStorage()._barometricPressure = nil} /// /// Gas resistance in MOhm measured public var gasResistance: Float { - get {return _storage._gasResistance} + get {return _storage._gasResistance ?? 0} set {_uniqueStorage()._gasResistance = newValue} } + /// Returns true if `gasResistance` has been explicitly set. + public var hasGasResistance: Bool {return _storage._gasResistance != nil} + /// Clears the value of `gasResistance`. Subsequent reads from it will return its default value. + public mutating func clearGasResistance() {_uniqueStorage()._gasResistance = nil} /// /// Voltage measured (To be depreciated in favor of PowerMetrics in Meshtastic 3.x) public var voltage: Float { - get {return _storage._voltage} + get {return _storage._voltage ?? 0} set {_uniqueStorage()._voltage = newValue} } + /// Returns true if `voltage` has been explicitly set. + public var hasVoltage: Bool {return _storage._voltage != nil} + /// Clears the value of `voltage`. Subsequent reads from it will return its default value. + public mutating func clearVoltage() {_uniqueStorage()._voltage = nil} /// /// Current measured (To be depreciated in favor of PowerMetrics in Meshtastic 3.x) public var current: Float { - get {return _storage._current} + get {return _storage._current ?? 0} set {_uniqueStorage()._current = newValue} } + /// Returns true if `current` has been explicitly set. + public var hasCurrent: Bool {return _storage._current != nil} + /// Clears the value of `current`. Subsequent reads from it will return its default value. + public mutating func clearCurrent() {_uniqueStorage()._current = nil} /// /// relative scale IAQ value as measured by Bosch BME680 . value 0-500. /// Belongs to Air Quality but is not particle but VOC measurement. Other VOC values can also be put in here. public var iaq: UInt32 { - get {return _storage._iaq} + get {return _storage._iaq ?? 0} set {_uniqueStorage()._iaq = newValue} } + /// Returns true if `iaq` has been explicitly set. + public var hasIaq: Bool {return _storage._iaq != nil} + /// Clears the value of `iaq`. Subsequent reads from it will return its default value. + public mutating func clearIaq() {_uniqueStorage()._iaq = nil} /// /// RCWL9620 Doppler Radar Distance Sensor, used for water level detection. Float value in mm. public var distance: Float { - get {return _storage._distance} + get {return _storage._distance ?? 0} set {_uniqueStorage()._distance = newValue} } + /// Returns true if `distance` has been explicitly set. + public var hasDistance: Bool {return _storage._distance != nil} + /// Clears the value of `distance`. Subsequent reads from it will return its default value. + public mutating func clearDistance() {_uniqueStorage()._distance = nil} /// /// VEML7700 high accuracy ambient light(Lux) digital 16-bit resolution sensor. public var lux: Float { - get {return _storage._lux} + get {return _storage._lux ?? 0} set {_uniqueStorage()._lux = newValue} } + /// Returns true if `lux` has been explicitly set. + public var hasLux: Bool {return _storage._lux != nil} + /// Clears the value of `lux`. Subsequent reads from it will return its default value. + public mutating func clearLux() {_uniqueStorage()._lux = nil} /// /// VEML7700 high accuracy white light(irradiance) not calibrated digital 16-bit resolution sensor. public var whiteLux: Float { - get {return _storage._whiteLux} + get {return _storage._whiteLux ?? 0} set {_uniqueStorage()._whiteLux = newValue} } + /// Returns true if `whiteLux` has been explicitly set. + public var hasWhiteLux: Bool {return _storage._whiteLux != nil} + /// Clears the value of `whiteLux`. Subsequent reads from it will return its default value. + public mutating func clearWhiteLux() {_uniqueStorage()._whiteLux = nil} /// /// Infrared lux public var irLux: Float { - get {return _storage._irLux} + get {return _storage._irLux ?? 0} set {_uniqueStorage()._irLux = newValue} } + /// Returns true if `irLux` has been explicitly set. + public var hasIrLux: Bool {return _storage._irLux != nil} + /// Clears the value of `irLux`. Subsequent reads from it will return its default value. + public mutating func clearIrLux() {_uniqueStorage()._irLux = nil} /// /// Ultraviolet lux public var uvLux: Float { - get {return _storage._uvLux} + get {return _storage._uvLux ?? 0} set {_uniqueStorage()._uvLux = newValue} } + /// Returns true if `uvLux` has been explicitly set. + public var hasUvLux: Bool {return _storage._uvLux != nil} + /// Clears the value of `uvLux`. Subsequent reads from it will return its default value. + public mutating func clearUvLux() {_uniqueStorage()._uvLux = nil} /// /// Wind direction in degrees /// 0 degrees = North, 90 = East, etc... public var windDirection: UInt32 { - get {return _storage._windDirection} + get {return _storage._windDirection ?? 0} set {_uniqueStorage()._windDirection = newValue} } + /// Returns true if `windDirection` has been explicitly set. + public var hasWindDirection: Bool {return _storage._windDirection != nil} + /// Clears the value of `windDirection`. Subsequent reads from it will return its default value. + public mutating func clearWindDirection() {_uniqueStorage()._windDirection = nil} /// /// Wind speed in m/s public var windSpeed: Float { - get {return _storage._windSpeed} + get {return _storage._windSpeed ?? 0} set {_uniqueStorage()._windSpeed = newValue} } + /// Returns true if `windSpeed` has been explicitly set. + public var hasWindSpeed: Bool {return _storage._windSpeed != nil} + /// Clears the value of `windSpeed`. Subsequent reads from it will return its default value. + public mutating func clearWindSpeed() {_uniqueStorage()._windSpeed = nil} /// /// Weight in KG public var weight: Float { - get {return _storage._weight} + get {return _storage._weight ?? 0} set {_uniqueStorage()._weight = newValue} } + /// Returns true if `weight` has been explicitly set. + public var hasWeight: Bool {return _storage._weight != nil} + /// Clears the value of `weight`. Subsequent reads from it will return its default value. + public mutating func clearWeight() {_uniqueStorage()._weight = nil} /// /// Wind gust in m/s public var windGust: Float { - get {return _storage._windGust} + get {return _storage._windGust ?? 0} set {_uniqueStorage()._windGust = newValue} } + /// Returns true if `windGust` has been explicitly set. + public var hasWindGust: Bool {return _storage._windGust != nil} + /// Clears the value of `windGust`. Subsequent reads from it will return its default value. + public mutating func clearWindGust() {_uniqueStorage()._windGust = nil} /// /// Wind lull in m/s public var windLull: Float { - get {return _storage._windLull} + get {return _storage._windLull ?? 0} set {_uniqueStorage()._windLull = newValue} } + /// Returns true if `windLull` has been explicitly set. + public var hasWindLull: Bool {return _storage._windLull != nil} + /// Clears the value of `windLull`. Subsequent reads from it will return its default value. + public mutating func clearWindLull() {_uniqueStorage()._windLull = nil} public var unknownFields = SwiftProtobuf.UnknownStorage() @@ -412,31 +521,80 @@ public struct PowerMetrics { /// /// Voltage (Ch1) - public var ch1Voltage: Float = 0 + public var ch1Voltage: Float { + get {return _ch1Voltage ?? 0} + set {_ch1Voltage = newValue} + } + /// Returns true if `ch1Voltage` has been explicitly set. + public var hasCh1Voltage: Bool {return self._ch1Voltage != nil} + /// Clears the value of `ch1Voltage`. Subsequent reads from it will return its default value. + public mutating func clearCh1Voltage() {self._ch1Voltage = nil} /// /// Current (Ch1) - public var ch1Current: Float = 0 + public var ch1Current: Float { + get {return _ch1Current ?? 0} + set {_ch1Current = newValue} + } + /// Returns true if `ch1Current` has been explicitly set. + public var hasCh1Current: Bool {return self._ch1Current != nil} + /// Clears the value of `ch1Current`. Subsequent reads from it will return its default value. + public mutating func clearCh1Current() {self._ch1Current = nil} /// /// Voltage (Ch2) - public var ch2Voltage: Float = 0 + public var ch2Voltage: Float { + get {return _ch2Voltage ?? 0} + set {_ch2Voltage = newValue} + } + /// Returns true if `ch2Voltage` has been explicitly set. + public var hasCh2Voltage: Bool {return self._ch2Voltage != nil} + /// Clears the value of `ch2Voltage`. Subsequent reads from it will return its default value. + public mutating func clearCh2Voltage() {self._ch2Voltage = nil} /// /// Current (Ch2) - public var ch2Current: Float = 0 + public var ch2Current: Float { + get {return _ch2Current ?? 0} + set {_ch2Current = newValue} + } + /// Returns true if `ch2Current` has been explicitly set. + public var hasCh2Current: Bool {return self._ch2Current != nil} + /// Clears the value of `ch2Current`. Subsequent reads from it will return its default value. + public mutating func clearCh2Current() {self._ch2Current = nil} /// /// Voltage (Ch3) - public var ch3Voltage: Float = 0 + public var ch3Voltage: Float { + get {return _ch3Voltage ?? 0} + set {_ch3Voltage = newValue} + } + /// Returns true if `ch3Voltage` has been explicitly set. + public var hasCh3Voltage: Bool {return self._ch3Voltage != nil} + /// Clears the value of `ch3Voltage`. Subsequent reads from it will return its default value. + public mutating func clearCh3Voltage() {self._ch3Voltage = nil} /// /// Current (Ch3) - public var ch3Current: Float = 0 + public var ch3Current: Float { + get {return _ch3Current ?? 0} + set {_ch3Current = newValue} + } + /// Returns true if `ch3Current` has been explicitly set. + public var hasCh3Current: Bool {return self._ch3Current != nil} + /// Clears the value of `ch3Current`. Subsequent reads from it will return its default value. + public mutating func clearCh3Current() {self._ch3Current = nil} public var unknownFields = SwiftProtobuf.UnknownStorage() public init() {} + + fileprivate var _ch1Voltage: Float? = nil + fileprivate var _ch1Current: Float? = nil + fileprivate var _ch2Voltage: Float? = nil + fileprivate var _ch2Current: Float? = nil + fileprivate var _ch3Voltage: Float? = nil + fileprivate var _ch3Current: Float? = nil } /// @@ -448,55 +606,152 @@ public struct AirQualityMetrics { /// /// Concentration Units Standard PM1.0 - public var pm10Standard: UInt32 = 0 + public var pm10Standard: UInt32 { + get {return _pm10Standard ?? 0} + set {_pm10Standard = newValue} + } + /// Returns true if `pm10Standard` has been explicitly set. + public var hasPm10Standard: Bool {return self._pm10Standard != nil} + /// Clears the value of `pm10Standard`. Subsequent reads from it will return its default value. + public mutating func clearPm10Standard() {self._pm10Standard = nil} /// /// Concentration Units Standard PM2.5 - public var pm25Standard: UInt32 = 0 + public var pm25Standard: UInt32 { + get {return _pm25Standard ?? 0} + set {_pm25Standard = newValue} + } + /// Returns true if `pm25Standard` has been explicitly set. + public var hasPm25Standard: Bool {return self._pm25Standard != nil} + /// Clears the value of `pm25Standard`. Subsequent reads from it will return its default value. + public mutating func clearPm25Standard() {self._pm25Standard = nil} /// /// Concentration Units Standard PM10.0 - public var pm100Standard: UInt32 = 0 + public var pm100Standard: UInt32 { + get {return _pm100Standard ?? 0} + set {_pm100Standard = newValue} + } + /// Returns true if `pm100Standard` has been explicitly set. + public var hasPm100Standard: Bool {return self._pm100Standard != nil} + /// Clears the value of `pm100Standard`. Subsequent reads from it will return its default value. + public mutating func clearPm100Standard() {self._pm100Standard = nil} /// /// Concentration Units Environmental PM1.0 - public var pm10Environmental: UInt32 = 0 + public var pm10Environmental: UInt32 { + get {return _pm10Environmental ?? 0} + set {_pm10Environmental = newValue} + } + /// Returns true if `pm10Environmental` has been explicitly set. + public var hasPm10Environmental: Bool {return self._pm10Environmental != nil} + /// Clears the value of `pm10Environmental`. Subsequent reads from it will return its default value. + public mutating func clearPm10Environmental() {self._pm10Environmental = nil} /// /// Concentration Units Environmental PM2.5 - public var pm25Environmental: UInt32 = 0 + public var pm25Environmental: UInt32 { + get {return _pm25Environmental ?? 0} + set {_pm25Environmental = newValue} + } + /// Returns true if `pm25Environmental` has been explicitly set. + public var hasPm25Environmental: Bool {return self._pm25Environmental != nil} + /// Clears the value of `pm25Environmental`. Subsequent reads from it will return its default value. + public mutating func clearPm25Environmental() {self._pm25Environmental = nil} /// /// Concentration Units Environmental PM10.0 - public var pm100Environmental: UInt32 = 0 + public var pm100Environmental: UInt32 { + get {return _pm100Environmental ?? 0} + set {_pm100Environmental = newValue} + } + /// Returns true if `pm100Environmental` has been explicitly set. + public var hasPm100Environmental: Bool {return self._pm100Environmental != nil} + /// Clears the value of `pm100Environmental`. Subsequent reads from it will return its default value. + public mutating func clearPm100Environmental() {self._pm100Environmental = nil} /// /// 0.3um Particle Count - public var particles03Um: UInt32 = 0 + public var particles03Um: UInt32 { + get {return _particles03Um ?? 0} + set {_particles03Um = newValue} + } + /// Returns true if `particles03Um` has been explicitly set. + public var hasParticles03Um: Bool {return self._particles03Um != nil} + /// Clears the value of `particles03Um`. Subsequent reads from it will return its default value. + public mutating func clearParticles03Um() {self._particles03Um = nil} /// /// 0.5um Particle Count - public var particles05Um: UInt32 = 0 + public var particles05Um: UInt32 { + get {return _particles05Um ?? 0} + set {_particles05Um = newValue} + } + /// Returns true if `particles05Um` has been explicitly set. + public var hasParticles05Um: Bool {return self._particles05Um != nil} + /// Clears the value of `particles05Um`. Subsequent reads from it will return its default value. + public mutating func clearParticles05Um() {self._particles05Um = nil} /// /// 1.0um Particle Count - public var particles10Um: UInt32 = 0 + public var particles10Um: UInt32 { + get {return _particles10Um ?? 0} + set {_particles10Um = newValue} + } + /// Returns true if `particles10Um` has been explicitly set. + public var hasParticles10Um: Bool {return self._particles10Um != nil} + /// Clears the value of `particles10Um`. Subsequent reads from it will return its default value. + public mutating func clearParticles10Um() {self._particles10Um = nil} /// /// 2.5um Particle Count - public var particles25Um: UInt32 = 0 + public var particles25Um: UInt32 { + get {return _particles25Um ?? 0} + set {_particles25Um = newValue} + } + /// Returns true if `particles25Um` has been explicitly set. + public var hasParticles25Um: Bool {return self._particles25Um != nil} + /// Clears the value of `particles25Um`. Subsequent reads from it will return its default value. + public mutating func clearParticles25Um() {self._particles25Um = nil} /// /// 5.0um Particle Count - public var particles50Um: UInt32 = 0 + public var particles50Um: UInt32 { + get {return _particles50Um ?? 0} + set {_particles50Um = newValue} + } + /// Returns true if `particles50Um` has been explicitly set. + public var hasParticles50Um: Bool {return self._particles50Um != nil} + /// Clears the value of `particles50Um`. Subsequent reads from it will return its default value. + public mutating func clearParticles50Um() {self._particles50Um = nil} /// /// 10.0um Particle Count - public var particles100Um: UInt32 = 0 + public var particles100Um: UInt32 { + get {return _particles100Um ?? 0} + set {_particles100Um = newValue} + } + /// Returns true if `particles100Um` has been explicitly set. + public var hasParticles100Um: Bool {return self._particles100Um != nil} + /// Clears the value of `particles100Um`. Subsequent reads from it will return its default value. + public mutating func clearParticles100Um() {self._particles100Um = nil} public var unknownFields = SwiftProtobuf.UnknownStorage() public init() {} + + fileprivate var _pm10Standard: UInt32? = nil + fileprivate var _pm25Standard: UInt32? = nil + fileprivate var _pm100Standard: UInt32? = nil + fileprivate var _pm10Environmental: UInt32? = nil + fileprivate var _pm25Environmental: UInt32? = nil + fileprivate var _pm100Environmental: UInt32? = nil + fileprivate var _particles03Um: UInt32? = nil + fileprivate var _particles05Um: UInt32? = nil + fileprivate var _particles10Um: UInt32? = nil + fileprivate var _particles25Um: UInt32? = nil + fileprivate var _particles50Um: UInt32? = nil + fileprivate var _particles100Um: UInt32? = nil } /// @@ -681,41 +936,45 @@ extension DeviceMetrics: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementa // allocates stack space for every case branch when no optimizations are // enabled. https://github.com/apple/swift-protobuf/issues/1034 switch fieldNumber { - case 1: try { try decoder.decodeSingularUInt32Field(value: &self.batteryLevel) }() - case 2: try { try decoder.decodeSingularFloatField(value: &self.voltage) }() - case 3: try { try decoder.decodeSingularFloatField(value: &self.channelUtilization) }() - case 4: try { try decoder.decodeSingularFloatField(value: &self.airUtilTx) }() - case 5: try { try decoder.decodeSingularUInt32Field(value: &self.uptimeSeconds) }() + case 1: try { try decoder.decodeSingularUInt32Field(value: &self._batteryLevel) }() + case 2: try { try decoder.decodeSingularFloatField(value: &self._voltage) }() + case 3: try { try decoder.decodeSingularFloatField(value: &self._channelUtilization) }() + case 4: try { try decoder.decodeSingularFloatField(value: &self._airUtilTx) }() + case 5: try { try decoder.decodeSingularUInt32Field(value: &self._uptimeSeconds) }() default: break } } } public func traverse(visitor: inout V) throws { - if self.batteryLevel != 0 { - try visitor.visitSingularUInt32Field(value: self.batteryLevel, fieldNumber: 1) - } - if self.voltage != 0 { - try visitor.visitSingularFloatField(value: self.voltage, fieldNumber: 2) - } - if self.channelUtilization != 0 { - try visitor.visitSingularFloatField(value: self.channelUtilization, fieldNumber: 3) - } - if self.airUtilTx != 0 { - try visitor.visitSingularFloatField(value: self.airUtilTx, fieldNumber: 4) - } - if self.uptimeSeconds != 0 { - try visitor.visitSingularUInt32Field(value: self.uptimeSeconds, fieldNumber: 5) - } + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._batteryLevel { + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 1) + } }() + try { if let v = self._voltage { + try visitor.visitSingularFloatField(value: v, fieldNumber: 2) + } }() + try { if let v = self._channelUtilization { + try visitor.visitSingularFloatField(value: v, fieldNumber: 3) + } }() + try { if let v = self._airUtilTx { + try visitor.visitSingularFloatField(value: v, fieldNumber: 4) + } }() + try { if let v = self._uptimeSeconds { + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 5) + } }() try unknownFields.traverse(visitor: &visitor) } public static func ==(lhs: DeviceMetrics, rhs: DeviceMetrics) -> Bool { - if lhs.batteryLevel != rhs.batteryLevel {return false} - if lhs.voltage != rhs.voltage {return false} - if lhs.channelUtilization != rhs.channelUtilization {return false} - if lhs.airUtilTx != rhs.airUtilTx {return false} - if lhs.uptimeSeconds != rhs.uptimeSeconds {return false} + if lhs._batteryLevel != rhs._batteryLevel {return false} + if lhs._voltage != rhs._voltage {return false} + if lhs._channelUtilization != rhs._channelUtilization {return false} + if lhs._airUtilTx != rhs._airUtilTx {return false} + if lhs._uptimeSeconds != rhs._uptimeSeconds {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } @@ -744,23 +1003,23 @@ extension EnvironmentMetrics: SwiftProtobuf.Message, SwiftProtobuf._MessageImple ] fileprivate class _StorageClass { - var _temperature: Float = 0 - var _relativeHumidity: Float = 0 - var _barometricPressure: Float = 0 - var _gasResistance: Float = 0 - var _voltage: Float = 0 - var _current: Float = 0 - var _iaq: UInt32 = 0 - var _distance: Float = 0 - var _lux: Float = 0 - var _whiteLux: Float = 0 - var _irLux: Float = 0 - var _uvLux: Float = 0 - var _windDirection: UInt32 = 0 - var _windSpeed: Float = 0 - var _weight: Float = 0 - var _windGust: Float = 0 - var _windLull: Float = 0 + var _temperature: Float? = nil + var _relativeHumidity: Float? = nil + var _barometricPressure: Float? = nil + var _gasResistance: Float? = nil + var _voltage: Float? = nil + var _current: Float? = nil + var _iaq: UInt32? = nil + var _distance: Float? = nil + var _lux: Float? = nil + var _whiteLux: Float? = nil + var _irLux: Float? = nil + var _uvLux: Float? = nil + var _windDirection: UInt32? = nil + var _windSpeed: Float? = nil + var _weight: Float? = nil + var _windGust: Float? = nil + var _windLull: Float? = nil #if swift(>=5.10) // This property is used as the initial default value for new instances of the type. @@ -835,57 +1094,61 @@ extension EnvironmentMetrics: SwiftProtobuf.Message, SwiftProtobuf._MessageImple public func traverse(visitor: inout V) throws { try withExtendedLifetime(_storage) { (_storage: _StorageClass) in - if _storage._temperature != 0 { - try visitor.visitSingularFloatField(value: _storage._temperature, fieldNumber: 1) - } - if _storage._relativeHumidity != 0 { - try visitor.visitSingularFloatField(value: _storage._relativeHumidity, fieldNumber: 2) - } - if _storage._barometricPressure != 0 { - try visitor.visitSingularFloatField(value: _storage._barometricPressure, fieldNumber: 3) - } - if _storage._gasResistance != 0 { - try visitor.visitSingularFloatField(value: _storage._gasResistance, fieldNumber: 4) - } - if _storage._voltage != 0 { - try visitor.visitSingularFloatField(value: _storage._voltage, fieldNumber: 5) - } - if _storage._current != 0 { - try visitor.visitSingularFloatField(value: _storage._current, fieldNumber: 6) - } - if _storage._iaq != 0 { - try visitor.visitSingularUInt32Field(value: _storage._iaq, fieldNumber: 7) - } - if _storage._distance != 0 { - try visitor.visitSingularFloatField(value: _storage._distance, fieldNumber: 8) - } - if _storage._lux != 0 { - try visitor.visitSingularFloatField(value: _storage._lux, fieldNumber: 9) - } - if _storage._whiteLux != 0 { - try visitor.visitSingularFloatField(value: _storage._whiteLux, fieldNumber: 10) - } - if _storage._irLux != 0 { - try visitor.visitSingularFloatField(value: _storage._irLux, fieldNumber: 11) - } - if _storage._uvLux != 0 { - try visitor.visitSingularFloatField(value: _storage._uvLux, fieldNumber: 12) - } - if _storage._windDirection != 0 { - try visitor.visitSingularUInt32Field(value: _storage._windDirection, fieldNumber: 13) - } - if _storage._windSpeed != 0 { - try visitor.visitSingularFloatField(value: _storage._windSpeed, fieldNumber: 14) - } - if _storage._weight != 0 { - try visitor.visitSingularFloatField(value: _storage._weight, fieldNumber: 15) - } - if _storage._windGust != 0 { - try visitor.visitSingularFloatField(value: _storage._windGust, fieldNumber: 16) - } - if _storage._windLull != 0 { - try visitor.visitSingularFloatField(value: _storage._windLull, fieldNumber: 17) - } + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = _storage._temperature { + try visitor.visitSingularFloatField(value: v, fieldNumber: 1) + } }() + try { if let v = _storage._relativeHumidity { + try visitor.visitSingularFloatField(value: v, fieldNumber: 2) + } }() + try { if let v = _storage._barometricPressure { + try visitor.visitSingularFloatField(value: v, fieldNumber: 3) + } }() + try { if let v = _storage._gasResistance { + try visitor.visitSingularFloatField(value: v, fieldNumber: 4) + } }() + try { if let v = _storage._voltage { + try visitor.visitSingularFloatField(value: v, fieldNumber: 5) + } }() + try { if let v = _storage._current { + try visitor.visitSingularFloatField(value: v, fieldNumber: 6) + } }() + try { if let v = _storage._iaq { + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 7) + } }() + try { if let v = _storage._distance { + try visitor.visitSingularFloatField(value: v, fieldNumber: 8) + } }() + try { if let v = _storage._lux { + try visitor.visitSingularFloatField(value: v, fieldNumber: 9) + } }() + try { if let v = _storage._whiteLux { + try visitor.visitSingularFloatField(value: v, fieldNumber: 10) + } }() + try { if let v = _storage._irLux { + try visitor.visitSingularFloatField(value: v, fieldNumber: 11) + } }() + try { if let v = _storage._uvLux { + try visitor.visitSingularFloatField(value: v, fieldNumber: 12) + } }() + try { if let v = _storage._windDirection { + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 13) + } }() + try { if let v = _storage._windSpeed { + try visitor.visitSingularFloatField(value: v, fieldNumber: 14) + } }() + try { if let v = _storage._weight { + try visitor.visitSingularFloatField(value: v, fieldNumber: 15) + } }() + try { if let v = _storage._windGust { + try visitor.visitSingularFloatField(value: v, fieldNumber: 16) + } }() + try { if let v = _storage._windLull { + try visitor.visitSingularFloatField(value: v, fieldNumber: 17) + } }() } try unknownFields.traverse(visitor: &visitor) } @@ -938,46 +1201,50 @@ extension PowerMetrics: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat // allocates stack space for every case branch when no optimizations are // enabled. https://github.com/apple/swift-protobuf/issues/1034 switch fieldNumber { - case 1: try { try decoder.decodeSingularFloatField(value: &self.ch1Voltage) }() - case 2: try { try decoder.decodeSingularFloatField(value: &self.ch1Current) }() - case 3: try { try decoder.decodeSingularFloatField(value: &self.ch2Voltage) }() - case 4: try { try decoder.decodeSingularFloatField(value: &self.ch2Current) }() - case 5: try { try decoder.decodeSingularFloatField(value: &self.ch3Voltage) }() - case 6: try { try decoder.decodeSingularFloatField(value: &self.ch3Current) }() + case 1: try { try decoder.decodeSingularFloatField(value: &self._ch1Voltage) }() + case 2: try { try decoder.decodeSingularFloatField(value: &self._ch1Current) }() + case 3: try { try decoder.decodeSingularFloatField(value: &self._ch2Voltage) }() + case 4: try { try decoder.decodeSingularFloatField(value: &self._ch2Current) }() + case 5: try { try decoder.decodeSingularFloatField(value: &self._ch3Voltage) }() + case 6: try { try decoder.decodeSingularFloatField(value: &self._ch3Current) }() default: break } } } public func traverse(visitor: inout V) throws { - if self.ch1Voltage != 0 { - try visitor.visitSingularFloatField(value: self.ch1Voltage, fieldNumber: 1) - } - if self.ch1Current != 0 { - try visitor.visitSingularFloatField(value: self.ch1Current, fieldNumber: 2) - } - if self.ch2Voltage != 0 { - try visitor.visitSingularFloatField(value: self.ch2Voltage, fieldNumber: 3) - } - if self.ch2Current != 0 { - try visitor.visitSingularFloatField(value: self.ch2Current, fieldNumber: 4) - } - if self.ch3Voltage != 0 { - try visitor.visitSingularFloatField(value: self.ch3Voltage, fieldNumber: 5) - } - if self.ch3Current != 0 { - try visitor.visitSingularFloatField(value: self.ch3Current, fieldNumber: 6) - } + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._ch1Voltage { + try visitor.visitSingularFloatField(value: v, fieldNumber: 1) + } }() + try { if let v = self._ch1Current { + try visitor.visitSingularFloatField(value: v, fieldNumber: 2) + } }() + try { if let v = self._ch2Voltage { + try visitor.visitSingularFloatField(value: v, fieldNumber: 3) + } }() + try { if let v = self._ch2Current { + try visitor.visitSingularFloatField(value: v, fieldNumber: 4) + } }() + try { if let v = self._ch3Voltage { + try visitor.visitSingularFloatField(value: v, fieldNumber: 5) + } }() + try { if let v = self._ch3Current { + try visitor.visitSingularFloatField(value: v, fieldNumber: 6) + } }() try unknownFields.traverse(visitor: &visitor) } public static func ==(lhs: PowerMetrics, rhs: PowerMetrics) -> Bool { - if lhs.ch1Voltage != rhs.ch1Voltage {return false} - if lhs.ch1Current != rhs.ch1Current {return false} - if lhs.ch2Voltage != rhs.ch2Voltage {return false} - if lhs.ch2Current != rhs.ch2Current {return false} - if lhs.ch3Voltage != rhs.ch3Voltage {return false} - if lhs.ch3Current != rhs.ch3Current {return false} + if lhs._ch1Voltage != rhs._ch1Voltage {return false} + if lhs._ch1Current != rhs._ch1Current {return false} + if lhs._ch2Voltage != rhs._ch2Voltage {return false} + if lhs._ch2Current != rhs._ch2Current {return false} + if lhs._ch3Voltage != rhs._ch3Voltage {return false} + if lhs._ch3Current != rhs._ch3Current {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } @@ -1006,76 +1273,80 @@ extension AirQualityMetrics: SwiftProtobuf.Message, SwiftProtobuf._MessageImplem // allocates stack space for every case branch when no optimizations are // enabled. https://github.com/apple/swift-protobuf/issues/1034 switch fieldNumber { - case 1: try { try decoder.decodeSingularUInt32Field(value: &self.pm10Standard) }() - case 2: try { try decoder.decodeSingularUInt32Field(value: &self.pm25Standard) }() - case 3: try { try decoder.decodeSingularUInt32Field(value: &self.pm100Standard) }() - case 4: try { try decoder.decodeSingularUInt32Field(value: &self.pm10Environmental) }() - case 5: try { try decoder.decodeSingularUInt32Field(value: &self.pm25Environmental) }() - case 6: try { try decoder.decodeSingularUInt32Field(value: &self.pm100Environmental) }() - case 7: try { try decoder.decodeSingularUInt32Field(value: &self.particles03Um) }() - case 8: try { try decoder.decodeSingularUInt32Field(value: &self.particles05Um) }() - case 9: try { try decoder.decodeSingularUInt32Field(value: &self.particles10Um) }() - case 10: try { try decoder.decodeSingularUInt32Field(value: &self.particles25Um) }() - case 11: try { try decoder.decodeSingularUInt32Field(value: &self.particles50Um) }() - case 12: try { try decoder.decodeSingularUInt32Field(value: &self.particles100Um) }() + case 1: try { try decoder.decodeSingularUInt32Field(value: &self._pm10Standard) }() + case 2: try { try decoder.decodeSingularUInt32Field(value: &self._pm25Standard) }() + case 3: try { try decoder.decodeSingularUInt32Field(value: &self._pm100Standard) }() + case 4: try { try decoder.decodeSingularUInt32Field(value: &self._pm10Environmental) }() + case 5: try { try decoder.decodeSingularUInt32Field(value: &self._pm25Environmental) }() + case 6: try { try decoder.decodeSingularUInt32Field(value: &self._pm100Environmental) }() + case 7: try { try decoder.decodeSingularUInt32Field(value: &self._particles03Um) }() + case 8: try { try decoder.decodeSingularUInt32Field(value: &self._particles05Um) }() + case 9: try { try decoder.decodeSingularUInt32Field(value: &self._particles10Um) }() + case 10: try { try decoder.decodeSingularUInt32Field(value: &self._particles25Um) }() + case 11: try { try decoder.decodeSingularUInt32Field(value: &self._particles50Um) }() + case 12: try { try decoder.decodeSingularUInt32Field(value: &self._particles100Um) }() default: break } } } public func traverse(visitor: inout V) throws { - if self.pm10Standard != 0 { - try visitor.visitSingularUInt32Field(value: self.pm10Standard, fieldNumber: 1) - } - if self.pm25Standard != 0 { - try visitor.visitSingularUInt32Field(value: self.pm25Standard, fieldNumber: 2) - } - if self.pm100Standard != 0 { - try visitor.visitSingularUInt32Field(value: self.pm100Standard, fieldNumber: 3) - } - if self.pm10Environmental != 0 { - try visitor.visitSingularUInt32Field(value: self.pm10Environmental, fieldNumber: 4) - } - if self.pm25Environmental != 0 { - try visitor.visitSingularUInt32Field(value: self.pm25Environmental, fieldNumber: 5) - } - if self.pm100Environmental != 0 { - try visitor.visitSingularUInt32Field(value: self.pm100Environmental, fieldNumber: 6) - } - if self.particles03Um != 0 { - try visitor.visitSingularUInt32Field(value: self.particles03Um, fieldNumber: 7) - } - if self.particles05Um != 0 { - try visitor.visitSingularUInt32Field(value: self.particles05Um, fieldNumber: 8) - } - if self.particles10Um != 0 { - try visitor.visitSingularUInt32Field(value: self.particles10Um, fieldNumber: 9) - } - if self.particles25Um != 0 { - try visitor.visitSingularUInt32Field(value: self.particles25Um, fieldNumber: 10) - } - if self.particles50Um != 0 { - try visitor.visitSingularUInt32Field(value: self.particles50Um, fieldNumber: 11) - } - if self.particles100Um != 0 { - try visitor.visitSingularUInt32Field(value: self.particles100Um, fieldNumber: 12) - } + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._pm10Standard { + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 1) + } }() + try { if let v = self._pm25Standard { + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 2) + } }() + try { if let v = self._pm100Standard { + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 3) + } }() + try { if let v = self._pm10Environmental { + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 4) + } }() + try { if let v = self._pm25Environmental { + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 5) + } }() + try { if let v = self._pm100Environmental { + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 6) + } }() + try { if let v = self._particles03Um { + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 7) + } }() + try { if let v = self._particles05Um { + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 8) + } }() + try { if let v = self._particles10Um { + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 9) + } }() + try { if let v = self._particles25Um { + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 10) + } }() + try { if let v = self._particles50Um { + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 11) + } }() + try { if let v = self._particles100Um { + try visitor.visitSingularUInt32Field(value: v, fieldNumber: 12) + } }() try unknownFields.traverse(visitor: &visitor) } public static func ==(lhs: AirQualityMetrics, rhs: AirQualityMetrics) -> Bool { - if lhs.pm10Standard != rhs.pm10Standard {return false} - if lhs.pm25Standard != rhs.pm25Standard {return false} - if lhs.pm100Standard != rhs.pm100Standard {return false} - if lhs.pm10Environmental != rhs.pm10Environmental {return false} - if lhs.pm25Environmental != rhs.pm25Environmental {return false} - if lhs.pm100Environmental != rhs.pm100Environmental {return false} - if lhs.particles03Um != rhs.particles03Um {return false} - if lhs.particles05Um != rhs.particles05Um {return false} - if lhs.particles10Um != rhs.particles10Um {return false} - if lhs.particles25Um != rhs.particles25Um {return false} - if lhs.particles50Um != rhs.particles50Um {return false} - if lhs.particles100Um != rhs.particles100Um {return false} + if lhs._pm10Standard != rhs._pm10Standard {return false} + if lhs._pm25Standard != rhs._pm25Standard {return false} + if lhs._pm100Standard != rhs._pm100Standard {return false} + if lhs._pm10Environmental != rhs._pm10Environmental {return false} + if lhs._pm25Environmental != rhs._pm25Environmental {return false} + if lhs._pm100Environmental != rhs._pm100Environmental {return false} + if lhs._particles03Um != rhs._particles03Um {return false} + if lhs._particles05Um != rhs._particles05Um {return false} + if lhs._particles10Um != rhs._particles10Um {return false} + if lhs._particles25Um != rhs._particles25Um {return false} + if lhs._particles50Um != rhs._particles50Um {return false} + if lhs._particles100Um != rhs._particles100Um {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } diff --git a/protobufs b/protobufs index 81fd9d37..c112ce6e 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 81fd9d374f1b364c2812b7a0ca2784a7605b6835 +Subproject commit c112ce6e1392e4bc812655fae5e8461c932b5267