From 9511ee76f3000f9c564f60e9b35d3d54bca4cec5 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Mon, 6 Feb 2023 10:26:04 -0800 Subject: [PATCH] Bug fixes --- Meshtastic/Helpers/BLEManager.swift | 2 +- Meshtastic/Helpers/MeshPackets.swift | 4 ++++ Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift | 2 +- Meshtastic/Views/Map/WaypointFormView.swift | 10 +++++----- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index b2f1e9b4..05047a3f 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -456,7 +456,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject { } } // NodeInfo - if decodedInfo.nodeInfo.num != 0 && !invalidVersion { + if decodedInfo.nodeInfo.num > 0 && !invalidVersion { nowKnown = true let nodeInfo = nodeInfoPacket(nodeInfo: decodedInfo.nodeInfo, channel: decodedInfo.packet.channel, context: context!) diff --git a/Meshtastic/Helpers/MeshPackets.swift b/Meshtastic/Helpers/MeshPackets.swift index 1f66aa57..ecafa677 100644 --- a/Meshtastic/Helpers/MeshPackets.swift +++ b/Meshtastic/Helpers/MeshPackets.swift @@ -230,6 +230,8 @@ func nodeInfoPacket (nodeInfo: NodeInfo, channel: UInt32, context: NSManagedObje let logString = String.localizedStringWithFormat(NSLocalizedString("mesh.log.nodeinfo.received %@", comment: "Node info received for: %@"), String(nodeInfo.num)) MeshLogger.log("📟 \(logString)") + guard (nodeInfo.num > 0) else { return nil } + let fetchNodeInfoRequest: NSFetchRequest = NSFetchRequest.init(entityName: "NodeInfoEntity") fetchNodeInfoRequest.predicate = NSPredicate(format: "num == %lld", Int64(nodeInfo.num)) @@ -384,6 +386,8 @@ func nodeInfoAppPacket (packet: MeshPacket, context: NSManagedObjectContext) { let logString = String.localizedStringWithFormat(NSLocalizedString("mesh.log.nodeinfo.received %@", comment: "Node info received for: %@"), String(packet.from)) MeshLogger.log("📟 \(logString)") + guard (packet.from > 0) else { return } + let fetchNodeInfoAppRequest: NSFetchRequest = NSFetchRequest.init(entityName: "NodeInfoEntity") fetchNodeInfoAppRequest.predicate = NSPredicate(format: "num == %lld", Int64(packet.from)) diff --git a/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift b/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift index bb923386..81007f67 100644 --- a/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift +++ b/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift @@ -174,7 +174,7 @@ struct MapViewSwiftUI: UIViewRepresentable { leftIcon.backgroundColor = UIColor(.accentColor) annotationView.leftCalloutAccessoryView = leftIcon let subtitle = UILabel() - if subtitle.text?.count ?? 0 > 0 { + if waypointAnnotation.longDescription?.count ?? 0 > 0 { subtitle.text = (waypointAnnotation.longDescription ?? "") + "\n" } else { diff --git a/Meshtastic/Views/Map/WaypointFormView.swift b/Meshtastic/Views/Map/WaypointFormView.swift index 5357c930..ff692e13 100644 --- a/Meshtastic/Views/Map/WaypointFormView.swift +++ b/Meshtastic/Views/Map/WaypointFormView.swift @@ -273,11 +273,11 @@ struct WaypointFormView: View { longitude = coordinate.longitude } -// if coordinate.distance(from: LocationHelper.DefaultLocation) == 0.0 { -// // Too close to apple park, bail out -// waypointId = 0 -// dismiss() -// } + if coordinate.distance(from: LocationHelper.DefaultLocation) == 0.0 { + // Too close to apple park, bail out + waypointId = 0 + dismiss() + } } } }