Meshtastic-Apple/MeshtasticProtobufs/Sources/meshtastic/interdevice.pb.swift

328 lines
10 KiB
Swift

// DO NOT EDIT.
// swift-format-ignore-file
// swiftlint:disable all
//
// Generated by the Swift generator plugin for the protocol buffer compiler.
// Source: meshtastic/interdevice.proto
//
// For information on using the generated types, please see the documentation:
// https://github.com/apple/swift-protobuf/
import SwiftProtobuf
// If the compiler emits an error on this type, it is because this file
// was generated by a version of the `protoc` Swift plug-in that is
// incompatible with the version of SwiftProtobuf to which you are linking.
// Please ensure that you are building against the same version of the API
// that was used to generate this file.
fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck {
struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {}
typealias Version = _2
}
public enum MessageType: SwiftProtobuf.Enum, Swift.CaseIterable {
public typealias RawValue = Int
case ack // = 0
/// in ms
case collectInterval // = 160
/// duration ms
case beepOn // = 161
/// cancel prematurely
case beepOff // = 162
case shutdown // = 163
case powerOn // = 164
case scd41Temp // = 176
case scd41Humidity // = 177
case scd41Co2 // = 178
case aht20Temp // = 179
case aht20Humidity // = 180
case tvocIndex // = 181
case UNRECOGNIZED(Int)
public init() {
self = .ack
}
public init?(rawValue: Int) {
switch rawValue {
case 0: self = .ack
case 160: self = .collectInterval
case 161: self = .beepOn
case 162: self = .beepOff
case 163: self = .shutdown
case 164: self = .powerOn
case 176: self = .scd41Temp
case 177: self = .scd41Humidity
case 178: self = .scd41Co2
case 179: self = .aht20Temp
case 180: self = .aht20Humidity
case 181: self = .tvocIndex
default: self = .UNRECOGNIZED(rawValue)
}
}
public var rawValue: Int {
switch self {
case .ack: return 0
case .collectInterval: return 160
case .beepOn: return 161
case .beepOff: return 162
case .shutdown: return 163
case .powerOn: return 164
case .scd41Temp: return 176
case .scd41Humidity: return 177
case .scd41Co2: return 178
case .aht20Temp: return 179
case .aht20Humidity: return 180
case .tvocIndex: return 181
case .UNRECOGNIZED(let i): return i
}
}
// The compiler won't synthesize support with the UNRECOGNIZED case.
public static let allCases: [MessageType] = [
.ack,
.collectInterval,
.beepOn,
.beepOff,
.shutdown,
.powerOn,
.scd41Temp,
.scd41Humidity,
.scd41Co2,
.aht20Temp,
.aht20Humidity,
.tvocIndex,
]
}
public struct SensorData: Sendable {
// 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 message type
public var type: MessageType = .ack
/// The sensor data, either as a float or an uint32
public var data: SensorData.OneOf_Data? = nil
public var floatValue: Float {
get {
if case .floatValue(let v)? = data {return v}
return 0
}
set {data = .floatValue(newValue)}
}
public var uint32Value: UInt32 {
get {
if case .uint32Value(let v)? = data {return v}
return 0
}
set {data = .uint32Value(newValue)}
}
public var unknownFields = SwiftProtobuf.UnknownStorage()
/// The sensor data, either as a float or an uint32
public enum OneOf_Data: Equatable, Sendable {
case floatValue(Float)
case uint32Value(UInt32)
}
public init() {}
}
public struct InterdeviceMessage: Sendable {
// 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 message data
public var data: InterdeviceMessage.OneOf_Data? = nil
public var nmea: String {
get {
if case .nmea(let v)? = data {return v}
return String()
}
set {data = .nmea(newValue)}
}
public var sensor: SensorData {
get {
if case .sensor(let v)? = data {return v}
return SensorData()
}
set {data = .sensor(newValue)}
}
public var unknownFields = SwiftProtobuf.UnknownStorage()
/// The message data
public enum OneOf_Data: Equatable, Sendable {
case nmea(String)
case sensor(SensorData)
}
public init() {}
}
// MARK: - Code below here is support for the SwiftProtobuf runtime.
fileprivate let _protobuf_package = "meshtastic"
extension MessageType: SwiftProtobuf._ProtoNameProviding {
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
0: .same(proto: "ACK"),
160: .same(proto: "COLLECT_INTERVAL"),
161: .same(proto: "BEEP_ON"),
162: .same(proto: "BEEP_OFF"),
163: .same(proto: "SHUTDOWN"),
164: .same(proto: "POWER_ON"),
176: .same(proto: "SCD41_TEMP"),
177: .same(proto: "SCD41_HUMIDITY"),
178: .same(proto: "SCD41_CO2"),
179: .same(proto: "AHT20_TEMP"),
180: .same(proto: "AHT20_HUMIDITY"),
181: .same(proto: "TVOC_INDEX"),
]
}
extension SensorData: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
public static let protoMessageName: String = _protobuf_package + ".SensorData"
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "type"),
2: .standard(proto: "float_value"),
3: .standard(proto: "uint32_value"),
]
public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(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.decodeSingularEnumField(value: &self.type) }()
case 2: try {
var v: Float?
try decoder.decodeSingularFloatField(value: &v)
if let v = v {
if self.data != nil {try decoder.handleConflictingOneOf()}
self.data = .floatValue(v)
}
}()
case 3: try {
var v: UInt32?
try decoder.decodeSingularUInt32Field(value: &v)
if let v = v {
if self.data != nil {try decoder.handleConflictingOneOf()}
self.data = .uint32Value(v)
}
}()
default: break
}
}
}
public func traverse<V: SwiftProtobuf.Visitor>(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.type != .ack {
try visitor.visitSingularEnumField(value: self.type, fieldNumber: 1)
}
switch self.data {
case .floatValue?: try {
guard case .floatValue(let v)? = self.data else { preconditionFailure() }
try visitor.visitSingularFloatField(value: v, fieldNumber: 2)
}()
case .uint32Value?: try {
guard case .uint32Value(let v)? = self.data else { preconditionFailure() }
try visitor.visitSingularUInt32Field(value: v, fieldNumber: 3)
}()
case nil: break
}
try unknownFields.traverse(visitor: &visitor)
}
public static func ==(lhs: SensorData, rhs: SensorData) -> Bool {
if lhs.type != rhs.type {return false}
if lhs.data != rhs.data {return false}
if lhs.unknownFields != rhs.unknownFields {return false}
return true
}
}
extension InterdeviceMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
public static let protoMessageName: String = _protobuf_package + ".InterdeviceMessage"
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "nmea"),
2: .same(proto: "sensor"),
]
public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(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 {
var v: String?
try decoder.decodeSingularStringField(value: &v)
if let v = v {
if self.data != nil {try decoder.handleConflictingOneOf()}
self.data = .nmea(v)
}
}()
case 2: try {
var v: SensorData?
var hadOneofValue = false
if let current = self.data {
hadOneofValue = true
if case .sensor(let m) = current {v = m}
}
try decoder.decodeSingularMessageField(value: &v)
if let v = v {
if hadOneofValue {try decoder.handleConflictingOneOf()}
self.data = .sensor(v)
}
}()
default: break
}
}
}
public func traverse<V: SwiftProtobuf.Visitor>(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
switch self.data {
case .nmea?: try {
guard case .nmea(let v)? = self.data else { preconditionFailure() }
try visitor.visitSingularStringField(value: v, fieldNumber: 1)
}()
case .sensor?: try {
guard case .sensor(let v)? = self.data else { preconditionFailure() }
try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
}()
case nil: break
}
try unknownFields.traverse(visitor: &visitor)
}
public static func ==(lhs: InterdeviceMessage, rhs: InterdeviceMessage) -> Bool {
if lhs.data != rhs.data {return false}
if lhs.unknownFields != rhs.unknownFields {return false}
return true
}
}