diff --git a/Meshtastic/Helpers/MeshPackets.swift b/Meshtastic/Helpers/MeshPackets.swift index 38a3b7a6..147308bf 100644 --- a/Meshtastic/Helpers/MeshPackets.swift +++ b/Meshtastic/Helpers/MeshPackets.swift @@ -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 = 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 = 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 = 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 = 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 diff --git a/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModel v 6.xcdatamodel/contents b/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModel v 6.xcdatamodel/contents index eca24535..6f9b7000 100644 --- a/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModel v 6.xcdatamodel/contents +++ b/Meshtastic/Meshtastic.xcdatamodeld/MeshtasticDataModel v 6.xcdatamodel/contents @@ -22,6 +22,7 @@ + @@ -203,7 +204,7 @@ - + diff --git a/Meshtastic/Views/Settings/Config/DisplayConfig.swift b/Meshtastic/Views/Settings/Config/DisplayConfig.swift index 6d4da661..f08c7dbf 100644 --- a/Meshtastic/Views/Settings/Config/DisplayConfig.swift +++ b/Meshtastic/Views/Settings/Config/DisplayConfig.swift @@ -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 { diff --git a/Meshtastic/Views/Settings/Config/Module/CannedMessagesConfig.swift b/Meshtastic/Views/Settings/Config/Module/CannedMessagesConfig.swift index 3fe04782..950c77de 100644 --- a/Meshtastic/Views/Settings/Config/Module/CannedMessagesConfig.swift +++ b/Meshtastic/Views/Settings/Config/Module/CannedMessagesConfig.swift @@ -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 }