From 39c802dd69b0a5d94066933c809240f91c1b7a5e Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Thu, 17 Aug 2023 08:46:10 -0700 Subject: [PATCH] Update protos --- .../Protobufs/meshtastic/admin.pb.swift | 8 + .../Protobufs/meshtastic/config.pb.swift | 16 +- .../Protobufs/meshtastic/localonly.pb.swift | 38 +++++ Meshtastic/Protobufs/meshtastic/mesh.pb.swift | 10 +- .../meshtastic/module_config.pb.swift | 161 ++++++++++++++++++ 5 files changed, 217 insertions(+), 16 deletions(-) diff --git a/Meshtastic/Protobufs/meshtastic/admin.pb.swift b/Meshtastic/Protobufs/meshtastic/admin.pb.swift index 88ab0f6d..50934353 100644 --- a/Meshtastic/Protobufs/meshtastic/admin.pb.swift +++ b/Meshtastic/Protobufs/meshtastic/admin.pb.swift @@ -742,6 +742,10 @@ struct AdminMessage { /// /// TODO: REPLACE case ambientlightingConfig // = 10 + + /// + /// TODO: REPLACE + case detectionsensorConfig // = 11 case UNRECOGNIZED(Int) init() { @@ -761,6 +765,7 @@ struct AdminMessage { case 8: self = .remotehardwareConfig case 9: self = .neighborinfoConfig case 10: self = .ambientlightingConfig + case 11: self = .detectionsensorConfig default: self = .UNRECOGNIZED(rawValue) } } @@ -778,6 +783,7 @@ struct AdminMessage { case .remotehardwareConfig: return 8 case .neighborinfoConfig: return 9 case .ambientlightingConfig: return 10 + case .detectionsensorConfig: return 11 case .UNRECOGNIZED(let i): return i } } @@ -816,6 +822,7 @@ extension AdminMessage.ModuleConfigType: CaseIterable { .remotehardwareConfig, .neighborinfoConfig, .ambientlightingConfig, + .detectionsensorConfig, ] } @@ -1428,6 +1435,7 @@ extension AdminMessage.ModuleConfigType: SwiftProtobuf._ProtoNameProviding { 8: .same(proto: "REMOTEHARDWARE_CONFIG"), 9: .same(proto: "NEIGHBORINFO_CONFIG"), 10: .same(proto: "AMBIENTLIGHTING_CONFIG"), + 11: .same(proto: "DETECTIONSENSOR_CONFIG"), ] } diff --git a/Meshtastic/Protobufs/meshtastic/config.pb.swift b/Meshtastic/Protobufs/meshtastic/config.pb.swift index 2b7b5c1d..f327d250 100644 --- a/Meshtastic/Protobufs/meshtastic/config.pb.swift +++ b/Meshtastic/Protobufs/meshtastic/config.pb.swift @@ -368,7 +368,7 @@ struct Config { var broadcastSmartMinimumDistance: UInt32 = 0 /// - /// The minumum number of seconds (since the last send) before we can send a position to the mesh if position_broadcast_smart_enabled + /// The minimum number of seconds (since the last send) before we can send a position to the mesh if position_broadcast_smart_enabled var broadcastSmartMinimumIntervalSecs: UInt32 = 0 var unknownFields = SwiftProtobuf.UnknownStorage() @@ -506,14 +506,6 @@ struct Config { /// 0 for default of 1 minute var waitBluetoothSecs: UInt32 = 0 - /// - /// Deprecated in 2.1.X - /// Mesh Super Deep Sleep Timeout Seconds - /// While in Light Sleep if this value is exceeded we will lower into super deep sleep - /// for sds_secs (default 1 year) or a button press - /// 0 for default of two hours, MAXUINT for disabled - var meshSdsTimeoutSecs: UInt32 = 0 - /// /// Super Deep Sleep Seconds /// While in Light Sleep if mesh_sds_timeout_secs is exceeded we will lower into super deep sleep @@ -1806,7 +1798,6 @@ extension Config.PowerConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImple 2: .standard(proto: "on_battery_shutdown_after_secs"), 3: .standard(proto: "adc_multiplier_override"), 4: .standard(proto: "wait_bluetooth_secs"), - 5: .standard(proto: "mesh_sds_timeout_secs"), 6: .standard(proto: "sds_secs"), 7: .standard(proto: "ls_secs"), 8: .standard(proto: "min_wake_secs"), @@ -1823,7 +1814,6 @@ extension Config.PowerConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImple case 2: try { try decoder.decodeSingularUInt32Field(value: &self.onBatteryShutdownAfterSecs) }() case 3: try { try decoder.decodeSingularFloatField(value: &self.adcMultiplierOverride) }() case 4: try { try decoder.decodeSingularUInt32Field(value: &self.waitBluetoothSecs) }() - case 5: try { try decoder.decodeSingularUInt32Field(value: &self.meshSdsTimeoutSecs) }() case 6: try { try decoder.decodeSingularUInt32Field(value: &self.sdsSecs) }() case 7: try { try decoder.decodeSingularUInt32Field(value: &self.lsSecs) }() case 8: try { try decoder.decodeSingularUInt32Field(value: &self.minWakeSecs) }() @@ -1846,9 +1836,6 @@ extension Config.PowerConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImple if self.waitBluetoothSecs != 0 { try visitor.visitSingularUInt32Field(value: self.waitBluetoothSecs, fieldNumber: 4) } - if self.meshSdsTimeoutSecs != 0 { - try visitor.visitSingularUInt32Field(value: self.meshSdsTimeoutSecs, fieldNumber: 5) - } if self.sdsSecs != 0 { try visitor.visitSingularUInt32Field(value: self.sdsSecs, fieldNumber: 6) } @@ -1869,7 +1856,6 @@ extension Config.PowerConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImple if lhs.onBatteryShutdownAfterSecs != rhs.onBatteryShutdownAfterSecs {return false} if lhs.adcMultiplierOverride != rhs.adcMultiplierOverride {return false} if lhs.waitBluetoothSecs != rhs.waitBluetoothSecs {return false} - if lhs.meshSdsTimeoutSecs != rhs.meshSdsTimeoutSecs {return false} if lhs.sdsSecs != rhs.sdsSecs {return false} if lhs.lsSecs != rhs.lsSecs {return false} if lhs.minWakeSecs != rhs.minWakeSecs {return false} diff --git a/Meshtastic/Protobufs/meshtastic/localonly.pb.swift b/Meshtastic/Protobufs/meshtastic/localonly.pb.swift index 219e3728..1d96373e 100644 --- a/Meshtastic/Protobufs/meshtastic/localonly.pb.swift +++ b/Meshtastic/Protobufs/meshtastic/localonly.pb.swift @@ -233,6 +233,28 @@ struct LocalModuleConfig { /// Clears the value of `neighborInfo`. Subsequent reads from it will return its default value. mutating func clearNeighborInfo() {_uniqueStorage()._neighborInfo = nil} + /// + /// The part of the config that is specific to the Ambient Lighting module + var ambientLighting: ModuleConfig.AmbientLightingConfig { + get {return _storage._ambientLighting ?? ModuleConfig.AmbientLightingConfig()} + set {_uniqueStorage()._ambientLighting = newValue} + } + /// Returns true if `ambientLighting` has been explicitly set. + var hasAmbientLighting: Bool {return _storage._ambientLighting != nil} + /// Clears the value of `ambientLighting`. Subsequent reads from it will return its default value. + mutating func clearAmbientLighting() {_uniqueStorage()._ambientLighting = nil} + + /// + /// The part of the config that is specific to the Detection Sensor module + var detectionSensor: ModuleConfig.DetectionSensorConfig { + get {return _storage._detectionSensor ?? ModuleConfig.DetectionSensorConfig()} + set {_uniqueStorage()._detectionSensor = newValue} + } + /// Returns true if `detectionSensor` has been explicitly set. + var hasDetectionSensor: Bool {return _storage._detectionSensor != nil} + /// Clears the value of `detectionSensor`. Subsequent reads from it will return its default value. + mutating func clearDetectionSensor() {_uniqueStorage()._detectionSensor = 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 @@ -395,6 +417,8 @@ extension LocalModuleConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplem 9: .same(proto: "audio"), 10: .standard(proto: "remote_hardware"), 11: .standard(proto: "neighbor_info"), + 12: .standard(proto: "ambient_lighting"), + 13: .standard(proto: "detection_sensor"), 8: .same(proto: "version"), ] @@ -409,6 +433,8 @@ extension LocalModuleConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplem var _audio: ModuleConfig.AudioConfig? = nil var _remoteHardware: ModuleConfig.RemoteHardwareConfig? = nil var _neighborInfo: ModuleConfig.NeighborInfoConfig? = nil + var _ambientLighting: ModuleConfig.AmbientLightingConfig? = nil + var _detectionSensor: ModuleConfig.DetectionSensorConfig? = nil var _version: UInt32 = 0 static let defaultInstance = _StorageClass() @@ -426,6 +452,8 @@ extension LocalModuleConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplem _audio = source._audio _remoteHardware = source._remoteHardware _neighborInfo = source._neighborInfo + _ambientLighting = source._ambientLighting + _detectionSensor = source._detectionSensor _version = source._version } } @@ -456,6 +484,8 @@ extension LocalModuleConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplem case 9: try { try decoder.decodeSingularMessageField(value: &_storage._audio) }() case 10: try { try decoder.decodeSingularMessageField(value: &_storage._remoteHardware) }() 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) }() default: break } } @@ -501,6 +531,12 @@ extension LocalModuleConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplem try { if let v = _storage._neighborInfo { try visitor.visitSingularMessageField(value: v, fieldNumber: 11) } }() + try { if let v = _storage._ambientLighting { + try visitor.visitSingularMessageField(value: v, fieldNumber: 12) + } }() + try { if let v = _storage._detectionSensor { + try visitor.visitSingularMessageField(value: v, fieldNumber: 13) + } }() } try unknownFields.traverse(visitor: &visitor) } @@ -520,6 +556,8 @@ extension LocalModuleConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplem if _storage._audio != rhs_storage._audio {return false} if _storage._remoteHardware != rhs_storage._remoteHardware {return false} 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._version != rhs_storage._version {return false} return true } diff --git a/Meshtastic/Protobufs/meshtastic/mesh.pb.swift b/Meshtastic/Protobufs/meshtastic/mesh.pb.swift index 3b759f18..959ef2c2 100644 --- a/Meshtastic/Protobufs/meshtastic/mesh.pb.swift +++ b/Meshtastic/Protobufs/meshtastic/mesh.pb.swift @@ -106,6 +106,10 @@ enum HardwareModel: SwiftProtobuf.Enum { /// B&Q Consulting Nano G2 Ultra: https://wiki.uniteng.com/en/meshtastic/nano-g2-ultra case nanoG2Ultra // = 18 + /// + /// LoRAType device: https://loratype.org/ + case loraType // = 19 + /// /// B&Q Consulting Station Edition G1: https://uniteng.com/wiki/doku.php?id=meshtastic:station case stationG1 // = 25 @@ -232,6 +236,7 @@ enum HardwareModel: SwiftProtobuf.Enum { case 16: self = .tloraT3S3 case 17: self = .nanoG1Explorer case 18: self = .nanoG2Ultra + case 19: self = .loraType case 25: self = .stationG1 case 26: self = .rak11310 case 32: self = .loraRelayV1 @@ -281,6 +286,7 @@ enum HardwareModel: SwiftProtobuf.Enum { case .tloraT3S3: return 16 case .nanoG1Explorer: return 17 case .nanoG2Ultra: return 18 + case .loraType: return 19 case .stationG1: return 25 case .rak11310: return 26 case .loraRelayV1: return 32 @@ -335,6 +341,7 @@ extension HardwareModel: CaseIterable { .tloraT3S3, .nanoG1Explorer, .nanoG2Ultra, + .loraType, .stationG1, .rak11310, .loraRelayV1, @@ -462,7 +469,7 @@ enum CriticalErrorCode: SwiftProtobuf.Enum { case transmitFailed // = 8 /// - /// We detected that the main CPU voltage dropped below the minumum acceptable value + /// We detected that the main CPU voltage dropped below the minimum acceptable value case brownout // = 9 /// Selftest of SX1262 radio chip failed @@ -2496,6 +2503,7 @@ extension HardwareModel: SwiftProtobuf._ProtoNameProviding { 16: .same(proto: "TLORA_T3_S3"), 17: .same(proto: "NANO_G1_EXPLORER"), 18: .same(proto: "NANO_G2_ULTRA"), + 19: .same(proto: "LORA_TYPE"), 25: .same(proto: "STATION_G1"), 26: .same(proto: "RAK11310"), 32: .same(proto: "LORA_RELAY_V1"), diff --git a/Meshtastic/Protobufs/meshtastic/module_config.pb.swift b/Meshtastic/Protobufs/meshtastic/module_config.pb.swift index fa696bdc..5fae17a2 100644 --- a/Meshtastic/Protobufs/meshtastic/module_config.pb.swift +++ b/Meshtastic/Protobufs/meshtastic/module_config.pb.swift @@ -194,6 +194,16 @@ struct ModuleConfig { set {payloadVariant = .ambientLighting(newValue)} } + /// + /// TODO: REPLACE + var detectionSensor: ModuleConfig.DetectionSensorConfig { + get { + if case .detectionSensor(let v)? = payloadVariant {return v} + return ModuleConfig.DetectionSensorConfig() + } + set {payloadVariant = .detectionSensor(newValue)} + } + var unknownFields = SwiftProtobuf.UnknownStorage() /// @@ -232,6 +242,9 @@ struct ModuleConfig { /// /// TODO: REPLACE case ambientLighting(ModuleConfig.AmbientLightingConfig) + /// + /// TODO: REPLACE + case detectionSensor(ModuleConfig.DetectionSensorConfig) #if !swift(>=4.1) static func ==(lhs: ModuleConfig.OneOf_PayloadVariant, rhs: ModuleConfig.OneOf_PayloadVariant) -> Bool { @@ -283,6 +296,10 @@ struct ModuleConfig { guard case .ambientLighting(let l) = lhs, case .ambientLighting(let r) = rhs else { preconditionFailure() } return l == r }() + case (.detectionSensor, .detectionSensor): return { + guard case .detectionSensor(let l) = lhs, case .detectionSensor(let r) = rhs else { preconditionFailure() } + return l == r + }() default: return false } } @@ -392,6 +409,57 @@ struct ModuleConfig { init() {} } + /// + /// Detection Sensor Module Config + struct DetectionSensorConfig { + // 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. + + /// + /// Whether the Module is enabled + var enabled: Bool = false + + /// + /// Interval in seconds of how often we can send a message to the mesh when a state change is detected + var minimumBroadcastSecs: UInt32 = 0 + + /// + /// Interval in seconds of how often we should send a message to the mesh with the current state regardless of changes + /// When set to 0, only state changes will be broadcasted + /// Works as a sort of status heartbeat for peace of mind + var stateBroadcastSecs: UInt32 = 0 + + /// + /// Send ASCII bell with alert message + /// Useful for triggering ext. notification on bell + var sendBell: Bool = false + + /// + /// Friendly name used to format message sent to mesh + /// Example: A name "Motion" would result in a message "Motion detected" + /// Maximum length of 20 characters + var name: String = String() + + /// + /// GPIO pin to monitor for state changes + var monitorPin: UInt32 = 0 + + /// + /// Whether or not the GPIO pin state detection is triggered on HIGH (1) + /// Otherwise LOW (0) + var detectionTriggeredHigh: Bool = false + + /// + /// Whether or not use INPUT_PULLUP mode for GPIO pin + /// Only applicable if the board uses pull-up resistors on the pin + var usePullup: Bool = false + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} + } + /// /// Audio Config for codec2 voice struct AudioConfig { @@ -1080,6 +1148,7 @@ extension ModuleConfig.OneOf_PayloadVariant: @unchecked Sendable {} extension ModuleConfig.MQTTConfig: @unchecked Sendable {} extension ModuleConfig.RemoteHardwareConfig: @unchecked Sendable {} extension ModuleConfig.NeighborInfoConfig: @unchecked Sendable {} +extension ModuleConfig.DetectionSensorConfig: @unchecked Sendable {} extension ModuleConfig.AudioConfig: @unchecked Sendable {} extension ModuleConfig.AudioConfig.Audio_Baud: @unchecked Sendable {} extension ModuleConfig.SerialConfig: @unchecked Sendable {} @@ -1121,6 +1190,7 @@ extension ModuleConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat 9: .standard(proto: "remote_hardware"), 10: .standard(proto: "neighbor_info"), 11: .standard(proto: "ambient_lighting"), + 12: .standard(proto: "detection_sensor"), ] mutating func decodeMessage(decoder: inout D) throws { @@ -1272,6 +1342,19 @@ extension ModuleConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat self.payloadVariant = .ambientLighting(v) } }() + case 12: try { + var v: ModuleConfig.DetectionSensorConfig? + var hadOneofValue = false + if let current = self.payloadVariant { + hadOneofValue = true + if case .detectionSensor(let m) = current {v = m} + } + try decoder.decodeSingularMessageField(value: &v) + if let v = v { + if hadOneofValue {try decoder.handleConflictingOneOf()} + self.payloadVariant = .detectionSensor(v) + } + }() default: break } } @@ -1327,6 +1410,10 @@ extension ModuleConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementat guard case .ambientLighting(let v)? = self.payloadVariant else { preconditionFailure() } try visitor.visitSingularMessageField(value: v, fieldNumber: 11) }() + case .detectionSensor?: try { + guard case .detectionSensor(let v)? = self.payloadVariant else { preconditionFailure() } + try visitor.visitSingularMessageField(value: v, fieldNumber: 12) + }() case nil: break } try unknownFields.traverse(visitor: &visitor) @@ -1501,6 +1588,80 @@ extension ModuleConfig.NeighborInfoConfig: SwiftProtobuf.Message, SwiftProtobuf. } } +extension ModuleConfig.DetectionSensorConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = ModuleConfig.protoMessageName + ".DetectionSensorConfig" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "enabled"), + 2: .standard(proto: "minimum_broadcast_secs"), + 3: .standard(proto: "state_broadcast_secs"), + 4: .standard(proto: "send_bell"), + 5: .same(proto: "name"), + 6: .standard(proto: "monitor_pin"), + 7: .standard(proto: "detection_triggered_high"), + 8: .standard(proto: "use_pullup"), + ] + + 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.minimumBroadcastSecs) }() + case 3: try { try decoder.decodeSingularUInt32Field(value: &self.stateBroadcastSecs) }() + case 4: try { try decoder.decodeSingularBoolField(value: &self.sendBell) }() + case 5: try { try decoder.decodeSingularStringField(value: &self.name) }() + case 6: try { try decoder.decodeSingularUInt32Field(value: &self.monitorPin) }() + case 7: try { try decoder.decodeSingularBoolField(value: &self.detectionTriggeredHigh) }() + case 8: try { try decoder.decodeSingularBoolField(value: &self.usePullup) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if self.enabled != false { + try visitor.visitSingularBoolField(value: self.enabled, fieldNumber: 1) + } + if self.minimumBroadcastSecs != 0 { + try visitor.visitSingularUInt32Field(value: self.minimumBroadcastSecs, fieldNumber: 2) + } + if self.stateBroadcastSecs != 0 { + try visitor.visitSingularUInt32Field(value: self.stateBroadcastSecs, fieldNumber: 3) + } + if self.sendBell != false { + try visitor.visitSingularBoolField(value: self.sendBell, fieldNumber: 4) + } + if !self.name.isEmpty { + try visitor.visitSingularStringField(value: self.name, fieldNumber: 5) + } + if self.monitorPin != 0 { + try visitor.visitSingularUInt32Field(value: self.monitorPin, fieldNumber: 6) + } + if self.detectionTriggeredHigh != false { + try visitor.visitSingularBoolField(value: self.detectionTriggeredHigh, fieldNumber: 7) + } + if self.usePullup != false { + try visitor.visitSingularBoolField(value: self.usePullup, fieldNumber: 8) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: ModuleConfig.DetectionSensorConfig, rhs: ModuleConfig.DetectionSensorConfig) -> Bool { + if lhs.enabled != rhs.enabled {return false} + if lhs.minimumBroadcastSecs != rhs.minimumBroadcastSecs {return false} + if lhs.stateBroadcastSecs != rhs.stateBroadcastSecs {return false} + if lhs.sendBell != rhs.sendBell {return false} + if lhs.name != rhs.name {return false} + if lhs.monitorPin != rhs.monitorPin {return false} + if lhs.detectionTriggeredHigh != rhs.detectionTriggeredHigh {return false} + if lhs.usePullup != rhs.usePullup {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + extension ModuleConfig.AudioConfig: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { static let protoMessageName: String = ModuleConfig.protoMessageName + ".AudioConfig" static let _protobuf_nameMap: SwiftProtobuf._NameMap = [