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>
207 lines
6.9 KiB
Swift
207 lines
6.9 KiB
Swift
//
|
|
// SerialConfig.swift
|
|
// Meshtastic Apple
|
|
//
|
|
// Copyright (c) Garth Vander Houwen 6/22/22.
|
|
//
|
|
import MeshtasticProtobufs
|
|
import OSLog
|
|
import SwiftUI
|
|
|
|
struct SerialConfig: 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 = false
|
|
|
|
@State var enabled = false
|
|
@State var echo = false
|
|
@State var rxd = 0
|
|
@State var txd = 0
|
|
@State var baudRate = 0
|
|
@State var timeout = 0
|
|
@State var overrideConsoleSerialPort = false
|
|
@State var mode = 0
|
|
|
|
var body: some View {
|
|
VStack {
|
|
Form {
|
|
ConfigHeader(title: "Serial", config: \.serialConfig, node: node, onAppear: setSerialValues)
|
|
|
|
Section(header: Text("Options")) {
|
|
|
|
Toggle(isOn: $enabled) {
|
|
Label("Enabled", systemImage: "terminal")
|
|
}
|
|
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
|
|
|
|
Toggle(isOn: $echo) {
|
|
Label("Echo", systemImage: "repeat")
|
|
Text("If set, any packets you send will be echoed back to your device.")
|
|
}
|
|
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
|
|
|
|
Picker("Baud", selection: $baudRate ) {
|
|
ForEach(SerialBaudRates.allCases) { sbr in
|
|
Text(sbr.description)
|
|
}
|
|
}
|
|
.pickerStyle(DefaultPickerStyle())
|
|
.listRowSeparator(/*@START_MENU_TOKEN@*/.visible/*@END_MENU_TOKEN@*/)
|
|
Picker("Timeout", selection: $timeout ) {
|
|
ForEach(SerialTimeoutIntervals.allCases) { sti in
|
|
Text(sti.description)
|
|
}
|
|
}
|
|
.pickerStyle(DefaultPickerStyle())
|
|
.listRowSeparator(.hidden)
|
|
Text("The amount of time to wait before we consider your packet as done.")
|
|
.foregroundColor(.gray)
|
|
.font(.callout)
|
|
|
|
Picker("Mode", selection: $mode ) {
|
|
ForEach(SerialModeTypes.allCases) { smt in
|
|
Text(smt.description)
|
|
}
|
|
}
|
|
.pickerStyle(DefaultPickerStyle())
|
|
}
|
|
Section(header: Text("GPIO")) {
|
|
|
|
Picker("Receive data (rxd) GPIO pin", selection: $rxd) {
|
|
ForEach(0..<49) {
|
|
if $0 == 0 {
|
|
Text("Unset")
|
|
} else {
|
|
Text("Pin \($0)")
|
|
}
|
|
}
|
|
}
|
|
.pickerStyle(DefaultPickerStyle())
|
|
.listRowSeparator(.visible)
|
|
|
|
Picker("Transmit data (txd) GPIO pin", selection: $txd) {
|
|
ForEach(0..<49) {
|
|
if $0 == 0 {
|
|
Text("Unset")
|
|
} else {
|
|
Text("Pin \($0)")
|
|
}
|
|
}
|
|
}
|
|
.pickerStyle(DefaultPickerStyle())
|
|
.listRowSeparator(.hidden)
|
|
Text("Set the GPIO pins for RXD and TXD.")
|
|
.foregroundColor(.gray)
|
|
.font(.callout)
|
|
}
|
|
}
|
|
.disabled(!accessoryManager.isConnected || node?.serialConfig == 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 {
|
|
var sc = ModuleConfig.SerialConfig()
|
|
sc.enabled = enabled
|
|
sc.echo = echo
|
|
sc.rxd = UInt32(rxd)
|
|
sc.txd = UInt32(txd)
|
|
sc.baud = SerialBaudRates(rawValue: baudRate)!.protoEnumValue()
|
|
sc.timeout = UInt32(timeout)
|
|
sc.overrideConsoleSerialPort = overrideConsoleSerialPort
|
|
sc.mode = SerialModeTypes(rawValue: mode)!.protoEnumValue()
|
|
|
|
Task {
|
|
_ = try await accessoryManager.saveSerialModuleConfig(config: sc, 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("Serial Config")
|
|
.navigationBarItems(
|
|
trailing: ZStack {
|
|
ConnectedDevice(
|
|
deviceConnected: accessoryManager.isConnected,
|
|
name: accessoryManager.activeConnection?.device.shortName ?? "?"
|
|
)
|
|
}
|
|
)
|
|
.onFirstAppear {
|
|
// Need to request a SerialModuleConfig 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.serialConfig == nil {
|
|
Task {
|
|
do {
|
|
Logger.mesh.info("⚙️ Empty or expired serial module config requesting via PKI admin")
|
|
try await accessoryManager.requestSerialModuleConfig(fromUser: connectedNode.user!, toUser: node.user!)
|
|
} catch {
|
|
Logger.mesh.info("🚨 Request for serial 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?.serialConfig?.enabled ?? false { hasChanges = true }
|
|
}
|
|
.onChange(of: echo) { oldEcho, newEcho in
|
|
if oldEcho != newEcho && newEcho != node?.serialConfig?.echo ?? false { hasChanges = true }
|
|
}
|
|
.onChange(of: rxd) { oldRxd, newRxd in
|
|
if oldRxd != newRxd && newRxd != node?.serialConfig?.rxd ?? -1 { hasChanges = true }
|
|
}
|
|
.onChange(of: txd) { oldTxd, newTxd in
|
|
if oldTxd != newTxd && newTxd != node?.serialConfig?.txd ?? -1 { hasChanges = true }
|
|
}
|
|
.onChange(of: baudRate) { oldBaud, newBaud in
|
|
if oldBaud != newBaud && newBaud != node?.serialConfig?.baudRate ?? -1 { hasChanges = true }
|
|
}
|
|
.onChange(of: timeout) { oldTimeout, newTimeout in
|
|
if oldTimeout != newTimeout && newTimeout != node?.serialConfig?.timeout ?? -1 { hasChanges = true }
|
|
}
|
|
.onChange(of: overrideConsoleSerialPort) { oldOverrideConsoleSerialPort, newOverrideConsoleSerialPort in
|
|
if oldOverrideConsoleSerialPort != newOverrideConsoleSerialPort && newOverrideConsoleSerialPort != node?.serialConfig?.overrideConsoleSerialPort ?? false { hasChanges = true }
|
|
}
|
|
.onChange(of: mode) { oldMode, newMode in
|
|
if oldMode != newMode && newMode != node?.serialConfig?.mode ?? -1 { hasChanges = true }
|
|
}
|
|
}
|
|
}
|
|
func setSerialValues() {
|
|
self.enabled = node?.serialConfig?.enabled ?? false
|
|
self.echo = node?.serialConfig?.echo ?? false
|
|
self.rxd = Int(node?.serialConfig?.rxd ?? 0)
|
|
self.txd = Int(node?.serialConfig?.txd ?? 0)
|
|
self.baudRate = Int(node?.serialConfig?.baudRate ?? 0)
|
|
self.timeout = Int(node?.serialConfig?.timeout ?? 0)
|
|
self.mode = Int(node?.serialConfig?.mode ?? 0)
|
|
self.overrideConsoleSerialPort = false // node?.serialConfig?.overrideConsoleSerialPort ?? false
|
|
self.hasChanges = false
|
|
}
|
|
}
|