Add values to config enums

This commit is contained in:
Garth Vander Houwen 2022-09-01 18:37:41 -07:00
parent cfe23b1d1c
commit a0e83160a2
4 changed files with 59 additions and 49 deletions

View file

@ -7,6 +7,43 @@
import Foundation
enum PositionBroadcastIntervals: Int, CaseIterable, Identifiable {
case fifteenSeconds = 15
case thirtySeconds = 30
case oneMinute = 60
case fiveMinutes = 300
case tenMinutes = 600
case fifteenMinutes = 0
case thirtyMinutes = 1800
case oneHour = 3600
var id: Int { self.rawValue }
var description: String {
get {
switch self {
case .fifteenSeconds:
return "Fifteen Seconds"
case .thirtySeconds:
return "Thirty Seconds"
case .oneMinute:
return "One Minute"
case .fiveMinutes:
return "Five Minutes"
case .tenMinutes:
return "Ten Minutes"
case .fifteenMinutes:
return "Fifteen Minutes"
case .thirtyMinutes:
return "Thirty Minutes"
case .oneHour:
return "One Hour"
}
}
}
}
enum GpsFormats: Int, CaseIterable, Identifiable {
case gpsFormatDec = 0
@ -81,7 +118,7 @@ enum GpsUpdateIntervals: Int, CaseIterable, Identifiable {
case .tenSeconds:
return "Ten Seconds"
case .fifteenSeconds:
return "fifteenSeconds"
return "Fifteen Seconds"
case .thirtySeconds:
return "Thirty Seconds"
case .oneMinute:
@ -105,6 +142,7 @@ enum GpsUpdateIntervals: Int, CaseIterable, Identifiable {
enum GpsAttemptTimes: Int, CaseIterable, Identifiable {
case fifteenSeconds = 15
case thirtySeconds = 0
case oneMinute = 60
case fiveMinutes = 300
@ -116,6 +154,8 @@ enum GpsAttemptTimes: Int, CaseIterable, Identifiable {
get {
switch self {
case .fifteenSeconds:
return "Fifteen Seconds"
case .thirtySeconds:
return "Thirty Seconds"
case .oneMinute:

View file

@ -1359,19 +1359,12 @@ func adminAppPacket (packet: MeshPacket, meshLogging: Bool, context: NSManagedOb
} else if let powerConfig = try? Config.PowerConfig(serializedData: packet.decoded.payload) {
print(try! powerConfig.jsonUTF8Data())
print(powerConfig.meshSdsTimeoutSecs)
}
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)
//}
}
func positionPacket (packet: MeshPacket, meshLogging: Bool, context: NSManagedObjectContext) {

View file

@ -10,11 +10,14 @@ import SwiftUI
enum SenderIntervals: Int, CaseIterable, Identifiable {
case off = 0
case fifteenSeconds = 15
case thirtySeconds = 30
case oneMinute = 60
case fiveMinutes = 300
case tenMinutes = 600
case fifteenMinutes = 900
case thirtyMinutes = 1800
var id: Int { self.rawValue }
var description: String {
@ -22,6 +25,8 @@ enum SenderIntervals: Int, CaseIterable, Identifiable {
switch self {
case .off:
return "Off"
case .fifteenSeconds:
return "Fifteen Seconds"
case .thirtySeconds:
return "Thirty Seconds"
case .oneMinute:
@ -32,6 +37,8 @@ enum SenderIntervals: Int, CaseIterable, Identifiable {
return "Ten Minutes"
case .fifteenMinutes:
return "Fifteen Minutes"
case .thirtyMinutes:
return "Thirty Minutes"
}
}
}

View file

@ -7,40 +7,6 @@
import SwiftUI
enum PositionBroadcastIntervals: Int, CaseIterable, Identifiable {
case thirtySeconds = 30
case oneMinute = 60
case fiveMinutes = 300
case tenMinutes = 600
case fifteenMinutes = 0
case thirtyMinutes = 1800
case oneHour = 3600
var id: Int { self.rawValue }
var description: String {
get {
switch self {
case .thirtySeconds:
return "Thirty Seconds"
case .oneMinute:
return "One Minute"
case .fiveMinutes:
return "Five Minutes"
case .tenMinutes:
return "Ten Minutes"
case .fifteenMinutes:
return "Fifteen Minutes"
case .thirtyMinutes:
return "Thirty Minutes"
case .oneHour:
return "One Hour"
}
}
}
}
struct PositionFlags: OptionSet
{
let rawValue: Int
@ -187,6 +153,12 @@ struct PositionConfig: View {
}
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
Toggle(isOn: $includePosAltMsl) {
Label("Altitude is Mean Sea Level", systemImage: "arrow.up.to.line.compact")
}
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
Toggle(isOn: $includePosSatsinview) {
Label("Number of satellites", systemImage: "skew")
@ -219,12 +191,6 @@ struct PositionConfig: View {
}
Section(header: Text("Advanced Position Flags")) {
Toggle(isOn: $includePosAltMsl) {
Text("Altitude is MSL")
}
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
Toggle(isOn: $includePosGeoSep) {
Text("Geoidal Seperation")
@ -370,6 +336,10 @@ struct PositionConfig: View {
if newFixed != node!.positionConfig!.fixedPosition { hasChanges = true }
}
}
.onChange(of: includePosAltitude || includePosAltMsl || includePosGeoSep || includePosDop || includePosHvdop || includePosSatsinview || includePosSeqNos || includePosTimestamp || includePosSpeed || includePosHeading) { newFlags in
hasChanges = true
}
.navigationViewStyle(StackNavigationViewStyle())
}
}