mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Use snr from routing message for single hop results rather than node
Clean up snr float handling in traceroute paths
This commit is contained in:
parent
6ee3a4ec5f
commit
f763026203
2 changed files with 9 additions and 10 deletions
|
|
@ -835,8 +835,8 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
|
|||
let traceRoute = getTraceRoute(id: Int64(decodedInfo.packet.decoded.requestID), context: context)
|
||||
traceRoute?.response = true
|
||||
if routingMessage.route.count == 0 {
|
||||
let snr = routingMessage.snrBack.count > 0 ? routingMessage.snrBack[0] / 4 : 0
|
||||
traceRoute?.snr = Float(snr)
|
||||
let snr = routingMessage.snrBack.count > 0 ? Float(routingMessage.snrBack[0]) / 4 : 0.0
|
||||
traceRoute?.snr = snr
|
||||
let logString = String.localizedStringWithFormat("mesh.log.traceroute.received.direct %@".localized, String(snr))
|
||||
MeshLogger.log("🪧 \(logString)")
|
||||
} else {
|
||||
|
|
@ -848,7 +848,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
|
|||
connectedHop.time = Date()
|
||||
connectedHop.num = connectedPeripheral.num
|
||||
connectedHop.name = connectedNode.user?.longName ?? "???"
|
||||
connectedHop.snr = Float(routingMessage.snrBack.last ?? 0 / 4)
|
||||
connectedHop.snr = Float(routingMessage.snrBack.last ?? 0) / 4
|
||||
if let mostRecent = traceRoute?.node?.positions?.lastObject as? PositionEntity, mostRecent.time! >= Calendar.current.date(byAdding: .hour, value: -24, to: Date())! {
|
||||
connectedHop.altitude = mostRecent.altitude
|
||||
connectedHop.latitudeI = mostRecent.latitudeI
|
||||
|
|
@ -866,7 +866,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
|
|||
let traceRouteHop = TraceRouteHopEntity(context: context)
|
||||
traceRouteHop.time = Date()
|
||||
if routingMessage.snrTowards.count >= index + 1 {
|
||||
traceRouteHop.snr = Float(routingMessage.snrTowards[index] / 4)
|
||||
traceRouteHop.snr = Float(routingMessage.snrTowards[index]) / 4
|
||||
}
|
||||
if let hn = hopNode, hn.hasPositions {
|
||||
if let mostRecent = hn.positions?.lastObject as? PositionEntity, mostRecent.time! >= Calendar.current.date(byAdding: .hour, value: -24, to: Date())! {
|
||||
|
|
@ -888,7 +888,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
|
|||
let destinationHop = TraceRouteHopEntity(context: context)
|
||||
destinationHop.name = traceRoute?.node?.user?.longName ?? "unknown".localized
|
||||
destinationHop.time = Date()
|
||||
destinationHop.snr = Float(routingMessage.snrTowards.last ?? 0 / 4)
|
||||
destinationHop.snr = Float(routingMessage.snrTowards.last ?? 0) / 4
|
||||
destinationHop.num = traceRoute?.node?.num ?? 0
|
||||
if let mostRecent = traceRoute?.node?.positions?.lastObject as? PositionEntity, mostRecent.time! >= Calendar.current.date(byAdding: .hour, value: -24, to: Date())! {
|
||||
destinationHop.altitude = mostRecent.altitude
|
||||
|
|
@ -910,7 +910,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
|
|||
traceRouteHop.time = Date()
|
||||
traceRouteHop.back = true
|
||||
if routingMessage.snrBack.count >= index + 1 {
|
||||
traceRouteHop.snr = Float(routingMessage.snrBack[index] / 4)
|
||||
traceRouteHop.snr = Float(routingMessage.snrBack[index]) / 4
|
||||
}
|
||||
if let hn = hopNode, hn.hasPositions {
|
||||
if let mostRecent = hn.positions?.lastObject as? PositionEntity, mostRecent.time! >= Calendar.current.date(byAdding: .hour, value: -24, to: Date())! {
|
||||
|
|
|
|||
|
|
@ -72,14 +72,13 @@ struct TraceRouteLog: View {
|
|||
}
|
||||
.listStyle(.plain)
|
||||
}
|
||||
.frame(minHeight: CGFloat(node.traceRoutes?.count ?? 0 * 40), maxHeight: 250)
|
||||
.frame(minHeight: CGFloat((node.traceRoutes?.count ?? 0) * 40), maxHeight: 250)
|
||||
Divider()
|
||||
ScrollView {
|
||||
if selectedRoute != nil {
|
||||
|
||||
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")
|
||||
Text("Trace route received directly by \(selectedRoute?.node?.user?.longName ?? "unknown".localized) with a SNR of \(String(format: "%.2f", selectedRoute?.snr ?? 0.0)) dB")
|
||||
} icon: {
|
||||
Image(systemName: "signpost.right.and.left")
|
||||
.symbolRenderingMode(.hierarchical)
|
||||
|
|
@ -131,7 +130,7 @@ struct TraceRouteLog: View {
|
|||
.symbolRenderingMode(.hierarchical)
|
||||
}
|
||||
}
|
||||
if false {//selectedRoute?.hops?.count ?? 0 >= 3 {
|
||||
if false {// selectedRoute?.hops?.count ?? 0 >= 3 {
|
||||
HStack(alignment: .center) {
|
||||
GeometryReader { geometry in
|
||||
let size = ((geometry.size.width >= geometry.size.height ? geometry.size.height : geometry.size.width) / 2) - (idiom == .phone ? 45 : 85)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue