From 3002d377a00490b8c62beb971fff566b904ae7a7 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Wed, 22 Feb 2023 16:12:34 -0800 Subject: [PATCH 1/3] Name app setting properly --- Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift b/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift index 4f40e95c..3534b784 100644 --- a/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift +++ b/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift @@ -22,7 +22,7 @@ struct MapViewSwiftUI: UIViewRepresentable { let centeringMode: CenteringMode let centerOnPositionsOnly: Bool - @AppStorage("meshMapRecenter") private var recenter = false + @AppStorage("meshMapRecentering") private var recenter = false // Offline Maps //make this view dependent on the UserDefault that is updated when importing a new map file @@ -114,6 +114,7 @@ struct MapViewSwiftUI: UIViewRepresentable { } DispatchQueue.main.async { + print(recenter) mapView.removeAnnotations(mapView.annotations) mapView.addAnnotations(waypoints) switch centeringMode { From b79e63e573328ac7b352cea16a166af1dfd00098 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Wed, 22 Feb 2023 16:33:47 -0800 Subject: [PATCH 2/3] Remove unused function --- Meshtastic/Helpers/BLEManager.swift | 68 +++++++++---------- .../Views/Map/Custom/MapViewSwiftUI.swift | 1 - 2 files changed, 34 insertions(+), 35 deletions(-) diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index 4bad7d2e..167e1c0f 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -2011,38 +2011,38 @@ extension BLEManager: CBCentralManagerDelegate { self.peripherals.removeAll(where: { $0.lastUpdate < visibleDuration}) } - func centralManager(_ central: CBCentralManager, willRestoreState dict: [String : Any]) { - - guard let peripherals = dict[CBCentralManagerRestoredStatePeripheralsKey] as? [CBPeripheral] else { - return - } - print(peripherals) - if peripherals.count > 0 { - //connectedPeripheral.peripheral = peripherals[0] - // 5 - //connectedPeripheral.peripheral.delegate = self - - for peripheral in peripherals { - - switch peripheral.state { - case .connecting: // I've only seen this happen when - // re-launching attached to Xcode. - print("Xcode Restore") - - case .connected: // Store for connection / requesting - // notifications when BT starts. - print("Actual restore") - //centralManager.connect(peripheral) - default: break - } - - - - // connectedPeripheral.peripheral - //connectedPeripheral.peripheral = peripheral - //connectedPeripheral.peripheral.delegate = self - } - } - print("willRestoreState Hit!") - } +// func centralManager(_ central: CBCentralManager, willRestoreState dict: [String : Any]) { +// +// guard let peripherals = dict[CBCentralManagerRestoredStatePeripheralsKey] as? [CBPeripheral] else { +// return +// } +// print(peripherals) +// if peripherals.count > 0 { +// //connectedPeripheral.peripheral = peripherals[0] +// // 5 +// //connectedPeripheral.peripheral.delegate = self +// +// for peripheral in peripherals { +// +// switch peripheral.state { +// case .connecting: // I've only seen this happen when +// // re-launching attached to Xcode. +// print("Xcode Restore") +// +// case .connected: // Store for connection / requesting +// // notifications when BT starts. +// print("Actual restore") +// //centralManager.connect(peripheral) +// default: break +// } +// +// +// +// // connectedPeripheral.peripheral +// //connectedPeripheral.peripheral = peripheral +// //connectedPeripheral.peripheral.delegate = self +// } +// } +// print("willRestoreState Hit!") +// } } diff --git a/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift b/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift index 3534b784..4cc5ef0b 100644 --- a/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift +++ b/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift @@ -114,7 +114,6 @@ struct MapViewSwiftUI: UIViewRepresentable { } DispatchQueue.main.async { - print(recenter) mapView.removeAnnotations(mapView.annotations) mapView.addAnnotations(waypoints) switch centeringMode { From dba78896663528cbc564af6e68e8a68eeef1ca1f Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Wed, 22 Feb 2023 20:31:08 -0800 Subject: [PATCH 3/3] Cleanup Client tracking mode some --- Meshtastic/Enums/IntervalEnums.swift | 6 ++ Meshtastic/Helpers/BLEManager.swift | 68 +++++++++---------- .../Views/Map/Custom/MapViewSwiftUI.swift | 9 ++- .../Views/Settings/Config/DeviceConfig.swift | 2 +- .../Module/ExternalNotificationConfig.swift | 2 +- .../Settings/Config/Module/MQTTConfig.swift | 2 +- .../Config/Module/TelemetryConfig.swift | 2 +- 7 files changed, 48 insertions(+), 43 deletions(-) diff --git a/Meshtastic/Enums/IntervalEnums.swift b/Meshtastic/Enums/IntervalEnums.swift index 5fc0dc20..93493767 100644 --- a/Meshtastic/Enums/IntervalEnums.swift +++ b/Meshtastic/Enums/IntervalEnums.swift @@ -93,6 +93,8 @@ enum SenderIntervals: Int, CaseIterable, Identifiable { enum UpdateIntervals: Int, CaseIterable, Identifiable { + case fiveSeconds = 5 + case tenSeconds = 10 case fifteenSeconds = 15 case thirtySeconds = 30 case oneMinute = 60 @@ -118,6 +120,10 @@ enum UpdateIntervals: Int, CaseIterable, Identifiable { get { switch self { + case .fiveSeconds: + return NSLocalizedString("interval.five.seconds", comment: "Five Seconds") + case .tenSeconds: + return NSLocalizedString("interval.ten.seconds", comment: "Ten Seconds") case .fifteenSeconds: return NSLocalizedString("interval.fifteen.seconds", comment: "Fifteen Seconds") case .thirtySeconds: diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index 167e1c0f..1082a22b 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -2011,38 +2011,38 @@ extension BLEManager: CBCentralManagerDelegate { self.peripherals.removeAll(where: { $0.lastUpdate < visibleDuration}) } -// func centralManager(_ central: CBCentralManager, willRestoreState dict: [String : Any]) { -// -// guard let peripherals = dict[CBCentralManagerRestoredStatePeripheralsKey] as? [CBPeripheral] else { -// return -// } -// print(peripherals) -// if peripherals.count > 0 { -// //connectedPeripheral.peripheral = peripherals[0] -// // 5 -// //connectedPeripheral.peripheral.delegate = self -// -// for peripheral in peripherals { -// -// switch peripheral.state { -// case .connecting: // I've only seen this happen when -// // re-launching attached to Xcode. -// print("Xcode Restore") -// -// case .connected: // Store for connection / requesting -// // notifications when BT starts. -// print("Actual restore") -// //centralManager.connect(peripheral) -// default: break -// } -// -// -// -// // connectedPeripheral.peripheral -// //connectedPeripheral.peripheral = peripheral -// //connectedPeripheral.peripheral.delegate = self -// } -// } -// print("willRestoreState Hit!") -// } + func centralManager(_ central: CBCentralManager, willRestoreState dict: [String : Any]) { + + guard let peripherals = dict[CBCentralManagerRestoredStatePeripheralsKey] as? [CBPeripheral] else { + return + } + print(peripherals) + if peripherals.count > 0 { + //connectedPeripheral.peripheral = peripherals[0] + // 5 + //connectedPeripheral.peripheral.delegate = self + + for peripheral in peripherals { + + switch peripheral.state { + case .connecting: // I've only seen this happen when + // re-launching attached to Xcode. + print("Xcode Restore") + + case .connected: // Store for connection / requesting + // notifications when BT starts. + print("Actual restore") + //centralManager.connect(peripheral) + default: break + } + + + + // connectedPeripheral.peripheral + //connectedPeripheral.peripheral = peripheral + //connectedPeripheral.peripheral.delegate = self + } + } + print("willRestoreState Hit!") + } } diff --git a/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift b/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift index 4cc5ef0b..55f707a2 100644 --- a/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift +++ b/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift @@ -50,12 +50,11 @@ struct MapViewSwiftUI: UIViewRepresentable { let center = CLLocationCoordinate2D(latitude: LocationHelper.currentLocation.latitude, longitude: LocationHelper.currentLocation.longitude) let region = MKCoordinateRegion(center: center, span: span) mapView.setRegion(region, animated: true) - mapView.setUserTrackingMode(.followWithHeading, animated: true) mapView.addAnnotations(positions) } // Other MKMapView Settings - mapView.showsUserLocation = true + mapView.showsUserLocation = false mapView.preferredConfiguration.elevationStyle = .realistic mapView.isPitchEnabled = true mapView.isRotateEnabled = true @@ -130,10 +129,10 @@ struct MapViewSwiftUI: UIViewRepresentable { } case .clientGps: mapView.addAnnotations(positions) + mapView.showsUserLocation = true + mapView.setUserTrackingMode(.followWithHeading, animated: true) if recenter { - let span = MKCoordinateSpan(latitudeDelta: 0.003, longitudeDelta: 0.003) - let region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: LocationHelper.currentLocation.latitude, longitude: LocationHelper.currentLocation.longitude), span: span) - mapView.setRegion(region, animated: true) + mapView.centerCoordinate = LocationHelper.currentLocation } } } diff --git a/Meshtastic/Views/Settings/Config/DeviceConfig.swift b/Meshtastic/Views/Settings/Config/DeviceConfig.swift index b979464d..67f87bca 100644 --- a/Meshtastic/Views/Settings/Config/DeviceConfig.swift +++ b/Meshtastic/Views/Settings/Config/DeviceConfig.swift @@ -204,7 +204,7 @@ struct DeviceConfig: View { // Need to request a LoRaConfig from the remote node before allowing changes if bleManager.connectedPeripheral != nil && node?.deviceConfig == nil { print("empty device config") - let connectedNode = getNodeInfo(id: bleManager.connectedPeripheral.num, context: context) + let connectedNode = getNodeInfo(id: bleManager.connectedPeripheral?.num ?? -1, context: context) if connectedNode != nil && connectedNode!.num > 0 { _ = bleManager.requestDeviceConfig(fromUser: connectedNode!.user!, toUser: node!.user!, adminIndex: connectedNode?.myInfo?.adminIndex ?? 0) } diff --git a/Meshtastic/Views/Settings/Config/Module/ExternalNotificationConfig.swift b/Meshtastic/Views/Settings/Config/Module/ExternalNotificationConfig.swift index f7255fdd..b1dcdf60 100644 --- a/Meshtastic/Views/Settings/Config/Module/ExternalNotificationConfig.swift +++ b/Meshtastic/Views/Settings/Config/Module/ExternalNotificationConfig.swift @@ -154,7 +154,7 @@ struct ExternalNotificationConfig: View { isPresented: $isPresentingSaveConfirm, titleVisibility: .visible ) { - let connectedNode = getNodeInfo(id: bleManager.connectedPeripheral.num, context: context) + let connectedNode = getNodeInfo(id: bleManager.connectedPeripheral?.num ?? -1, context: context) if connectedNode != nil { let nodeName = node?.user?.longName ?? NSLocalizedString("unknown", comment: "Unknown") let buttonText = String.localizedStringWithFormat(NSLocalizedString("save.config %@", comment: "Save Config for %@"), nodeName) diff --git a/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift b/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift index ec2d9735..7872d90a 100644 --- a/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift +++ b/Meshtastic/Views/Settings/Config/Module/MQTTConfig.swift @@ -143,7 +143,7 @@ struct MQTTConfig: View { isPresented: $isPresentingSaveConfirm, titleVisibility: .visible ) { - let connectedNode = getNodeInfo(id: bleManager.connectedPeripheral.num, context: context) + let connectedNode = getNodeInfo(id: bleManager.connectedPeripheral?.num ?? -1, context: context) if connectedNode != nil { let nodeName = node?.user?.longName ?? NSLocalizedString("unknown", comment: "Unknown") let buttonText = String.localizedStringWithFormat(NSLocalizedString("save.config %@", comment: "Save Config for %@"), nodeName) diff --git a/Meshtastic/Views/Settings/Config/Module/TelemetryConfig.swift b/Meshtastic/Views/Settings/Config/Module/TelemetryConfig.swift index fad65cd7..bbcda4e0 100644 --- a/Meshtastic/Views/Settings/Config/Module/TelemetryConfig.swift +++ b/Meshtastic/Views/Settings/Config/Module/TelemetryConfig.swift @@ -77,7 +77,7 @@ struct TelemetryConfig: View { isPresented: $isPresentingSaveConfirm, titleVisibility: .visible ) { - let connectedNode = getNodeInfo(id: bleManager.connectedPeripheral.num, context: context) + let connectedNode = getNodeInfo(id: bleManager.connectedPeripheral?.num ?? -1, context: context) if connectedNode != nil { let nodeName = node?.user?.longName ?? NSLocalizedString("unknown", comment: "Unknown") let buttonText = String.localizedStringWithFormat(NSLocalizedString("save.config %@", comment: "Save Config for %@"), nodeName)