mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Fix incoming keys
This commit is contained in:
parent
f52a0918d0
commit
2daf3e3536
5 changed files with 56 additions and 28 deletions
|
|
@ -1429,8 +1429,15 @@
|
|||
"Bad" : {
|
||||
|
||||
},
|
||||
"Bad Packets: %d" : {
|
||||
|
||||
"Bad Packets: %d %@%%" : {
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "new",
|
||||
"value" : "Bad Packets: %1$d %2$@%%"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Bandwidth" : {
|
||||
|
||||
|
|
@ -16079,11 +16086,15 @@
|
|||
"Override automatic OLED screen detection." : {
|
||||
|
||||
},
|
||||
"Packets Received: %d" : {
|
||||
|
||||
},
|
||||
"Packets Sent: %d" : {
|
||||
|
||||
"Packets: Sent: %d Received: %d" : {
|
||||
"localizations" : {
|
||||
"en" : {
|
||||
"stringUnit" : {
|
||||
"state" : "new",
|
||||
"value" : "Packets: Sent: %1$d Received: %2$d"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"password" : {
|
||||
"localizations" : {
|
||||
|
|
@ -22314,6 +22325,9 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Uptime: %@" : {
|
||||
|
||||
},
|
||||
"Use a PWM output (like the RAK Buzzer) for tunes instead of an on/off output. This will ignore the output, output duration and active settings and use the device config buzzer GPIO option instead." : {
|
||||
|
||||
|
|
|
|||
|
|
@ -864,8 +864,10 @@ func textMessageAppPacket(
|
|||
newMessage.isEmoji = packet.decoded.emoji == 1
|
||||
newMessage.channel = Int32(packet.channel)
|
||||
newMessage.portNum = Int32(packet.decoded.portnum.rawValue)
|
||||
newMessage.publicKey = packet.publicKey
|
||||
newMessage.pkiEncrypted = packet.pkiEncrypted
|
||||
if newMessage.toUser?.pkiEncrypted ?? false {
|
||||
newMessage.pkiEncrypted = true
|
||||
newMessage.publicKey = packet.publicKey
|
||||
}
|
||||
if packet.decoded.portnum == PortNum.detectionSensorApp {
|
||||
if !UserDefaults.enableDetectionNotifications {
|
||||
newMessage.read = true
|
||||
|
|
@ -889,9 +891,11 @@ func textMessageAppPacket(
|
|||
newMessage.fromUser?.newPublicKey = newMessage.publicKey
|
||||
}
|
||||
} else {
|
||||
/// We have no key, set it
|
||||
newMessage.fromUser?.publicKey = packet.publicKey
|
||||
newMessage.fromUser?.pkiEncrypted = packet.pkiEncrypted
|
||||
/// We have no key, set it if it is not empty
|
||||
if !packet.publicKey.isEmpty {
|
||||
newMessage.fromUser?.pkiEncrypted = true
|
||||
newMessage.fromUser?.publicKey = packet.publicKey
|
||||
}
|
||||
}
|
||||
if packet.rxTime > 0 {
|
||||
newMessage.fromUser?.userNode?.lastHeard = Date(timeIntervalSince1970: TimeInterval(Int64(packet.rxTime)))
|
||||
|
|
|
|||
|
|
@ -181,8 +181,11 @@ func upsertNodeInfoPacket (packet: MeshPacket, context: NSManagedObjectContext)
|
|||
newUser.role = Int32(newUserMessage.role.rawValue)
|
||||
newUser.hwModel = String(describing: newUserMessage.hwModel).uppercased()
|
||||
newUser.hwModelId = Int32(newUserMessage.hwModel.rawValue)
|
||||
newUser.pkiEncrypted = packet.pkiEncrypted
|
||||
newUser.publicKey = packet.publicKey
|
||||
if !newUserMessage.publicKey.isEmpty {
|
||||
newUser.pkiEncrypted = true
|
||||
newUser.publicKey = newUserMessage.publicKey
|
||||
}
|
||||
|
||||
Task {
|
||||
Api().loadDeviceHardwareData { (hw) in
|
||||
let dh = hw.first(where: { $0.hwModel == newUser.hwModelId })
|
||||
|
|
@ -209,8 +212,10 @@ func upsertNodeInfoPacket (packet: MeshPacket, context: NSManagedObjectContext)
|
|||
} else {
|
||||
if packet.from > Constants.minimumNodeNum {
|
||||
let newUser = createUser(num: Int64(packet.from), context: context)
|
||||
newNode.user?.pkiEncrypted = packet.pkiEncrypted
|
||||
newNode.user?.publicKey = packet.publicKey
|
||||
if !packet.publicKey.isEmpty {
|
||||
newNode.user?.pkiEncrypted = true
|
||||
newNode.user?.publicKey = packet.publicKey
|
||||
}
|
||||
newNode.user = newUser
|
||||
}
|
||||
}
|
||||
|
|
@ -224,6 +229,7 @@ func upsertNodeInfoPacket (packet: MeshPacket, context: NSManagedObjectContext)
|
|||
myInfoEntity.rebootCount = 0
|
||||
do {
|
||||
try context.save()
|
||||
Logger.data.info("💾 [NodeInfo] Saved a NodeInfo for node number: \(packet.from.toHex(), privacy: .public)")
|
||||
Logger.data.info("💾 [MyInfoEntity] Saved a new myInfo for node number: \(packet.from.toHex(), privacy: .public)")
|
||||
} catch {
|
||||
context.rollback()
|
||||
|
|
@ -271,10 +277,9 @@ func upsertNodeInfoPacket (packet: MeshPacket, context: NSManagedObjectContext)
|
|||
fetchedNode[0].user!.role = Int32(nodeInfoMessage.user.role.rawValue)
|
||||
fetchedNode[0].user!.hwModel = String(describing: nodeInfoMessage.user.hwModel).uppercased()
|
||||
fetchedNode[0].user!.hwModelId = Int32(nodeInfoMessage.user.hwModel.rawValue)
|
||||
|
||||
if !packet.publicKey.isEmpty {
|
||||
fetchedNode[0].user!.pkiEncrypted = packet.pkiEncrypted
|
||||
fetchedNode[0].user!.publicKey = packet.publicKey
|
||||
if !nodeInfoMessage.user.publicKey.isEmpty {
|
||||
fetchedNode[0].user!.pkiEncrypted = true
|
||||
fetchedNode[0].user!.publicKey = nodeInfoMessage.user.publicKey
|
||||
}
|
||||
Task {
|
||||
Api().loadDeviceHardwareData { (hw) in
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ struct Connect: View {
|
|||
}
|
||||
VStack {
|
||||
let localStats = node?.telemetries?.filtered(using: NSPredicate(format: "metricsType == 6")).lastObject as? TelemetryEntity
|
||||
|
||||
if localStats != nil {
|
||||
Divider()
|
||||
if localStats?.numTotalNodes ?? 0 >= 100 {
|
||||
|
|
@ -111,25 +112,29 @@ struct Connect: View {
|
|||
.font(.caption)
|
||||
.fontWeight(.medium)
|
||||
.foregroundStyle(.secondary)
|
||||
Text("Packets Sent: \(localStats?.numPacketsTx ?? 0)")
|
||||
Text("Packets: Sent: \(localStats?.numPacketsTx ?? 0) Received: \(localStats?.numPacketsRx ?? 0)")
|
||||
.font(.caption)
|
||||
.fontWeight(.medium)
|
||||
.foregroundStyle(.secondary)
|
||||
Text("Packets Received: \(localStats?.numPacketsRx ?? 0)")
|
||||
.font(.caption)
|
||||
.fontWeight(.medium)
|
||||
.foregroundStyle(.secondary)
|
||||
Text("Bad Packets: \(localStats?.numPacketsRxBad ?? 0)")
|
||||
let errorRate = (Double(localStats?.numPacketsRxBad ?? -1) / Double(localStats?.numPacketsRx ?? -1)) * 100
|
||||
Text("Bad Packets: \(localStats?.numPacketsRxBad ?? 0) \(String(format: "Error Rate: %.2f", errorRate))%")
|
||||
.font(.caption)
|
||||
.fontWeight(.medium)
|
||||
.foregroundStyle(.secondary)
|
||||
.fixedSize()
|
||||
let now = Date.now
|
||||
let later = now + TimeInterval(Double(localStats?.numPacketsRxBad ?? 0))
|
||||
let uptime = (now..<later).formatted(.components(style: .narrow))
|
||||
Text("Uptime: \(uptime)")
|
||||
.font(.caption)
|
||||
.fontWeight(.medium)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
}
|
||||
}
|
||||
.font(.caption)
|
||||
.foregroundColor(Color.gray)
|
||||
.padding([.top, .bottom])
|
||||
.padding([.top])
|
||||
.swipeActions {
|
||||
Button(role: .destructive) {
|
||||
if let connectedPeripheral = bleManager.connectedPeripheral,
|
||||
|
|
|
|||
|
|
@ -191,6 +191,7 @@ struct NodeInfoView: View {
|
|||
var timerRange: ClosedRange<Date>
|
||||
|
||||
var body: some View {
|
||||
let errorRate = (Double(badReceivedPackets) / Double(receivedPackets)) * 100
|
||||
VStack(alignment: .leading, spacing: 0) {
|
||||
Text(nodeName)
|
||||
.font(nodeName.count > 14 ? .callout : .title3)
|
||||
|
|
@ -208,7 +209,6 @@ struct NodeInfoView: View {
|
|||
.foregroundStyle(.secondary)
|
||||
.opacity(isLuminanceReduced ? 0.8 : 1.0)
|
||||
.fixedSize()
|
||||
let errorRate = (Double(badReceivedPackets) / Double(receivedPackets)) * 100
|
||||
Text("Bad: \(badReceivedPackets) \(String(format: "Error Rate: %.2f", errorRate))%")
|
||||
.font(.caption)
|
||||
.fontWeight(.medium)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue