mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Create a my info when creating a nodeinfo
This commit is contained in:
parent
a990d7f2bd
commit
4d26512dba
1 changed files with 14 additions and 0 deletions
|
|
@ -130,6 +130,20 @@ func upsertNodeInfoPacket (packet: MeshPacket, context: NSManagedObjectContext)
|
|||
newUser.hwModel = String(describing: newUserMessage.hwModel).uppercased()
|
||||
newNode.user = newUser
|
||||
}
|
||||
|
||||
let myInfoEntity = MyInfoEntity(context: context)
|
||||
myInfoEntity.myNodeNum = Int64(packet.from)
|
||||
myInfoEntity.rebootCount = 0
|
||||
do {
|
||||
try context.save()
|
||||
print("💾 Saved a new myInfo for node number: \(String(packet.from))")
|
||||
} catch {
|
||||
context.rollback()
|
||||
let nsError = error as NSError
|
||||
print("💥 Error Inserting New Core Data MyInfoEntity: \(nsError)")
|
||||
}
|
||||
newNode.myInfo = myInfoEntity
|
||||
|
||||
} else {
|
||||
// Update an existing node
|
||||
fetchedNode[0].id = Int64(packet.from)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue