From 350ec121d7ef4e08353e17282956064a8d953607 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sun, 28 Jan 2024 09:36:19 -0800 Subject: [PATCH] Revert broken channel key validation Remove block range test Add notes that router role is not for mobile nodes --- Meshtastic/Extensions/UserDefaults.swift | 8 ---- Meshtastic/Helpers/BLEManager.swift | 6 +-- Meshtastic/Helpers/MeshPackets.swift | 6 +-- Meshtastic/Views/Settings/AppSettings.swift | 10 ----- Meshtastic/Views/Settings/Channels.swift | 45 ++++++--------------- en.lproj/Localizable.strings | 4 +- 6 files changed, 19 insertions(+), 60 deletions(-) diff --git a/Meshtastic/Extensions/UserDefaults.swift b/Meshtastic/Extensions/UserDefaults.swift index 00b5b6e3..6a4c54a4 100644 --- a/Meshtastic/Extensions/UserDefaults.swift +++ b/Meshtastic/Extensions/UserDefaults.swift @@ -9,7 +9,6 @@ import Foundation extension UserDefaults { enum Keys: String, CaseIterable { - case enableRangeTest case preferredPeripheralId case preferredPeripheralNum case provideLocation @@ -32,13 +31,6 @@ extension UserDefaults { func reset() { Keys.allCases.forEach { removeObject(forKey: $0.rawValue) } } - static var blockRangeTest: Bool { - get { - UserDefaults.standard.bool(forKey: "blockRangeTest") - } set { - UserDefaults.standard.set(newValue, forKey: "blockRangeTest") - } - } static var preferredPeripheralId: String { get { UserDefaults.standard.string(forKey: "preferredPeripheralId") ?? "" diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index 155f19bf..bcb027fd 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -594,7 +594,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate // Log any other unknownApp calls if !nowKnown { MeshLogger.log("🕸️ MESH PACKET received for Unknown App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") } case .textMessageApp, .detectionSensorApp: - textMessageAppPacket(packet: decodedInfo.packet, blockRangeTest: UserDefaults.blockRangeTest, connectedNode: (self.connectedPeripheral != nil ? connectedPeripheral.num : 0), context: context!) + textMessageAppPacket(packet: decodedInfo.packet, connectedNode: (self.connectedPeripheral != nil ? connectedPeripheral.num : 0), context: context!) case .remoteHardwareApp: MeshLogger.log("🕸️ MESH PACKET received for Remote Hardware App UNHANDLED \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")") case .positionApp: @@ -620,8 +620,8 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate MeshLogger.log("🕸️ MESH PACKET received for Store and Forward App - Store and Forward is disabled.") } case .rangeTestApp: - if wantRangeTestPackets && !UserDefaults.blockRangeTest { - textMessageAppPacket(packet: decodedInfo.packet, blockRangeTest: false, connectedNode: (self.connectedPeripheral != nil ? connectedPeripheral.num : 0), context: context!) + if wantRangeTestPackets { + textMessageAppPacket(packet: decodedInfo.packet, connectedNode: (self.connectedPeripheral != nil ? connectedPeripheral.num : 0), context: context!) } else { MeshLogger.log("🕸️ MESH PACKET received for Range Test App Range testing is disabled.") diff --git a/Meshtastic/Helpers/MeshPackets.swift b/Meshtastic/Helpers/MeshPackets.swift index 9b720845..d2e6a8f1 100644 --- a/Meshtastic/Helpers/MeshPackets.swift +++ b/Meshtastic/Helpers/MeshPackets.swift @@ -721,13 +721,9 @@ func telemetryPacket(packet: MeshPacket, connectedNode: Int64, context: NSManage } } -func textMessageAppPacket(packet: MeshPacket, blockRangeTest: Bool, connectedNode: Int64, context: NSManagedObjectContext) { +func textMessageAppPacket(packet: MeshPacket, connectedNode: Int64, context: NSManagedObjectContext) { if let messageText = String(bytes: packet.decoded.payload, encoding: .utf8) { - - if blockRangeTest && messageText.starts(with: "seq ") { - return - } MeshLogger.log("💬 \("mesh.log.textmessage.received".localized)") diff --git a/Meshtastic/Views/Settings/AppSettings.swift b/Meshtastic/Views/Settings/AppSettings.swift index ba705afc..f9520b91 100644 --- a/Meshtastic/Views/Settings/AppSettings.swift +++ b/Meshtastic/Views/Settings/AppSettings.swift @@ -11,7 +11,6 @@ struct AppSettings: View { @State var totalDownloadedTileSize = "" @StateObject var locationHelper = LocationHelper() @State var provideLocation: Bool = UserDefaults.provideLocation - @State var blockRangeTest: Bool = UserDefaults.blockRangeTest @State var useLegacyMap: Bool = UserDefaults.mapUseLegacy @State var provideLocationInterval: Int = UserDefaults.provideLocationInterval @State private var isPresentingCoreDataResetConfirm = false @@ -20,12 +19,6 @@ struct AppSettings: View { VStack { Form { Section(header: Text("options")) { - - Toggle(isOn: $blockRangeTest) { - Label("range.test.blocked", systemImage: "x.circle") - } - .toggleStyle(SwitchToggleStyle(tint: .accentColor)) - Toggle(isOn: $useLegacyMap) { Label("map.use.legacy", systemImage: "map") } @@ -151,9 +144,6 @@ struct AppSettings: View { self.bleManager.context = context } } - .onChange(of: blockRangeTest) { newBlockRangeTest in - UserDefaults.blockRangeTest = newBlockRangeTest - } .onChange(of: provideLocation) { newProvideLocation in UserDefaults.provideLocation = newProvideLocation if bleManager.connectedPeripheral != nil { diff --git a/Meshtastic/Views/Settings/Channels.swift b/Meshtastic/Views/Settings/Channels.swift index 88bcd2ab..b8ad588c 100644 --- a/Meshtastic/Views/Settings/Channels.swift +++ b/Meshtastic/Views/Settings/Channels.swift @@ -1,6 +1,6 @@ // -// ShareChannel.swift -// MeshtasticApple +// Channels.swift +// Meshtastic Apple // // Copyright(c) Garth Vander Houwen 4/8/22. // @@ -25,7 +25,6 @@ struct Channels: View { var node: NodeInfoEntity? @State var hasChanges = false - @State var hasValidKey = false @State private var isPresentingEditView = false @State private var isPresentingSaveConfirm: Bool = false @State private var channelIndex: Int32 = 0 @@ -168,34 +167,16 @@ struct Channels: View { HStack(alignment: .top) { Text("Key") Spacer() - TextField( - "Key", - text: $channelKey - ) - .padding(4) - .disableAutocorrection(true) - .keyboardType(.alphabet) - .foregroundColor(Color.gray) - .textSelection(.enabled) - .background( - RoundedRectangle(cornerRadius: 25.0) - .stroke( - hasValidKey ? - Color.green : - Color.red - , lineWidth: 2.0) - ) - .onChange(of: channelKey, perform: { _ in - let tempKey = Data(base64Encoded: channelKey) ?? Data() - if tempKey.count == channelKeySize || channelKeySize == -1{ - hasValidKey = true - } - else { - hasValidKey = false - } - hasChanges = true - }) - .disabled(channelKeySize <= 0) + Text(channelKey) + .foregroundColor(Color.gray) + .textSelection(.enabled) +// TextField( +// "", +// text: $channelKey, +// axis: .vertical +// ) +// .foregroundColor(Color.gray) +// .disabled(true) } Picker("Channel Role", selection: $channelRole) { if channelRole == 1 { @@ -275,7 +256,7 @@ struct Channels: View { } label: { Label("save", systemImage: "square.and.arrow.down") } - .disabled(bleManager.connectedPeripheral == nil || !hasChanges || !hasValidKey) + .disabled(bleManager.connectedPeripheral == nil || !hasChanges) .buttonStyle(.bordered) .buttonBorderShape(.capsule) .controlSize(.large) diff --git a/en.lproj/Localizable.strings b/en.lproj/Localizable.strings index 16ae26bc..425b8e01 100644 --- a/en.lproj/Localizable.strings +++ b/en.lproj/Localizable.strings @@ -71,8 +71,8 @@ "device.role.clienthidden"=" Used for nodes that \"only speak when spoken to\" Turns all of the routine broadcasts but allows for ad-hoc communication. Still rebroadcasts, but with local only rebroadcast mode (known meshes only). Can be used for private operation or to dramatically reduce airtime / power consumption."; "device.role.clientmute"="Client Mute - Same as a client except packets will not hop over this node, does not contribute to routing packets for mesh."; "device.role.lostandfound"="Used to automatically send a text message to the mesh with the current position of the device on a frequent interval: \"I'm lost! Position: lat / long\""; -"device.role.router"="Router - Mesh packets will prefer to be routed over this node. Assumes device will operate in a standalone manner while placed in a location with a coverage advantage. WARNING: The BLE/Wi-Fi radios and the OLED screen will be put to sleep."; -"device.role.routerclient"="Router Client - Hybrid of the Client and Router roles. Similar to Router, except the Router Client can be used as both a Router and an app connected Client. BLE/Wi-Fi and OLED screen will not be put to sleep."; +"device.role.router"="Router - Assumes device will operate in a standalone manner while placed in a location with a coverage advantage, not for mobile nodes. WARNING: The BLE/Wi-Fi radios and the OLED screen will be put to sleep."; +"device.role.routerclient"="Router Client - Hybrid of the Client and Router roles. Similar to Router, except the Router Client can be used as both a Router and an app connected Client. Also not for mobile nodes. BLE/Wi-Fi and OLED screen will not be put to sleep."; "device.role.repeater"="Repeater - Mesh packets will prefer to be routed over this node. This role eliminates all features other than mesh routing, this node will not even appear as part of the network. Please see Rebroadcast Mode for additional settings specific to this role."; "device.role.tracker"="Tracker - For use with devices intended as a GPS tracker. Position packets sent from this device will be higher priority, with position broadcasting every two minutes. Smart Position Broadcast will default to off."; "device.role.tak"="Used for nodes dedicated for connection to an ATAK EUD. Turns off many of the routine broadcasts to favor CoT packet stream from the Meshtastic ATAK plugin -> IMeshService -> Node";