diff --git a/Meshtastic/Helpers/MeshPackets.swift b/Meshtastic/Helpers/MeshPackets.swift index 8d530ce4..760b5d08 100644 --- a/Meshtastic/Helpers/MeshPackets.swift +++ b/Meshtastic/Helpers/MeshPackets.swift @@ -214,6 +214,7 @@ func deviceMetadataPacket (metadata: DeviceMetadata, fromNum: Int64, context: NS if fetchedNode.count > 0 { fetchedNode[0].metadata = newMetadata } else { + let newNode = createNodeInfo(num: Int64(fromNum), context: context) newNode.metadata = newMetadata } diff --git a/Meshtastic/Persistence/UpdateCoreData.swift b/Meshtastic/Persistence/UpdateCoreData.swift index b38a38ba..fdf3334c 100644 --- a/Meshtastic/Persistence/UpdateCoreData.swift +++ b/Meshtastic/Persistence/UpdateCoreData.swift @@ -265,11 +265,14 @@ func upsertPositionPacket (packet: MeshPacket, context: NSManagedObjectContext) return } /// Don't save nearly the same position over and over. If the next position is less than 10 meters from the new position, delete the previous position and save the new one. - if mutablePositions.count > 0 { + if mutablePositions.count > 0 && position.precisionBits == 32 { let mostRecent = mutablePositions.lastObject as! PositionEntity - if mostRecent.coordinate.distance(from: position.coordinate) < 10 { + if mostRecent.coordinate.distance(from: position.coordinate) < 15 { mutablePositions.remove(mostRecent) } + } else if mutablePositions.count > 0 && 11...16 ~= position.precisionBits { + /// Don't store any history for reduced accuracy positions, we will just show a circle + mutablePositions.removeAllObjects() } mutablePositions.add(position) fetchedNode[0].id = Int64(packet.from) diff --git a/Meshtastic/Views/Nodes/MeshMap.swift b/Meshtastic/Views/Nodes/MeshMap.swift index 5263bc37..09e99044 100644 --- a/Meshtastic/Views/Nodes/MeshMap.swift +++ b/Meshtastic/Views/Nodes/MeshMap.swift @@ -116,6 +116,15 @@ struct MeshMap: View { selectedPosition = (selectedPosition == position ? nil : position) } } + /// Reduced Precision Map Circles + if 11...16 ~= position.precisionBits { + let pp = PositionPrecision(rawValue: Int(position.precisionBits)) + let radius : CLLocationDistance = pp?.precisionMeters ?? 0 + if radius > 0.0 { + MapCircle(center: position.coordinate, radius: radius) + .foregroundStyle(Color(nodeColor).opacity(0.60)) + } + } /// Routes ForEach(Array(routes), id: \.id) { route in let routeLocations = Array(route.locations!) as! [LocationEntity] diff --git a/Meshtastic/Views/Settings/Channels.swift b/Meshtastic/Views/Settings/Channels.swift index 3b97a374..d09e986f 100644 --- a/Meshtastic/Views/Settings/Channels.swift +++ b/Meshtastic/Views/Settings/Channels.swift @@ -46,7 +46,7 @@ struct Channels: View { @State private var positionsEnabled = true /// Minimum Version for granular position configuration - @State var minimumVersion = "2.2.20" + @State var minimumVersion = "2.2.24" var body: some View { @@ -424,6 +424,7 @@ struct Channels: View { channelRole = 2 channelKey = key positionsEnabled = false + preciseLocation = false positionPrecision = 0 uplink = false downlink = false