Просмотр исходного кода

CGM BT address shown in xdrip UI

The CGM Bluetooth address is a unique. xDrip4iOS writes the address to shared user defaults as soon as it connects to a CGM.
FAX reads this address and uses the device as heartbeat.

This commit makes the address visible in the UI and can be compared to the address visible in xDrip4iOS

(cherry picked from commit 82de85cf6e7138db09924308050cb558ee514feb)
Johan Degraeve 3 лет назад
Родитель
Сommit
6baadd9679

+ 2 - 0
FreeAPS/Sources/Modules/CGM/CGMStateModel.swift

@@ -13,12 +13,14 @@ extension CGM {
         @Published var calendarIDs: [String] = []
         @Published var currentCalendarID: String = ""
         @Persisted(key: "CalendarManager.currentCalendarID") var storedCalendarID: String? = nil
+        @Published var cgmTransmitterDeviceAddress: String? = nil
 
         override func subscribe() {
             cgm = settingsManager.settings.cgm
             transmitterID = UserDefaults.standard.dexcomTransmitterID ?? ""
             currentCalendarID = storedCalendarID ?? ""
             calendarIDs = calendarManager.calendarIDs()
+            cgmTransmitterDeviceAddress = UserDefaults.standard.cgmTransmitterDeviceAddress
 
             subscribeSetting(\.useCalendar, on: $createCalendarEvents) { createCalendarEvents = $0 }
             subscribeSetting(\.uploadGlucose, on: $uploadGlucose) { uploadGlucose = $0 }

+ 13 - 0
FreeAPS/Sources/Modules/CGM/View/CGMRootView.swift

@@ -45,6 +45,19 @@ extension CGM {
                     Text("Calibrations").navigationLink(to: .calibrations, from: self)
                 }
 
+                if state.cgm == .xdrip {
+                    Section(header: Text("Heartbeat")) {
+                        VStack(alignment: .leading) {
+                            if let cgmTransmitterDeviceAddress = state.cgmTransmitterDeviceAddress {
+                                Text("CGM address :")
+                                Text(cgmTransmitterDeviceAddress)
+                            } else {
+                                Text("CGM is not used as heartbeat.")
+                            }
+                        }
+                    }
+                }
+
                 Section(header: Text("Calendar")) {
                     Toggle("Create events in calendar", isOn: $state.createCalendarEvents)
                     if state.calendarIDs.isNotEmpty {