From 049d2d251f85842d5024653e1ea61350e401dc01 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sat, 17 Sep 2022 12:45:34 -0700 Subject: [PATCH 1/2] Add updated proto --- Meshtastic/Protobufs/module_config.pb.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Meshtastic/Protobufs/module_config.pb.swift b/Meshtastic/Protobufs/module_config.pb.swift index c9626648..832dc69a 100644 --- a/Meshtastic/Protobufs/module_config.pb.swift +++ b/Meshtastic/Protobufs/module_config.pb.swift @@ -330,6 +330,7 @@ struct ModuleConfig { case `default` // = 0 case simple // = 1 case proto // = 2 + case textmsg // = 3 case UNRECOGNIZED(Int) init() { @@ -341,6 +342,7 @@ struct ModuleConfig { case 0: self = .default case 1: self = .simple case 2: self = .proto + case 3: self = .textmsg default: self = .UNRECOGNIZED(rawValue) } } @@ -350,6 +352,7 @@ struct ModuleConfig { case .default: return 0 case .simple: return 1 case .proto: return 2 + case .textmsg: return 3 case .UNRECOGNIZED(let i): return i } } @@ -649,6 +652,7 @@ extension ModuleConfig.SerialConfig.Serial_Mode: CaseIterable { .default, .simple, .proto, + .textmsg, ] } @@ -1001,6 +1005,7 @@ extension ModuleConfig.SerialConfig.Serial_Mode: SwiftProtobuf._ProtoNameProvidi 0: .same(proto: "DEFAULT"), 1: .same(proto: "SIMPLE"), 2: .same(proto: "PROTO"), + 3: .same(proto: "TEXTMSG"), ] } From 3cbf8adbd1f2d879fa8f085d56a4064aa5498736 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sun, 18 Sep 2022 08:56:08 -0700 Subject: [PATCH 2/2] Update data model to include lora config values --- Meshtastic.xcodeproj/project.pbxproj | 4 +- Meshtastic/Helpers/MeshPackets.swift | 14 ++ .../Meshtastic.xcdatamodeld/.xccurrentversion | 2 +- .../contents | 219 ++++++++++++++++++ .../Views/Settings/Config/LoRaConfig.swift | 5 + .../Settings/Config/Module/MQTTConfig.swift | 2 +- 6 files changed, 243 insertions(+), 3 deletions(-) create mode 100644 Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModel v 12.xcdatamodel/contents diff --git a/Meshtastic.xcodeproj/project.pbxproj b/Meshtastic.xcodeproj/project.pbxproj index a59a61fd..a30f1345 100644 --- a/Meshtastic.xcodeproj/project.pbxproj +++ b/Meshtastic.xcodeproj/project.pbxproj @@ -177,6 +177,7 @@ DD90860D26F69BAE00DC5189 /* NodeMap.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NodeMap.swift; sourceTree = ""; }; DD913638270DFF4C00D7ACF3 /* LocalNotificationManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalNotificationManager.swift; sourceTree = ""; }; DD9D8F2E2764403B00080993 /* CoreDataSample.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = CoreDataSample.xcdatamodel; sourceTree = ""; }; + DDA1C48528D77310009933EC /* MeshtasticDataModel v 12.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "MeshtasticDataModel v 12.xcdatamodel"; sourceTree = ""; }; DDA6B2E828419CF2003E8C16 /* MeshPackets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MeshPackets.swift; sourceTree = ""; }; DDA6B2EA28420A7B003E8C16 /* NodeAnnotation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NodeAnnotation.swift; sourceTree = ""; }; DDAF8C5226EB1DF10058C060 /* BLEManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BLEManager.swift; sourceTree = ""; }; @@ -1163,6 +1164,7 @@ DD9D8F2D2764403B00080993 /* Meshtastic.xcdatamodeld */ = { isa = XCVersionGroup; children = ( + DDA1C48528D77310009933EC /* MeshtasticDataModel v 12.xcdatamodel */, DD1925B528CD591B00720036 /* MeshtasticDataModel v 11.xcdatamodel */, DD2160AD28C5536B00C17253 /* MeshtasticDataModel v 10.xcdatamodel */, DD5929A528C0F292003DB21D /* MeshtasticDataModel v 9.xcdatamodel */, @@ -1175,7 +1177,7 @@ DD45C77427BD4EF80011784F /* MeshtasticDataModel v2.xcdatamodel */, DD9D8F2E2764403B00080993 /* CoreDataSample.xcdatamodel */, ); - currentVersion = DD1925B528CD591B00720036 /* MeshtasticDataModel v 11.xcdatamodel */; + currentVersion = DDA1C48528D77310009933EC /* MeshtasticDataModel v 12.xcdatamodel */; name = Meshtastic.xcdatamodeld; path = Meshtastic/Meshtastic.xcdatamodeld; sourceTree = ""; diff --git a/Meshtastic/Helpers/MeshPackets.swift b/Meshtastic/Helpers/MeshPackets.swift index abf5baf4..af928ad7 100644 --- a/Meshtastic/Helpers/MeshPackets.swift +++ b/Meshtastic/Helpers/MeshPackets.swift @@ -197,6 +197,13 @@ func localConfig (config: Config, meshlogging: Bool, context:NSManagedObjectCont newLoRaConfig.modemPreset = Int32(config.lora.modemPreset.rawValue) newLoRaConfig.hopLimit = Int32(config.lora.hopLimit) newLoRaConfig.txPower = Int32(config.lora.txPower) + newLoRaConfig.txEnabled = config.lora.txEnabled + newLoRaConfig.usePreset = config.lora.usePreset + newLoRaConfig.bandwidth = Int32(config.lora.bandwidth) + newLoRaConfig.spreadFactor = Int32(config.lora.spreadFactor) + newLoRaConfig.codingRate = Int32(config.lora.codingRate) + newLoRaConfig.spreadFactor = Int32(config.lora.spreadFactor) + newLoRaConfig.frequencyOffset = Int32(config.lora.frequencyOffset) fetchedNode[0].loRaConfig = newLoRaConfig @@ -206,6 +213,13 @@ func localConfig (config: Config, meshlogging: Bool, context:NSManagedObjectCont fetchedNode[0].loRaConfig?.modemPreset = Int32(config.lora.modemPreset.rawValue) fetchedNode[0].loRaConfig?.hopLimit = Int32(config.lora.hopLimit) fetchedNode[0].loRaConfig?.txPower = Int32(config.lora.txPower) + fetchedNode[0].loRaConfig?.txEnabled = config.lora.txEnabled + fetchedNode[0].loRaConfig?.usePreset = config.lora.usePreset + fetchedNode[0].loRaConfig?.bandwidth = Int32(config.lora.bandwidth) + fetchedNode[0].loRaConfig?.spreadFactor = Int32(config.lora.spreadFactor) + fetchedNode[0].loRaConfig?.codingRate = Int32(config.lora.codingRate) + fetchedNode[0].loRaConfig?.spreadFactor = Int32(config.lora.spreadFactor) + fetchedNode[0].loRaConfig?.frequencyOffset = Int32(config.lora.frequencyOffset) } do { diff --git a/Meshtastic/Meshtastic.xcdatamodeld/.xccurrentversion b/Meshtastic/Meshtastic.xcdatamodeld/.xccurrentversion index 0d87f123..8c5ea2ac 100644 --- a/Meshtastic/Meshtastic.xcdatamodeld/.xccurrentversion +++ b/Meshtastic/Meshtastic.xcdatamodeld/.xccurrentversion @@ -3,6 +3,6 @@ _XCCurrentVersionName - MeshtasticDataModel v 11.xcdatamodel + MeshtasticDataModel v 12.xcdatamodel diff --git a/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModel v 12.xcdatamodel/contents b/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModel v 12.xcdatamodel/contents new file mode 100644 index 00000000..225e9842 --- /dev/null +++ b/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModel v 12.xcdatamodel/contents @@ -0,0 +1,219 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Meshtastic/Views/Settings/Config/LoRaConfig.swift b/Meshtastic/Views/Settings/Config/LoRaConfig.swift index 2e63c168..644a1527 100644 --- a/Meshtastic/Views/Settings/Config/LoRaConfig.swift +++ b/Meshtastic/Views/Settings/Config/LoRaConfig.swift @@ -22,6 +22,8 @@ struct LoRaConfig: View { @State var modemPreset = 0 @State var hopLimit = 0 @State var txPower = 0 + @State var txEnabled = true + @State var usePreset = true var body: some View { @@ -119,8 +121,11 @@ struct LoRaConfig: View { self.hopLimit = Int(node!.loRaConfig?.hopLimit ?? 0) self.region = Int(node!.loRaConfig?.regionCode ?? 0) + self.usePreset = node!.loRaConfig?.usePreset ?? true self.modemPreset = Int(node!.loRaConfig?.modemPreset ?? 0) + self.txEnabled = node!.loRaConfig?.txEnabled ?? true self.txPower = Int(node!.loRaConfig?.txPower ?? 0) + self.hasChanges = false self.initialLoad = false } diff --git a/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift b/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift index 16c905ff..7f5fd3d5 100644 --- a/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift +++ b/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift @@ -159,7 +159,7 @@ struct MQTTConfig: View { "Are you sure?", isPresented: $isPresentingSaveConfirm ) { - Button("Save WiFI Config to \(bleManager.connectedPeripheral != nil ? bleManager.connectedPeripheral.longName : "Unknown")?") { + Button("Save MQTT Config to \(bleManager.connectedPeripheral != nil ? bleManager.connectedPeripheral.longName : "Unknown")?") { var mqtt = ModuleConfig.MQTTConfig() mqtt.enabled = self.enabled