Log node info packet json

This commit is contained in:
Garth Vander Houwen 2024-09-05 10:39:54 -07:00
parent 1853afde73
commit 6e6027263a
6 changed files with 9 additions and 25 deletions

View file

@ -5426,7 +5426,7 @@
"Device GPS" : {
},
"Device is managed by a mesh administrator." : {
"Device is managed by a mesh administrator, the user is unable to access any of the device settings." : {
},
"Device Metrics" : {
@ -6923,9 +6923,6 @@
},
"Enabling Ethernet will disable the bluetooth connection to the app." : {
},
"Enabling Managed mode will restrict access to all radio configurations, such as short/long names, regions, channels, modules, etc. and will only be accessible through the Admin channel. To avoid being locked out, make sure the Admin channel is working properly before enabling it." : {
},
"Enabling WiFi will disable the bluetooth connection to the app." : {

View file

@ -766,6 +766,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
case .waypointApp:
waypointPacket(packet: decodedInfo.packet, context: context)
case .nodeinfoApp:
MeshLogger.log("🕸️ MESH PACKET received for Node Info App for PKI LOCK debugging \((try? decodedInfo.packet.jsonString()) ?? "JSON Decode Failure")")
if !invalidVersion { upsertNodeInfoPacket(packet: decodedInfo.packet, context: context) }
case .routingApp:
if !invalidVersion { routingPacket(packet: decodedInfo.packet, connectedNodeNum: self.connectedPeripheral.num, context: context) }

View file

@ -366,7 +366,7 @@ func nodeInfoPacket (nodeInfo: NodeInfo, channel: UInt32, context: NSManagedObje
fetchedNode[0].user = UserEntity(context: context)
}
// Set the public key for a user if it is empty, don't update
if fetchedNode[0].user?.publicKey?.isEmpty == nil && !nodeInfo.user.publicKey.isEmpty {
if fetchedNode[0].user?.publicKey == nil && !nodeInfo.user.publicKey.isEmpty {
fetchedNode[0].user?.pkiEncrypted = true
fetchedNode[0].user?.publicKey = nodeInfo.user.publicKey
}

View file

@ -269,8 +269,11 @@ 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)
fetchedNode[0].user!.pkiEncrypted = packet.pkiEncrypted
fetchedNode[0].user!.publicKey = packet.publicKey
if !packet.publicKey.isEmpty {
fetchedNode[0].user!.pkiEncrypted = packet.pkiEncrypted
fetchedNode[0].user!.publicKey = packet.publicKey
}
Task {
Api().loadDeviceHardwareData { (hw) in
let dh = hw.first(where: { $0.hwModel == fetchedNode[0].user?.hwModelId ?? 0 })

View file

@ -29,7 +29,6 @@ struct DeviceConfig: View {
@State var nodeInfoBroadcastSecs = 10800
@State var doubleTapAsButtonPress = false
@State var ledHeartbeatEnabled = true
@State var isManaged = false
@State var tzdef = ""
var body: some View {
@ -62,12 +61,6 @@ struct DeviceConfig: View {
}
.pickerStyle(DefaultPickerStyle())
Toggle(isOn: $isManaged) {
Label("Managed Device", systemImage: "gearshape.arrow.triangle.2.circlepath")
Text("Enabling Managed mode will restrict access to all radio configurations, such as short/long names, regions, channels, modules, etc. and will only be accessible through the Admin channel. To avoid being locked out, make sure the Admin channel is working properly before enabling it.")
}
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
Picker("Node Info Broadcast Interval", selection: $nodeInfoBroadcastSecs ) {
ForEach(UpdateIntervals.allCases) { ui in
if ui.rawValue >= 3600 {
@ -213,13 +206,8 @@ struct DeviceConfig: View {
dc.rebroadcastMode = RebroadcastModes(rawValue: rebroadcastMode)?.protoEnumValue() ?? RebroadcastModes.all.protoEnumValue()
dc.nodeInfoBroadcastSecs = UInt32(nodeInfoBroadcastSecs)
dc.doubleTapAsButtonPress = doubleTapAsButtonPress
dc.isManaged = isManaged
dc.tzdef = tzdef
dc.ledHeartbeatDisabled = !ledHeartbeatEnabled
if isManaged {
serialEnabled = false
debugLogEnabled = false
}
let adminMessageId = bleManager.saveDeviceConfig(config: dc, fromUser: connectedNode!.user!, toUser: node!.user!, adminIndex: connectedNode?.myInfo?.adminIndex ?? 0)
if adminMessageId > 0 {
// Should show a saved successfully alert once I know that to be true
@ -287,9 +275,6 @@ struct DeviceConfig: View {
.onChange(of: doubleTapAsButtonPress) {
if $0 != node?.deviceConfig?.doubleTapAsButtonPress { hasChanges = true }
}
.onChange(of: isManaged) {
if $0 != node?.deviceConfig?.isManaged { hasChanges = true }
}
.onChange(of: tzdef) { newTzdef in
if newTzdef != node?.deviceConfig?.tzdef { hasChanges = true }
}
@ -312,7 +297,6 @@ struct DeviceConfig: View {
}
self.doubleTapAsButtonPress = node?.deviceConfig?.doubleTapAsButtonPress ?? false
self.ledHeartbeatEnabled = node?.deviceConfig?.ledHeartbeatEnabled ?? true
self.isManaged = node?.deviceConfig?.isManaged ?? false
self.tzdef = node?.deviceConfig?.tzdef ?? ""
if self.tzdef.isEmpty {
self.tzdef = TimeZone.current.posixDescription

View file

@ -75,7 +75,6 @@ struct SecurityConfig: View {
Text("Serial Console over the Stream API.")
}
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
Toggle(isOn: $debugLogApiEnabled) {
Label("Debug Logs", systemImage: "ant.fill")
Text("Output live debug logging over serial, view and export position-redacted device logs over Bluetooth.")
@ -86,7 +85,7 @@ struct SecurityConfig: View {
if adminKey.length > 0 || adminChannelEnabled {
Toggle(isOn: $isManaged) {
Label("Managed Device", systemImage: "gearshape.arrow.triangle.2.circlepath")
Text("Device is managed by a mesh administrator.")
Text("Device is managed by a mesh administrator, the user is unable to access any of the device settings.")
}
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
}