mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Trace route cleanup, smarter positions for phone locations on ios 17
This commit is contained in:
parent
690ef05b1d
commit
8dc1210607
3 changed files with 33 additions and 5 deletions
|
|
@ -664,8 +664,9 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
|
|||
if hopNode != nil {
|
||||
hopNodes.append(traceRouteHop)
|
||||
}
|
||||
routeString += "\(hopNode?.user?.longName ?? "unknown".localized) --> "
|
||||
routeString += "\(hopNode?.user?.longName ?? "unknown".localized) -->"
|
||||
}
|
||||
routeString += traceRoute?.node?.user?.longName ?? "unknown".localized
|
||||
traceRoute?.routeText = routeString
|
||||
traceRoute?.hops = NSOrderedSet(array: hopNodes)
|
||||
do {
|
||||
|
|
@ -676,8 +677,6 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
|
|||
let nsError = error as NSError
|
||||
print("💥 Error Updating Core Data TraceRouteHOp: \(nsError)")
|
||||
}
|
||||
|
||||
routeString += "\(decodedInfo.packet.from)"
|
||||
let logString = String.localizedStringWithFormat("mesh.log.traceroute.received.route %@".localized, routeString)
|
||||
MeshLogger.log("🪧 \(logString)")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ import CoreLocation
|
|||
static let shared = LocationsHandler() // Create a single, shared instance of the object.
|
||||
private let manager: CLLocationManager
|
||||
private var background: CLBackgroundActivitySession?
|
||||
var locationsArray: [CLLocation]
|
||||
var enableSmartPosition: Bool
|
||||
|
||||
@Published var lastLocation = CLLocation()
|
||||
@Published var isStationary = false
|
||||
|
|
@ -36,6 +38,9 @@ import CoreLocation
|
|||
|
||||
private init() {
|
||||
self.manager = CLLocationManager() // Creating a location manager instance is safe to call here in `MainActor`.
|
||||
locationsArray = [CLLocation]()
|
||||
enableSmartPosition = true
|
||||
self.manager.distanceFilter = 5
|
||||
}
|
||||
|
||||
func startLocationUpdates() {
|
||||
|
|
@ -53,7 +58,16 @@ import CoreLocation
|
|||
self.lastLocation = loc
|
||||
self.isStationary = update.isStationary
|
||||
self.count += 1
|
||||
print("Location \(self.count): \(self.lastLocation)")
|
||||
var locationAdded: Bool
|
||||
if enableSmartPosition {
|
||||
locationAdded = addLocation(loc)
|
||||
} else {
|
||||
locationsArray.append(loc)
|
||||
locationAdded = true
|
||||
}
|
||||
if !locationAdded {
|
||||
print("Bad Location \(self.count): \(loc)")
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
|
|
@ -68,6 +82,21 @@ import CoreLocation
|
|||
self.updatesStarted = false
|
||||
}
|
||||
|
||||
func addLocation(_ location: CLLocation) -> Bool {
|
||||
let age = -location.timestamp.timeIntervalSinceNow
|
||||
if age > 10 {
|
||||
return false
|
||||
}
|
||||
if location.horizontalAccuracy < 0 {
|
||||
return false
|
||||
}
|
||||
if location.horizontalAccuracy > 100 {
|
||||
return false
|
||||
}
|
||||
locationsArray.append(location)
|
||||
return true
|
||||
}
|
||||
|
||||
static let DefaultLocation = CLLocationCoordinate2D(latitude: 37.3346, longitude: -122.0090)
|
||||
|
||||
static var satsInView: Int {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ struct TraceRouteLog: View {
|
|||
List(node.traceRoutes?.reversed() as? [TraceRouteEntity] ?? [], id: \.self, selection: $selectedRoute) { route in
|
||||
|
||||
Label {
|
||||
Text("\(route.time?.formatted() ?? "unknown".localized) - \(route.response ? (route.hops?.count == 0 && route.response ? "Direct" : "\(route.hops?.count == 0) Hops") : "No Response")")
|
||||
Text("\(route.time?.formatted() ?? "unknown".localized) - \(route.response ? (route.hops?.count == 0 && route.response ? "Direct" : "\(route.hops?.count ?? 0) Hops") : "No Response")")
|
||||
} icon: {
|
||||
Image(systemName: route.response ? (route.hops?.count == 0 && route.response ? "person.line.dotted.person" : "point.3.connected.trianglepath.dotted") : "person.slash")
|
||||
.symbolRenderingMode(.hierarchical)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue