// DO NOT EDIT. // swift-format-ignore-file // // Generated by the Swift generator plugin for the protocol buffer compiler. // Source: channel.proto // // For information on using the generated types, please see the documentation: // https://github.com/apple/swift-protobuf/ /// /// Meshtastic protobufs /// /// For more information on protobufs (and tools to use them with the language of your choice) see /// https://developers.google.com/protocol-buffers/docs/proto3 /// /// We are not placing any of these defs inside a package, because if you do the /// resulting nanopb version is super verbose package mesh. /// /// Protobuf build instructions: /// /// To build java classes for reading writing: /// protoc -I=. --java_out /tmp mesh.proto /// /// To generate Nanopb c code: /// /home/kevinh/packages/nanopb-0.4.0-linux-x86/generator-bin/protoc --nanopb_out=/tmp -I=app/src/main/proto mesh.proto /// /// Nanopb binaries available here: https://jpa.kapsi.fi/nanopb/download/ use nanopb 0.4.0 import Foundation 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 } /// /// Full settings (center freq, spread factor, pre-shared secret key etc...) /// needed to configure a radio for speaking on a particular channel This /// information can be encoded as a QRcode/url so that other users can configure /// their radio to join the same channel. /// A note about how channel names are shown to users: channelname-Xy /// poundsymbol is a prefix used to indicate this is a channel name (idea from @professr). /// Where X is a letter from A-Z (base 26) representing a hash of the PSK for this /// channel - so that if the user changes anything about the channel (which does /// force a new PSK) this letter will also change. Thus preventing user confusion if /// two friends try to type in a channel name of "BobsChan" and then can't talk /// because their PSKs will be different. /// The PSK is hashed into this letter by "0x41 + [xor all bytes of the psk ] modulo 26" /// This also allows the option of someday if people have the PSK off (zero), the /// users COULD type in a channel name and be able to talk. /// Y is a lower case letter from a-z that represents the channel 'speed' settings /// (for some future definition of speed) /// /// FIXME: Add description of multi-channel support and how primary vs secondary channels are used. /// FIXME: explain how apps use channels for security. /// explain how remote settings and remote gpio are managed as an example struct ChannelSettings { // 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. /// /// If zero then, use default max legal continuous power (ie. something that won't /// burn out the radio hardware) /// In most cases you should use zero here. /// Units are in dBm. var txPower: Int32 = 0 /// /// Note: This is the 'old' mechanism for specifying channel parameters. /// Either modem_config or bandwidth/spreading/coding will be specified - NOT BOTH. /// As a heuristic: If bandwidth is specified, do not use modem_config. /// Because protobufs take ZERO space when the value is zero this works out nicely. /// This value is replaced by bandwidth/spread_factor/coding_rate. /// If you'd like to experiment with other options add them to MeshRadio.cpp in the device code. var modemConfig: ChannelSettings.ModemConfig = .bw125Cr45Sf128 /// /// Bandwidth in MHz /// Certain bandwidth numbers are 'special' and will be converted to the /// appropriate floating point value: 31 -> 31.25MHz var bandwidth: UInt32 = 0 /// /// A number from 7 to 12. /// Indicates number of chirps per symbol as 1<=4.2) extension ChannelSettings.ModemConfig: CaseIterable { // The compiler won't synthesize support with the UNRECOGNIZED case. static var allCases: [ChannelSettings.ModemConfig] = [ .bw125Cr45Sf128, .bw500Cr45Sf128, .bw3125Cr48Sf512, .bw125Cr48Sf4096, .bw250Cr46Sf2048, .bw250Cr47Sf1024, ] } #endif // swift(>=4.2) /// /// A pair of a channel number, mode and the (sharable) settings for that channel struct Channel { // 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 index of this channel in the channel table (from 0 to MAX_NUM_CHANNELS-1) /// (Someday - not currently implemented) An index of -1 could be used to mean "set by name", /// in which case the target node will find and set the channel by settings.name. var index: Int32 = 0 /// /// The new settings, or NULL to disable that channel var settings: ChannelSettings { get {return _settings ?? ChannelSettings()} set {_settings = newValue} } /// Returns true if `settings` has been explicitly set. var hasSettings: Bool {return self._settings != nil} /// Clears the value of `settings`. Subsequent reads from it will return its default value. mutating func clearSettings() {self._settings = nil} var role: Channel.Role = .disabled var unknownFields = SwiftProtobuf.UnknownStorage() /// /// How this channel is being used (or not). /// /// Note: this field is an enum to give us options for the future. /// In particular, someday we might make a 'SCANNING' option. /// SCANNING channels could have different frequencies and the radio would /// occasionally check that freq to see if anything is being transmitted. /// /// For devices that have multiple physical radios attached, we could keep multiple PRIMARY/SCANNING channels active at once to allow /// cross band routing as needed. /// If a device has only a single radio (the common case) only one channel can be PRIMARY at a time /// (but any number of SECONDARY channels can't be sent received on that common frequency) enum Role: SwiftProtobuf.Enum { typealias RawValue = Int /// /// This channel is not in use right now case disabled // = 0 /// /// This channel is used to set the frequency for the radio - all other enabled channels must be SECONDARY case primary // = 1 /// /// Secondary channels are only used for encryption/decryption/authentication purposes. /// Their radio settings (freq etc) are ignored, only psk is used. case secondary // = 2 case UNRECOGNIZED(Int) init() { self = .disabled } init?(rawValue: Int) { switch rawValue { case 0: self = .disabled case 1: self = .primary case 2: self = .secondary default: self = .UNRECOGNIZED(rawValue) } } var rawValue: Int { switch self { case .disabled: return 0 case .primary: return 1 case .secondary: return 2 case .UNRECOGNIZED(let i): return i } } } init() {} fileprivate var _settings: ChannelSettings? = nil } #if swift(>=4.2) extension Channel.Role: CaseIterable { // The compiler won't synthesize support with the UNRECOGNIZED case. static var allCases: [Channel.Role] = [ .disabled, .primary, .secondary, ] } #endif // swift(>=4.2) // MARK: - Code below here is support for the SwiftProtobuf runtime. extension ChannelSettings: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { static let protoMessageName: String = "ChannelSettings" static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 1: .standard(proto: "tx_power"), 3: .standard(proto: "modem_config"), 6: .same(proto: "bandwidth"), 7: .standard(proto: "spread_factor"), 8: .standard(proto: "coding_rate"), 9: .standard(proto: "channel_num"), 4: .same(proto: "psk"), 5: .same(proto: "name"), 10: .same(proto: "id"), 16: .standard(proto: "uplink_enabled"), 17: .standard(proto: "downlink_enabled"), ] 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.decodeSingularInt32Field(value: &self.txPower) }() case 3: try { try decoder.decodeSingularEnumField(value: &self.modemConfig) }() case 4: try { try decoder.decodeSingularBytesField(value: &self.psk) }() case 5: try { try decoder.decodeSingularStringField(value: &self.name) }() case 6: try { try decoder.decodeSingularUInt32Field(value: &self.bandwidth) }() case 7: try { try decoder.decodeSingularUInt32Field(value: &self.spreadFactor) }() case 8: try { try decoder.decodeSingularUInt32Field(value: &self.codingRate) }() case 9: try { try decoder.decodeSingularUInt32Field(value: &self.channelNum) }() case 10: try { try decoder.decodeSingularFixed32Field(value: &self.id) }() case 16: try { try decoder.decodeSingularBoolField(value: &self.uplinkEnabled) }() case 17: try { try decoder.decodeSingularBoolField(value: &self.downlinkEnabled) }() default: break } } } func traverse(visitor: inout V) throws { if self.txPower != 0 { try visitor.visitSingularInt32Field(value: self.txPower, fieldNumber: 1) } if self.modemConfig != .bw125Cr45Sf128 { try visitor.visitSingularEnumField(value: self.modemConfig, fieldNumber: 3) } if !self.psk.isEmpty { try visitor.visitSingularBytesField(value: self.psk, fieldNumber: 4) } if !self.name.isEmpty { try visitor.visitSingularStringField(value: self.name, fieldNumber: 5) } if self.bandwidth != 0 { try visitor.visitSingularUInt32Field(value: self.bandwidth, fieldNumber: 6) } if self.spreadFactor != 0 { try visitor.visitSingularUInt32Field(value: self.spreadFactor, fieldNumber: 7) } if self.codingRate != 0 { try visitor.visitSingularUInt32Field(value: self.codingRate, fieldNumber: 8) } if self.channelNum != 0 { try visitor.visitSingularUInt32Field(value: self.channelNum, fieldNumber: 9) } if self.id != 0 { try visitor.visitSingularFixed32Field(value: self.id, fieldNumber: 10) } if self.uplinkEnabled != false { try visitor.visitSingularBoolField(value: self.uplinkEnabled, fieldNumber: 16) } if self.downlinkEnabled != false { try visitor.visitSingularBoolField(value: self.downlinkEnabled, fieldNumber: 17) } try unknownFields.traverse(visitor: &visitor) } static func ==(lhs: ChannelSettings, rhs: ChannelSettings) -> Bool { if lhs.txPower != rhs.txPower {return false} if lhs.modemConfig != rhs.modemConfig {return false} if lhs.bandwidth != rhs.bandwidth {return false} if lhs.spreadFactor != rhs.spreadFactor {return false} if lhs.codingRate != rhs.codingRate {return false} if lhs.channelNum != rhs.channelNum {return false} if lhs.psk != rhs.psk {return false} if lhs.name != rhs.name {return false} if lhs.id != rhs.id {return false} if lhs.uplinkEnabled != rhs.uplinkEnabled {return false} if lhs.downlinkEnabled != rhs.downlinkEnabled {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } } extension ChannelSettings.ModemConfig: SwiftProtobuf._ProtoNameProviding { static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 0: .same(proto: "Bw125Cr45Sf128"), 1: .same(proto: "Bw500Cr45Sf128"), 2: .same(proto: "Bw31_25Cr48Sf512"), 3: .same(proto: "Bw125Cr48Sf4096"), 4: .same(proto: "Bw250Cr46Sf2048"), 5: .same(proto: "Bw250Cr47Sf1024"), ] } extension Channel: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { static let protoMessageName: String = "Channel" static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 1: .same(proto: "index"), 2: .same(proto: "settings"), 3: .same(proto: "role"), ] 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.decodeSingularInt32Field(value: &self.index) }() case 2: try { try decoder.decodeSingularMessageField(value: &self._settings) }() case 3: try { try decoder.decodeSingularEnumField(value: &self.role) }() default: break } } } func traverse(visitor: inout V) throws { if self.index != 0 { try visitor.visitSingularInt32Field(value: self.index, fieldNumber: 1) } if let v = self._settings { try visitor.visitSingularMessageField(value: v, fieldNumber: 2) } if self.role != .disabled { try visitor.visitSingularEnumField(value: self.role, fieldNumber: 3) } try unknownFields.traverse(visitor: &visitor) } static func ==(lhs: Channel, rhs: Channel) -> Bool { if lhs.index != rhs.index {return false} if lhs._settings != rhs._settings {return false} if lhs.role != rhs.role {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } } extension Channel.Role: SwiftProtobuf._ProtoNameProviding { static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 0: .same(proto: "DISABLED"), 1: .same(proto: "PRIMARY"), 2: .same(proto: "SECONDARY"), ] }