diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index fd302375..df3219b6 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -532,7 +532,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate tryClearExistingChannels() } // NodeInfo - if decodedInfo.nodeInfo.num > 0 && !invalidVersion { + if decodedInfo.nodeInfo.num > 0 {// && !invalidVersion { nowKnown = true let nodeInfo = nodeInfoPacket(nodeInfo: decodedInfo.nodeInfo, channel: decodedInfo.packet.channel, context: context!) diff --git a/Meshtastic/Helpers/LocationsHandler.swift b/Meshtastic/Helpers/LocationsHandler.swift index 263964cd..4742914a 100644 --- a/Meshtastic/Helpers/LocationsHandler.swift +++ b/Meshtastic/Helpers/LocationsHandler.swift @@ -58,7 +58,7 @@ import CoreLocation if !self.updatesStarted { break } // End location updates by breaking out of the loop. if let loc = update.location { self.isStationary = update.isStationary - self.count += 1 + var locationAdded: Bool if enableSmartPosition { locationAdded = addLocation(loc) @@ -67,8 +67,8 @@ import CoreLocation locationsArray.append(loc) locationAdded = true } - if !locationAdded { - //print("Bad Location \(self.count): \(loc)") + if locationAdded { + self.count += 1 } } } diff --git a/Meshtastic/Helpers/MeshPackets.swift b/Meshtastic/Helpers/MeshPackets.swift index 40221a44..83cb25db 100644 --- a/Meshtastic/Helpers/MeshPackets.swift +++ b/Meshtastic/Helpers/MeshPackets.swift @@ -194,7 +194,6 @@ func deviceMetadataPacket (metadata: DeviceMetadata, fromNum: Int64, context: NS } if fetchedNode.count > 0 { let newMetadata = DeviceMetadataEntity(context: context) - newMetadata.firmwareVersion = metadata.firmwareVersion newMetadata.deviceStateVersion = Int32(metadata.deviceStateVersion) newMetadata.canShutdown = metadata.canShutdown newMetadata.hasWifi = metadata.hasWifi_p diff --git a/Meshtastic/Views/Settings/RouteRecorder.swift b/Meshtastic/Views/Settings/RouteRecorder.swift index 405d9fb1..086cb6e5 100644 --- a/Meshtastic/Views/Settings/RouteRecorder.swift +++ b/Meshtastic/Views/Settings/RouteRecorder.swift @@ -23,6 +23,7 @@ struct RouteRecorder: View { @Namespace var namespace @Namespace var routerecorderscope @State var recording: RouteEntity? + @State var color: Color = .blue var body: some View { VStack { @@ -33,8 +34,9 @@ struct RouteRecorder: View { let lineCoords = locationsHandler.locationsArray.compactMap({(position) -> CLLocationCoordinate2D in return position.coordinate }) + let gradient = LinearGradient( - colors: [.blue], + colors: [color], startPoint: .leading, endPoint: .trailing ) let dashed = StrokeStyle( @@ -49,13 +51,6 @@ struct RouteRecorder: View { } .ignoresSafeArea(.all, edges: [.top, .leading, .trailing]) .mapScope(routerecorderscope) -// .mapControls { -// MapScaleView(scope: routerecorderscope) -// MapUserLocationButton(scope: routerecorderscope) -// MapPitchToggle(scope: routerecorderscope) -// MapCompass(scope: routerecorderscope) -// } - .transition(.slide) .safeAreaInset(edge: .bottom) { ZStack { VStack { @@ -164,11 +159,12 @@ struct RouteRecorder: View { locationsHandler.locationsArray.removeAll() locationsHandler.recordingStarted = Date() let newRoute = RouteEntity(context: context) - newRoute.name = String("Route Recording - \(Date().formatted())") + newRoute.name = String("Route Recording") newRoute.id = Int32.random(in: Int32(Int8.max) ... Int32.max) newRoute.color = Int64(UIColor.random.hex) newRoute.date = Date() - newRoute.enabled = true + newRoute.enabled = false + color = Color(UIColor(hex: UInt32(newRoute.color))) self.recording = newRoute do { try context.save() @@ -221,6 +217,19 @@ struct RouteRecorder: View { locationsHandler.elevationGain = 0.0 locationsHandler.locationsArray.removeAll() locationsHandler.recordingStarted = nil + if let rec = recording { + rec.enabled = true + context.refresh(rec, mergeChanges:true) + } + + do { + try context.save() + print("💾 Saved a route finish") + } catch { + context.rollback() + let nsError = error as NSError + print("💥 Error Saving RouteEntity from the Route Recorder \(nsError)") + } } label: { Label("finish", systemImage: "flag.checkered") } diff --git a/Meshtastic/Views/Settings/Routes.swift b/Meshtastic/Views/Settings/Routes.swift index 5039f724..44a65690 100644 --- a/Meshtastic/Views/Settings/Routes.swift +++ b/Meshtastic/Views/Settings/Routes.swift @@ -135,6 +135,7 @@ struct Routes: View { } } } + .badge(route.locations?.count ?? 0) .swipeActions { Button(role: .destructive) { context.delete(route) @@ -147,6 +148,7 @@ struct Routes: View { Label("delete", systemImage: "trash") } } + } .listStyle(.plain) } diff --git a/Meshtastic/Views/Settings/Settings.swift b/Meshtastic/Views/Settings/Settings.swift index 2c201a7b..cedaeb11 100644 --- a/Meshtastic/Views/Settings/Settings.swift +++ b/Meshtastic/Views/Settings/Settings.swift @@ -299,17 +299,17 @@ struct Settings: View { } .tag(SettingsSidebar.adminMessageLog) } -// Section(header: Text("Firmware")) { -// NavigationLink { -// Firmware(node: nodes.first(where: { $0.num == preferredNodeNum })) -// } label: { -// Image(systemName: "arrow.up.arrow.down.square") -// .symbolRenderingMode(.hierarchical) -// Text("Firmware Updates") -// } -// .tag(SettingsSidebar.about) -// .disabled(selectedNode > 0 && selectedNode != preferredNodeNum) -// } + Section(header: Text("Firmware")) { + NavigationLink { + Firmware(node: nodes.first(where: { $0.num == preferredNodeNum })) + } label: { + Image(systemName: "arrow.up.arrow.down.square") + .symbolRenderingMode(.hierarchical) + Text("Firmware Updates") + } + .tag(SettingsSidebar.about) + .disabled(selectedNode > 0 && selectedNode != preferredNodeNum) + } } } .onAppear {