From 9922e19fcedfd2852ea1974682925cc8067f3c71 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Fri, 20 Oct 2023 16:14:29 -0700 Subject: [PATCH] Check for admin channel on settings drop down, hide catalyst map controls that don't work --- Meshtastic/Extensions/UserDefaults.swift | 3 --- Meshtastic/Helpers/BLEManager.swift | 12 +++++++++++- Meshtastic/Protobufs/meshtastic/config.pb.swift | 11 +++++++++++ Meshtastic/Protobufs/meshtastic/mesh.pb.swift | 8 ++++++++ Meshtastic/Views/Nodes/Helpers/NodeMapSwiftUI.swift | 9 +++++---- Meshtastic/Views/Settings/Settings.swift | 5 ++++- 6 files changed, 39 insertions(+), 9 deletions(-) diff --git a/Meshtastic/Extensions/UserDefaults.swift b/Meshtastic/Extensions/UserDefaults.swift index 48305399..97e99b98 100644 --- a/Meshtastic/Extensions/UserDefaults.swift +++ b/Meshtastic/Extensions/UserDefaults.swift @@ -123,9 +123,6 @@ extension UserDefaults { UserDefaults.standard.set(newValue, forKey: "enableMapPointsOfInterest") } } - - - static var enableOfflineMaps: Bool { get { UserDefaults.standard.bool(forKey: "enableOfflineMaps") diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index 68f65f92..c724662e 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -144,6 +144,9 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate func disconnectPeripheral(reconnect: Bool = true) { guard let connectedPeripheral = connectedPeripheral else { return } + if mqttProxyConnected { + mqttManager.mqttClientProxy?.disconnect() + } automaticallyReconnect = reconnect centralManager?.cancelPeripheralConnection(connectedPeripheral.peripheral) FROMRADIO_characteristic = nil @@ -789,7 +792,14 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate meshPacket.from = fromNodeNum meshPacket.wantAck = true var dataMessage = DataMessage() - dataMessage.payload = try! waypoint.serializedData() + do { + dataMessage.payload = try waypoint.serializedData() + } + catch { + // Could not serialiaze the payload + return false + } + dataMessage.portnum = PortNum.waypointApp meshPacket.decoded = dataMessage var toRadio: ToRadio! diff --git a/Meshtastic/Protobufs/meshtastic/config.pb.swift b/Meshtastic/Protobufs/meshtastic/config.pb.swift index f33e0eb7..d04e9003 100644 --- a/Meshtastic/Protobufs/meshtastic/config.pb.swift +++ b/Meshtastic/Protobufs/meshtastic/config.pb.swift @@ -237,6 +237,13 @@ struct Config { /// When used in conjunction with power.is_power_saving = true, nodes will wake up, /// send environment telemetry, and then sleep for telemetry.environment_update_interval seconds. case sensor // = 6 + + /// + /// TAK device role + /// 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 + case tak // = 7 case UNRECOGNIZED(Int) init() { @@ -252,6 +259,7 @@ struct Config { case 4: self = .repeater case 5: self = .tracker case 6: self = .sensor + case 7: self = .tak default: self = .UNRECOGNIZED(rawValue) } } @@ -265,6 +273,7 @@ struct Config { case .repeater: return 4 case .tracker: return 5 case .sensor: return 6 + case .tak: return 7 case .UNRECOGNIZED(let i): return i } } @@ -1285,6 +1294,7 @@ extension Config.DeviceConfig.Role: CaseIterable { .repeater, .tracker, .sensor, + .tak, ] } @@ -1692,6 +1702,7 @@ extension Config.DeviceConfig.Role: SwiftProtobuf._ProtoNameProviding { 4: .same(proto: "REPEATER"), 5: .same(proto: "TRACKER"), 6: .same(proto: "SENSOR"), + 7: .same(proto: "TAK"), ] } diff --git a/Meshtastic/Protobufs/meshtastic/mesh.pb.swift b/Meshtastic/Protobufs/meshtastic/mesh.pb.swift index c4d94c49..cc2388a8 100644 --- a/Meshtastic/Protobufs/meshtastic/mesh.pb.swift +++ b/Meshtastic/Protobufs/meshtastic/mesh.pb.swift @@ -208,6 +208,10 @@ enum HardwareModel: SwiftProtobuf.Enum { /// Heltec HT-CT62 with ESP32-C3 CPU and SX1262 LoRa case heltecHt62 // = 53 + /// + /// EBYTE SPI LoRa module and ESP32-S3 + case ebyteEsp32S3 // = 54 + /// /// ------------------------------------------------------------------------------------------------------------------------------------------ /// Reserved ID For developing private Ports. These will show up in live traffic sparsely, so we can use a high number. Keep it within 8 bits. @@ -265,6 +269,7 @@ enum HardwareModel: SwiftProtobuf.Enum { case 51: self = .tWatchS3 case 52: self = .picomputerS3 case 53: self = .heltecHt62 + case 54: self = .ebyteEsp32S3 case 255: self = .privateHw default: self = .UNRECOGNIZED(rawValue) } @@ -316,6 +321,7 @@ enum HardwareModel: SwiftProtobuf.Enum { case .tWatchS3: return 51 case .picomputerS3: return 52 case .heltecHt62: return 53 + case .ebyteEsp32S3: return 54 case .privateHw: return 255 case .UNRECOGNIZED(let i): return i } @@ -372,6 +378,7 @@ extension HardwareModel: CaseIterable { .tWatchS3, .picomputerS3, .heltecHt62, + .ebyteEsp32S3, .privateHw, ] } @@ -2534,6 +2541,7 @@ extension HardwareModel: SwiftProtobuf._ProtoNameProviding { 51: .same(proto: "T_WATCH_S3"), 52: .same(proto: "PICOMPUTER_S3"), 53: .same(proto: "HELTEC_HT62"), + 54: .same(proto: "EBYTE_ESP32_S3"), 255: .same(proto: "PRIVATE_HW"), ] } diff --git a/Meshtastic/Views/Nodes/Helpers/NodeMapSwiftUI.swift b/Meshtastic/Views/Nodes/Helpers/NodeMapSwiftUI.swift index 584d3b53..3546f7ec 100644 --- a/Meshtastic/Views/Nodes/Helpers/NodeMapSwiftUI.swift +++ b/Meshtastic/Views/Nodes/Helpers/NodeMapSwiftUI.swift @@ -353,10 +353,11 @@ struct NodeMapSwiftUI: View { } #if targetEnvironment(macCatalyst) - MapZoomStepper(scope: mapScope) - .mapControlVisibility(.visible) - MapPitchSlider(scope: mapScope) - .mapControlVisibility(.visible) + /// Hide non fuctional catalyst controls +// MapZoomStepper(scope: mapScope) +// .mapControlVisibility(.visible) +// MapPitchSlider(scope: mapScope) +// .mapControlVisibility(.visible) #endif } .controlSize(.regular) diff --git a/Meshtastic/Views/Settings/Settings.swift b/Meshtastic/Views/Settings/Settings.swift index 8a84f474..59b75425 100644 --- a/Meshtastic/Views/Settings/Settings.swift +++ b/Meshtastic/Views/Settings/Settings.swift @@ -59,6 +59,9 @@ struct Settings: View { } .tag(SettingsSidebar.appSettings) let node = nodes.first(where: { $0.num == connectedNodeNum }) + let hasAdmin = node?.myInfo?.adminIndex ?? 0 > 0 ? true : false + + if !(node?.deviceConfig?.isManaged ?? false) { Section("Configure") { Picker("Configuring Node", selection: $selectedNode) { @@ -72,7 +75,7 @@ struct Settings: View { } else if node.metadata != nil { Text("Remote Config: \(node.user?.longName ?? "unknown".localized)") .tag(Int(node.num)) - } else { + } else if hasAdmin { Text("Request Admin: \(node.user?.longName ?? "unknown".localized)") .tag(Int(node.num)) }