Delete broadcast user

This commit is contained in:
Garth Vander Houwen 2022-11-08 13:01:43 -08:00
parent cdc4288278
commit e798cd3e7a

View file

@ -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<NSFetchRequestResult> = 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