react-native-mytatva-rn-sdk 1.2.54 → 1.2.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/mytatvarnsdk/CgmTrackyLibModule.kt +10 -11
- package/ios/Database/GlucoseData+CoreDataProperties.h +11 -1
- package/ios/Database/GlucoseData+CoreDataProperties.m +11 -1
- package/ios/Database/KLTDatabaseHandler.m +23 -4
- package/ios/Database/MyTatva.xcdatamodeld/MyTatva.xcdatamodel/contents +12 -1
- package/ios/Support/API.swift +9 -9
- package/ios/Support/Converter/DataConverter.swift +9 -9
- package/ios/ViewControllers/ConnectToSensorViewController.swift +1 -0
- package/ios/ViewModel/FinalViewModel.swift +33 -6
- package/package.json +1 -1
|
@@ -63,7 +63,7 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
|
|
|
63
63
|
var authenticateSDKService: AuthenticateSDKService
|
|
64
64
|
private val job = Job()
|
|
65
65
|
private val scope = CoroutineScope(Dispatchers.IO + job)
|
|
66
|
-
var prefsHelper: SharedPreferencesLibraryUtil
|
|
66
|
+
var prefsHelper: SharedPreferencesLibraryUtil? = null
|
|
67
67
|
private val apiScope = CoroutineScope(Dispatchers.IO + SupervisorJob())
|
|
68
68
|
private var debounceJob: Job? = null
|
|
69
69
|
private var isBatchProcessing = false
|
|
@@ -184,18 +184,17 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
|
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
)*/
|
|
187
|
-
|
|
188
187
|
val response = Gson().fromJson(apiResponse, CgmSensorResponse::class.java)
|
|
189
188
|
val sensor = response.data?.firstOrNull()
|
|
190
189
|
|
|
190
|
+
|
|
191
191
|
if (sensor != null && !sensor.startDate.isNullOrEmpty() && !sensor.endDate.isNullOrEmpty()) {
|
|
192
192
|
val startDate = sensor.startDate
|
|
193
193
|
val endDate = sensor.endDate
|
|
194
194
|
val sensorId = sensor.sensorId
|
|
195
195
|
val currentPatientId = patientId
|
|
196
|
-
|
|
197
|
-
val
|
|
198
|
-
val lastSensorId = prefsHelper.qrInformation.sensor
|
|
196
|
+
val lastPatientId = prefsHelper?.lastPatientId
|
|
197
|
+
val lastSensorId = prefsHelper?.qrInformation?.sensor
|
|
199
198
|
|
|
200
199
|
if (lastPatientId != null && lastSensorId != null && (lastPatientId != currentPatientId || lastSensorId != sensorId)) {
|
|
201
200
|
mModel.clearAllGlucoseAndDeviceData()
|
|
@@ -216,8 +215,8 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
|
|
|
216
215
|
pocDevice.qrMessage, envType
|
|
217
216
|
)
|
|
218
217
|
} else {
|
|
219
|
-
prefsHelper
|
|
220
|
-
prefsHelper
|
|
218
|
+
prefsHelper?.lastPatientId = currentPatientId
|
|
219
|
+
prefsHelper?.qrInformation?.sensor = sensorId
|
|
221
220
|
}
|
|
222
221
|
} else {
|
|
223
222
|
postEventDataToAPI(
|
|
@@ -425,7 +424,7 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
|
|
|
425
424
|
val currentTime = System.currentTimeMillis()
|
|
426
425
|
var dataAge = System.currentTimeMillis()
|
|
427
426
|
|
|
428
|
-
val lastSyncData = prefsHelper
|
|
427
|
+
val lastSyncData = prefsHelper?.lastSyncData
|
|
429
428
|
val currentSyncTimeInMillis = lastSyncData?.timeInMillis
|
|
430
429
|
|
|
431
430
|
if (lastSyncData != null) {
|
|
@@ -606,7 +605,7 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
|
|
|
606
605
|
|
|
607
606
|
Handler(Looper.getMainLooper()).postDelayed({
|
|
608
607
|
try {
|
|
609
|
-
val lastSyncData = prefsHelper
|
|
608
|
+
val lastSyncData = prefsHelper?.lastSyncData
|
|
610
609
|
Log.d("lastSyncData: ", Gson().toJson(lastSyncData).toString())
|
|
611
610
|
|
|
612
611
|
val currentTime = System.currentTimeMillis()
|
|
@@ -720,7 +719,7 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
|
|
|
720
719
|
lastDeviceStatus = null
|
|
721
720
|
|
|
722
721
|
// Clear any cached data if needed
|
|
723
|
-
prefsHelper
|
|
722
|
+
prefsHelper?.clearQRInformation() // if you have such method
|
|
724
723
|
|
|
725
724
|
// Reset last processed sync time
|
|
726
725
|
lastProcessedSyncTimeInMillis = null
|
|
@@ -915,7 +914,7 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
|
|
|
915
914
|
it.deviceId,
|
|
916
915
|
it.glucoseId
|
|
917
916
|
)
|
|
918
|
-
prefsHelper
|
|
917
|
+
prefsHelper?.lastSyncData = syncData
|
|
919
918
|
lastProcessedSyncTimeInMillis = null
|
|
920
919
|
Log.d(
|
|
921
920
|
"Sync Metadata",
|
|
@@ -31,7 +31,17 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
31
31
|
@property (nullable, nonatomic, copy) NSNumber *trend;
|
|
32
32
|
@property (nullable, nonatomic, copy) NSNumber *userBG;
|
|
33
33
|
@property (nullable, nonatomic, retain) Device *device;
|
|
34
|
-
|
|
34
|
+
@property (nullable, nonatomic, copy) NSNumber *glucoseId;
|
|
35
|
+
@property (nullable, nonatomic, copy) NSNumber *isDelete;
|
|
36
|
+
@property (nullable, nonatomic, copy) NSNumber *year;
|
|
37
|
+
@property (nullable, nonatomic, copy) NSNumber *countdownDays;
|
|
38
|
+
@property (nullable, nonatomic, copy) NSNumber *countdownHours;
|
|
39
|
+
@property (nullable, nonatomic, copy) NSNumber *countdownMinutes;
|
|
40
|
+
@property (nullable, nonatomic, copy) NSNumber *minute;
|
|
41
|
+
@property (nullable, nonatomic, copy) NSNumber *month;
|
|
42
|
+
@property (nullable, nonatomic, copy) NSNumber *day;
|
|
43
|
+
@property (nullable, nonatomic, copy) NSNumber *hour;
|
|
44
|
+
@property (nullable, nonatomic, copy) NSNumber *error;
|
|
35
45
|
@end
|
|
36
46
|
|
|
37
47
|
NS_ASSUME_NONNULL_END
|
|
@@ -24,11 +24,21 @@
|
|
|
24
24
|
@dynamic initialBeginDate;
|
|
25
25
|
@dynamic iw;
|
|
26
26
|
@dynamic k;
|
|
27
|
+
@dynamic error;
|
|
27
28
|
@dynamic operatingCurrent;
|
|
28
29
|
@dynamic receiveDateTime;
|
|
29
30
|
@dynamic temperature;
|
|
30
31
|
@dynamic trend;
|
|
31
32
|
@dynamic userBG;
|
|
32
33
|
@dynamic device;
|
|
33
|
-
|
|
34
|
+
@dynamic year;
|
|
35
|
+
@dynamic countdownDays;
|
|
36
|
+
@dynamic countdownHours;
|
|
37
|
+
@dynamic countdownMinutes;
|
|
38
|
+
@dynamic isDelete;
|
|
39
|
+
@dynamic glucoseId;
|
|
40
|
+
@dynamic minute;
|
|
41
|
+
@dynamic month;
|
|
42
|
+
@dynamic day;
|
|
43
|
+
@dynamic hour;
|
|
34
44
|
@end
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
data.countdownHours = @(currentGlucose.countdownHours);
|
|
64
64
|
data.countdownMinutes = @(currentGlucose.countdownMinutes);
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
// [Notification_Center postNotificationName:@"ErrorStatusFromTransmitter" object:data];
|
|
67
67
|
[self.appDelegate saveContext];
|
|
68
68
|
}
|
|
69
69
|
|
|
@@ -123,6 +123,8 @@
|
|
|
123
123
|
GlucoseData *glucose = [NSEntityDescription insertNewObjectForEntityForName:@"GlucoseData" inManagedObjectContext:self.context];
|
|
124
124
|
glucose.userBG = data.userBG;
|
|
125
125
|
glucose.dataId = data.glucoseId;
|
|
126
|
+
glucose.device = data.device;
|
|
127
|
+
glucose.isDelete = 0;
|
|
126
128
|
|
|
127
129
|
glucose.receiveDateTime = [NSString stringWithFormat:@"%@-%02d-%02d %02d:%02d",data.year,[data.month intValue],[data.day intValue],[data.hour intValue],[data.minute intValue]];
|
|
128
130
|
glucose.initialBeginDate = data.device.initialBeginDate;
|
|
@@ -177,7 +179,20 @@
|
|
|
177
179
|
data.countdownHours = @(currentGlucose.countdownHours);
|
|
178
180
|
data.countdownMinutes = @(currentGlucose.countdownMinutes);
|
|
179
181
|
|
|
180
|
-
|
|
182
|
+
glucose.countdownDays = @(currentGlucose.countdownDays);
|
|
183
|
+
glucose.countdownHours = @(currentGlucose.countdownHours);
|
|
184
|
+
glucose.countdownMinutes = @(currentGlucose.countdownMinutes);
|
|
185
|
+
glucose.year = data.year;
|
|
186
|
+
glucose.glucoseId = data.glucoseId;
|
|
187
|
+
glucose.month = data.month;
|
|
188
|
+
glucose.day = data.day;
|
|
189
|
+
glucose.minute = data.minute;
|
|
190
|
+
glucose.hour = data.hour;
|
|
191
|
+
glucose.error = data.error;
|
|
192
|
+
|
|
193
|
+
// [Notification_Center postNotificationName:@"ErrorStatusFromTransmitter" object: glucose];
|
|
194
|
+
[Notification_Center postNotificationName:@"CheckErrorStatusFromLastBatchData" object: glucose];
|
|
195
|
+
|
|
181
196
|
[self.appDelegate saveContext];
|
|
182
197
|
return glucose;
|
|
183
198
|
}
|
|
@@ -216,7 +231,7 @@
|
|
|
216
231
|
// 🖨️ Add single-line logging for each GlucoseData entry
|
|
217
232
|
NSLog(@"==== GlucoseData (Fetched %lu records) for Device: %@ ====", (unsigned long)resendDatas.count, currentDevice.identifier);
|
|
218
233
|
for (GlucoseData *g in resendDatas) {
|
|
219
|
-
NSLog(@"[ID:%@] Date:%@ | glu:%@ mmol/L | gluADC:%@ mg/dL | BG:%@ | T:%@°C | Ib:%@ | Iw:%@ | Trend:%@ | Err:%@ | CalStatus:%@",
|
|
234
|
+
NSLog(@"[ID:%@] Date:%@ | glu:%@ mmol/L | gluADC:%@ mg/dL | BG:%@ | T:%@°C | Ib:%@ | Iw:%@ | Trend:%@ | Err:%@ | CalStatus:%@ | countdownMinut:%@ | countdownHours:%@ | countdownDays:%@" ,
|
|
220
235
|
g.dataId,
|
|
221
236
|
g.receiveDateTime,
|
|
222
237
|
g.glu,
|
|
@@ -227,7 +242,11 @@
|
|
|
227
242
|
g.operatingCurrent,
|
|
228
243
|
g.trend,
|
|
229
244
|
g.errorCode,
|
|
230
|
-
g.calibrationStatus
|
|
245
|
+
g.calibrationStatus,
|
|
246
|
+
g.countdownMinutes,
|
|
247
|
+
g.countdownHours,
|
|
248
|
+
g.countdownDays
|
|
249
|
+
|
|
231
250
|
);
|
|
232
251
|
}
|
|
233
252
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
2
|
-
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="
|
|
2
|
+
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="23788.4" systemVersion="24F74" minimumToolsVersion="Automatic" sourceLanguage="Swift" usedWithSwiftData="YES" userDefinedModelVersionIdentifier="">
|
|
3
3
|
<entity name="Advertise" representedClassName="Advertise" syncable="YES">
|
|
4
4
|
<attribute name="advertiseDateTime" optional="YES" attributeType="String"/>
|
|
5
5
|
<attribute name="isConnectable" optional="YES" attributeType="Boolean" usesScalarValueType="NO"/>
|
|
@@ -24,18 +24,29 @@
|
|
|
24
24
|
<entity name="GlucoseData" representedClassName="GlucoseData" syncable="YES">
|
|
25
25
|
<attribute name="blankCurrent" optional="YES" attributeType="Double" defaultValueString="0" usesScalarValueType="NO"/>
|
|
26
26
|
<attribute name="calibrationStatus" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="NO"/>
|
|
27
|
+
<attribute name="countdownDays" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
|
|
28
|
+
<attribute name="countdownHours" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
|
|
29
|
+
<attribute name="countdownMinutes" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
|
|
27
30
|
<attribute name="dataId" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="NO"/>
|
|
31
|
+
<attribute name="day" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES"/>
|
|
32
|
+
<attribute name="error" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
|
|
28
33
|
<attribute name="errorCode" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="NO"/>
|
|
29
34
|
<attribute name="glu" optional="YES" attributeType="Double" defaultValueString="0.0" usesScalarValueType="NO"/>
|
|
30
35
|
<attribute name="gluADC" optional="YES" attributeType="Double" defaultValueString="0.0" usesScalarValueType="NO"/>
|
|
36
|
+
<attribute name="glucoseId" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
|
|
37
|
+
<attribute name="hour" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES"/>
|
|
31
38
|
<attribute name="initialBeginDate" optional="YES" attributeType="String"/>
|
|
39
|
+
<attribute name="isDelete" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
|
|
32
40
|
<attribute name="iw" optional="YES" attributeType="Double" defaultValueString="0.0" usesScalarValueType="NO"/>
|
|
33
41
|
<attribute name="k" optional="YES" attributeType="Double" defaultValueString="0.0" usesScalarValueType="NO"/>
|
|
42
|
+
<attribute name="minute" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES"/>
|
|
43
|
+
<attribute name="month" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES"/>
|
|
34
44
|
<attribute name="operatingCurrent" optional="YES" attributeType="Double" defaultValueString="0.0" usesScalarValueType="NO"/>
|
|
35
45
|
<attribute name="receiveDateTime" optional="YES" attributeType="String"/>
|
|
36
46
|
<attribute name="temperature" optional="YES" attributeType="Double" defaultValueString="0.0" usesScalarValueType="NO"/>
|
|
37
47
|
<attribute name="trend" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="NO"/>
|
|
38
48
|
<attribute name="userBG" optional="YES" attributeType="Double" defaultValueString="0.0" usesScalarValueType="NO"/>
|
|
49
|
+
<attribute name="year" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="YES"/>
|
|
39
50
|
<relationship name="device" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Device"/>
|
|
40
51
|
</entity>
|
|
41
52
|
<entity name="ReceiveDataInfo" representedClassName="ReceiveData" syncable="YES">
|
package/ios/Support/API.swift
CHANGED
|
@@ -42,23 +42,23 @@ let envType = UserDefaults.standard.string(forKey: "envType") ?? "uat"
|
|
|
42
42
|
|
|
43
43
|
struct CGMLog: Codable {
|
|
44
44
|
let timeInMillis: Double
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
let countdownMinutes: Int
|
|
46
|
+
let countdownDays: Int
|
|
47
47
|
let hypoglycemiaEarlyWarnMinutes: Int
|
|
48
48
|
let showGlucoseMG: Int
|
|
49
|
-
|
|
49
|
+
let glucoseId: Int
|
|
50
50
|
let name: String
|
|
51
51
|
let bytes: [Int]
|
|
52
52
|
let showGlucose: Float
|
|
53
53
|
let Ib: Float
|
|
54
54
|
let Iw: Float
|
|
55
|
-
|
|
55
|
+
let countdownHours: Int
|
|
56
56
|
let T: Float
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
let year: Int32
|
|
58
|
+
let month: Int32
|
|
59
|
+
let day: Int32
|
|
60
|
+
let hour: Int32
|
|
61
|
+
let minute: Int32
|
|
62
62
|
let trendObject: TrendObject
|
|
63
63
|
let glucoseStatusObject: GlucoseStatusObject
|
|
64
64
|
let errorObject: ErrorObject
|
|
@@ -10,23 +10,23 @@ import Foundation
|
|
|
10
10
|
func ReceiveDataToLog(data: GlucoseData) -> CGMLog {
|
|
11
11
|
let cgmLogs = CGMLog(
|
|
12
12
|
timeInMillis: Double(Date().timeIntervalSince1970 * 1000),
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
countdownMinutes: (data.countdownMinutes as? Int) ?? 0,
|
|
14
|
+
countdownDays: (data.countdownDays as? Int) ?? 0,
|
|
15
15
|
hypoglycemiaEarlyWarnMinutes: 0, // still missing, you can map if available
|
|
16
16
|
showGlucoseMG: (data.gluADC as? Int) ?? 0,
|
|
17
|
-
|
|
17
|
+
glucoseId: Int(truncating: data.glucoseId ?? 0),
|
|
18
18
|
name: data.device?.advertise?.localName ?? "",
|
|
19
19
|
bytes: [], // still missing: need raw data source
|
|
20
20
|
showGlucose: (data.glu as? Float) ?? 0,
|
|
21
21
|
Ib: (data.blankCurrent as? Float) ?? 0,
|
|
22
22
|
Iw: (data.operatingCurrent as? Float) ?? 0,
|
|
23
|
-
|
|
23
|
+
countdownHours: (data.countdownHours as? Int) ?? 0,
|
|
24
24
|
T: (data.temperature as? Float) ?? 0.0,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
year: (data.year as? Int32) ?? 0,
|
|
26
|
+
month: (data.month as? Int32) ?? 0,
|
|
27
|
+
day: (data.day as? Int32) ?? 0,
|
|
28
|
+
hour: (data.hour as? Int32) ?? 0,
|
|
29
|
+
minute: (data.minute as? Int32) ?? 0,
|
|
30
30
|
|
|
31
31
|
trendObject: TrendObject(
|
|
32
32
|
trendId: (data.trend as? Int) ?? 0,
|
|
@@ -214,6 +214,7 @@ class ConnectToSensorViewController: UIViewController {
|
|
|
214
214
|
|
|
215
215
|
func connectSensor(value: String, controller: ConnectToSensorViewController) {
|
|
216
216
|
UserDefaults.standard.set(value, forKey: "sensorId")
|
|
217
|
+
|
|
217
218
|
var isMatch = false
|
|
218
219
|
|
|
219
220
|
var regex = #"^[A-Z0-9][0-9](0[1-9]|[1-9][0-9]|[A-Z][1-9A-Z])(00[1-9]|0[1-9][0-9]|[1-9][0-9][0-9]){2}[0-9]{4,5}[0-9A-Z]{3}$"#
|
|
@@ -123,6 +123,8 @@ import Foundation
|
|
|
123
123
|
if device.connectedDateTime == nil && device.disconnectedDateTime == nil {
|
|
124
124
|
viewModel.manager.startScan()
|
|
125
125
|
viewModel.debouncer.update(with: .transmitterDisconnect)
|
|
126
|
+
} else {
|
|
127
|
+
|
|
126
128
|
}
|
|
127
129
|
} else {
|
|
128
130
|
print("⚠️ currentDevice is nil")
|
|
@@ -311,11 +313,13 @@ class FinalViewModel: NSObject {
|
|
|
311
313
|
|
|
312
314
|
NotificationCenter.default.addObserver(self, selector: #selector(bluetoothEnable(_:)), name: NSNotification.Name("BluetoothEnable"), object: nil)
|
|
313
315
|
|
|
314
|
-
|
|
316
|
+
// NotificationCenter.default.addObserver(self, selector: #selector(errorStatusFromTransmitter(_:)), name: NSNotification.Name("ErrorStatusFromTransmitter"), object: nil)
|
|
315
317
|
|
|
316
318
|
NotificationCenter.default.addObserver(self, selector: #selector(handleLatestReceiveData(_:)), name: NSNotification.Name(KLTAlertCurrentInInitialNotify), object: nil)
|
|
317
319
|
|
|
318
320
|
NotificationCenter.default.addObserver(self, selector: #selector(updateData(_:)), name: NSNotification.Name(KLTUpdateDataNotify), object: nil)
|
|
321
|
+
|
|
322
|
+
NotificationCenter.default.addObserver(self, selector: #selector(checkErrorStatusFromLastBatchData(_:)), name: NSNotification.Name("CheckErrorStatusFromLastBatchData"), object: nil)
|
|
319
323
|
}
|
|
320
324
|
|
|
321
325
|
func removeAllObservers() {
|
|
@@ -323,11 +327,13 @@ class FinalViewModel: NSObject {
|
|
|
323
327
|
|
|
324
328
|
NotificationCenter.default.removeObserver(self, name: NSNotification.Name("BluetoothEnable"), object: nil)
|
|
325
329
|
|
|
326
|
-
|
|
330
|
+
// NotificationCenter.default.removeObserver(self, name: NSNotification.Name("ErrorStatusFromTransmitter"), object: nil)
|
|
327
331
|
|
|
328
332
|
NotificationCenter.default.removeObserver(self, name: NSNotification.Name(KLTAlertCurrentInInitialNotify), object: nil)
|
|
329
333
|
|
|
330
334
|
NotificationCenter.default.removeObserver(self, name: NSNotification.Name(KLTUpdateDataNotify), object: nil)
|
|
335
|
+
|
|
336
|
+
NotificationCenter.default.removeObserver(self, name: NSNotification.Name("CheckErrorStatusFromLastBatchData"), object: nil)
|
|
331
337
|
}
|
|
332
338
|
|
|
333
339
|
|
|
@@ -342,7 +348,9 @@ class FinalViewModel: NSObject {
|
|
|
342
348
|
|
|
343
349
|
private func uploadBatch(batches: [[GlucoseData]], index: Int) {
|
|
344
350
|
guard index < batches.count else {
|
|
345
|
-
|
|
351
|
+
if index != 0 {
|
|
352
|
+
NotificationCenter.default.post(name: Notification.Name("CheckErrorStatusFromLastBatchData"), object: batches.last?.last)
|
|
353
|
+
}
|
|
346
354
|
print("✅ All batches uploaded")
|
|
347
355
|
return
|
|
348
356
|
}
|
|
@@ -404,9 +412,8 @@ class FinalViewModel: NSObject {
|
|
|
404
412
|
self.uploadData(data: arrayFromInitial)
|
|
405
413
|
}
|
|
406
414
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
guard let receiveData = notification.object as? ReceiveData else { return }
|
|
415
|
+
@objc func checkErrorStatusFromLastBatchData(_ notification: Notification) {
|
|
416
|
+
guard let receiveData = notification.object as? GlucoseData else { return }
|
|
410
417
|
|
|
411
418
|
let errorCode = ErrorCode(rawValue: Int32(receiveData.error?.intValue ?? 0))
|
|
412
419
|
if errorCode == ErrorCode.ERROR_CODE_FLOODING_WATER {
|
|
@@ -425,6 +432,26 @@ class FinalViewModel: NSObject {
|
|
|
425
432
|
}
|
|
426
433
|
}
|
|
427
434
|
|
|
435
|
+
// @objc func errorStatusFromTransmitter(_ notification: Notification) {
|
|
436
|
+
// guard let receiveData = notification.object as? ReceiveData else { return }
|
|
437
|
+
//
|
|
438
|
+
// let errorCode = ErrorCode(rawValue: Int32(receiveData.error?.intValue ?? 0))
|
|
439
|
+
// if errorCode == ErrorCode.ERROR_CODE_FLOODING_WATER {
|
|
440
|
+
// debouncer.update(with: CGMConnectionStatus.moistureDetect)
|
|
441
|
+
// //API.shared.sendStatus(status: .moistureDetect)
|
|
442
|
+
// } else if errorCode == ErrorCode.ERROR_CODE_CURRENT_SMALL || errorCode == ErrorCode.ERROR_CODE_NOISE || errorCode == ErrorCode.ERROR_CODE_SENSITIVITY_ATTENUATION {
|
|
443
|
+
// debouncer.update(with: CGMConnectionStatus.weakSignal)
|
|
444
|
+
// //API.shared.sendStatus(status: .weakSignal)
|
|
445
|
+
// } else if errorCode != ErrorCode.ERROR_CODE_NONE {
|
|
446
|
+
// debouncer.update(with: CGMConnectionStatus.errorCommon)
|
|
447
|
+
// //API.shared.sendStatus(status: .errorCommon)
|
|
448
|
+
// }
|
|
449
|
+
// if receiveData.countdownDays == 0 && receiveData.countdownHours == 0 && receiveData.countdownMinutes == 0 {
|
|
450
|
+
// debouncer.update(with: CGMConnectionStatus.expired)
|
|
451
|
+
// //API.shared.sendStatus(status: .expired)
|
|
452
|
+
// }
|
|
453
|
+
// }
|
|
454
|
+
|
|
428
455
|
@objc func handleLatestReceiveData(_ notification: Notification) {
|
|
429
456
|
print("====> handleLatestReceiveData")
|
|
430
457
|
guard let receiveData = notification.object as? ReceiveData else { return }
|