mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Handle topic change
keep less positions in memory
This commit is contained in:
parent
8a8cd69383
commit
61a98a09b9
7 changed files with 47 additions and 28 deletions
|
|
@ -1572,7 +1572,7 @@
|
|||
CODE_SIGN_ENTITLEMENTS = Meshtastic/Meshtastic.entitlements;
|
||||
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 841;
|
||||
CURRENT_PROJECT_VERSION = 842;
|
||||
DEVELOPMENT_ASSET_PATHS = "\"Meshtastic/Preview Content\"";
|
||||
DEVELOPMENT_TEAM = GCH7VS5Y9R;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
|
|
@ -1606,7 +1606,7 @@
|
|||
CODE_SIGN_ENTITLEMENTS = Meshtastic/Meshtastic.entitlements;
|
||||
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 841;
|
||||
CURRENT_PROJECT_VERSION = 842;
|
||||
DEVELOPMENT_ASSET_PATHS = "\"Meshtastic/Preview Content\"";
|
||||
DEVELOPMENT_TEAM = GCH7VS5Y9R;
|
||||
ENABLE_PREVIEWS = YES;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ extension UserDefaults {
|
|||
case detectionSensorRole
|
||||
case enableSmartPosition
|
||||
case modemPreset
|
||||
case firmwareVersion
|
||||
}
|
||||
|
||||
func reset() {
|
||||
|
|
@ -211,4 +212,12 @@ extension UserDefaults {
|
|||
UserDefaults.standard.set(newValue, forKey: "modemPreset")
|
||||
}
|
||||
}
|
||||
static var firmwareVersion: String {
|
||||
get {
|
||||
UserDefaults.standard.string(forKey: "firmwareVersion") ?? "0.0.0"
|
||||
}
|
||||
set {
|
||||
UserDefaults.standard.set(newValue, forKey: "firmwareVersion")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -582,6 +582,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
|
|||
nowKnown = true
|
||||
connectedVersion = String(version.dropLast())
|
||||
appState.firmwareVersion = connectedVersion
|
||||
UserDefaults.firmwareVersion = connectedVersion
|
||||
}
|
||||
let supportedVersion = connectedVersion == "0.0.0" || self.minimumVersion.compare(connectedVersion, options: .numeric) == .orderedAscending || minimumVersion.compare(connectedVersion, options: .numeric) == .orderedSame
|
||||
if !supportedVersion {
|
||||
|
|
|
|||
|
|
@ -60,14 +60,10 @@ import CoreLocation
|
|||
self.isStationary = update.isStationary
|
||||
|
||||
var locationAdded: Bool
|
||||
if enableSmartPosition {
|
||||
locationAdded = addLocation(loc)
|
||||
//print("Added Location \(self.count): \(loc)")
|
||||
} else {
|
||||
locationsArray.append(loc)
|
||||
locationAdded = true
|
||||
}
|
||||
if locationAdded {
|
||||
locationAdded = addLocation(loc, smartPostion: enableSmartPosition)
|
||||
if !isRecording && locationAdded {
|
||||
self.count = 1
|
||||
} else if locationAdded && isRecording {
|
||||
self.count += 1
|
||||
}
|
||||
}
|
||||
|
|
@ -84,19 +80,21 @@ import CoreLocation
|
|||
self.updatesStarted = false
|
||||
}
|
||||
|
||||
func addLocation(_ location: CLLocation) -> Bool {
|
||||
let age = -location.timestamp.timeIntervalSinceNow
|
||||
if age > 10 {
|
||||
print("Bad Location \(self.count): Too Old \(age) seconds ago \(location)")
|
||||
return false
|
||||
}
|
||||
if location.horizontalAccuracy < 0 {
|
||||
print("Bad Location \(self.count): Horizontal Accuracy: \(location.horizontalAccuracy) \(location)")
|
||||
return false
|
||||
}
|
||||
if location.horizontalAccuracy > 25 {
|
||||
print("Bad Location \(self.count): Horizontal Accuracy: \(location.horizontalAccuracy) \(location)")
|
||||
return false
|
||||
func addLocation(_ location: CLLocation, smartPostion: Bool) -> Bool {
|
||||
if smartPostion {
|
||||
let age = -location.timestamp.timeIntervalSinceNow
|
||||
if age > 10 {
|
||||
print("Bad Location \(self.count): Too Old \(age) seconds ago \(location)")
|
||||
return false
|
||||
}
|
||||
if location.horizontalAccuracy < 0 {
|
||||
print("Bad Location \(self.count): Horizontal Accuracy: \(location.horizontalAccuracy) \(location)")
|
||||
return false
|
||||
}
|
||||
if location.horizontalAccuracy > 25 {
|
||||
print("Bad Location \(self.count): Horizontal Accuracy: \(location.horizontalAccuracy) \(location)")
|
||||
return false
|
||||
}
|
||||
}
|
||||
if isRecording {
|
||||
if let lastLocation = locationsArray.last {
|
||||
|
|
@ -107,8 +105,10 @@ import CoreLocation
|
|||
elevationGain += gain
|
||||
}
|
||||
}
|
||||
locationsArray.append(location)
|
||||
} else {
|
||||
locationsArray = [location]
|
||||
}
|
||||
locationsArray.append(location)
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class MqttClientProxyManager {
|
|||
private static let defaultKeepAliveInterval: Int32 = 60
|
||||
weak var delegate: MqttClientProxyManagerDelegate?
|
||||
var mqttClientProxy: CocoaMQTT?
|
||||
var topic = "msh/2/e"
|
||||
var topic = "msh"
|
||||
var debugLog = false
|
||||
func connectFromConfigSettings(node: NodeInfoEntity) {
|
||||
let defaultServerAddress = "mqtt.meshtastic.org"
|
||||
|
|
@ -36,13 +36,16 @@ class MqttClientProxyManager {
|
|||
defaultServerPort = Int(fullHost.components(separatedBy: ":")[1]) ?? (useSsl ? 8883 : 1883)
|
||||
}
|
||||
}
|
||||
let minimumVersion = "2.3.0"
|
||||
let latestVersion = minimumVersion.compare(UserDefaults.firmwareVersion, options: .numeric) == .orderedSame
|
||||
|
||||
if let host = host {
|
||||
let port = defaultServerPort
|
||||
let username = node.mqttConfig?.username
|
||||
let password = node.mqttConfig?.password
|
||||
let root = node.mqttConfig?.root?.count ?? 0 > 0 ? node.mqttConfig?.root : "msh"
|
||||
let prefix = root! + "/2/e"
|
||||
topic = prefix + "/#"
|
||||
let prefix = root!
|
||||
topic = prefix + (latestVersion ? "/2/e" : "/2/c") + "/#"
|
||||
let qos = CocoaMQTTQoS(rawValue: UInt8(1))!
|
||||
connect(host: host, port: port, useSsl: useSsl, username: username, password: password, topic: topic, qos: qos, cleanSession: true)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,9 +24,15 @@ struct AppSettings: View {
|
|||
Label("appsettings.provide.location", systemImage: "location.circle.fill")
|
||||
}
|
||||
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
|
||||
Text("Use your phone's gps to provide a location to your node. Must have location access and precise location enabled for Meshtastic in Settings.")
|
||||
.font(.caption2)
|
||||
.foregroundColor(.gray)
|
||||
if provideLocation {
|
||||
Toggle(isOn: $enableSmartPosition) {
|
||||
Label("appsettings.smartposition", systemImage: "brain")
|
||||
Text("Will only send a position to the phone if it is recent and of high horizontal accuracy.")
|
||||
.font(.caption2)
|
||||
.foregroundColor(.gray)
|
||||
}
|
||||
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
|
||||
VStack {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ struct Firmware: View {
|
|||
@Environment(\.managedObjectContext) var context
|
||||
@EnvironmentObject var bleManager: BLEManager
|
||||
var node: NodeInfoEntity?
|
||||
@State var minimumVersion = "2.2.21"
|
||||
@State var minimumVersion = "2.3.0"
|
||||
@State var version = ""
|
||||
@State private var currentDevice: DeviceHardware?
|
||||
@State private var latestStable: FirmwareRelease?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue