From 8c98f818a34f8da77325b8eb7ced4d42f29e0459 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sun, 14 Jan 2024 11:42:38 -0800 Subject: [PATCH] Update protos --- .../Protobufs/meshtastic/admin.pb.swift | 40 ++++++++ .../Protobufs/meshtastic/config.pb.swift | 21 ++++- .../Protobufs/meshtastic/localonly.pb.swift | 19 ++++ .../meshtastic/module_config.pb.swift | 92 +++++++++++++++++++ .../Protobufs/meshtastic/portnums.pb.swift | 9 ++ 5 files changed, 177 insertions(+), 4 deletions(-) diff --git a/Meshtastic/Protobufs/meshtastic/admin.pb.swift b/Meshtastic/Protobufs/meshtastic/admin.pb.swift index 75591fee..ab96c32c 100644 --- a/Meshtastic/Protobufs/meshtastic/admin.pb.swift +++ b/Meshtastic/Protobufs/meshtastic/admin.pb.swift @@ -224,6 +224,17 @@ struct AdminMessage { set {payloadVariant = .getNodeRemoteHardwarePinsResponse(newValue)} } + /// + /// Enter (UF2) DFU mode + /// Only implemented on NRF52 currently + var enterDfuModeRequest: Bool { + get { + if case .enterDfuModeRequest(let v)? = payloadVariant {return v} + return false + } + set {payloadVariant = .enterDfuModeRequest(newValue)} + } + /// /// Set the owner for this node var setOwner: User { @@ -445,6 +456,10 @@ struct AdminMessage { /// Respond with the mesh's nodes with their available gpio pins for RemoteHardware module use case getNodeRemoteHardwarePinsResponse(NodeRemoteHardwarePinsResponse) /// + /// Enter (UF2) DFU mode + /// Only implemented on NRF52 currently + case enterDfuModeRequest(Bool) + /// /// Set the owner for this node case setOwner(User) /// @@ -579,6 +594,10 @@ struct AdminMessage { guard case .getNodeRemoteHardwarePinsResponse(let l) = lhs, case .getNodeRemoteHardwarePinsResponse(let r) = rhs else { preconditionFailure() } return l == r }() + case (.enterDfuModeRequest, .enterDfuModeRequest): return { + guard case .enterDfuModeRequest(let l) = lhs, case .enterDfuModeRequest(let r) = rhs else { preconditionFailure() } + return l == r + }() case (.setOwner, .setOwner): return { guard case .setOwner(let l) = lhs, case .setOwner(let r) = rhs else { preconditionFailure() } return l == r @@ -763,6 +782,10 @@ struct AdminMessage { /// /// TODO: REPLACE case detectionsensorConfig // = 11 + + /// + /// TODO: REPLACE + case paxcounterConfig // = 12 case UNRECOGNIZED(Int) init() { @@ -783,6 +806,7 @@ struct AdminMessage { case 9: self = .neighborinfoConfig case 10: self = .ambientlightingConfig case 11: self = .detectionsensorConfig + case 12: self = .paxcounterConfig default: self = .UNRECOGNIZED(rawValue) } } @@ -801,6 +825,7 @@ struct AdminMessage { case .neighborinfoConfig: return 9 case .ambientlightingConfig: return 10 case .detectionsensorConfig: return 11 + case .paxcounterConfig: return 12 case .UNRECOGNIZED(let i): return i } } @@ -840,6 +865,7 @@ extension AdminMessage.ModuleConfigType: CaseIterable { .neighborinfoConfig, .ambientlightingConfig, .detectionsensorConfig, + .paxcounterConfig, ] } @@ -926,6 +952,7 @@ extension AdminMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat 18: .standard(proto: "set_ham_mode"), 19: .standard(proto: "get_node_remote_hardware_pins_request"), 20: .standard(proto: "get_node_remote_hardware_pins_response"), + 21: .standard(proto: "enter_dfu_mode_request"), 32: .standard(proto: "set_owner"), 33: .standard(proto: "set_channel"), 34: .standard(proto: "set_config"), @@ -1141,6 +1168,14 @@ extension AdminMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat self.payloadVariant = .getNodeRemoteHardwarePinsResponse(v) } }() + case 21: try { + var v: Bool? + try decoder.decodeSingularBoolField(value: &v) + if let v = v { + if self.payloadVariant != nil {try decoder.handleConflictingOneOf()} + self.payloadVariant = .enterDfuModeRequest(v) + } + }() case 32: try { var v: User? var hadOneofValue = false @@ -1368,6 +1403,10 @@ extension AdminMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat guard case .getNodeRemoteHardwarePinsResponse(let v)? = self.payloadVariant else { preconditionFailure() } try visitor.visitSingularMessageField(value: v, fieldNumber: 20) }() + case .enterDfuModeRequest?: try { + guard case .enterDfuModeRequest(let v)? = self.payloadVariant else { preconditionFailure() } + try visitor.visitSingularBoolField(value: v, fieldNumber: 21) + }() case .setOwner?: try { guard case .setOwner(let v)? = self.payloadVariant else { preconditionFailure() } try visitor.visitSingularMessageField(value: v, fieldNumber: 32) @@ -1466,6 +1505,7 @@ extension AdminMessage.ModuleConfigType: SwiftProtobuf._ProtoNameProviding { 9: .same(proto: "NEIGHBORINFO_CONFIG"), 10: .same(proto: "AMBIENTLIGHTING_CONFIG"), 11: .same(proto: "DETECTIONSENSOR_CONFIG"), + 12: .same(proto: "PAXCOUNTER_CONFIG"), ] } diff --git a/Meshtastic/Protobufs/meshtastic/config.pb.swift b/Meshtastic/Protobufs/meshtastic/config.pb.swift index ef91027c..5fc6a263 100644 --- a/Meshtastic/Protobufs/meshtastic/config.pb.swift +++ b/Meshtastic/Protobufs/meshtastic/config.pb.swift @@ -387,10 +387,7 @@ struct Config { var gpsUpdateInterval: UInt32 = 0 /// - /// How long should we try to get our position during each gps_update_interval attempt? (in seconds) - /// Or if zero, use the default of 30 seconds. - /// If we don't get a new gps fix in that time, the gps will be put into sleep until the next gps_update_rate - /// window. + /// Deprecated in favor of using smart / regular broadcast intervals as implicit attempt time var gpsAttemptTime: UInt32 = 0 /// @@ -1115,6 +1112,14 @@ struct Config { /// /// Ukraine 868mhz case ua868 // = 15 + + /// + /// Malaysia 433mhz + case my433 // = 16 + + /// + /// Malaysia 919mhz + case my919 // = 17 case UNRECOGNIZED(Int) init() { @@ -1139,6 +1144,8 @@ struct Config { case 13: self = .lora24 case 14: self = .ua433 case 15: self = .ua868 + case 16: self = .my433 + case 17: self = .my919 default: self = .UNRECOGNIZED(rawValue) } } @@ -1161,6 +1168,8 @@ struct Config { case .lora24: return 13 case .ua433: return 14 case .ua868: return 15 + case .my433: return 16 + case .my919: return 17 case .UNRECOGNIZED(let i): return i } } @@ -1420,6 +1429,8 @@ extension Config.LoRaConfig.RegionCode: CaseIterable { .lora24, .ua433, .ua868, + .my433, + .my919, ] } @@ -2325,6 +2336,8 @@ extension Config.LoRaConfig.RegionCode: SwiftProtobuf._ProtoNameProviding { 13: .same(proto: "LORA_24"), 14: .same(proto: "UA_433"), 15: .same(proto: "UA_868"), + 16: .same(proto: "MY_433"), + 17: .same(proto: "MY_919"), ] } diff --git a/Meshtastic/Protobufs/meshtastic/localonly.pb.swift b/Meshtastic/Protobufs/meshtastic/localonly.pb.swift index 1d96373e..6e215220 100644 --- a/Meshtastic/Protobufs/meshtastic/localonly.pb.swift +++ b/Meshtastic/Protobufs/meshtastic/localonly.pb.swift @@ -255,6 +255,17 @@ struct LocalModuleConfig { /// Clears the value of `detectionSensor`. Subsequent reads from it will return its default value. mutating func clearDetectionSensor() {_uniqueStorage()._detectionSensor = nil} + /// + /// Paxcounter Config + var paxcounter: ModuleConfig.PaxcounterConfig { + get {return _storage._paxcounter ?? ModuleConfig.PaxcounterConfig()} + set {_uniqueStorage()._paxcounter = newValue} + } + /// Returns true if `paxcounter` has been explicitly set. + var hasPaxcounter: Bool {return _storage._paxcounter != nil} + /// Clears the value of `paxcounter`. Subsequent reads from it will return its default value. + mutating func clearPaxcounter() {_uniqueStorage()._paxcounter = nil} + /// /// A version integer used to invalidate old save files when we make /// incompatible changes This integer is set at build time and is private to @@ -419,6 +430,7 @@ extension LocalModuleConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplem 11: .standard(proto: "neighbor_info"), 12: .standard(proto: "ambient_lighting"), 13: .standard(proto: "detection_sensor"), + 14: .same(proto: "paxcounter"), 8: .same(proto: "version"), ] @@ -435,6 +447,7 @@ extension LocalModuleConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplem var _neighborInfo: ModuleConfig.NeighborInfoConfig? = nil var _ambientLighting: ModuleConfig.AmbientLightingConfig? = nil var _detectionSensor: ModuleConfig.DetectionSensorConfig? = nil + var _paxcounter: ModuleConfig.PaxcounterConfig? = nil var _version: UInt32 = 0 static let defaultInstance = _StorageClass() @@ -454,6 +467,7 @@ extension LocalModuleConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplem _neighborInfo = source._neighborInfo _ambientLighting = source._ambientLighting _detectionSensor = source._detectionSensor + _paxcounter = source._paxcounter _version = source._version } } @@ -486,6 +500,7 @@ extension LocalModuleConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplem case 11: try { try decoder.decodeSingularMessageField(value: &_storage._neighborInfo) }() case 12: try { try decoder.decodeSingularMessageField(value: &_storage._ambientLighting) }() case 13: try { try decoder.decodeSingularMessageField(value: &_storage._detectionSensor) }() + case 14: try { try decoder.decodeSingularMessageField(value: &_storage._paxcounter) }() default: break } } @@ -537,6 +552,9 @@ extension LocalModuleConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplem try { if let v = _storage._detectionSensor { try visitor.visitSingularMessageField(value: v, fieldNumber: 13) } }() + try { if let v = _storage._paxcounter { + try visitor.visitSingularMessageField(value: v, fieldNumber: 14) + } }() } try unknownFields.traverse(visitor: &visitor) } @@ -558,6 +576,7 @@ extension LocalModuleConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplem if _storage._neighborInfo != rhs_storage._neighborInfo {return false} if _storage._ambientLighting != rhs_storage._ambientLighting {return false} if _storage._detectionSensor != rhs_storage._detectionSensor {return false} + if _storage._paxcounter != rhs_storage._paxcounter {return false} if _storage._version != rhs_storage._version {return false} return true } diff --git a/Meshtastic/Protobufs/meshtastic/module_config.pb.swift b/Meshtastic/Protobufs/meshtastic/module_config.pb.swift index b1720e41..3aee0200 100644 --- a/Meshtastic/Protobufs/meshtastic/module_config.pb.swift +++ b/Meshtastic/Protobufs/meshtastic/module_config.pb.swift @@ -204,6 +204,16 @@ struct ModuleConfig { set {payloadVariant = .detectionSensor(newValue)} } + /// + /// TODO: REPLACE + var paxcounter: ModuleConfig.PaxcounterConfig { + get { + if case .paxcounter(let v)? = payloadVariant {return v} + return ModuleConfig.PaxcounterConfig() + } + set {payloadVariant = .paxcounter(newValue)} + } + var unknownFields = SwiftProtobuf.UnknownStorage() /// @@ -245,6 +255,9 @@ struct ModuleConfig { /// /// TODO: REPLACE case detectionSensor(ModuleConfig.DetectionSensorConfig) + /// + /// TODO: REPLACE + case paxcounter(ModuleConfig.PaxcounterConfig) #if !swift(>=4.1) static func ==(lhs: ModuleConfig.OneOf_PayloadVariant, rhs: ModuleConfig.OneOf_PayloadVariant) -> Bool { @@ -300,6 +313,10 @@ struct ModuleConfig { guard case .detectionSensor(let l) = lhs, case .detectionSensor(let r) = rhs else { preconditionFailure() } return l == r }() + case (.paxcounter, .paxcounter): return { + guard case .paxcounter(let l) = lhs, case .paxcounter(let r) = rhs else { preconditionFailure() } + return l == r + }() default: return false } } @@ -551,6 +568,24 @@ struct ModuleConfig { init() {} } + /// + /// Config for the Paxcounter Module + struct PaxcounterConfig { + // 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. + + /// + /// Enable the Paxcounter Module + var enabled: Bool = false + + var paxcounterUpdateInterval: UInt32 = 0 + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + } + /// /// Serial Config struct SerialConfig { @@ -1177,6 +1212,7 @@ extension ModuleConfig.NeighborInfoConfig: @unchecked Sendable {} extension ModuleConfig.DetectionSensorConfig: @unchecked Sendable {} extension ModuleConfig.AudioConfig: @unchecked Sendable {} extension ModuleConfig.AudioConfig.Audio_Baud: @unchecked Sendable {} +extension ModuleConfig.PaxcounterConfig: @unchecked Sendable {} extension ModuleConfig.SerialConfig: @unchecked Sendable {} extension ModuleConfig.SerialConfig.Serial_Baud: @unchecked Sendable {} extension ModuleConfig.SerialConfig.Serial_Mode: @unchecked Sendable {} @@ -1217,6 +1253,7 @@ extension ModuleConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat 10: .standard(proto: "neighbor_info"), 11: .standard(proto: "ambient_lighting"), 12: .standard(proto: "detection_sensor"), + 13: .same(proto: "paxcounter"), ] mutating func decodeMessage(decoder: inout D) throws { @@ -1381,6 +1418,19 @@ extension ModuleConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat self.payloadVariant = .detectionSensor(v) } }() + case 13: try { + var v: ModuleConfig.PaxcounterConfig? + var hadOneofValue = false + if let current = self.payloadVariant { + hadOneofValue = true + if case .paxcounter(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payloadVariant = .paxcounter(v) + } + }() default: break } } @@ -1440,6 +1490,10 @@ extension ModuleConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat guard case .detectionSensor(let v)? = self.payloadVariant else { preconditionFailure() } try visitor.visitSingularMessageField(value: v, fieldNumber: 12) }() + case .paxcounter?: try { + guard case .paxcounter(let v)? = self.payloadVariant else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 13) + }() case nil: break } try unknownFields.traverse(visitor: &visitor) @@ -1770,6 +1824,44 @@ extension ModuleConfig.AudioConfig.Audio_Baud: SwiftProtobuf._ProtoNameProviding ] } +extension ModuleConfig.PaxcounterConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = ModuleConfig.protoMessageName + ".PaxcounterConfig" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "enabled"), + 2: .standard(proto: "paxcounter_update_interval"), + ] + + 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.decodeSingularBoolField(value: &self.enabled) }() + case 2: try { try decoder.decodeSingularUInt32Field(value: &self.paxcounterUpdateInterval) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if self.enabled != false { + try visitor.visitSingularBoolField(value: self.enabled, fieldNumber: 1) + } + if self.paxcounterUpdateInterval != 0 { + try visitor.visitSingularUInt32Field(value: self.paxcounterUpdateInterval, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: ModuleConfig.PaxcounterConfig, rhs: ModuleConfig.PaxcounterConfig) -> Bool { + if lhs.enabled != rhs.enabled {return false} + if lhs.paxcounterUpdateInterval != rhs.paxcounterUpdateInterval {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + extension ModuleConfig.SerialConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { static let protoMessageName: String = ModuleConfig.protoMessageName + ".SerialConfig" static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ diff --git a/Meshtastic/Protobufs/meshtastic/portnums.pb.swift b/Meshtastic/Protobufs/meshtastic/portnums.pb.swift index 6c32de74..319d48f9 100644 --- a/Meshtastic/Protobufs/meshtastic/portnums.pb.swift +++ b/Meshtastic/Protobufs/meshtastic/portnums.pb.swift @@ -118,6 +118,11 @@ enum PortNum: SwiftProtobuf.Enum { /// ENCODING: IP Packet. Handled by the python API, firmware ignores this one and pases on. case ipTunnelApp // = 33 + /// + /// Paxcounter lib included in the firmware + /// ENCODING: protobuf + case paxcounterApp // = 34 + /// /// Provides a hardware serial interface to send and receive from the Meshtastic network. /// Connect to the RX/TX pins of a device with 38400 8N1. Packets received from the Meshtastic @@ -206,6 +211,7 @@ enum PortNum: SwiftProtobuf.Enum { case 10: self = .detectionSensorApp case 32: self = .replyApp case 33: self = .ipTunnelApp + case 34: self = .paxcounterApp case 64: self = .serialApp case 65: self = .storeForwardApp case 66: self = .rangeTestApp @@ -236,6 +242,7 @@ enum PortNum: SwiftProtobuf.Enum { case .detectionSensorApp: return 10 case .replyApp: return 32 case .ipTunnelApp: return 33 + case .paxcounterApp: return 34 case .serialApp: return 64 case .storeForwardApp: return 65 case .rangeTestApp: return 66 @@ -271,6 +278,7 @@ extension PortNum: CaseIterable { .detectionSensorApp, .replyApp, .ipTunnelApp, + .paxcounterApp, .serialApp, .storeForwardApp, .rangeTestApp, @@ -308,6 +316,7 @@ extension PortNum: SwiftProtobuf._ProtoNameProviding { 10: .same(proto: "DETECTION_SENSOR_APP"), 32: .same(proto: "REPLY_APP"), 33: .same(proto: "IP_TUNNEL_APP"), + 34: .same(proto: "PAXCOUNTER_APP"), 64: .same(proto: "SERIAL_APP"), 65: .same(proto: "STORE_FORWARD_APP"), 66: .same(proto: "RANGE_TEST_APP"),