From c8c79abb9e3d678a6f6d1744ac3ea0f60785f83c Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Mon, 7 Jul 2025 10:50:30 -0500 Subject: [PATCH] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- Meshtastic/Helpers/BLEManager.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index 96268569..b5d12ae9 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -1186,7 +1186,10 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate success = false } else { - let fromUserNum: Int64 = self.connectedPeripheral?.num ?? 0 + guard let fromUserNum = self.connectedPeripheral?.num else { + Logger.mesh.error("🚫 Connected peripheral user number is nil, cannot send message.") + return false + } let messageUsers = UserEntity.fetchRequest() messageUsers.predicate = NSPredicate(format: "num IN %@", [fromUserNum, Int64(toUserNum)])