diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index 31df4c92..cf8f9510 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -759,6 +759,16 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject { wayPointEntity.icon = Int64(waypoint.icon) wayPointEntity.latitudeI = waypoint.latitudeI wayPointEntity.longitudeI = waypoint.longitudeI + if waypoint.expire > 0 { + wayPointEntity.expire = Date.init(timeIntervalSince1970: Double(waypoint.expire)) + } else { + wayPointEntity.expire = nil + } + if waypoint.lockedTo > 0 { + wayPointEntity.locked = Int64(waypoint.lockedTo) + } else { + wayPointEntity.locked = 0 + } do { try context!.save() print("💾 Updated Waypoint from Waypoint App Packet From: \(fromNodeNum)") diff --git a/Meshtastic/Views/Map/WaypointFormView.swift b/Meshtastic/Views/Map/WaypointFormView.swift index 767a9614..fcaf8766 100644 --- a/Meshtastic/Views/Map/WaypointFormView.swift +++ b/Meshtastic/Views/Map/WaypointFormView.swift @@ -109,15 +109,15 @@ struct WaypointFormView: View { } } -// Toggle(isOn: $expires) { -// Label("Expires", systemImage: "clock.badge.xmark") -// } -// .toggleStyle(SwitchToggleStyle(tint: .accentColor)) -// if expires { -// DatePicker("Expire", selection: $expire, in: Date.now...) -// .datePickerStyle(.compact) -// .font(.callout) -// } + Toggle(isOn: $expires) { + Label("Expires", systemImage: "clock.badge.xmark") + } + .toggleStyle(SwitchToggleStyle(tint: .accentColor)) + if expires { + DatePicker("Expire", selection: $expire, in: Date.now...) + .datePickerStyle(.compact) + .font(.callout) + } Toggle(isOn: $locked) { Label("Locked", systemImage: "lock") } @@ -182,17 +182,56 @@ struct WaypointFormView: View { .padding(.bottom) if waypointId > 0 { - Button(role: .destructive) { + + Menu { + Button("For me", action: { let waypoint = getWaypoint(id: Int64(waypointId), context: bleManager.context!) - bleManager.context!.delete(waypoint) - do { - try bleManager.context!.save() - } catch { - bleManager.context!.rollback() - } - dismiss() - } label: { + bleManager.context!.delete(waypoint) + do { + try bleManager.context!.save() + } catch { + bleManager.context!.rollback() + } + dismiss() }) + Button("For everyone", action: { + var newWaypoint = Waypoint() + + if waypointId > 0 { + newWaypoint.id = UInt32(waypointId) + } else { + newWaypoint.id = UInt32.random(in: UInt32(UInt8.max).. 0 ? name : "Dropped Pin" + newWaypoint.description_p = description + newWaypoint.latitudeI = Int32(coordinate.latitude * 1e7) + newWaypoint.longitudeI = Int32(coordinate.longitude * 1e7) + // Unicode scalar value for the icon emoji string + let unicodeScalers = icon.unicodeScalars + // First element as an UInt32 + let unicode = unicodeScalers[unicodeScalers.startIndex].value + newWaypoint.icon = unicode + if locked { + + if lockedTo == 0 { + newWaypoint.lockedTo = UInt32(bleManager.connectedPeripheral!.num) + } else { + newWaypoint.lockedTo = UInt32(lockedTo) + } + } + newWaypoint.expire = 1 + if bleManager.sendWaypoint(waypoint: newWaypoint) { + waypointId = 0 + dismiss() + } else { + waypointId = 0 + dismiss() + print("Send waypoint failed") + } + }) + } + label: { Label("delete", systemImage: "trash") + .foregroundColor(.red) } .buttonStyle(.bordered) .buttonBorderShape(.capsule) @@ -234,11 +273,11 @@ struct WaypointFormView: View { longitude = coordinate.longitude } - if coordinate.distance(from: LocationHelper.DefaultLocation) == 0.0 { - // Too close to apple park, bail out - waypointId = 0 - dismiss() - } +// if coordinate.distance(from: LocationHelper.DefaultLocation) == 0.0 { +// // Too close to apple park, bail out +// waypointId = 0 +// dismiss() +// } } } } diff --git a/Meshtastic/Views/Settings/ShareChannels.swift b/Meshtastic/Views/Settings/ShareChannels.swift index 663926a3..da2655ec 100644 --- a/Meshtastic/Views/Settings/ShareChannels.swift +++ b/Meshtastic/Views/Settings/ShareChannels.swift @@ -288,7 +288,7 @@ struct ShareChannels: View { loRaConfig.usePreset = node?.loRaConfig?.usePreset ?? true loRaConfig.channelNum = UInt32(node?.loRaConfig?.channelNum ?? 0) channelSet.loraConfig = loRaConfig - if node != nil { + if node != nil && node?.myInfo != nil { for ch in node!.myInfo!.channels!.array as! [ChannelEntity] { if ch.role > 0 { diff --git a/de.lproj/Localizable.strings b/de.lproj/Localizable.strings index 7da486b3..65eca292 100644 --- a/de.lproj/Localizable.strings +++ b/de.lproj/Localizable.strings @@ -146,6 +146,7 @@ "mesh.log.device.config %@"="Geräte Konfiguration empfangen: %@"; "mesh.log.display.config %@"="Display Konfiguration empfangen: %@"; "mesh.log.devicemetadata %@"="Anforderung der Geräte Metadaten für %@"; +"mesh.log.device.metadata.received %@"="Device Metadata received from: %@"; "mesh.log.externalnotification.config %@"="External Notifiation module config received: %@"; "mesh.log.lora.config %@"="LoRa config received: %@"; "mesh.log.lora.config.sent %@"="Sent a LoRa.Config for: %@"; diff --git a/en.lproj/Localizable.strings b/en.lproj/Localizable.strings index eb3f3caa..4872c315 100644 --- a/en.lproj/Localizable.strings +++ b/en.lproj/Localizable.strings @@ -146,6 +146,7 @@ "mesh.log.device.config %@"="Device config received: %@"; "mesh.log.display.config %@"="Display config received: %@"; "mesh.log.devicemetadata %@"="Requesting Device Metadata for %@"; +"mesh.log.device.metadata.received %@"="Device Metadata received from: %@"; "mesh.log.externalnotification.config %@"="External Notifiation module config received: %@"; "mesh.log.lora.config %@"="LoRa config received: %@"; "mesh.log.lora.config.sent %@"="Sent a LoRa.Config for: %@"; diff --git a/zh-Hans.lproj/Localizable.strings b/zh-Hans.lproj/Localizable.strings index 8a9f0699..48bb8a74 100644 --- a/zh-Hans.lproj/Localizable.strings +++ b/zh-Hans.lproj/Localizable.strings @@ -146,6 +146,7 @@ "mesh.log.device.config %@"="Device config received: %@"; "mesh.log.display.config %@"="Display config received: %@"; "mesh.log.devicemetadata %@"="Requesting Device Metadata for %@"; +"mesh.log.device.metadata.received %@"="Device Metadata admin message received from: %@"; "mesh.log.externalnotification.config %@"="External Notifiation module config received: %@"; "mesh.log.lora.config %@"="LoRa config received: %@"; "mesh.log.lora.config.sent %@"="Sent a LoRa.Config for: %@";