mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Make sure position flags are saving properly to the core data database
This commit is contained in:
parent
fdb0f6310e
commit
bbb0434a3e
2 changed files with 16 additions and 4 deletions
|
|
@ -69,11 +69,13 @@ func PositionToCsvFile(positions: [PositionEntity]) -> String {
|
|||
var csvString: String = ""
|
||||
|
||||
// Create Position Header
|
||||
csvString = "Latitude, Longitude, Alt, Sats, Speed, Heading, SeqNo, Timestamp"
|
||||
csvString = "SeqNo, Latitude, Longitude, Alt, Sats, Speed, Heading, Timestamp"
|
||||
|
||||
for pos in positions {
|
||||
|
||||
csvString += "\n"
|
||||
csvString += String(pos.seqNo)
|
||||
csvString += ", "
|
||||
csvString += String(pos.latitude ?? 0)
|
||||
csvString += ", "
|
||||
csvString += String(pos.longitude ?? 0)
|
||||
|
|
@ -86,8 +88,6 @@ func PositionToCsvFile(positions: [PositionEntity]) -> String {
|
|||
csvString += ", "
|
||||
csvString += String(pos.heading)
|
||||
csvString += ", "
|
||||
csvString += String(pos.seqNo)
|
||||
csvString += ", "
|
||||
|
||||
csvString += pos.time?.formattedDate(format: "yyyy-MM-dd HH:mm:ss") ?? "Unknown Age"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -867,10 +867,13 @@ func nodeInfoPacket (nodeInfo: NodeInfo, meshLogging: Bool, context: NSManagedOb
|
|||
if nodeInfo.position.latitudeI > 0 || nodeInfo.position.longitudeI > 0 {
|
||||
|
||||
let position = PositionEntity(context: context)
|
||||
position.seqNo = Int32(nodeInfo.position.seqNumber)
|
||||
position.latitudeI = nodeInfo.position.latitudeI
|
||||
position.longitudeI = nodeInfo.position.longitudeI
|
||||
position.altitude = nodeInfo.position.altitude
|
||||
position.satsInView = Int32(nodeInfo.position.satsInView)
|
||||
position.speed = Int32(nodeInfo.position.groundSpeed)
|
||||
position.heading = Int32(nodeInfo.position.groundTrack)
|
||||
position.time = Date(timeIntervalSince1970: TimeInterval(Int64(nodeInfo.position.time)))
|
||||
|
||||
var newPostions = [PositionEntity]()
|
||||
|
|
@ -1152,11 +1155,20 @@ func positionPacket (packet: MeshPacket, meshLogging: Bool, context: NSManagedOb
|
|||
if fetchedNode.count == 1 {
|
||||
|
||||
let position = PositionEntity(context: context)
|
||||
|
||||
position.seqNo = Int32(positionMessage.seqNumber)
|
||||
position.latitudeI = positionMessage.latitudeI
|
||||
position.longitudeI = positionMessage.longitudeI
|
||||
position.altitude = positionMessage.altitude
|
||||
position.satsInView = Int32(positionMessage.satsInView)
|
||||
position.time = Date(timeIntervalSince1970: TimeInterval(Int64(positionMessage.time)))
|
||||
position.speed = Int32(positionMessage.groundSpeed)
|
||||
position.heading = Int32(positionMessage.groundTrack)
|
||||
|
||||
if positionMessage.timestamp != 0 {
|
||||
position.time = Date(timeIntervalSince1970: TimeInterval(Int64(positionMessage.timestamp)))
|
||||
} else {
|
||||
position.time = Date(timeIntervalSince1970: TimeInterval(Int64(positionMessage.time)))
|
||||
}
|
||||
|
||||
let mutablePositions = fetchedNode[0].positions!.mutableCopy() as! NSMutableOrderedSet
|
||||
mutablePositions.add(position)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue