Merge pull request #158 from meshtastic/position_flags

Position flags and Enum Updates
This commit is contained in:
Garth Vander Houwen 2022-09-01 19:27:19 -07:00 committed by GitHub
commit ed145569cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 83 additions and 50 deletions

View file

@ -7,6 +7,52 @@
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
case sixHours = 21600
case twelveHours = 43200
case twentyFourHours = 86400
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"
case .sixHours:
return "Six Hours"
case .twelveHours:
return "Twelve Hours"
case .twentyFourHours:
return "Twenty Four Hours"
}
}
}
}
enum GpsFormats: Int, CaseIterable, Identifiable {
case gpsFormatDec = 0
@ -68,6 +114,9 @@ enum GpsUpdateIntervals: Int, CaseIterable, Identifiable {
case fifteenMinutes = 900
case thirtyMinutes = 1800
case oneHour = 3600
case sixHours = 21600
case twelveHours = 43200
case twentyFourHours = 86400
case maxInt32 = 2147483647
var id: Int { self.rawValue }
@ -75,13 +124,12 @@ enum GpsUpdateIntervals: Int, CaseIterable, Identifiable {
get {
switch self {
case .fiveSeconds:
return "Five Seconds"
case .tenSeconds:
return "Ten Seconds"
case .fifteenSeconds:
return "fifteenSeconds"
return "Fifteen Seconds"
case .thirtySeconds:
return "Thirty Seconds"
case .oneMinute:
@ -96,6 +144,12 @@ enum GpsUpdateIntervals: Int, CaseIterable, Identifiable {
return "Thirty Minutes"
case .oneHour:
return "One Hour"
case .sixHours:
return "Six Hours"
case .twelveHours:
return "Twelve Hours"
case .twentyFourHours:
return "Twenty Four Hours"
case .maxInt32:
return "On Boot Only"
}
@ -105,6 +159,9 @@ enum GpsUpdateIntervals: Int, CaseIterable, Identifiable {
enum GpsAttemptTimes: Int, CaseIterable, Identifiable {
case fiveSeconds = 5
case tenSeconds = 10
case fifteenSeconds = 15
case thirtySeconds = 0
case oneMinute = 60
case fiveMinutes = 300
@ -116,6 +173,12 @@ enum GpsAttemptTimes: Int, CaseIterable, Identifiable {
get {
switch self {
case .fiveSeconds:
return "Five Seconds"
case .tenSeconds:
return "Ten Seconds"
case .fifteenSeconds:
return "Fifteen Seconds"
case .thirtySeconds:
return "Thirty Seconds"
case .oneMinute:

View file

@ -1359,7 +1359,6 @@ 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)
} else if let channel = try? Channel(serializedData: packet.decoded.payload) {
print(try! channel.jsonUTF8Data())
@ -1368,13 +1367,7 @@ 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)
//}
}
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())
}
}