diff --git a/Meshtastic/Extensions/CoreData/NodeInfoEntityExtension.swift b/Meshtastic/Extensions/CoreData/NodeInfoEntityExtension.swift index 7585fb1e..7d313191 100644 --- a/Meshtastic/Extensions/CoreData/NodeInfoEntityExtension.swift +++ b/Meshtastic/Extensions/CoreData/NodeInfoEntityExtension.swift @@ -40,7 +40,8 @@ extension NodeInfoEntity { } var hasTraceRoutes: Bool { - return traceRoutes?.count ?? 0 > 0 + let routes = traceRoutes?.filter { ($0 as AnyObject).response } + return routes?.count ?? 0 > 0 } var hasPax: Bool { diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index 4f89a110..4d6e2c75 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -897,6 +897,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate traceRoute?.hasPositions = true } hopNodes.append(destinationHop) + /// Add the destination node to the end of the route towards string and the beginning of teh route back string routeString += "\(traceRoute?.node?.user?.longName ?? "unknown".localized) \((traceRoute?.node?.num ?? 0).toHex()) \(traceRoute?.node?.snr ?? 0 > 0 ? traceRoute?.node?.snr ?? 0 : 0.0)dB)" var routeBackString = "\(traceRoute?.node?.user?.longName ?? "unknown".localized) \((traceRoute?.node?.num ?? 0).toHex()) \(traceRoute?.node?.snr ?? 0 > 0 ? traceRoute?.node?.snr ?? 0 : 0.0)dB) --> " traceRoute?.hopsBack = Int32(routingMessage.routeBack.count) @@ -927,9 +928,6 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate } hopNodes.append(traceRouteHop) routeBackString += "\(hopNode?.user?.longName ?? (node == 4294967295 ? "Repeater" : String(hopNode?.num.toHex() ?? "unknown".localized))) \(hopNode?.viaMqtt ?? false ? "MQTT" : "") (\(traceRouteHop.snr > 0 ? hopNode?.snr ?? 0.0 : 0.0)dB) --> " - - - } routeBackString += "\(connectedNode.user?.longName ?? String(connectedNode.num.toHex())) \(connectedNode.snr > 0 ? connectedNode.snr : 0.0)dB)" traceRoute?.routeText = routeString diff --git a/Meshtastic/Views/Layouts/TraceRoute.swift b/Meshtastic/Views/Layouts/TraceRoute.swift index bb79f747..fd4d7d92 100644 --- a/Meshtastic/Views/Layouts/TraceRoute.swift +++ b/Meshtastic/Views/Layouts/TraceRoute.swift @@ -56,13 +56,13 @@ struct TraceRoute: Layout { subview.place(at: point, anchor: .center, proposal: .unspecified) - DispatchQueue.main.async { + // DispatchQueue.main.async { if index % 2 == 0 { subview[Rotation.self]?.wrappedValue = .zero } else { subview[Rotation.self]?.wrappedValue = .radians(angle) } - } + // } } } } diff --git a/Meshtastic/Views/Nodes/TraceRouteLog.swift b/Meshtastic/Views/Nodes/TraceRouteLog.swift index 2ba7eb45..268055e2 100644 --- a/Meshtastic/Views/Nodes/TraceRouteLog.swift +++ b/Meshtastic/Views/Nodes/TraceRouteLog.swift @@ -37,7 +37,7 @@ struct TraceRouteLog: View { VStack { List(node.traceRoutes?.reversed() as? [TraceRouteEntity] ?? [], id: \.self, selection: $selectedRoute) { route in Label { - if route.response && route.hops?.count == 0 { + if route.response && route.hopsTowards == 0 { Text("\(route.time?.formatted() ?? "unknown".localized) - Direct") .font(.caption) } else if route.response && route.hopsTowards == 1 { @@ -76,7 +76,16 @@ struct TraceRouteLog: View { Divider() ScrollView { if selectedRoute != nil { - if selectedRoute?.response ?? false && selectedRoute?.hopsTowards ?? 0 > 1 { + + if selectedRoute?.response ?? false && selectedRoute?.hopsTowards ?? 0 == 0 { + Label { + Text("Trace route received directly by \(selectedRoute?.node?.user?.longName ?? "unknown".localized) with a SNR of \(String(format: "%.2f", selectedRoute?.node?.snr ?? 0.0)) dB") + } icon: { + Image(systemName: "signpost.right.and.left") + .symbolRenderingMode(.hierarchical) + } + .font(.title3) + } else if selectedRoute?.response ?? false && selectedRoute?.hopsTowards ?? 0 > 0 { Label { Text("Route: \(selectedRoute?.routeText ?? "unknown".localized)") } icon: { @@ -91,14 +100,6 @@ struct TraceRouteLog: View { .symbolRenderingMode(.hierarchical) } .font(.title3) - } else if selectedRoute?.response ?? false { - Label { - Text("Trace route received directly by \(selectedRoute?.node?.user?.longName ?? "unknown".localized) with a SNR of \(String(format: "%.2f", selectedRoute?.node?.snr ?? 0.0)) dB") - } icon: { - Image(systemName: "signpost.right.and.left") - .symbolRenderingMode(.hierarchical) - } - .font(.title3) } else if !(selectedRoute?.sent ?? true) { Label { VStack {