From 288b35d6fc01efe256335c4842d7d3a294d3051d Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Sat, 22 Oct 2022 13:05:54 -0700 Subject: [PATCH] QR Code fixes --- Meshtastic/Helpers/BLEManager.swift | 3 --- Meshtastic/Helpers/MeshPackets.swift | 5 +++++ Meshtastic/Views/Settings/ShareChannels.swift | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index d1908a5d..75b0fa4c 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -410,11 +410,9 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph guard (connectedPeripheral!.peripheral.state == CBPeripheralState.connected) else { return } if FROMRADIO_characteristic == nil { - MeshLogger.log("🚨 Unsupported Firmware Version Detected, unable to connect to device.") invalidVersion = true return - } else { MeshLogger.log("ℹ️ Issuing wantConfig to \(connectedPeripheral!.peripheral.name ?? "Unknown")") //BLE Characteristics discovered, issue wantConfig @@ -423,7 +421,6 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph toRadio.wantConfigID = configNonce let binaryData: Data = try! toRadio.serializedData() connectedPeripheral!.peripheral.writeValue(binaryData, for: TORADIO_characteristic, type: .withResponse) - // Either Read the config complete value or from num notify value connectedPeripheral!.peripheral.readValue(for: FROMRADIO_characteristic) } diff --git a/Meshtastic/Helpers/MeshPackets.swift b/Meshtastic/Helpers/MeshPackets.swift index 87f53ad3..ce9222e8 100644 --- a/Meshtastic/Helpers/MeshPackets.swift +++ b/Meshtastic/Helpers/MeshPackets.swift @@ -773,8 +773,13 @@ func channelPacket (channel: Channel, fromNum: Int64, context: NSManagedObjectCo newChannel.name = channel.settings.name newChannel.role = Int32(channel.role.rawValue) newChannel.psk = channel.settings.psk + let mutableChannels = fetchedMyInfo[0].channels!.mutableCopy() as! NSMutableOrderedSet + if channel.role.rawValue == 1 { + mutableChannels.removeAllObjects() + } + mutableChannels.add(newChannel) fetchedMyInfo[0].channels = mutableChannels.copy() as? NSOrderedSet diff --git a/Meshtastic/Views/Settings/ShareChannels.swift b/Meshtastic/Views/Settings/ShareChannels.swift index e4b8fa2e..dc9d3eb8 100644 --- a/Meshtastic/Views/Settings/ShareChannels.swift +++ b/Meshtastic/Views/Settings/ShareChannels.swift @@ -282,6 +282,7 @@ struct ShareChannels: View { loRaConfig.hopLimit = UInt32(node?.loRaConfig?.hopLimit ?? 3) loRaConfig.txEnabled = node?.loRaConfig?.txEnabled ?? false loRaConfig.txPower = node?.loRaConfig?.txPower ?? 0 + loRaConfig.usePreset = node?.loRaConfig?.usePreset ?? true loRaConfig.channelNum = UInt32(node?.loRaConfig?.channelNum ?? 0) channelSet.loraConfig = loRaConfig if node != nil {