From fd23e0734c4190e6e35b40e83c03e2623ed80b0c Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sat, 30 Sep 2023 12:42:49 -0700 Subject: [PATCH] Fix admin message for store and forward config. --- Meshtastic/Helpers/BLEManager.swift | 3 --- Meshtastic/Persistence/UpdateCoreData.swift | 8 +++++++- Meshtastic/Views/Messages/ChannelMessageList.swift | 4 ++-- .../Views/Settings/Config/Module/StoreForward.swift | 4 ++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index 6d99e61a..de3c8ad0 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -28,9 +28,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate @Published var isSwitchedOn: Bool = false @Published var automaticallyReconnect: Bool = true @Published var mqttProxyConnected: Bool = false - @StateObject var appState = AppState.shared - //public var locationHelper = LocationHelper.shared public var minimumVersion = "2.0.0" public var connectedVersion: String public var isConnecting: Bool = false @@ -43,7 +41,6 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate var lastPosition: CLLocationCoordinate2D? let emptyNodeNum: UInt32 = 4294967295 let mqttManager = MqttClientProxyManager.shared - //var locationHelper = LocationHelper.shared var wantRangeTestPackets = false /* Meshtastic Service Details */ var TORADIO_characteristic: CBCharacteristic! diff --git a/Meshtastic/Persistence/UpdateCoreData.swift b/Meshtastic/Persistence/UpdateCoreData.swift index 322a9a5a..3c08fdf3 100644 --- a/Meshtastic/Persistence/UpdateCoreData.swift +++ b/Meshtastic/Persistence/UpdateCoreData.swift @@ -120,6 +120,8 @@ func upsertNodeInfoPacket (packet: MeshPacket, context: NSManagedObjectContext) newNode.rssi = packet.rxRssi if let nodeInfoMessage = try? NodeInfo(serializedData: packet.decoded.payload) { newNode.channel = Int32(nodeInfoMessage.channel) + print(packet.channel) + print("Channel From Message\(nodeInfoMessage.channel)") } if let newUserMessage = try? User(serializedData: packet.decoded.payload) { let newUser = UserEntity(context: context) @@ -130,6 +132,10 @@ func upsertNodeInfoPacket (packet: MeshPacket, context: NSManagedObjectContext) newUser.hwModel = String(describing: newUserMessage.hwModel).uppercased() newNode.user = newUser } + + if newNode.user == nil { + print("Nil User on nodeinfo") + } let myInfoEntity = MyInfoEntity(context: context) myInfoEntity.myNodeNum = Int64(packet.from) @@ -201,7 +207,7 @@ func upsertPositionPacket (packet: MeshPacket, context: NSManagedObjectContext) if let positionMessage = try? Position(serializedData: packet.decoded.payload) { // Don't save empty position packets - if positionMessage.longitudeI > 0 || positionMessage.latitudeI > 0 && (positionMessage.latitudeI != 373346000 && positionMessage.longitudeI != -1220090000) { + if (positionMessage.longitudeI == 0 && positionMessage.latitudeI == 0) && (positionMessage.latitudeI != 373346000 && positionMessage.longitudeI != -1220090000) { guard let fetchedNode = try context.fetch(fetchNodePositionRequest) as? [NodeInfoEntity] else { return } diff --git a/Meshtastic/Views/Messages/ChannelMessageList.swift b/Meshtastic/Views/Messages/ChannelMessageList.swift index 74a92b70..49281d65 100644 --- a/Meshtastic/Views/Messages/ChannelMessageList.swift +++ b/Meshtastic/Views/Messages/ChannelMessageList.swift @@ -258,14 +258,14 @@ struct ChannelMessageList: View { } .padding([.top]) .scrollDismissesKeyboard(.immediately) - .onAppear(perform: { + .onAppear { if self.bleManager.context == nil { self.bleManager.context = context } if channel.allPrivateMessages.count > 0 { scrollView.scrollTo(channel.allPrivateMessages.last!.messageId) } - }) + } .onChange(of: channel.allPrivateMessages, perform: { _ in if channel.allPrivateMessages.count > 0 { scrollView.scrollTo(channel.allPrivateMessages.last!.messageId) diff --git a/Meshtastic/Views/Settings/Config/Module/StoreForward.swift b/Meshtastic/Views/Settings/Config/Module/StoreForward.swift index f46efe6b..fe28c841 100644 --- a/Meshtastic/Views/Settings/Config/Module/StoreForward.swift +++ b/Meshtastic/Views/Settings/Config/Module/StoreForward.swift @@ -36,8 +36,8 @@ struct StoreForwardConfig: View { } else if node != nil && node?.num ?? 0 != bleManager.connectedPeripheral?.num ?? 0 { // Let users know what is going on if they are using remote admin and don't have the config yet - if node?.detectionSensorConfig == nil { - Text("Detection Sensor config data was requested over the admin channel but no response has been returned from the remote node. You can check the status of admin message requests in the admin message log.") + if node?.storeForwardConfig == nil { + Text("Store and forward config data was requested over the admin channel but no response has been returned from the remote node. You can check the status of admin message requests in the admin message log.") .font(.callout) .foregroundColor(.orange) } else {