diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index 672588a8..0b70a265 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -592,6 +592,22 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph case .max: print("MAX PORT NUM OF 511") } + + // MARK: Check for an All / Broadcast User and delete it as a transition to multi channel + let fetchBCUserRequest: NSFetchRequest = NSFetchRequest.init(entityName: "UserEntity") + fetchBCUserRequest.predicate = NSPredicate(format: "num == %lld", Int64(broadcastNodeNum)) + + do { + let fetchedUser = try context?.fetch(fetchBCUserRequest) as! [UserEntity] + if fetchedUser.count > 0 { + + context?.delete(fetchedUser[0]) + print("🗑️ Deleted the All - Broadcast User") + } + + } catch { + MeshLogger.log("💥 Error Deleting the All - Broadcast User") + } // MARK: Share Location Position Update Timer // Use context to pass the radio name with the timer