From 506772bf619940f222315133ef8f4d1e9fa469c4 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Mon, 23 Sep 2024 16:38:18 -0700 Subject: [PATCH] Client notifications --- Meshtastic/Helpers/BLEManager.swift | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index e62093e9..894401c7 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -653,7 +653,19 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate ) mqttManager.mqttClientProxy?.publish(message) } else if decodedInfo.payloadVariant == FromRadio.OneOf_PayloadVariant.clientNotification(decodedInfo.clientNotification) { - Logger.data.error("⚠️ Client Notification") + let manager = LocalNotificationManager() + manager.notifications = [ + Notification( + id: UUID().uuidString, + title: "Firmware Notification", + subtitle: "\(decodedInfo.clientNotification.level)".capitalized, + content: decodedInfo.clientNotification.message, + target: "settings", + path: "meshtastic:///settings/debugLogs" + ) + ] + manager.schedule() + Logger.data.error("⚠️ Client Notification \((try? decodedInfo.clientNotification.jsonString()) ?? "JSON Decode Failure")") } switch decodedInfo.packet.decoded.portnum { @@ -944,8 +956,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate // Use a RunLoop to prevent the timer from running on the main UI thread if UserDefaults.provideLocation { let interval = UserDefaults.provideLocationInterval >= 10 ? UserDefaults.provideLocationInterval : 30 - positionTimer = Timer.scheduledTimer(timeInterval: TimeInterval(3.0), target: self, selector: #selector(positionTimerFired), userInfo: context, repeats: true) - positionTimer = Timer.scheduledTimer(timeInterval: TimeInterval(3.0), target: self, selector: #selector(positionTimerFired), userInfo: context, repeats: true) + positionTimer = Timer.scheduledTimer(timeInterval: TimeInterval(interval), target: self, selector: #selector(positionTimerFired), userInfo: context, repeats: true) if positionTimer != nil { RunLoop.current.add(positionTimer!, forMode: .common) }