Clean up circle text on messages, read and log new config structure

This commit is contained in:
Garth Vander Houwen 2022-06-15 22:11:37 -07:00
parent 9396383ade
commit c20c595067
3 changed files with 57 additions and 10 deletions

View file

@ -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())") }

View file

@ -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)

View file

@ -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)
}
}