Extra logging for config packets

This commit is contained in:
Garth Vander Houwen 2022-08-07 08:31:39 -07:00
parent a03f50da51
commit 602ff58db8
4 changed files with 93 additions and 14 deletions

View file

@ -21,6 +21,10 @@ func localConfig (config: Config, meshlogging: Bool, context:NSManagedObjectCont
isDefault = true
print("📟 Default Device config")
} else {
print("📟 Custom Device config")
}
let fetchNodeInfoRequest: NSFetchRequest<NSFetchRequestResult> = NSFetchRequest.init(entityName: "NodeInfoEntity")
@ -96,6 +100,10 @@ func localConfig (config: Config, meshlogging: Bool, context:NSManagedObjectCont
isDefault = true
print("🖥️ Default Display config")
} else {
print("🖥️ Custom Display config")
}
let fetchNodeInfoRequest: NSFetchRequest<NSFetchRequestResult> = NSFetchRequest.init(entityName: "NodeInfoEntity")
@ -116,12 +124,14 @@ func localConfig (config: Config, meshlogging: Bool, context:NSManagedObjectCont
newDisplayConfig.screenOnSeconds = 0
newDisplayConfig.screenCarouselInterval = 0
newDisplayConfig.gpsFormat = 0
newDisplayConfig.compassNorthTop = false
} else {
newDisplayConfig.gpsFormat = Int32(config.display.gpsFormat.rawValue)
newDisplayConfig.screenOnSeconds = Int32(config.display.screenOnSecs)
newDisplayConfig.screenCarouselInterval = Int32(config.display.autoScreenCarouselSecs)
newDisplayConfig.compassNorthTop = config.display.compassNorthTop
}
fetchedNode[0].displayConfig = newDisplayConfig
@ -132,12 +142,14 @@ func localConfig (config: Config, meshlogging: Bool, context:NSManagedObjectCont
fetchedNode[0].displayConfig?.screenOnSeconds = 0
fetchedNode[0].displayConfig?.screenCarouselInterval = 0
fetchedNode[0].displayConfig?.gpsFormat = 0
fetchedNode[0].displayConfig?.compassNorthTop = false
} else {
fetchedNode[0].displayConfig?.gpsFormat = Int32(config.display.gpsFormat.rawValue)
fetchedNode[0].displayConfig?.screenOnSeconds = Int32(config.display.screenOnSecs)
fetchedNode[0].displayConfig?.screenCarouselInterval = Int32(config.display.autoScreenCarouselSecs)
fetchedNode[0].displayConfig?.compassNorthTop = config.display.compassNorthTop
}
}
@ -153,10 +165,15 @@ func localConfig (config: Config, meshlogging: Bool, context:NSManagedObjectCont
let nsError = error as NSError
print("💥 Error Updating Core Data DisplayConfigEntity: \(nsError)")
}
} else {
print("💥 No Nodes found in local database matching node number \(nodeNum) unable to save Display Config")
}
} catch {
let nsError = error as NSError
print("💥 Fetching node for core data DisplayConfigEntity failed: \(nsError)")
}
}
@ -245,7 +262,7 @@ func localConfig (config: Config, meshlogging: Bool, context:NSManagedObjectCont
}
} else {
print("💥 No Nodes found in core data matching connected node number \(nodeNum)")
print("💥 No Nodes found in local database matching node number \(nodeNum) unable to save Lora Config")
}
@ -339,10 +356,15 @@ func localConfig (config: Config, meshlogging: Bool, context:NSManagedObjectCont
let nsError = error as NSError
print("💥 Error Updating Core Data PositionConfigEntity: \(nsError)")
}
} else {
print("💥 No Nodes found in local database matching node number \(nodeNum) unable to save Position Config")
}
} catch {
let nsError = error as NSError
print("💥 Fetching node for core data PositionConfigEntity failed: \(nsError)")
}
}
@ -414,12 +436,17 @@ func localConfig (config: Config, meshlogging: Bool, context:NSManagedObjectCont
context.rollback()
let nsError = error as NSError
print("💥 Error Updating Core Data WifionfigEntity: \(nsError)")
print("💥 Error Updating Core Data WiFiConfigEntity: \(nsError)")
}
} else {
print("💥 No Nodes found in local database matching node number \(nodeNum) unable to save WiFi Config")
}
} catch {
let nsError = error as NSError
print("💥 Fetching node for core data WiFiConfigEntity failed: \(nsError)")
}
}
}
@ -435,6 +462,9 @@ func moduleConfig (config: ModuleConfig, meshlogging: Bool, context:NSManagedObj
isDefault = true
print("🥫 Default Canned Message Module config")
} else {
print("🥫 Custom Canned Message Module config")
}
let fetchNodeInfoRequest: NSFetchRequest<NSFetchRequestResult> = NSFetchRequest.init(entityName: "NodeInfoEntity")
@ -522,10 +552,15 @@ func moduleConfig (config: ModuleConfig, meshlogging: Bool, context:NSManagedObj
let nsError = error as NSError
print("💥 Error Updating Core Data CannedMessageConfigEntity: \(nsError)")
}
} else {
print("💥 No Nodes found in local database matching node number \(nodeNum) unable to save Canned Message Module Config")
}
} catch {
let nsError = error as NSError
print("💥 Fetching node for core data CannedMessageConfigEntity failed: \(nsError)")
}
}
@ -537,6 +572,10 @@ func moduleConfig (config: ModuleConfig, meshlogging: Bool, context:NSManagedObj
isDefault = true
print("🚨 Default External Notifiation Module config")
} else {
print("🚨 Custom External Notifiation Module config")
}
let fetchNodeInfoRequest: NSFetchRequest<NSFetchRequestResult> = NSFetchRequest.init(entityName: "NodeInfoEntity")
@ -609,10 +648,15 @@ func moduleConfig (config: ModuleConfig, meshlogging: Bool, context:NSManagedObj
let nsError = error as NSError
print("💥 Error Updating Core Data ExternalNotificationConfigEntity: \(nsError)")
}
} else {
print("💥 No Nodes found in local database matching node number \(nodeNum) unable to save External Notifiation Module Config")
}
} catch {
let nsError = error as NSError
print("💥 Fetching node for core data ExternalNotificationConfigEntity failed: \(nsError)")
}
}
@ -682,10 +726,15 @@ func moduleConfig (config: ModuleConfig, meshlogging: Bool, context:NSManagedObj
let nsError = error as NSError
print("💥 Error Updating Core Data RangeTestConfigEntity: \(nsError)")
}
} else {
print("💥 No Nodes found in local database matching node number \(nodeNum) unable to save Range Test Module Config")
}
} catch {
let nsError = error as NSError
print("💥 Fetching node for core data RangeTestConfigEntity failed: \(nsError)")
}
}
@ -776,10 +825,15 @@ func moduleConfig (config: ModuleConfig, meshlogging: Bool, context:NSManagedObj
let nsError = error as NSError
print("💥 Error Updating Core Data SerialConfigEntity: \(nsError)")
}
} else {
print("💥 No Nodes found in local database matching node number \(nodeNum) unable to save Serial Module Config")
}
} catch {
let nsError = error as NSError
print("💥 Fetching node for core data SerialConfigEntity failed: \(nsError)")
}
}
@ -856,10 +910,15 @@ func moduleConfig (config: ModuleConfig, meshlogging: Bool, context:NSManagedObj
let nsError = error as NSError
print("💥 Error Updating Core Data TelemetryConfigEntity: \(nsError)")
}
} else {
print("💥 No Nodes found in local database matching node number \(nodeNum) unable to save Telemetry Module Config")
}
} catch {
let nsError = error as NSError
print("💥 Fetching node for core data TelemetryConfigEntity failed: \(nsError)")
}
}
}
@ -1208,6 +1267,7 @@ func adminAppPacket (packet: MeshPacket, meshLogging: Bool, context: NSManagedOb
}
if meshLogging { MeshLogger.log(" MESH PACKET received for Admin App UNHANDLED \(try! packet.jsonString())") }
//PowerConfig
@ -1265,6 +1325,7 @@ func positionPacket (packet: MeshPacket, meshLogging: Bool, context: NSManagedOb
print("💥 Error Saving NodeInfoEntity from POSITION_APP \(nsError)")
}
}
} else {
print("💥 Empty POSITION_APP Packet")
@ -1487,7 +1548,7 @@ func textMessageAppPacket(packet: MeshPacket, connectedNode: Int64, meshLogging:
print("💥 Failed to save new MessageEntity \(nsError)")
}
do {
print(newMessage)
if messageSaved && (newMessage.toUser != nil && newMessage.toUser!.num == broadcastNodeNum || connectedNode == newMessage.toUser!.num) {
// Create an iOS Notification for the received message and schedule it immediately

View file

@ -22,6 +22,7 @@
<relationship name="deviceConfigNode" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="NodeInfoEntity" inverseName="deviceConfig" inverseEntity="NodeInfoEntity"/>
</entity>
<entity name="DisplayConfigEntity" representedClassName="DisplayConfigEntity" syncable="YES" codeGenerationType="class">
<attribute name="compassNorthTop" optional="YES" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
<attribute name="gpsFormat" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="num" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="screenCarouselInterval" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
@ -203,7 +204,7 @@
<elements>
<element name="CannedMessageConfigEntity" positionX="45" positionY="144" width="128" height="209"/>
<element name="DeviceConfigEntity" positionX="45" positionY="144" width="128" height="104"/>
<element name="DisplayConfigEntity" positionX="54" positionY="153" width="128" height="104"/>
<element name="DisplayConfigEntity" positionX="54" positionY="153" width="128" height="119"/>
<element name="ExternalNotificationConfigEntity" positionX="63" positionY="162" width="128" height="149"/>
<element name="LoRaConfigEntity" positionX="45" positionY="144" width="128" height="119"/>
<element name="MessageEntity" positionX="-36" positionY="63" width="128" height="245"/>

View file

@ -134,13 +134,14 @@ struct DisplayConfig: View {
@State var screenOnSeconds = 0
@State var screenCarouselInterval = 0
@State var gpsFormat = 0
@State var compassNorthTop = false
var body: some View {
VStack {
Form {
Section(header: Text("Timing")) {
Section(header: Text("Device Screen")) {
Picker("Screen on for", selection: $screenOnSeconds ) {
ForEach(ScreenOnIntervals.allCases) { soi in
@ -161,8 +162,15 @@ struct DisplayConfig: View {
Text("Automatically toggles to the next page on the screen like a carousel, based the specified interval.")
.font(.caption)
.listRowSeparator(.visible)
Toggle(isOn: $compassNorthTop) {
Label("Always point north", systemImage: "location.north.circle")
}
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
Text("The compass heading on the screen outside of the circle will always point north.")
.font(.caption)
}
Section(header: Text("Format")) {
Picker("GPS Format", selection: $gpsFormat ) {
@ -203,6 +211,7 @@ struct DisplayConfig: View {
dc.gpsFormat = GpsFormats(rawValue: gpsFormat)!.protoEnumValue()
dc.screenOnSecs = UInt32(screenOnSeconds)
dc.autoScreenCarouselSecs = UInt32(screenCarouselInterval)
dc.compassNorthTop = compassNorthTop
let adminMessageId = bleManager.saveDisplayConfig(config: dc, fromUser: node!.user!, toUser: node!.user!, wantResponse: true)
@ -234,6 +243,7 @@ struct DisplayConfig: View {
self.gpsFormat = Int(node!.displayConfig?.gpsFormat ?? 0)
self.screenOnSeconds = Int(node!.displayConfig?.screenOnSeconds ?? 0)
self.screenCarouselInterval = Int(node!.displayConfig?.screenCarouselInterval ?? 0)
self.compassNorthTop = node!.displayConfig?.compassNorthTop ?? false
self.hasChanges = false
self.initialLoad = false
}
@ -252,6 +262,13 @@ struct DisplayConfig: View {
if newCarouselSecs != node!.displayConfig!.screenCarouselInterval { hasChanges = true }
}
}
.onChange(of: compassNorthTop) { newCompassNorthTop in
if node != nil && node!.displayConfig != nil {
if newCompassNorthTop != node!.displayConfig!.compassNorthTop { hasChanges = true }
}
}
.onChange(of: gpsFormat) { newGpsFormat in
if node != nil && node!.displayConfig != nil {

View file

@ -241,7 +241,7 @@ struct CannedMessagesConfig: View {
Section(header: Text("Key Mapping")) {
Picker("inputbrokerEventCw", selection: $inputbrokerEventCw ) {
Picker("Clockwise Rotary Event", selection: $inputbrokerEventCw ) {
ForEach(InputEventChars.allCases) { iec in
Text(iec.description)
}
@ -250,7 +250,7 @@ struct CannedMessagesConfig: View {
.padding(.top, 10)
.padding(.bottom, 10)
Picker("inputbrokerEventCcw", selection: $inputbrokerEventCcw ) {
Picker("Counter Clockwise Rotary Event", selection: $inputbrokerEventCcw ) {
ForEach(InputEventChars.allCases) { iec in
Text(iec.description)
}
@ -259,7 +259,7 @@ struct CannedMessagesConfig: View {
.padding(.top, 10)
.padding(.bottom, 10)
Picker("inputBrokerEventPress", selection: $inputbrokerEventPress ) {
Picker("Encoder Press Event", selection: $inputbrokerEventPress ) {
ForEach(InputEventChars.allCases) { iec in
Text(iec.description)
}
@ -379,9 +379,9 @@ struct CannedMessagesConfig: View {
inputbrokerPinA = 4
inputbrokerPinB = 10
inputbrokerPinPress = 3
inputbrokerEventCw = InputEventChars.keyNone.rawValue
inputbrokerEventCcw = InputEventChars.keyNone.rawValue
inputbrokerEventPress = InputEventChars.keyNone.rawValue
inputbrokerEventCw = InputEventChars.keyUp.rawValue
inputbrokerEventCcw = InputEventChars.keyDown.rawValue
inputbrokerEventPress = InputEventChars.keySelect.rawValue
} else if newPreset == 2 {
@ -391,8 +391,8 @@ struct CannedMessagesConfig: View {
inputbrokerPinA = 25
inputbrokerPinB = 39
inputbrokerPinPress = 36
inputbrokerEventCw = InputEventChars.keyUp.rawValue
inputbrokerEventCcw = InputEventChars.keyDown.rawValue
inputbrokerEventCw = InputEventChars.keyLeft.rawValue
inputbrokerEventCcw = InputEventChars.keyRight.rawValue
inputbrokerEventPress = InputEventChars.keySelect.rawValue
}