diff --git a/MeshtasticApple/Helpers/BLEManager.swift b/MeshtasticApple/Helpers/BLEManager.swift index badd164e..61a455a5 100644 --- a/MeshtasticApple/Helpers/BLEManager.swift +++ b/MeshtasticApple/Helpers/BLEManager.swift @@ -197,9 +197,9 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph } } - // let today = Date() - // let visibleDuration = Calendar.current.date(byAdding: .second, value: -7, to: Date())! - // peripherals.removeAll(where: { $0.lastUpdate <= visibleDuration}) + let today = Date() + let visibleDuration = Calendar.current.date(byAdding: .second, value: -2, to: today)! + peripherals.removeAll(where: { $0.lastUpdate <= visibleDuration}) } // Called when a peripheral is connected @@ -395,7 +395,9 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph switch decodedInfo.packet.decoded.portnum { + // Handle Any local only packets we get over BLE case .unknownApp: + if decodedInfo.myInfo.myNodeNum != 0 { let myInfo = myInfoPacket(myInfo: decodedInfo.myInfo, meshLogging: meshLoggingEnabled, context: context!) @@ -427,6 +429,10 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph } } + } else if decodedInfo.config.version == 13 { + + localConfig(config: decodedInfo.config, meshlogging: meshLoggingEnabled, context: context!, nodeLongName: self.connectedPeripheral.longName) + } else { if meshLoggingEnabled { MeshLogger.log("â„šī¸ MESH PACKET received for Unknown App UNHANDLED \(try! decodedInfo.packet.jsonString())") } diff --git a/MeshtasticApple/Helpers/MeshPackets.swift b/MeshtasticApple/Helpers/MeshPackets.swift index 78fd07a6..8a8b3304 100644 --- a/MeshtasticApple/Helpers/MeshPackets.swift +++ b/MeshtasticApple/Helpers/MeshPackets.swift @@ -9,6 +9,48 @@ import Foundation import CoreData import SwiftUI +func localConfig (config: LocalConfig, meshlogging: Bool, context:NSManagedObjectContext, nodeLongName: String) { + + // We don't care about any of the Power settings + // We don't want to manage wifi from the phone app and disconnect our device + if meshlogging { MeshLogger.log("âš™ī¸ Local Config version \(config.version) received for \(nodeLongName)") } + + if (try! config.device.jsonString()) == "{}" { + + print("📟 Default Device config") + + } else { + + print("📟 Has Device config") + } + + if (try! config.display.jsonString()) == "{}" { + + print("đŸ–Ĩī¸ Default Display config") + + } else { + + print("đŸ–Ĩī¸ Has Display config") + } + + if (try! config.lora.jsonString()) == "{}" { + + print("📡 Default LoRa config") + + } else { + + print("📡 Has LoRa config") + } + + if (try! config.position.jsonString()) == "{}" { + + print("📍 Default Position config") + + } else { + + print("📍 Has Position config") + } +} func myInfoPacket (myInfo: MyNodeInfo, meshLogging: Bool, context: NSManagedObjectContext) -> MyInfoEntity? { @@ -352,15 +394,10 @@ func adminAppPacket (packet: MeshPacket, meshLogging: Bool, context: NSManagedOb } - if meshLogging { MeshLogger.log("â„šī¸ MESH PACKET received for Admin App UNHANDLED \(try! packet.jsonString())") } //PowerConfig //WiFiConfig - - - - //if let loraConfig = try? MeshtasticApple.Config.LoRaConfig(serializedData: packet.serializedData) { // print(loraConfig) diff --git a/MeshtasticApple/Views/Messages/UserMessageList.swift b/MeshtasticApple/Views/Messages/UserMessageList.swift index 65250db4..d70a18ec 100644 --- a/MeshtasticApple/Views/Messages/UserMessageList.swift +++ b/MeshtasticApple/Views/Messages/UserMessageList.swift @@ -75,13 +75,17 @@ struct UserMessageList: View { if currentUser { Spacer(minLength:50) } if !currentUser { - CircleText(text: message.fromUser?.shortName ?? "????", color: currentUser ? .accentColor : Color(.darkGray), circleSize: 46, fontSize: 16).padding(.all, 5) + + CircleText(text: message.fromUser?.shortName ?? "????", color: currentUser ? .accentColor : Color(.darkGray), circleSize: 44, fontSize: 14) + .padding(.all, 5) + .offset(y: -5) } VStack(alignment: currentUser ? .trailing : .leading) { Text(message.messagePayload ?? "EMPTY MESSAGE") .padding(10) + .foregroundColor(.white) .background(currentUser ? Color.blue : Color(.darkGray)) .cornerRadius(15) @@ -284,8 +288,8 @@ struct UserMessageList: View { } .padding(.bottom) .id(user.messageList.firstIndex(of: message)) - if !currentUser { + Spacer(minLength:50) } }