From 263d79cfb6af298a786190cc803cdb348e0b30e3 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Tue, 7 Nov 2023 15:25:20 -0800 Subject: [PATCH] Clean up disconnect notification --- Meshtastic.xcodeproj/project.pbxproj | 10 +++++----- Meshtastic/Helpers/BLEManager.swift | 18 ++++++++---------- ...odeMapControl.swift => NodeMapMapkit.swift} | 2 +- .../Helpers/{ => Map}/NodeMapSwiftUI.swift | 0 .../Views/Nodes/Helpers/NodeDetail.swift | 2 +- 5 files changed, 15 insertions(+), 17 deletions(-) rename Meshtastic/Views/Nodes/Helpers/Map/{NodeMapControl.swift => NodeMapMapkit.swift} (99%) rename Meshtastic/Views/Nodes/Helpers/{ => Map}/NodeMapSwiftUI.swift (100%) diff --git a/Meshtastic.xcodeproj/project.pbxproj b/Meshtastic.xcodeproj/project.pbxproj index c75659b3..3d6a1a71 100644 --- a/Meshtastic.xcodeproj/project.pbxproj +++ b/Meshtastic.xcodeproj/project.pbxproj @@ -143,7 +143,7 @@ DDDB26422AABF655003AFCB7 /* NodeListItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDB26412AABF655003AFCB7 /* NodeListItem.swift */; }; DDDB26442AAC0206003AFCB7 /* NodeDetail.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDB26432AAC0206003AFCB7 /* NodeDetail.swift */; }; DDDB26462AACC0B7003AFCB7 /* NodeInfoItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDB26452AACC0B7003AFCB7 /* NodeInfoItem.swift */; }; - DDDB26482AACD6D1003AFCB7 /* NodeMapControl.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDB26472AACD6D1003AFCB7 /* NodeMapControl.swift */; }; + DDDB26482AACD6D1003AFCB7 /* NodeMapMapkit.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDB26472AACD6D1003AFCB7 /* NodeMapMapkit.swift */; }; DDDB443629F6287000EE2349 /* MapButtons.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDB443529F6287000EE2349 /* MapButtons.swift */; }; DDDB443D29F6592F00EE2349 /* NetworkManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDB443C29F6592F00EE2349 /* NetworkManager.swift */; }; DDDB444029F79AB000EE2349 /* UserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDDB443F29F79AB000EE2349 /* UserDefaults.swift */; }; @@ -367,7 +367,7 @@ DDDB26412AABF655003AFCB7 /* NodeListItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NodeListItem.swift; sourceTree = ""; }; DDDB26432AAC0206003AFCB7 /* NodeDetail.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NodeDetail.swift; sourceTree = ""; }; DDDB26452AACC0B7003AFCB7 /* NodeInfoItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NodeInfoItem.swift; sourceTree = ""; }; - DDDB26472AACD6D1003AFCB7 /* NodeMapControl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NodeMapControl.swift; sourceTree = ""; }; + DDDB26472AACD6D1003AFCB7 /* NodeMapMapkit.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NodeMapMapkit.swift; sourceTree = ""; }; DDDB26492AAD743E003AFCB7 /* MeshtasticDataModelV18.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = MeshtasticDataModelV18.xcdatamodel; sourceTree = ""; }; DDDB443529F6287000EE2349 /* MapButtons.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapButtons.swift; sourceTree = ""; }; DDDB443C29F6592F00EE2349 /* NetworkManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkManager.swift; sourceTree = ""; }; @@ -631,7 +631,8 @@ DDAD49EB2AFAE82500B4425D /* Map */ = { isa = PBXGroup; children = ( - DDDB26472AACD6D1003AFCB7 /* NodeMapControl.swift */, + DDB6CCFA2AAF805100945AF6 /* NodeMapSwiftUI.swift */, + DDDB26472AACD6D1003AFCB7 /* NodeMapMapkit.swift */, ); path = Map; sourceTree = ""; @@ -831,7 +832,6 @@ DDDB26432AAC0206003AFCB7 /* NodeDetail.swift */, DDDB26452AACC0B7003AFCB7 /* NodeInfoItem.swift */, DDDB26412AABF655003AFCB7 /* NodeListItem.swift */, - DDB6CCFA2AAF805100945AF6 /* NodeMapSwiftUI.swift */, DD13AA482AB73BF400BA0C98 /* PositionPopover.swift */, DD760AAD2ABAC706002C022E /* WaypointPopover.swift */, ); @@ -1117,7 +1117,7 @@ DDDB263F2AABEE20003AFCB7 /* NodeList.swift in Sources */, DDA0B6B2294CDC55001356EC /* Channels.swift in Sources */, DDB8F4102A9EE5B400230ECE /* Messages.swift in Sources */, - DDDB26482AACD6D1003AFCB7 /* NodeMapControl.swift in Sources */, + DDDB26482AACD6D1003AFCB7 /* NodeMapMapkit.swift in Sources */, DD4A911E2708C65400501B7E /* AppSettings.swift in Sources */, DD5E5209298EE33B00D21B61 /* module_config.pb.swift in Sources */, DD2160AF28C5552500C17253 /* MQTTConfig.swift in Sources */, diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index 8d743f72..773f061b 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -209,14 +209,13 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate print("🚨 BLE Disconnected: \(peripheral.name ?? "Unknown") Error Code: \(errorCode) Error: \(e.localizedDescription)") } else if errorCode == 7 { // CBError.Code.peripheralDisconnected The specified device has disconnected from us. // Seems to be what is received when a tbeam sleeps, immediately recconnecting does not work. - if UserDefaults.preferredPeripheralId == peripheral.identifier.uuidString{ + if UserDefaults.preferredPeripheralId == peripheral.identifier.uuidString { manager.notifications = [ Notification( id: (peripheral.identifier.uuidString), - title: "Disconnected from Preferred Device", - subtitle: "Device: \(peripheral.name ?? "unknown".localized)", - content: "Error Code: 7, seems to be what is received when a tbeam sleeps, immediately recconnecting does not work.", - target: "device" + title: "Radio Disconnected", + subtitle: "\(peripheral.name ?? "unknown".localized)", + content: e.localizedDescription ) ] manager.schedule() @@ -228,14 +227,13 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate lastConnectionError = "🚨 " + String.localizedStringWithFormat("ble.errorcode.14 %@".localized, e.localizedDescription) print("🚨 BLE Disconnected: \(peripheral.name ?? "Unknown") Error Code: \(errorCode) Error: \(lastConnectionError)") } else { - if UserDefaults.preferredPeripheralId == peripheral.identifier.uuidString{ + if UserDefaults.preferredPeripheralId == peripheral.identifier.uuidString { manager.notifications = [ Notification( id: (peripheral.identifier.uuidString), - title: "Disconnected from Preferred Device", - subtitle: "Device: \(peripheral.name ?? "unknown".localized)", - content: "Error Code: \(errorCode), \(e.localizedDescription)", - target: "device" + title: "Radio Disconnected", + subtitle: "\(peripheral.name ?? "unknown".localized)", + content: e.localizedDescription ) ] manager.schedule() diff --git a/Meshtastic/Views/Nodes/Helpers/Map/NodeMapControl.swift b/Meshtastic/Views/Nodes/Helpers/Map/NodeMapMapkit.swift similarity index 99% rename from Meshtastic/Views/Nodes/Helpers/Map/NodeMapControl.swift rename to Meshtastic/Views/Nodes/Helpers/Map/NodeMapMapkit.swift index 75a455b7..cd1ef380 100644 --- a/Meshtastic/Views/Nodes/Helpers/Map/NodeMapControl.swift +++ b/Meshtastic/Views/Nodes/Helpers/Map/NodeMapMapkit.swift @@ -9,7 +9,7 @@ import CoreLocation import MapKit import WeatherKit -struct NodeMapControl: View { +struct NodeMapMapkit: View { @Environment(\.managedObjectContext) var context @EnvironmentObject var bleManager: BLEManager diff --git a/Meshtastic/Views/Nodes/Helpers/NodeMapSwiftUI.swift b/Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift similarity index 100% rename from Meshtastic/Views/Nodes/Helpers/NodeMapSwiftUI.swift rename to Meshtastic/Views/Nodes/Helpers/Map/NodeMapSwiftUI.swift diff --git a/Meshtastic/Views/Nodes/Helpers/NodeDetail.swift b/Meshtastic/Views/Nodes/Helpers/NodeDetail.swift index f60337cb..58096955 100644 --- a/Meshtastic/Views/Nodes/Helpers/NodeDetail.swift +++ b/Meshtastic/Views/Nodes/Helpers/NodeDetail.swift @@ -44,7 +44,7 @@ struct NodeDetail: View { if #available (iOS 17, macOS 14, *) { NodeMapSwiftUI(node: node, showUserLocation: connectedNode?.num ?? 0 == node.num) } else { - NodeMapControl(node: node) + NodeMapMapkit(node: node) } } label: {