From 3b6f7fdbee0733ccdd7f6774b5c97568fa68395a Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sat, 18 Apr 2026 16:52:22 -0700 Subject: [PATCH] Firmware pop up and channel button fixes --- Meshtastic/Views/Connect/Connect.swift | 4 +- Meshtastic/Views/Settings/Channels.swift | 80 ++++++++++++------------ 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/Meshtastic/Views/Connect/Connect.swift b/Meshtastic/Views/Connect/Connect.swift index d72cc5c0..010b60bd 100644 --- a/Meshtastic/Views/Connect/Connect.swift +++ b/Meshtastic/Views/Connect/Connect.swift @@ -377,12 +377,14 @@ struct Connect: View { } catch { Logger.data.error("💥 Error fetching node info: \(error.localizedDescription, privacy: .public)") } - // Check firmware version on connection + // Check firmware version on connection (only if version is known) + if let firmwareVersion = accessoryManager.activeConnection?.device.firmwareVersion, firmwareVersion != "?.?.?" && !firmwareVersion.isEmpty { let meetsMinimumVersion = accessoryManager.checkIsVersionSupported(forVersion: accessoryManager.minimumVersion) let meetsSecurityVersion = accessoryManager.checkIsVersionSupported(forVersion: accessoryManager.securityVersion) invalidFirmwareVersion = !meetsMinimumVersion showSecurityVersionNag = meetsMinimumVersion && !meetsSecurityVersion } + } } } #if !targetEnvironment(macCatalyst) diff --git a/Meshtastic/Views/Settings/Channels.swift b/Meshtastic/Views/Settings/Channels.swift index ef3cead4..010b1745 100644 --- a/Meshtastic/Views/Settings/Channels.swift +++ b/Meshtastic/Views/Settings/Channels.swift @@ -145,6 +145,45 @@ struct Channels: View { } } } + if node.myInfo?.channels?.array.count ?? 0 < 8 { + Button { + let channelIndexes = node.myInfo?.channels?.compactMap({(ch) -> Int in + return (ch as AnyObject).index + }) + let firstChannelIndex = firstMissingChannelIndex(channelIndexes ?? []) + channelKeySize = 16 + let key = generateChannelKey(size: channelKeySize) + channelName = "" + channelIndex = Int32(firstChannelIndex) + channelRole = 2 + channelKey = key + positionsEnabled = false + preciseLocation = false + positionPrecision = 0 + uplink = false + downlink = false + + let newChannel = ChannelEntity(context: context) + newChannel.id = channelIndex + newChannel.index = channelIndex + newChannel.uplinkEnabled = uplink + newChannel.downlinkEnabled = downlink + newChannel.name = channelName + newChannel.role = Int32(channelRole) + newChannel.psk = Data(base64Encoded: channelKey) ?? Data() + newChannel.positionPrecision = Int32(positionPrecision) + selectedChannel = newChannel + hasChanges = true + + } label: { + Label("Add Channel", systemImage: "plus.square") + } + .buttonStyle(.bordered) + .buttonBorderShape(.capsule) + .controlSize(.large) + .frame(maxWidth: .infinity) + .padding(.vertical, 8) + } } .sheet(item: $selectedChannel) { _ in #if targetEnvironment(macCatalyst) @@ -246,45 +285,6 @@ struct Channels: View { #endif } } - if node.myInfo?.channels?.array.count ?? 0 < 8 { - - Button { - let channelIndexes = node.myInfo?.channels?.compactMap({(ch) -> Int in - return (ch as AnyObject).index - }) - let firstChannelIndex = firstMissingChannelIndex(channelIndexes ?? []) - channelKeySize = 16 - let key = generateChannelKey(size: channelKeySize) - channelName = "" - channelIndex = Int32(firstChannelIndex) - channelRole = 2 - channelKey = key - positionsEnabled = false - preciseLocation = false - positionPrecision = 0 - uplink = false - downlink = false - - let newChannel = ChannelEntity(context: context) - newChannel.id = channelIndex - newChannel.index = channelIndex - newChannel.uplinkEnabled = uplink - newChannel.downlinkEnabled = downlink - newChannel.name = channelName - newChannel.role = Int32(channelRole) - newChannel.psk = Data(base64Encoded: channelKey) ?? Data() - newChannel.positionPrecision = Int32(positionPrecision) - selectedChannel = newChannel - hasChanges = true - - } label: { - Label("Add Channel", systemImage: "plus.square") - } - .buttonStyle(.bordered) - .buttonBorderShape(.capsule) - .controlSize(.large) - .padding() - } } .sheet(isPresented: $showingHelp) { ChannelsHelp() @@ -301,9 +301,7 @@ struct Channels: View { Image(systemName: !showingHelp ? "questionmark.circle" : "questionmark.circle.fill") .padding(.vertical, 5) } - .tint(Color(UIColor.secondarySystemBackground)) .foregroundColor(.accentColor) - .buttonStyle(.borderedProminent) } .controlSize(.regular) .padding(5)