Skip to content

Unnecessary alarms1 #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions LibreTransmitter/LibreTransmitterManager+Transmitters.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions LibreTransmitter/LibreTransmitterManagerV3.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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? {
Expand Down
26 changes: 1 addition & 25 deletions LibreTransmitter/NotificationHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down Expand Up @@ -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 {
Expand Down