From fd3addc5e3f6b737b4147fb5e4d5d9482810348c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Inge=20Berg?= Date: Fri, 7 Jul 2023 13:25:56 +0200 Subject: [PATCH 1/2] Removed bluetooth-off alarm as it is already covered by Loop itself, removed restored state notification --- ...LibreTransmitterManager+Transmitters.swift | 9 +++---- .../LibreTransmitterManagerV3.swift | 4 +-- LibreTransmitter/NotificationHelper.swift | 26 +------------------ .../NotificationHelperOverride.swift | 2 +- 4 files changed, 7 insertions(+), 34 deletions(-) diff --git a/LibreTransmitter/LibreTransmitterManager+Transmitters.swift b/LibreTransmitter/LibreTransmitterManager+Transmitters.swift index b8ea2ed..d13e62f 100644 --- a/LibreTransmitter/LibreTransmitterManager+Transmitters.swift +++ b/LibreTransmitter/LibreTransmitterManager+Transmitters.swift @@ -216,14 +216,11 @@ extension LibreTransmitterManagerV3 { self.transmitterInfoObservable.connectionState = self.proxy?.connectionStateString ?? "n/a" self.transmitterInfoObservable.transmitterType = self.proxy?.shortTransmitterName ?? "Unknown" } - switch state { - case .Connected: + + if case .Connected = state { lastConnected = Date() - case .powerOff: - NotificationHelper.sendBluetoothPowerOffNotification() - default: - break } + return } diff --git a/LibreTransmitter/LibreTransmitterManagerV3.swift b/LibreTransmitter/LibreTransmitterManagerV3.swift index de72574..4160932 100644 --- a/LibreTransmitter/LibreTransmitterManagerV3.swift +++ b/LibreTransmitter/LibreTransmitterManagerV3.swift @@ -53,8 +53,8 @@ open class LibreTransmitterManagerV3: CGMManager, LibreTransmitterDelegate { public func libreManagerDidRestoreState(found peripherals: [CBPeripheral], connected to: CBPeripheral?) { let devicename = to?.name ?? "no device" let id = to?.identifier.uuidString ?? "null" - let msg = "Bluetooth State restored (Loop restarted?). Found \(peripherals.count) peripherals, and connected to \(devicename) with identifier \(id)" - NotificationHelper.sendRestoredStateNotification(msg: msg) + + logger.debug("Bluetooth State restored (Loop restarted?). Found \(peripherals.count) peripherals, and connected to \(devicename) with identifier \(id)") } public var batteryLevel: Double? { diff --git a/LibreTransmitter/NotificationHelper.swift b/LibreTransmitter/NotificationHelper.swift index 71389e5..95f74fe 100644 --- a/LibreTransmitter/NotificationHelper.swift +++ b/LibreTransmitter/NotificationHelper.swift @@ -26,10 +26,8 @@ public enum NotificationHelper { case lowBattery = "com.loopkit.libremiaomiao.lowbattery-notification" case sensorExpire = "com.loopkit.libremiaomiao.SensorExpire-notification" case noBridgeSelected = "com.loopkit.libremiaomiao.noBridgeSelected-notification" - case bluetoothPoweredOff = "com.loopkit.libremiaomiao.bluetoothPoweredOff-notification" case invalidChecksum = "com.loopkit.libremiaomiao.invalidChecksum-notification" case calibrationOngoing = "com.loopkit.libremiaomiao.calibration-notification" - case restoredState = "com.loopkit.libremiaomiao.state-notification" case libre2directFinishedSetup = "com.loopkit.libremiaomiao.libre2direct-notification" } @@ -307,29 +305,7 @@ public extension NotificationHelper { // MARK: - Notification sendout public extension NotificationHelper { - static func sendRestoredStateNotification(msg: String) { - ensureCanSendNotification { - logger.debug("\(#function) sending RestoredStateNotification") - - let content = UNMutableNotificationContent() - content.title = "State was restored" - content.body = msg - - addRequest(identifier: .restoredState, content: content, deleteOld: true ) - } - } - - static func sendBluetoothPowerOffNotification() { - ensureCanSendNotification { - logger.debug("\(#function) sending BluetoothPowerOffNotification") - - let content = UNMutableNotificationContent() - content.title = "Bluetooth Power Off" - content.body = "Please turn on Bluetooth" - - addRequest(identifier: .bluetoothPoweredOff, content: content) - } - } + static func sendNoTransmitterSelectedNotification() { ensureCanSendNotification { diff --git a/LibreTransmitter/NotificationHelperOverride.swift b/LibreTransmitter/NotificationHelperOverride.swift index 80daa2c..74d8b4c 100644 --- a/LibreTransmitter/NotificationHelperOverride.swift +++ b/LibreTransmitter/NotificationHelperOverride.swift @@ -10,6 +10,6 @@ import Foundation enum NotificationHelperOverride { static var shouldOverrideRequestCriticalPermissions : Bool { // if you want LibreTransmitter to try upgrading to critical notifications, change this - false + true } } From ba2d633cfa992c6c5a97196e91fa2d6191e61bf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Inge=20Berg?= Date: Fri, 7 Jul 2023 13:30:30 +0200 Subject: [PATCH 2/2] reset LibreTransmitter/NotificationHelperOverride.swift --- LibreTransmitter/NotificationHelperOverride.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LibreTransmitter/NotificationHelperOverride.swift b/LibreTransmitter/NotificationHelperOverride.swift index 74d8b4c..80daa2c 100644 --- a/LibreTransmitter/NotificationHelperOverride.swift +++ b/LibreTransmitter/NotificationHelperOverride.swift @@ -10,6 +10,6 @@ import Foundation enum NotificationHelperOverride { static var shouldOverrideRequestCriticalPermissions : Bool { // if you want LibreTransmitter to try upgrading to critical notifications, change this - true + false } }