mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
* Update messaging list separator insets
* Dont show unread messages or notifications for emoji reactions matching iMessage.
* Restore ble state method (#1416)
* Restore BLE State
* Log privacy
* AccessoryManager to handle restored connection
* Comment task out
* Update restore state function based on conversation with jake
* Update Meshtastic/Accessory/Transports/Bluetooth Low Energy/BLETransport.swift
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update Meshtastic/Accessory/Transports/Bluetooth Low Energy/BLETransport.swift
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
---------
Co-authored-by: Jake-B <jake-b@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Two Column Node List (#1425)
* Restore BLE State
* Log privacy
* AccessoryManager to handle restored connection
* Comment task out
* Switch the node list to a two column layout
* Keep asian translations of channel details string
* Update restore state function based on conversation with jake
* Update Meshtastic/Accessory/Transports/Bluetooth Low Energy/BLETransport.swift
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update Meshtastic/Accessory/Transports/Bluetooth Low Energy/BLETransport.swift
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* always show node list search bar
* Update auto correct modifier
* Dont show online animations for ios 17, remove online animation from node map, remove online circle from position popover
* Work in progress.
* Update detents
* Gate the discovery process while restoring
* Use geometry reader to size weather tiles on node details
* Update BLE Transport
* Update location weather condistion styles
* Log privacy in didReceive
* Remove extra dividers from admin key config, fix onboarding typo
* Bump minimum catalyst target
* Bump mac target version
* Use @FetchRequest for UserList to try and use less memory on ios 17
* Revert change to @fetchrequest
* Stab in the dark for Devices crash
* Updated UserList (back?) to @FetchRequest
* Set mac minimum to 15
* Nil out continuation after use
* Use @FetchRequest for the node list to stop crashes on iOS 17
* Handle failed connections during restoration
---------
Co-authored-by: Jake-B <jake-b@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update protos
* Update protos
* Remove stale keys
* Serbian translations update (#1422)
* Log privacy
* Add Serbian translations
---------
Co-authored-by: Garth Vander Houwen <garthvh@yahoo.com>
* Clarify public key sub-text in security settings (#1412)
* Clarify public key sub-text in settings
* Trigger lint
* freq slot num pad (#1410)
* kill keyboard toolbar on lora config
* delete extranious scrollDismissesKeyboard
* Properly set catalyst target
* Update Meshtastic/Views/Onboarding/DeviceOnboarding.swift
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update Meshtastic/Views/Settings/Config/SecurityConfig.swift
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Update Meshtastic/Enums/DeviceEnums.swift
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Make current location nilable, remove log spam
* clean up toUser logic
* Fix telemetry entity not added in nodeInfoPacket
* fix typo: powerMetrics.hasChXCurrent mismatch
* Duplicate decoding of telemetry.current removed
* Clean up mesh map fetch request and distance filter logic
* Revert attempt to fix message logic
* Bump datadog version
* Missing message fix, attempt #2 (#1431)
Co-authored-by: Jake-B <jake-b@users.noreply.github.com>
* Retry fewer times for longer
* Revert "Missing message fix, attempt #2 (#1431)" (#1432)
This reverts commit a96d318adb.
* Make retry 2 seconds
* Add back link to node details from position popover without navigation stack and link, clear notifications when deleting database
* Add clear notifications function
* Link from channel messages to node info
* Link to node details
* Discovery on retry fix
* Discovery on retry fix fix
* Add contact to device node db if you get an encrypted send faild routing error
* Seperate channel message view into two views for better performance.
* Refactor User Message List
* Update device hardware
Add liquid glass to config save button
* Save button cleanup
* Update button structure on users view
* Move encrypted send logic out of the router. Update protos
* Restore node long- and short- names (#1442)
Co-authored-by: Jake-B <jake-b@users.noreply.github.com>
* Update Meshtastic/Accessory/Transports/Bluetooth Low Energy/BLEConnection.swift
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Revert routing error
* Toggle for enabling device telemetry broadcast enable
* Update
* Enhancements for interval dropdowns (#1445)
* Cleanup
* Fix core data version
* Add never to update interval
* Device telemetry Enabled Boolean (#1446)
* Update core data and interval picker
* Move formatter
* Rework to nest options under enabled
* Clearer names
* Safer devicehardware api call, remove node history filter from mesh map
* Fix build
* Simplify mesh map filter
* Remove stale translation keys
---------
Co-authored-by: Jake-B <jake-b@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Nikola Dašić <dasic.nikola@yandex.com>
Co-authored-by: Spencer Smith <dontaskspencer@gmail.com>
Co-authored-by: Benjamin Faershtein <119711889+RCGV1@users.noreply.github.com>
Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
197 lines
7.3 KiB
Swift
197 lines
7.3 KiB
Swift
//
|
|
// StoreForward.swift
|
|
// Meshtastic
|
|
//
|
|
// Copyright(c) Garth Vander Houwen 8/26/23.
|
|
//
|
|
import MeshtasticProtobufs
|
|
import OSLog
|
|
import SwiftUI
|
|
|
|
struct StoreForwardConfig: View {
|
|
|
|
@Environment(\.managedObjectContext) var context
|
|
@EnvironmentObject var accessoryManager: AccessoryManager
|
|
@Environment(\.dismiss) private var goBack
|
|
var node: NodeInfoEntity?
|
|
@State private var isPresentingSaveConfirm: Bool = false
|
|
@State var hasChanges: Bool = false
|
|
/// Enable the Store and Forward Module
|
|
@State var enabled = false
|
|
/// Is a S&F Server
|
|
@State var isServer = false
|
|
/// Send a Heartbeat
|
|
@State var heartbeat: Bool = false
|
|
/// Number of Records
|
|
@State var records = 0
|
|
/// Max number of history items to return
|
|
@State var historyReturnMax = 0
|
|
/// Time window for history
|
|
@State var historyReturnWindow = 0
|
|
|
|
var body: some View {
|
|
Form {
|
|
ConfigHeader(title: "Store & Forward", config: \.storeForwardConfig, node: node, onAppear: setStoreAndForwardValues)
|
|
|
|
Section(header: Text("Options")) {
|
|
Toggle(isOn: $enabled) {
|
|
Label("Enabled", systemImage: "envelope.arrow.triangle.branch")
|
|
Text("Enables the store and forward module.")
|
|
}
|
|
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
|
|
}
|
|
|
|
if enabled {
|
|
Section(header: Text("Settings")) {
|
|
Toggle(isOn: $heartbeat) {
|
|
Label("Send Heartbeat", systemImage: "waveform.path.ecg")
|
|
Text("Send a heartbeat to advertise the server's presence.")
|
|
}
|
|
Picker("Number of records", selection: $records) {
|
|
Text("Unset").tag(0)
|
|
Text("25").tag(25)
|
|
Text("50").tag(50)
|
|
Text("75").tag(75)
|
|
Text("100").tag(100)
|
|
}
|
|
.pickerStyle(DefaultPickerStyle())
|
|
Picker("History Return Max", selection: $historyReturnMax) {
|
|
Text("Unset").tag(0)
|
|
Text("25").tag(25)
|
|
Text("50").tag(50)
|
|
Text("75").tag(75)
|
|
Text("100").tag(100)
|
|
}
|
|
.pickerStyle(DefaultPickerStyle())
|
|
Picker("History Return Window", selection: $historyReturnWindow) {
|
|
Text("Unset").tag(0)
|
|
Text("One Minute").tag(60)
|
|
Text("Five Minutes").tag(300)
|
|
Text("Ten Minutes").tag(600)
|
|
Text("Fifteen Minutes").tag(900)
|
|
Text("Thirty Minutes").tag(1800)
|
|
Text("One Hour").tag(3600)
|
|
Text("Two Hours").tag(7200)
|
|
}
|
|
.pickerStyle(DefaultPickerStyle())
|
|
}
|
|
|
|
Section(header: Text("Server Option")) {
|
|
Toggle(isOn: $isServer) {
|
|
Label("Server", systemImage: "server.rack")
|
|
Text("Enable this device as a Store and Forward server. Requires an ESP32 device with PSRAM.")
|
|
}
|
|
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
|
|
if isServer {
|
|
Text("Store and forward servers require an ESP32 device with PSRAM or Linux Native.")
|
|
.foregroundColor(.gray)
|
|
.font(.callout)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.scrollDismissesKeyboard(.interactively)
|
|
.disabled(!accessoryManager.isConnected || node?.storeForwardConfig == nil)
|
|
.safeAreaInset(edge: .bottom, alignment: .center) {
|
|
HStack(spacing: 0) {
|
|
SaveConfigButton(node: node, hasChanges: $hasChanges) {
|
|
let connectedNode = getNodeInfo(id: accessoryManager.activeDeviceNum ?? -1, context: context)
|
|
if connectedNode != nil {
|
|
/// Let the user set isServer for the connected node, for nodes on the mesh set isServer based
|
|
/// on receipt of a primary heartbeat
|
|
if connectedNode?.num ?? 0 == node?.num ?? -1 {
|
|
connectedNode?.storeForwardConfig?.isRouter = isServer
|
|
do {
|
|
try context.save()
|
|
} catch {
|
|
Logger.mesh.error("Failed to save isServer: \(error.localizedDescription, privacy: .public)")
|
|
}
|
|
}
|
|
|
|
var sfc = ModuleConfig.StoreForwardConfig()
|
|
sfc.isServer = isServer
|
|
sfc.enabled = self.enabled
|
|
sfc.heartbeat = self.heartbeat
|
|
sfc.records = UInt32(self.records)
|
|
sfc.historyReturnMax = UInt32(self.historyReturnMax)
|
|
sfc.historyReturnWindow = UInt32(self.historyReturnWindow)
|
|
|
|
Task {
|
|
_ = try await accessoryManager.saveStoreForwardModuleConfig(config: sfc, fromUser: connectedNode!.user!, toUser: node!.user!)
|
|
Task { @MainActor in
|
|
// Should show a saved successfully alert once I know that to be true
|
|
// for now just disable the button after a successful save
|
|
hasChanges = false
|
|
goBack()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.navigationTitle("Store & Forward Config")
|
|
.navigationBarItems(
|
|
trailing: ZStack {
|
|
ConnectedDevice(
|
|
deviceConnected: accessoryManager.isConnected,
|
|
name: accessoryManager.activeConnection?.device.shortName ?? "?"
|
|
)
|
|
}
|
|
)
|
|
.onFirstAppear {
|
|
// Need to request a StoreForwardModuleConfig from the remote node before allowing changes
|
|
if let deviceNum = accessoryManager.activeDeviceNum, let node {
|
|
let connectedNode = getNodeInfo(id: deviceNum, context: context)
|
|
if let connectedNode {
|
|
if node.num != deviceNum {
|
|
if UserDefaults.enableAdministration && node.num != deviceNum {
|
|
/// 2.5 Administration with session passkey
|
|
let expiration = node.sessionExpiration ?? Date()
|
|
if expiration < Date() || node.storeForwardConfig == nil {
|
|
Task {
|
|
do {
|
|
Logger.mesh.info("⚙️ Empty or expired store & forward module config requesting via PKI admin")
|
|
try await accessoryManager.requestStoreAndForwardModuleConfig(fromUser: connectedNode.user!, toUser: node.user!)
|
|
} catch {
|
|
Logger.mesh.info("🚨 Request for store & forward module config failed")
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
/// Legacy Administration
|
|
Logger.mesh.info("☠️ Using insecure legacy admin that is no longer supported, please upgrade your firmware.")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.onChange(of: enabled) { oldEnabled, newEnabled in
|
|
if oldEnabled != newEnabled && newEnabled != node!.storeForwardConfig!.enabled { hasChanges = true }
|
|
}
|
|
.onChange(of: isServer) { oldIsServer, newIsServer in
|
|
if oldIsServer != newIsServer && newIsServer != node!.storeForwardConfig!.isRouter { hasChanges = true }
|
|
}
|
|
.onChange(of: heartbeat) { oldHeartbeat, newHeartbeat in
|
|
if oldHeartbeat != newHeartbeat && newHeartbeat != node?.storeForwardConfig?.heartbeat ?? true { hasChanges = true }
|
|
}
|
|
.onChange(of: records) { oldRecords, newRecords in
|
|
if oldRecords != newRecords && newRecords != node!.storeForwardConfig?.records ?? -1 { hasChanges = true }
|
|
}
|
|
.onChange(of: historyReturnMax) { oldHistoryReturnMax, newHistoryReturnMax in
|
|
if oldHistoryReturnMax != newHistoryReturnMax && newHistoryReturnMax != node!.storeForwardConfig?.historyReturnMax ?? -1 { hasChanges = true }
|
|
}
|
|
.onChange(of: historyReturnWindow) { oldHistoryReturnWindow, newHistoryReturnWindow in
|
|
if oldHistoryReturnWindow != newHistoryReturnWindow && newHistoryReturnWindow != node!.storeForwardConfig?.historyReturnWindow ?? -1 { hasChanges = true }
|
|
}
|
|
}
|
|
|
|
func setStoreAndForwardValues() {
|
|
self.enabled = (node?.storeForwardConfig?.enabled ?? false)
|
|
self.isServer = (node?.storeForwardConfig?.isRouter ?? false)
|
|
self.heartbeat = (node?.storeForwardConfig?.heartbeat ?? true)
|
|
self.records = Int(node?.storeForwardConfig?.records ?? 50)
|
|
self.historyReturnMax = Int(node?.storeForwardConfig?.historyReturnMax ?? 100)
|
|
self.historyReturnWindow = Int(node?.storeForwardConfig?.historyReturnWindow ?? 7200)
|
|
self.hasChanges = false
|
|
}
|
|
}
|