react-native-mytatva-rn-sdk 1.2.25 → 1.2.26
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.
|
@@ -121,64 +121,58 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
|
|
|
121
121
|
try {
|
|
122
122
|
userToken = token
|
|
123
123
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
124
|
+
authenticateSDKService.getCGMData(
|
|
125
|
+
environment = if ("uat".uppercase() == "PROD") TATVA_ENVIRONMENT.PROD else TATVA_ENVIRONMENT.STAGE,
|
|
126
|
+
token = userToken,
|
|
127
|
+
responseListener = object : AuthenticateSDKService.ResponseListener {
|
|
128
|
+
override fun onResponseSuccess(response: String) {
|
|
129
129
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
token = userToken,
|
|
133
|
-
responseListener = object : AuthenticateSDKService.ResponseListener {
|
|
134
|
-
override fun onResponseSuccess(response: String) {
|
|
130
|
+
val response = Gson().fromJson(response, CgmSensorResponse::class.java)
|
|
131
|
+
val sensor = response.data?.firstOrNull()
|
|
135
132
|
|
|
136
|
-
|
|
137
|
-
val
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
if (isCurrentDateInRange(startDate, endDate)) {
|
|
148
|
-
|
|
149
|
-
println("Current date is in range")
|
|
150
|
-
|
|
151
|
-
val pocDevice =
|
|
152
|
-
RepositoryDevice.getInstance(BApplication.getContext()).latestDeviceIoThread
|
|
153
|
-
if (pocDevice != null) {
|
|
154
|
-
if (pocDevice.isUnBind) {
|
|
155
|
-
postEventDataToAPI(
|
|
156
|
-
pocDevice,
|
|
157
|
-
DeviceStatus.TRANSMITTER_DISCONNECT.id,
|
|
158
|
-
pocDevice.qrMessage
|
|
159
|
-
)
|
|
160
|
-
} else {
|
|
161
|
-
postEventDataToAPI(
|
|
162
|
-
pocDevice,
|
|
163
|
-
DeviceStatus.TRANSMITTER_DISCONNECT.id,
|
|
164
|
-
sensorId
|
|
165
|
-
)
|
|
166
|
-
}
|
|
167
|
-
}
|
|
133
|
+
if (sensor != null && !sensor.startDate.isNullOrEmpty() && !sensor.endDate.isNullOrEmpty()) {
|
|
134
|
+
val startDate = sensor.startDate
|
|
135
|
+
val endDate = sensor.endDate
|
|
136
|
+
val sensorId = sensor.sensorId
|
|
137
|
+
|
|
138
|
+
println("Start Date: $startDate")
|
|
139
|
+
println("End Date: $endDate")
|
|
140
|
+
|
|
141
|
+
if (isCurrentDateInRange(startDate, endDate)) {
|
|
142
|
+
|
|
143
|
+
println("Current date is in range")
|
|
168
144
|
|
|
145
|
+
val pocDevice =
|
|
146
|
+
RepositoryDevice.getInstance(BApplication.getContext()).latestDeviceIoThread
|
|
147
|
+
if (pocDevice != null) {
|
|
148
|
+
if (pocDevice.isUnBind) {
|
|
149
|
+
postEventDataToAPI(
|
|
150
|
+
pocDevice,
|
|
151
|
+
DeviceStatus.TRANSMITTER_DISCONNECT.id,
|
|
152
|
+
pocDevice.qrMessage
|
|
153
|
+
)
|
|
154
|
+
}
|
|
169
155
|
} else {
|
|
170
|
-
|
|
156
|
+
postEventDataToAPI(
|
|
157
|
+
pocDevice,
|
|
158
|
+
DeviceStatus.TRANSMITTER_DISCONNECT.id,
|
|
159
|
+
sensorId
|
|
160
|
+
)
|
|
171
161
|
}
|
|
162
|
+
|
|
172
163
|
} else {
|
|
173
|
-
println("
|
|
164
|
+
println("Current date is out of range")
|
|
174
165
|
}
|
|
166
|
+
} else {
|
|
167
|
+
println("Start or End date not available")
|
|
175
168
|
}
|
|
169
|
+
}
|
|
176
170
|
|
|
177
|
-
|
|
178
|
-
}
|
|
171
|
+
override fun onResponseFail() {
|
|
179
172
|
}
|
|
180
|
-
|
|
181
|
-
|
|
173
|
+
}
|
|
174
|
+
)
|
|
175
|
+
|
|
182
176
|
} catch (e: Exception) {
|
|
183
177
|
Log.e("observeTransmitterUnbindStatus", "observeTransmitterUnbindStatus: ${e.message}")
|
|
184
178
|
}
|
|
@@ -130,6 +130,20 @@
|
|
|
130
130
|
glucose.temperature = data.temperature;
|
|
131
131
|
float algo_k = [[User_Defaults objectForKey:@"algo_k"] floatValue];
|
|
132
132
|
float algo_r = [[User_Defaults objectForKey:@"algo_r"] floatValue];
|
|
133
|
+
|
|
134
|
+
NSString *dateString = data.receiveDateTime;
|
|
135
|
+
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
|
|
136
|
+
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm"];
|
|
137
|
+
[dateFormatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
|
|
138
|
+
NSDate *date = [dateFormatter dateFromString:dateString];
|
|
139
|
+
if (date) {
|
|
140
|
+
NSTimeInterval timeMillis = [date timeIntervalSince1970] * 1000; // Convert to milliseconds
|
|
141
|
+
NSLog(@"Milliseconds since epoch: %.0f", timeMillis);
|
|
142
|
+
NSNumber *numberFromTimeMillis = [NSNumber numberWithDouble:timeMillis]; // Wrap the NSTimeInterval into an NSNumber
|
|
143
|
+
} else {
|
|
144
|
+
NSLog(@"Invalid date string format");
|
|
145
|
+
}
|
|
146
|
+
|
|
133
147
|
|
|
134
148
|
LatestData *d = nil;
|
|
135
149
|
NSString *localName = data.device.advertise.localName;
|
|
@@ -137,13 +151,24 @@
|
|
|
137
151
|
if (userBG > 0) {
|
|
138
152
|
d = [[LatestData alloc] initWithParameters:glucose.dataId.intValue andIw:[glucose.operatingCurrent floatValue] andIb:[glucose.blankCurrent floatValue] andT:[glucose.temperature floatValue] andK0:algo_k andR:algo_r andDay:[data.day intValue] andHour:[data.hour intValue] andMinute:[data.minute intValue] andNewBgToGlucoseId:glucose.dataId.intValue andNewBgValue:userBG andName:localName];
|
|
139
153
|
} else {
|
|
140
|
-
d = [[LatestData alloc] initWithParameters:([glucose.dataId intValue]) andIw:[glucose.operatingCurrent floatValue] andIb:[glucose.blankCurrent floatValue] andT:[glucose.temperature floatValue] andK0:algo_k andR:algo_r andDay:[data.day intValue] andHour:[data.hour intValue] andMinute:[data.minute intValue] andName:localName];
|
|
154
|
+
d = [[LatestData alloc] initWithParameters:([glucose.dataId intValue]) andIw:[glucose.operatingCurrent floatValue] andIb:[glucose.blankCurrent floatValue] andT:[glucose.temperature floatValue] andK0:algo_k andR:algo_r andDay:[data.day intValue] andHour:[data.hour intValue] andMinute:[data.minute intValue] andName:localName ];
|
|
141
155
|
}
|
|
142
156
|
d.algorithm = AlgorithmType_CT4;
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
NSLog( @"sensorInfosensorInf %f", d.R);
|
|
161
|
+
|
|
162
|
+
NSLog( @"sensorInfosensorInfosensorInfosensorInfo %@", d.sensorInfo);
|
|
163
|
+
|
|
164
|
+
NSLog(@"算法入参dataId=%@, operatingCurrent=%@, blankCurrent=%@, temperature=%@, algo_k=%@, algo_r=%@, day=%@, hour=%@, minute=%@, localName=%@, algorithm=%@, year=%@, milles=%@", @(d.glucoseId), @(d.Iw), @(d.Ib), @(d.T), @(d.K0), @(d.R), @(d.day), @(d.hour), @(d.minute), d.name, @(d.algorithm), @(d.year), @(d.timeMillis));
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
143
168
|
|
|
144
|
-
KLTLog(@"算法入参dataId=%@, operatingCurrent=%@, blankCurrent=%@, temperature=%@, algo_k=%@, algo_r=%@, day=%@, hour=%@, minute=%@, localName=%@, newBgValue=%@, algorithm=%@", @(d.glucoseId), @(d.Iw), @(d.Ib), @(d.T), @(d.K0), @(d.R), @(d.day), @(d.hour), @(d.minute), d.name, @(d.newBgValue), @(d.algorithm));
|
|
145
169
|
CurrentGlucose *currentGlucose = [AlgorithmTools algorithmLatestGlucose:d];
|
|
146
170
|
|
|
171
|
+
|
|
147
172
|
if (currentGlucose.errorCode == ERROR_CODE_ALGORITHM_DATA) {
|
|
148
173
|
[self reloadQueryHistoryData];
|
|
149
174
|
|
|
@@ -153,11 +178,35 @@
|
|
|
153
178
|
d = [[LatestData alloc] initWithParameters:([glucose.dataId intValue]) andIw:[glucose.operatingCurrent floatValue] andIb:[glucose.blankCurrent floatValue] andT:[glucose.temperature floatValue] andK0:algo_k andR:algo_r andDay:[data.day intValue] andHour:[data.hour intValue] andMinute:[data.minute intValue] andName:localName];
|
|
154
179
|
}
|
|
155
180
|
d.algorithm = AlgorithmType_CT4;
|
|
181
|
+
|
|
156
182
|
|
|
157
|
-
|
|
183
|
+
NSLog(@"ERROR_CODE_ALGORITHM_DATA:dataId=%@, operatingCurrent=%@, blankCurrent=%@, temperature=%@, algo_k=%@, algo_r=%@, day=%@, hour=%@, minute=%@, localName=%@, newBgValue=%@, algorithm=%@", @(d.glucoseId), @(d.Iw), @(d.Ib), @(d.T), @(d.K0), @(d.R), @(d.day), @(d.hour), @(d.minute), d.name, @(d.newBgValue), @(d.algorithm));
|
|
158
184
|
currentGlucose = [AlgorithmTools algorithmLatestGlucose:d];
|
|
185
|
+
|
|
186
|
+
NSString *logString = [NSString stringWithFormat:@"glucoseId=%@, Iw=%@, Ib=%@, T=%@,dayCount=%@, hour=%@, minute=%@, milles=%@, GluMG=%@,BGCount=%@, BGICount=%@, errorCode=%@ trend=%@ calibrationStatus=%@, countdownDays=%@, countdownHours=%@, countdownMinutes=%@ ",
|
|
187
|
+
@(d.glucoseId),
|
|
188
|
+
@(d.Iw),
|
|
189
|
+
@(d.Ib),
|
|
190
|
+
@(d.T),
|
|
191
|
+
@(d.day),
|
|
192
|
+
@(d.hour),
|
|
193
|
+
@(d.minute),
|
|
194
|
+
@(d.timeMillis),
|
|
195
|
+
@(currentGlucose.GluMG),
|
|
196
|
+
@(currentGlucose.BGCount),
|
|
197
|
+
@(currentGlucose.BGICount),
|
|
198
|
+
@(currentGlucose.errorCode),
|
|
199
|
+
@(currentGlucose.trend),
|
|
200
|
+
@(currentGlucose.BGMG),
|
|
201
|
+
@(currentGlucose.countdownDays),
|
|
202
|
+
@(currentGlucose.countdownHours),
|
|
203
|
+
@(currentGlucose.countdownHours)
|
|
204
|
+
|
|
205
|
+
];
|
|
206
|
+
|
|
159
207
|
}
|
|
160
208
|
|
|
209
|
+
|
|
161
210
|
glucose.errorCode = @(currentGlucose.errorCode);
|
|
162
211
|
glucose.trend = @(currentGlucose.trend);
|
|
163
212
|
/* glucose.glu 保存 ADC 算法结果 单位mmol */
|
|
@@ -172,11 +221,29 @@
|
|
|
172
221
|
data.calibration = @(currentGlucose.BGMG);
|
|
173
222
|
data.error = @(currentGlucose.errorCode);
|
|
174
223
|
data.trend = @(currentGlucose.trend);
|
|
175
|
-
data.countdownDays = @(currentGlucose.countdownDays);
|
|
176
|
-
data.countdownHours = @(currentGlucose.countdownHours);
|
|
177
|
-
data.countdownMinutes = @(currentGlucose.countdownMinutes);
|
|
178
224
|
|
|
179
|
-
[
|
|
225
|
+
NSString *logString = [NSString stringWithFormat:@"glucoseId=%@, Iw=%@, Ib=%@, T=%@,dayCount=%@, hour=%@, minute=%@, milles=%@, GluMG=%@,BGCount=%@, BGICount=%@, errorCode=%@ trend=%@ calibrationStatus=%@, countdownDays=%@, countdownHours=%@, countdownMinutes=%@ ",
|
|
226
|
+
@(d.glucoseId),
|
|
227
|
+
@(d.Iw),
|
|
228
|
+
@(d.Ib),
|
|
229
|
+
@(d.T),
|
|
230
|
+
@(d.day),
|
|
231
|
+
@(d.hour),
|
|
232
|
+
@(d.minute),
|
|
233
|
+
@(d.timeMillis),
|
|
234
|
+
@(currentGlucose.GluMG),
|
|
235
|
+
@(currentGlucose.BGCount),
|
|
236
|
+
@(currentGlucose.BGICount),
|
|
237
|
+
@(currentGlucose.errorCode),
|
|
238
|
+
@(currentGlucose.trend),
|
|
239
|
+
@(currentGlucose.BGMG),
|
|
240
|
+
@(currentGlucose.countdownDays),
|
|
241
|
+
@(currentGlucose.countdownHours),
|
|
242
|
+
@(currentGlucose.countdownHours)
|
|
243
|
+
|
|
244
|
+
];
|
|
245
|
+
|
|
246
|
+
|
|
180
247
|
[self.appDelegate saveContext];
|
|
181
248
|
return glucose;
|
|
182
249
|
}
|
|
@@ -267,7 +334,7 @@
|
|
|
267
334
|
NSFetchRequest *request = [[NSFetchRequest alloc] init];
|
|
268
335
|
NSPredicate *predicate;
|
|
269
336
|
if (needUserBG) {
|
|
270
|
-
predicate = [NSPredicate predicateWithFormat:@"device.identifier = %@ AND initialBeginDate = %@ &&
|
|
337
|
+
predicate = [NSPredicate predicateWithFormat:@"device.identifier = %@ AND initialBeginDate = %@ && userBG > 0 && userBG != NIL AND isDelete == NIL",currentDevice.identifier, currentDevice.initialBeginDate];
|
|
271
338
|
} else {
|
|
272
339
|
predicate = [NSPredicate predicateWithFormat:@"device.identifier = %@ AND initialBeginDate = %@ AND isDelete == NIL",currentDevice.identifier, currentDevice.initialBeginDate];
|
|
273
340
|
}
|
|
@@ -396,7 +463,7 @@
|
|
|
396
463
|
ReceiveData *receiveModel = needUserBgs[i];
|
|
397
464
|
bgToGlucoseIds[i] = receiveModel.glucoseId.intValue;
|
|
398
465
|
bgValues[i] = roundf(receiveModel.userBG.floatValue * 18);
|
|
399
|
-
|
|
466
|
+
NSLog(@"newBgToGlucoseIds: bgToGlucoseIds=%@, userBG=%@", receiveModel.glucoseId, receiveModel.userBG);
|
|
400
467
|
}
|
|
401
468
|
data.newBgToGlucoseIds = bgToGlucoseIds;
|
|
402
469
|
data.newBgToGlucoseIdsCount = (int)numberOfUserBgs;
|
|
@@ -411,7 +478,7 @@
|
|
|
411
478
|
data.R = algo_r;
|
|
412
479
|
|
|
413
480
|
CurrentGlucose *currentGlucose = [AlgorithmTools algorithmGlucose:data];
|
|
414
|
-
|
|
481
|
+
NSLog(@"rerunADCAlgo: algorithm=%@, currentGlucose.errorCode = %@", @(data.algorithm), @(currentGlucose.errorCode));
|
|
415
482
|
if (Iws != nil) {
|
|
416
483
|
free(Iws);
|
|
417
484
|
Iws = nil;
|