From 643e200d51cd11acb7b496e1b7407108b505e407 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sun, 4 Jan 2026 20:58:06 -0800 Subject: [PATCH] Revert "NFC Tag contact (#1537)" This reverts commit 5c22b8b6e0176f4927bfc79234dabe109b215edf. --- Localizable.xcstrings | 17 +-- Meshtastic/Info.plist | 2 - Meshtastic/Meshtastic.entitlements | 4 - Meshtastic/Router/NavigationState.swift | 1 - Meshtastic/Views/Settings/Settings.swift | 9 -- Meshtastic/Views/Settings/Tools.swift | 164 ----------------------- 6 files changed, 1 insertion(+), 196 deletions(-) delete mode 100644 Meshtastic/Views/Settings/Tools.swift diff --git a/Localizable.xcstrings b/Localizable.xcstrings index bb6de690b..c6603edca 100644 --- a/Localizable.xcstrings +++ b/Localizable.xcstrings @@ -9143,10 +9143,6 @@ } } }, - "Create Node Contact NFC Tag" : { - "comment" : "A section header that instructs the user to create a contact NFC tag.", - "isCommentAutoGenerated" : true - }, "Create Waypoint" : { "localizations" : { "de" : { @@ -23754,10 +23750,6 @@ } } }, - "Node Name: %@" : { - "comment" : "A text label displaying the name of the connected node.", - "isCommentAutoGenerated" : true - }, "Node Number" : { "localizations" : { "de" : { @@ -37838,9 +37830,6 @@ } } } - }, - "Tools" : { - }, "Topic: %@" : { "localizations" : { @@ -41737,10 +41726,6 @@ } } }, - "Write Contact to NFC Tag" : { - "comment" : "A button that writes a contact to an NFC tag.", - "isCommentAutoGenerated" : true - }, "x" : { "localizations" : { "it" : { @@ -42343,4 +42328,4 @@ } }, "version" : "1.1" -} \ No newline at end of file +} diff --git a/Meshtastic/Info.plist b/Meshtastic/Info.plist index c2cbcdd8c..863fb0e94 100644 --- a/Meshtastic/Info.plist +++ b/Meshtastic/Info.plist @@ -97,8 +97,6 @@ LSSupportsOpeningDocumentsInPlace - NFCReaderUsageDescription - We use NFC tags to share node contacts NSBluetoothAlwaysUsageDescription We use bluetooth to connect to nearby Meshtastic Devices NSBluetoothPeripheralUsageDescription diff --git a/Meshtastic/Meshtastic.entitlements b/Meshtastic/Meshtastic.entitlements index a35e74eed..4dbdb836e 100644 --- a/Meshtastic/Meshtastic.entitlements +++ b/Meshtastic/Meshtastic.entitlements @@ -9,10 +9,6 @@ com.apple.developer.carplay-communication - com.apple.developer.nfc.readersession.formats - - TAG - com.apple.developer.usernotifications.critical-alerts com.apple.developer.weatherkit diff --git a/Meshtastic/Router/NavigationState.swift b/Meshtastic/Router/NavigationState.swift index 8c2ff6b37..48a97b93d 100644 --- a/Meshtastic/Router/NavigationState.swift +++ b/Meshtastic/Router/NavigationState.swift @@ -52,7 +52,6 @@ enum SettingsNavigationState: String { case debugLogs case appFiles case firmwareUpdates - case tools } struct NavigationState: Hashable { diff --git a/Meshtastic/Views/Settings/Settings.swift b/Meshtastic/Views/Settings/Settings.swift index 25b0e75a5..d3d15a66e 100644 --- a/Meshtastic/Views/Settings/Settings.swift +++ b/Meshtastic/Views/Settings/Settings.swift @@ -355,13 +355,6 @@ struct Settings: View { Image(systemName: "gearshape") } } - NavigationLink(value: SettingsNavigationState.tools) { - Label { - Text("Tools") - } icon: { - Image(systemName: "hammer") - } - } NavigationLink(value: SettingsNavigationState.routes) { Label { Text("Routes") @@ -528,8 +521,6 @@ struct Settings: View { AppData() case .firmwareUpdates: Firmware(node: node) - case .tools: - Tools() } } .onChange(of: UserDefaults.preferredPeripheralNum ) { _, newConnectedNode in diff --git a/Meshtastic/Views/Settings/Tools.swift b/Meshtastic/Views/Settings/Tools.swift deleted file mode 100644 index 75e439de8..000000000 --- a/Meshtastic/Views/Settings/Tools.swift +++ /dev/null @@ -1,164 +0,0 @@ -// -// Tools.swift -// Meshtastic -// -// Created by Benjamin Faershtein on 12/31/25. -// - -import SwiftUI -import CoreNFC -import MeshtasticProtobufs -import OSLog - -struct Tools: View { - @EnvironmentObject var accessoryManager: AccessoryManager - @Environment(\.managedObjectContext) var context - - @StateObject private var nfcReader = NFCReader() - - var connectedNode: NodeInfoEntity? { - if let num = accessoryManager.activeDeviceNum { - return getNodeInfo(id: num, context: context) - } - return nil - } - - var qrString: String { - var contact = SharedContact() - contact.nodeNum = UInt32(connectedNode?.num ?? 0) - contact.user = connectedNode?.toProto().user ?? User() - contact.manuallyVerified = true - - do { - let contactString = try contact.serializedData().base64EncodedString() - return "https://meshtastic.org/v/#" + contactString.base64ToBase64url() - } catch { - Logger.services.error("Error serializing contact: \(error)") - return "" - } - } - - var body: some View { - VStack{ - List { - Section(header: Text("Create Node Contact NFC Tag")) { - if let node = connectedNode { - Text("Node Name: \(node.user?.longName ?? "Unknown")") - - Button { - nfcReader.scan(theActualData: qrString) - } label: { - Label("Write Contact to NFC Tag", systemImage: "tag") - } - .disabled(qrString.isEmpty) - } - } - } - } - .navigationTitle("Tools") - .navigationBarTitleDisplayMode(.inline) - } -} - -#Preview { - Tools() -} - -final class NFCReader: NSObject, ObservableObject, NFCNDEFReaderSessionDelegate { - - private let logger = Logger(subsystem: "org.meshtastic.app", category: "NFC") - private var payloadString = "" - private var session: NFCNDEFReaderSession? - - func scan(theActualData: String) { - payloadString = theActualData - - session = NFCNDEFReaderSession( - delegate: self, - queue: nil, - invalidateAfterFirstRead: false - ) - - session?.alertMessage = "Hold your iPhone near the NFC tag." - session?.begin() - } - - func readerSessionDidBecomeActive(_ session: NFCNDEFReaderSession) { - logger.debug("NFC session became active") - } - - func readerSession(_ session: NFCNDEFReaderSession, - didInvalidateWithError error: Error) { - logger.error("NFC session invalidated: \(error.localizedDescription)") - } - - func readerSession(_ session: NFCNDEFReaderSession, - didDetectNDEFs messages: [NFCNDEFMessage]) { - } - - func readerSession(_ session: NFCNDEFReaderSession, - didDetect tags: [NFCNDEFTag]) { - - guard tags.count == 1, let tag = tags.first else { - session.alertMessage = "More than one tag detected. Please present only one." - DispatchQueue.global().asyncAfter(deadline: .now() + .milliseconds(500)) { - session.restartPolling() - } - return - } - - session.connect(to: tag) { error in - if let error { - self.logger.error("Failed to connect to tag: \(error.localizedDescription)") - session.alertMessage = "Failed to connect to tag." - session.invalidate() - return - } - - tag.queryNDEFStatus { status, _, error in - if let error { - self.logger.error("Failed to query NDEF status: \(error.localizedDescription)") - session.alertMessage = "Failed to read tag." - session.invalidate() - return - } - - switch status { - case .notSupported: - self.logger.error("Tag does not support NDEF") - session.alertMessage = "Tag does not support NDEF." - session.invalidate() - - case .readOnly: - self.logger.error("Tag is read-only") - session.alertMessage = "Tag is read-only." - session.invalidate() - - case .readWrite: - guard let payload = - NFCNDEFPayload.wellKnownTypeURIPayload( - string: self.payloadString - ) else { - self.logger.error("Invalid NDEF payload") - session.alertMessage = "Invalid payload." - session.invalidate() - return - } - - let message = NFCNDEFMessage(records: [payload]) - - tag.writeNDEF(message) { error in - if let error { - self.logger.error("Failed to write NDEF: \(error.localizedDescription)") - session.alertMessage = "Failed to write tag." - } else { - self.logger.info("Successfully wrote NFC tag") - session.alertMessage = "NFC tag written successfully." - } - session.invalidate() - } - } - } - } - } -}