mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
SwiftLint Whitespace fixes
This commit is contained in:
parent
c3cbe9fb57
commit
fdade220de
104 changed files with 1644 additions and 1832 deletions
|
|
@ -7,18 +7,14 @@
|
|||
import SwiftUI
|
||||
|
||||
struct CannedMessagesConfig: View {
|
||||
|
||||
@Environment(\.managedObjectContext) var context
|
||||
@EnvironmentObject var bleManager: BLEManager
|
||||
@Environment(\.dismiss) private var goBack
|
||||
|
||||
var node: NodeInfoEntity?
|
||||
|
||||
@State private var isPresentingSaveConfirm: Bool = false
|
||||
@State var hasChanges = false
|
||||
@State var hasMessagesChanges = false
|
||||
@State var configPreset = 0
|
||||
|
||||
@State var enabled = false
|
||||
/// CannedMessageModule will sends a bell character with the messages.
|
||||
@State var sendBell: Bool = false
|
||||
|
|
@ -38,29 +34,22 @@ struct CannedMessagesConfig: View {
|
|||
@State var inputbrokerEventCcw = 0
|
||||
/// Generate input event on Press of this kind.
|
||||
@State var inputbrokerEventPress = 0
|
||||
|
||||
@State var messages = ""
|
||||
|
||||
var body: some View {
|
||||
|
||||
VStack {
|
||||
|
||||
Form {
|
||||
|
||||
Section(header: Text("options")) {
|
||||
|
||||
Toggle(isOn: $enabled) {
|
||||
|
||||
Label("enabled", systemImage: "list.bullet.rectangle.fill")
|
||||
}
|
||||
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
|
||||
|
||||
Toggle(isOn: $sendBell) {
|
||||
|
||||
Label("Send Bell", systemImage: "bell")
|
||||
}
|
||||
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
|
||||
|
||||
Picker("Configuration Presets", selection: $configPreset ) {
|
||||
ForEach(ConfigPresets.allCases) { cp in
|
||||
Text(cp.description)
|
||||
|
|
@ -69,26 +58,21 @@ struct CannedMessagesConfig: View {
|
|||
.pickerStyle(DefaultPickerStyle())
|
||||
.padding(.top, 10)
|
||||
.padding(.bottom, 10)
|
||||
|
||||
}
|
||||
|
||||
HStack {
|
||||
Label("Messages", systemImage: "message.fill")
|
||||
TextField("Messages separate with |", text: $messages, axis: .vertical)
|
||||
.foregroundColor(.gray)
|
||||
.autocapitalization(.none)
|
||||
.disableAutocorrection(true)
|
||||
.onChange(of: messages, perform: { value in
|
||||
.onChange(of: messages, perform: { _ in
|
||||
|
||||
let totalBytes = messages.utf8.count
|
||||
|
||||
// Only mess with the value if it is too big
|
||||
if totalBytes > 198 {
|
||||
|
||||
let firstNBytes = Data(messages.utf8.prefix(198))
|
||||
|
||||
if let maxBytesString = String(data: firstNBytes, encoding: String.Encoding.utf8) {
|
||||
|
||||
// Set the shortName back to the last place where it was the right size
|
||||
messages = maxBytesString
|
||||
}
|
||||
|
|
@ -98,35 +82,27 @@ struct CannedMessagesConfig: View {
|
|||
.foregroundColor(.gray)
|
||||
}
|
||||
.keyboardType(.default)
|
||||
|
||||
Section(header: Text("Control Type")) {
|
||||
|
||||
|
||||
Toggle(isOn: $rotary1Enabled) {
|
||||
|
||||
Label("Rotary 1", systemImage: "dial.min")
|
||||
}
|
||||
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
|
||||
.disabled(updown1Enabled)
|
||||
|
||||
Toggle(isOn: $updown1Enabled) {
|
||||
|
||||
Label("Up Down 1", systemImage: "arrow.up.arrow.down")
|
||||
}
|
||||
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
|
||||
.disabled(rotary1Enabled)
|
||||
|
||||
}
|
||||
.disabled(configPreset > 0)
|
||||
Section(header: Text("Inputs")) {
|
||||
|
||||
Picker("Pin A", selection: $inputbrokerPinA) {
|
||||
ForEach(0..<40) {
|
||||
|
||||
if $0 == 0 {
|
||||
Text("unset")
|
||||
} else {
|
||||
|
||||
Text("Pin \($0)")
|
||||
}
|
||||
}
|
||||
|
|
@ -134,14 +110,11 @@ struct CannedMessagesConfig: View {
|
|||
.pickerStyle(DefaultPickerStyle())
|
||||
Text("GPIO pin for rotary encoder A port.")
|
||||
.font(.caption)
|
||||
|
||||
Picker("Pin B", selection: $inputbrokerPinB) {
|
||||
ForEach(0..<40) {
|
||||
|
||||
if $0 == 0 {
|
||||
Text("unset")
|
||||
} else {
|
||||
|
||||
Text("Pin \($0)")
|
||||
}
|
||||
}
|
||||
|
|
@ -149,14 +122,11 @@ struct CannedMessagesConfig: View {
|
|||
.pickerStyle(DefaultPickerStyle())
|
||||
Text("GPIO pin for rotary encoder B port.")
|
||||
.font(.caption)
|
||||
|
||||
Picker("Press Pin", selection: $inputbrokerPinPress) {
|
||||
ForEach(0..<40) {
|
||||
|
||||
if $0 == 0 {
|
||||
Text("unset")
|
||||
} else {
|
||||
|
||||
Text("Pin \($0)")
|
||||
}
|
||||
}
|
||||
|
|
@ -164,12 +134,9 @@ struct CannedMessagesConfig: View {
|
|||
.pickerStyle(DefaultPickerStyle())
|
||||
Text("GPIO pin for rotary encoder Press port.")
|
||||
.font(.caption)
|
||||
|
||||
}
|
||||
.disabled(configPreset > 0)
|
||||
|
||||
Section(header: Text("Key Mapping")) {
|
||||
|
||||
Picker("Clockwise Rotary Event", selection: $inputbrokerEventCw ) {
|
||||
ForEach(InputEventChars.allCases) { iec in
|
||||
Text(iec.description)
|
||||
|
|
@ -178,7 +145,6 @@ struct CannedMessagesConfig: View {
|
|||
.pickerStyle(DefaultPickerStyle())
|
||||
.padding(.top, 10)
|
||||
.padding(.bottom, 10)
|
||||
|
||||
Picker("Counter Clockwise Rotary Event", selection: $inputbrokerEventCcw ) {
|
||||
ForEach(InputEventChars.allCases) { iec in
|
||||
Text(iec.description)
|
||||
|
|
@ -187,7 +153,6 @@ struct CannedMessagesConfig: View {
|
|||
.pickerStyle(DefaultPickerStyle())
|
||||
.padding(.top, 10)
|
||||
.padding(.bottom, 10)
|
||||
|
||||
Picker("Encoder Press Event", selection: $inputbrokerEventPress ) {
|
||||
ForEach(InputEventChars.allCases) { iec in
|
||||
Text(iec.description)
|
||||
|
|
@ -201,10 +166,8 @@ struct CannedMessagesConfig: View {
|
|||
}
|
||||
.scrollDismissesKeyboard(.immediately)
|
||||
.disabled(self.bleManager.connectedPeripheral == nil || node?.cannedMessageConfig == nil)
|
||||
|
||||
Button {
|
||||
isPresentingSaveConfirm = true
|
||||
|
||||
} label: {
|
||||
Label("save", systemImage: "square.and.arrow.down")
|
||||
}
|
||||
|
|
@ -287,7 +250,7 @@ struct CannedMessagesConfig: View {
|
|||
self.messages = node?.cannedMessageConfig?.messages ?? ""
|
||||
self.hasChanges = false
|
||||
self.hasMessagesChanges = false
|
||||
|
||||
|
||||
// Need to request a CannedMessagesModuleConfig from the remote node before allowing changes
|
||||
if bleManager.connectedPeripheral != nil && node?.cannedMessageConfig == nil {
|
||||
print("empty canned messages module config")
|
||||
|
|
@ -298,9 +261,9 @@ struct CannedMessagesConfig: View {
|
|||
}
|
||||
}
|
||||
.onChange(of: configPreset) { newPreset in
|
||||
|
||||
|
||||
if newPreset == 1 {
|
||||
|
||||
|
||||
// RAK Rotary Encoder
|
||||
updown1Enabled = true
|
||||
rotary1Enabled = false
|
||||
|
|
@ -310,9 +273,9 @@ struct CannedMessagesConfig: View {
|
|||
inputbrokerEventCw = InputEventChars.down.rawValue
|
||||
inputbrokerEventCcw = InputEventChars.up.rawValue
|
||||
inputbrokerEventPress = InputEventChars.select.rawValue
|
||||
|
||||
|
||||
} else if newPreset == 2 {
|
||||
|
||||
|
||||
// CardKB / RAK Keypad
|
||||
updown1Enabled = false
|
||||
rotary1Enabled = false
|
||||
|
|
@ -323,7 +286,7 @@ struct CannedMessagesConfig: View {
|
|||
inputbrokerEventCcw = InputEventChars.none.rawValue
|
||||
inputbrokerEventPress = InputEventChars.none.rawValue
|
||||
}
|
||||
|
||||
|
||||
hasChanges = true
|
||||
}
|
||||
.onChange(of: enabled) { newEnabled in
|
||||
|
|
|
|||
|
|
@ -7,13 +7,13 @@
|
|||
import SwiftUI
|
||||
|
||||
struct ExternalNotificationConfig: View {
|
||||
|
||||
|
||||
@Environment(\.managedObjectContext) var context
|
||||
@EnvironmentObject var bleManager: BLEManager
|
||||
@Environment(\.dismiss) private var goBack
|
||||
|
||||
|
||||
var node: NodeInfoEntity?
|
||||
|
||||
|
||||
@State private var isPresentingSaveConfirm: Bool = false
|
||||
@State var hasChanges = false
|
||||
@State var enabled = false
|
||||
|
|
@ -30,9 +30,9 @@ struct ExternalNotificationConfig: View {
|
|||
@State var outputVibra = 0
|
||||
@State var outputMilliseconds = 0
|
||||
@State var nagTimeout = 0
|
||||
|
||||
|
||||
var body: some View {
|
||||
|
||||
|
||||
Form {
|
||||
Section(header: Text("options")) {
|
||||
Toggle(isOn: $enabled) {
|
||||
|
|
@ -58,8 +58,7 @@ struct ExternalNotificationConfig: View {
|
|||
Section(header: Text("Primary GPIO")
|
||||
.font(.caption)
|
||||
.foregroundColor(.gray)
|
||||
.textCase(.uppercase))
|
||||
{
|
||||
.textCase(.uppercase)) {
|
||||
Toggle(isOn: $active) {
|
||||
Label("Active", systemImage: "togglepower")
|
||||
}
|
||||
|
|
@ -93,12 +92,11 @@ struct ExternalNotificationConfig: View {
|
|||
Text("Specifies how long the monitored GPIO should output.")
|
||||
.font(.caption)
|
||||
}
|
||||
|
||||
|
||||
Section(header: Text("Optional GPIO")
|
||||
.font(.caption)
|
||||
.foregroundColor(.gray)
|
||||
.textCase(.uppercase))
|
||||
{
|
||||
.textCase(.uppercase)) {
|
||||
Toggle(isOn: $alertBellBuzzer) {
|
||||
Label("Alert GPIO buzzer when receiving a bell", systemImage: "bell")
|
||||
}
|
||||
|
|
@ -174,7 +172,7 @@ struct ExternalNotificationConfig: View {
|
|||
enc.outputMs = UInt32(outputMilliseconds)
|
||||
enc.usePwm = usePWM
|
||||
let adminMessageId = bleManager.saveExternalNotificationModuleConfig(config: enc, fromUser: connectedNode!.user!, toUser: node!.user!, adminIndex: connectedNode?.myInfo?.adminIndex ?? 0)
|
||||
if adminMessageId > 0{
|
||||
if adminMessageId > 0 {
|
||||
// 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
|
||||
|
|
@ -208,7 +206,7 @@ struct ExternalNotificationConfig: View {
|
|||
self.nagTimeout = Int(node?.externalNotificationConfig?.nagTimeout ?? 0)
|
||||
self.usePWM = node?.externalNotificationConfig?.usePWM ?? false
|
||||
self.hasChanges = false
|
||||
|
||||
|
||||
// Need to request a TelemetryModuleConfig from the remote node before allowing changes
|
||||
if bleManager.connectedPeripheral != nil && node?.externalNotificationConfig == nil {
|
||||
print("empty external notification module config")
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
import SwiftUI
|
||||
|
||||
struct MQTTConfig: View {
|
||||
|
||||
|
||||
@Environment(\.managedObjectContext) var context
|
||||
@EnvironmentObject var bleManager: BLEManager
|
||||
@Environment(\.dismiss) private var goBack
|
||||
|
|
@ -20,9 +20,9 @@ struct MQTTConfig: View {
|
|||
@State var password = ""
|
||||
@State var encryptionEnabled = false
|
||||
@State var jsonEnabled = false
|
||||
|
||||
|
||||
var body: some View {
|
||||
|
||||
|
||||
Form {
|
||||
Section(header: Text("options")) {
|
||||
Toggle(isOn: $enabled) {
|
||||
|
|
@ -30,7 +30,7 @@ struct MQTTConfig: View {
|
|||
Label("enabled", systemImage: "dot.radiowaves.right")
|
||||
}
|
||||
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
|
||||
|
||||
|
||||
Toggle(isOn: $encryptionEnabled) {
|
||||
|
||||
Label("Encryption Enabled", systemImage: "lock.icloud")
|
||||
|
|
@ -50,7 +50,7 @@ struct MQTTConfig: View {
|
|||
.foregroundColor(.gray)
|
||||
.autocapitalization(.none)
|
||||
.disableAutocorrection(true)
|
||||
.onChange(of: address, perform: { value in
|
||||
.onChange(of: address, perform: { _ in
|
||||
let totalBytes = address.utf8.count
|
||||
// Only mess with the value if it is too big
|
||||
if totalBytes > 30 {
|
||||
|
|
@ -66,24 +66,24 @@ struct MQTTConfig: View {
|
|||
.keyboardType(.default)
|
||||
}
|
||||
.autocorrectionDisabled()
|
||||
|
||||
|
||||
HStack {
|
||||
Label("mqtt.username", systemImage: "person.text.rectangle")
|
||||
TextField("mqtt.username", text: $username)
|
||||
.foregroundColor(.gray)
|
||||
.autocapitalization(.none)
|
||||
.disableAutocorrection(true)
|
||||
.onChange(of: username, perform: { value in
|
||||
.onChange(of: username, perform: { _ in
|
||||
|
||||
let totalBytes = username.utf8.count
|
||||
|
||||
|
||||
// Only mess with the value if it is too big
|
||||
if totalBytes > 62 {
|
||||
|
||||
let firstNBytes = Data(username.utf8.prefix(62))
|
||||
|
||||
|
||||
if let maxBytesString = String(data: firstNBytes, encoding: String.Encoding.utf8) {
|
||||
|
||||
|
||||
// Set the shortName back to the last place where it was the right size
|
||||
username = maxBytesString
|
||||
}
|
||||
|
|
@ -100,17 +100,17 @@ struct MQTTConfig: View {
|
|||
.foregroundColor(.gray)
|
||||
.autocapitalization(.none)
|
||||
.disableAutocorrection(true)
|
||||
.onChange(of: password, perform: { value in
|
||||
.onChange(of: password, perform: { _ in
|
||||
|
||||
let totalBytes = password.utf8.count
|
||||
|
||||
|
||||
// Only mess with the value if it is too big
|
||||
if totalBytes > 62 {
|
||||
|
||||
let firstNBytes = Data(password.utf8.prefix(62))
|
||||
|
||||
|
||||
if let maxBytesString = String(data: firstNBytes, encoding: String.Encoding.utf8) {
|
||||
|
||||
|
||||
// Set the shortName back to the last place where it was the right size
|
||||
password = maxBytesString
|
||||
}
|
||||
|
|
@ -127,7 +127,7 @@ struct MQTTConfig: View {
|
|||
}
|
||||
.scrollDismissesKeyboard(.interactively)
|
||||
.disabled(self.bleManager.connectedPeripheral == nil || node?.mqttConfig == nil)
|
||||
|
||||
|
||||
Button {
|
||||
isPresentingSaveConfirm = true
|
||||
} label: {
|
||||
|
|
@ -182,7 +182,7 @@ struct MQTTConfig: View {
|
|||
self.encryptionEnabled = (node?.mqttConfig?.encryptionEnabled ?? false)
|
||||
self.jsonEnabled = (node?.mqttConfig?.jsonEnabled ?? false)
|
||||
self.hasChanges = false
|
||||
|
||||
|
||||
// Need to request a TelemetryModuleConfig from the remote node before allowing changes
|
||||
if bleManager.connectedPeripheral != nil && node?.telemetryConfig == nil {
|
||||
print("empty mqtt module config")
|
||||
|
|
|
|||
|
|
@ -7,19 +7,19 @@
|
|||
import SwiftUI
|
||||
|
||||
struct RangeTestConfig: View {
|
||||
|
||||
|
||||
@Environment(\.managedObjectContext) var context
|
||||
@EnvironmentObject var bleManager: BLEManager
|
||||
@Environment(\.dismiss) private var goBack
|
||||
|
||||
|
||||
var node: NodeInfoEntity?
|
||||
|
||||
|
||||
@State private var isPresentingSaveConfirm: Bool = false
|
||||
@State var hasChanges = false
|
||||
@State var enabled = false
|
||||
@State var sender = 0
|
||||
@State var save = false
|
||||
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
Form {
|
||||
|
|
@ -65,7 +65,7 @@ struct RangeTestConfig: View {
|
|||
let nodeName = node?.user?.longName ?? NSLocalizedString("unknown", comment: "Unknown")
|
||||
let buttonText = String.localizedStringWithFormat(NSLocalizedString("save.config %@", comment: "Save Config for %@"), nodeName)
|
||||
Button(buttonText) {
|
||||
|
||||
|
||||
let connectedNode = getNodeInfo(id: bleManager.connectedPeripheral.num, context: context)
|
||||
if connectedNode != nil {
|
||||
var rtc = ModuleConfig.RangeTestConfig()
|
||||
|
|
@ -96,7 +96,7 @@ struct RangeTestConfig: View {
|
|||
self.save = node?.rangeTestConfig?.save ?? false
|
||||
self.sender = Int(node?.rangeTestConfig?.sender ?? 0)
|
||||
self.hasChanges = false
|
||||
|
||||
|
||||
// Need to request a RangeTestModule Config from the remote node before allowing changes
|
||||
if bleManager.connectedPeripheral != nil && node?.rangeTestConfig == nil {
|
||||
print("empty range test module config")
|
||||
|
|
|
|||
|
|
@ -7,16 +7,16 @@
|
|||
import SwiftUI
|
||||
|
||||
struct SerialConfig: View {
|
||||
|
||||
|
||||
@Environment(\.managedObjectContext) var context
|
||||
@EnvironmentObject var bleManager: BLEManager
|
||||
@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
|
||||
|
|
@ -24,21 +24,21 @@ struct SerialConfig: View {
|
|||
@State var baudRate = 0
|
||||
@State var timeout = 0
|
||||
@State var mode = 0
|
||||
|
||||
|
||||
var body: some View {
|
||||
|
||||
|
||||
VStack {
|
||||
|
||||
Form {
|
||||
|
||||
|
||||
Section(header: Text("options")) {
|
||||
|
||||
|
||||
Toggle(isOn: $enabled) {
|
||||
|
||||
Label("enabled", systemImage: "terminal")
|
||||
}
|
||||
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
|
||||
|
||||
|
||||
Toggle(isOn: $echo) {
|
||||
|
||||
Label("echo", systemImage: "repeat")
|
||||
|
|
@ -46,14 +46,14 @@ struct SerialConfig: View {
|
|||
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
|
||||
Text("If set, any packets you send will be echoed back to your device.")
|
||||
.font(.caption)
|
||||
|
||||
|
||||
Picker("Baud", selection: $baudRate ) {
|
||||
ForEach(SerialBaudRates.allCases) { sbr in
|
||||
Text(sbr.description)
|
||||
}
|
||||
}
|
||||
.pickerStyle(DefaultPickerStyle())
|
||||
|
||||
|
||||
Picker("timeout", selection: $timeout ) {
|
||||
ForEach(SerialTimeoutIntervals.allCases) { sti in
|
||||
Text(sti.description)
|
||||
|
|
@ -62,7 +62,7 @@ struct SerialConfig: View {
|
|||
.pickerStyle(DefaultPickerStyle())
|
||||
Text("The amount of time to wait before we consider your packet as done.")
|
||||
.font(.caption)
|
||||
|
||||
|
||||
Picker("mode", selection: $mode ) {
|
||||
ForEach(SerialModeTypes.allCases) { smt in
|
||||
Text(smt.description)
|
||||
|
|
@ -71,7 +71,7 @@ struct SerialConfig: View {
|
|||
.pickerStyle(DefaultPickerStyle())
|
||||
}
|
||||
Section(header: Text("GPIO")) {
|
||||
|
||||
|
||||
Picker("Receive data (rxd) GPIO pin", selection: $rxd) {
|
||||
ForEach(0..<40) {
|
||||
if $0 == 0 {
|
||||
|
|
@ -98,13 +98,13 @@ struct SerialConfig: View {
|
|||
}
|
||||
}
|
||||
.disabled(self.bleManager.connectedPeripheral == nil || node?.serialConfig == nil)
|
||||
|
||||
|
||||
Button {
|
||||
|
||||
|
||||
isPresentingSaveConfirm = true
|
||||
|
||||
|
||||
} label: {
|
||||
|
||||
|
||||
Label("save", systemImage: "square.and.arrow.down")
|
||||
}
|
||||
.disabled(bleManager.connectedPeripheral == nil || !hasChanges)
|
||||
|
|
@ -113,7 +113,7 @@ struct SerialConfig: View {
|
|||
.controlSize(.large)
|
||||
.padding()
|
||||
.confirmationDialog(
|
||||
|
||||
|
||||
"are.you.sure",
|
||||
isPresented: $isPresentingSaveConfirm,
|
||||
titleVisibility: .visible
|
||||
|
|
@ -131,9 +131,9 @@ struct SerialConfig: View {
|
|||
sc.baud = SerialBaudRates(rawValue: baudRate)!.protoEnumValue()
|
||||
sc.timeout = UInt32(timeout)
|
||||
sc.mode = SerialModeTypes(rawValue: mode)!.protoEnumValue()
|
||||
|
||||
|
||||
let adminMessageId = bleManager.saveSerialModuleConfig(config: sc, fromUser: connectedNode!.user!, toUser: node!.user!, adminIndex: connectedNode?.myInfo?.adminIndex ?? 0)
|
||||
|
||||
|
||||
if adminMessageId > 0 {
|
||||
// Should show a saved successfully alert once I know that to be true
|
||||
// for now just disable the button after a successful save
|
||||
|
|
@ -153,7 +153,7 @@ struct SerialConfig: View {
|
|||
ConnectedDevice(bluetoothOn: bleManager.isSwitchedOn, deviceConnected: bleManager.connectedPeripheral != nil, name: (bleManager.connectedPeripheral != nil) ? bleManager.connectedPeripheral.shortName : "????")
|
||||
})
|
||||
.onAppear {
|
||||
|
||||
|
||||
self.bleManager.context = context
|
||||
self.enabled = node?.serialConfig?.enabled ?? false
|
||||
self.echo = node?.serialConfig?.echo ?? false
|
||||
|
|
@ -163,7 +163,7 @@ struct SerialConfig: View {
|
|||
self.timeout = Int(node?.serialConfig?.timeout ?? 0)
|
||||
self.mode = Int(node?.serialConfig?.mode ?? 0)
|
||||
self.hasChanges = false
|
||||
|
||||
|
||||
// Need to request a SerialModuleConfig from the remote node before allowing changes
|
||||
if bleManager.connectedPeripheral != nil && node?.serialConfig == nil {
|
||||
print("empty serial module config")
|
||||
|
|
@ -175,51 +175,51 @@ struct SerialConfig: View {
|
|||
|
||||
}
|
||||
.onChange(of: enabled) { newEnabled in
|
||||
|
||||
|
||||
if node != nil && node!.serialConfig != nil {
|
||||
|
||||
|
||||
if newEnabled != node!.serialConfig!.enabled { hasChanges = true }
|
||||
}
|
||||
}
|
||||
.onChange(of: echo) { newEcho in
|
||||
|
||||
|
||||
if node != nil && node!.serialConfig != nil {
|
||||
|
||||
|
||||
if newEcho != node!.serialConfig!.echo { hasChanges = true }
|
||||
}
|
||||
}
|
||||
.onChange(of: rxd) { newRxd in
|
||||
|
||||
|
||||
if node != nil && node!.serialConfig != nil {
|
||||
|
||||
|
||||
if newRxd != node!.serialConfig!.rxd { hasChanges = true }
|
||||
}
|
||||
}
|
||||
.onChange(of: txd) { newTxd in
|
||||
|
||||
|
||||
if node != nil && node!.serialConfig != nil {
|
||||
|
||||
if newTxd != node!.serialConfig!.txd { hasChanges = true }
|
||||
}
|
||||
}
|
||||
.onChange(of: baudRate) { newBaud in
|
||||
|
||||
|
||||
if node != nil && node!.serialConfig != nil {
|
||||
|
||||
|
||||
if newBaud != node!.serialConfig!.baudRate { hasChanges = true }
|
||||
}
|
||||
}
|
||||
.onChange(of: timeout) { newTimeout in
|
||||
|
||||
|
||||
if node != nil && node!.serialConfig != nil {
|
||||
|
||||
|
||||
if newTimeout != node!.serialConfig!.timeout { hasChanges = true }
|
||||
}
|
||||
}
|
||||
.onChange(of: mode) { newMode in
|
||||
|
||||
|
||||
if node != nil && node!.serialConfig != nil {
|
||||
|
||||
|
||||
if newMode != node!.serialConfig!.mode { hasChanges = true }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,13 +7,13 @@
|
|||
import SwiftUI
|
||||
|
||||
struct TelemetryConfig: View {
|
||||
|
||||
|
||||
@Environment(\.managedObjectContext) var context
|
||||
@EnvironmentObject var bleManager: BLEManager
|
||||
@Environment(\.dismiss) private var goBack
|
||||
|
||||
|
||||
var node: NodeInfoEntity?
|
||||
|
||||
|
||||
@State private var isPresentingSaveConfirm: Bool = false
|
||||
@State var hasChanges = false
|
||||
@State var deviceUpdateInterval = 0
|
||||
|
|
@ -21,9 +21,9 @@ struct TelemetryConfig: View {
|
|||
@State var environmentMeasurementEnabled = false
|
||||
@State var environmentScreenEnabled = false
|
||||
@State var environmentDisplayFahrenheit = false
|
||||
|
||||
|
||||
var body: some View {
|
||||
|
||||
|
||||
VStack {
|
||||
Form {
|
||||
Section(header: Text("update.interval")) {
|
||||
|
|
@ -88,7 +88,7 @@ struct TelemetryConfig: View {
|
|||
tc.environmentMeasurementEnabled = environmentMeasurementEnabled
|
||||
tc.environmentScreenEnabled = environmentScreenEnabled
|
||||
tc.environmentDisplayFahrenheit = environmentDisplayFahrenheit
|
||||
let adminMessageId = bleManager.saveTelemetryModuleConfig(config: tc, fromUser: connectedNode!.user!, toUser: node!.user!, adminIndex: connectedNode?.myInfo?.adminIndex ?? 0)
|
||||
let adminMessageId = bleManager.saveTelemetryModuleConfig(config: tc, fromUser: connectedNode!.user!, toUser: node!.user!, adminIndex: connectedNode?.myInfo?.adminIndex ?? 0)
|
||||
if adminMessageId > 0 {
|
||||
// Should show a saved successfully alert once I know that to be true
|
||||
// for now just disable the button after a successful save
|
||||
|
|
@ -114,7 +114,7 @@ struct TelemetryConfig: View {
|
|||
self.environmentScreenEnabled = node?.telemetryConfig?.environmentScreenEnabled ?? false
|
||||
self.environmentDisplayFahrenheit = node?.telemetryConfig?.environmentDisplayFahrenheit ?? false
|
||||
self.hasChanges = false
|
||||
|
||||
|
||||
// Need to request a TelemetryModuleConfig from the remote node before allowing changes
|
||||
if bleManager.connectedPeripheral != nil && node?.telemetryConfig == nil {
|
||||
print("empty telemetry module config")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue