From b327f1397181c3fa3b17ae48f7eda94e7a9c686a Mon Sep 17 00:00:00 2001 From: Jake-B Date: Sat, 1 Nov 2025 16:45:02 -0400 Subject: [PATCH] perferredPeripheralId fix --- .../AccessoryManager+Connect.swift | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/Meshtastic/Accessory/Accessory Manager/AccessoryManager+Connect.swift b/Meshtastic/Accessory/Accessory Manager/AccessoryManager+Connect.swift index d63f8acf..3e2dd76f 100644 --- a/Meshtastic/Accessory/Accessory Manager/AccessoryManager+Connect.swift +++ b/Meshtastic/Accessory/Accessory Manager/AccessoryManager+Connect.swift @@ -66,15 +66,6 @@ extension AccessoryManager { Logger.transport.info("[Accessory] Event stream closed") } self.activeConnection = (device: device, connection: connection) - - // if we don't have a peripheralId, set it now at the beginning of the - // connect process (because I think it is used in other parts of the app - // during the connect process? - // Otherwise, UserDefault.preferredPeripheralId is set in the Connect - // view, as part of the "Connect to new radio?" confirmation dialog logic. - if UserDefaults.preferredPeripheralId.isEmpty { - UserDefaults.preferredPeripheralId = device.id.uuidString - } } catch let error as CBError where error.code == .peerRemovedPairingInformation { await self.connectionStepper?.cancelCurrentlyExecutingStep(withError: AccessoryError.coreBluetoothError(error), cancelFullProcess: true) } @@ -119,6 +110,10 @@ extension AccessoryManager { Logger.transport.info("🔗👟 [Connect] Step 5: Send wantConfig (database)") self.updateState(.retrievingDatabase(nodeCount: 0)) self.allowDisconnect = true + + Logger.transport.info("🔗 Saving preferredPeripheralId: \(device.id.uuidString)") + UserDefaults.preferredPeripheralId = device.id.uuidString + try await self.sendWantDatabase() }