Fix channel bug

This commit is contained in:
Garth Vander Houwen 2023-01-02 20:11:58 -08:00
parent e95ccee52e
commit 12fdddd565
2 changed files with 5 additions and 13 deletions

View file

@ -742,7 +742,7 @@ func channelPacket (channel: Channel, fromNum: Int64, context: NSManagedObjectCo
MeshLogger.log("🎛️ \(logString)")
let fetchedMyInfoRequest: NSFetchRequest<NSFetchRequestResult> = NSFetchRequest.init(entityName: "MyInfoEntity")
fetchedMyInfoRequest.predicate = NSPredicate(format: "myNodeNum == %lld", channel.index, String(fromNum))
fetchedMyInfoRequest.predicate = NSPredicate(format: "myNodeNum == %lld", fromNum)
do {
@ -932,7 +932,7 @@ func nodeInfoPacket (nodeInfo: NodeInfo, channel: UInt32, context: NSManagedObje
func nodeInfoAppPacket (packet: MeshPacket, context: NSManagedObjectContext) {
let logString = String.localizedStringWithFormat(NSLocalizedString("mesh.log.nodeinfo.received %@", comment: "Node info received for: %@"), packet.from)
let logString = String.localizedStringWithFormat(NSLocalizedString("mesh.log.nodeinfo.received %@", comment: "Node info received for: %@"), String(packet.from))
MeshLogger.log("📟 \(logString)")
let fetchNodeInfoAppRequest: NSFetchRequest<NSFetchRequestResult> = NSFetchRequest.init(entityName: "NodeInfoEntity")

View file

@ -25,7 +25,6 @@ struct MQTTConfig: View {
Form {
Section(header: Text("options")) {
Toggle(isOn: $enabled) {
Label("enabled", systemImage: "dot.radiowaves.right")
@ -43,10 +42,8 @@ struct MQTTConfig: View {
Label("JSON Enabled", systemImage: "ellipsis.curlybraces")
}
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
}
Section(header: Text("Custom Server")) {
HStack {
Label("Address", systemImage: "server.rack")
TextField("Server Address", text: $address)
@ -54,16 +51,11 @@ struct MQTTConfig: View {
.autocapitalization(.none)
.disableAutocorrection(true)
.onChange(of: address, perform: { value in
let totalBytes = address.utf8.count
// Only mess with the value if it is too big
if totalBytes > 30 {
let firstNBytes = Data(username.utf8.prefix(30))
if let maxBytesString = String(data: firstNBytes, encoding: String.Encoding.utf8) {
// Set the shortName back to the last place where it was the right size
address = maxBytesString
}
@ -187,17 +179,17 @@ struct MQTTConfig: View {
self.hasChanges = false
}
.onChange(of: enabled) { newEnabled in
if node != nil && node!.mqttConfig != nil {
if node != nil && node?.mqttConfig != nil {
if newEnabled != node!.mqttConfig!.enabled { hasChanges = true }
}
}
.onChange(of: encryptionEnabled) { newEncryptionEnabled in
if node != nil && node!.mqttConfig != nil {
if node != nil && node?.mqttConfig != nil {
if newEncryptionEnabled != node!.mqttConfig!.encryptionEnabled { hasChanges = true }
}
}
.onChange(of: jsonEnabled) { newJsonEnabled in
if node != nil && node!.mqttConfig != nil {
if node != nil && node?.mqttConfig != nil {
if newJsonEnabled != node!.mqttConfig!.jsonEnabled { hasChanges = true }
}
}