react-native-mytatva-rn-sdk 1.2.55 → 1.2.57
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.
|
@@ -317,6 +317,7 @@
|
|
|
317
317
|
|
|
318
318
|
if ([command isEqualToString:@"06"]) {
|
|
319
319
|
// 06:CT3初始化协议响应后发射低功耗
|
|
320
|
+
//After CT3 initialization protocol response, the transmitter enters low power mode.
|
|
320
321
|
if ([ProtocalTools init_response:characteristic.value andEDevice:self.eDevice]) {
|
|
321
322
|
KLTLocalSettingManager.shareInstance.canConnectOtherDevice = NO;
|
|
322
323
|
|
|
@@ -349,6 +350,7 @@
|
|
|
349
350
|
if ([command isEqualToString:@"07"]) {
|
|
350
351
|
// CT3/CT4 每3分钟上来的数据
|
|
351
352
|
//Data uploaded every 3 minutes from CT3/CT4
|
|
353
|
+
KLTLog(@"==============>>> Data uploaded every 3 minutes from CT3/CT4");
|
|
352
354
|
[self handleReceiveDataWithPrefix07:characteristic.value];
|
|
353
355
|
}
|
|
354
356
|
|
|
@@ -253,9 +253,6 @@
|
|
|
253
253
|
return resendDatas;
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
256
|
// 如果不是第一次连接发射器,更新device连接次数和连接时间
|
|
260
257
|
- (void)updateDeviceWithDeviceId:(NSString *)identify
|
|
261
258
|
scannedTime:(NSString *)scannedTime
|
|
@@ -380,7 +377,6 @@
|
|
|
380
377
|
allData = [allData sortedArrayUsingDescriptors:@[
|
|
381
378
|
[NSSortDescriptor sortDescriptorWithKey:@"receiveDateTime" ascending:YES]
|
|
382
379
|
]];
|
|
383
|
-
|
|
384
380
|
return allData;
|
|
385
381
|
}
|
|
386
382
|
|
|
@@ -31,9 +31,10 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
31
31
|
@property (nonatomic, assign) BOOL hasNumberPrefix;
|
|
32
32
|
|
|
33
33
|
// 是否能连其他发射器 NO:标识当前已绑定发射器 YES:当前未绑定发射器
|
|
34
|
-
|
|
35
|
-
//NO
|
|
36
|
-
//YES
|
|
34
|
+
//“Whether another transmitter can be connected”
|
|
35
|
+
//NO – a transmitter is already bound.
|
|
36
|
+
//YES – no transmitter is currently bound.
|
|
37
|
+
|
|
37
38
|
@property (nonatomic, assign) BOOL canConnectOtherDevice;
|
|
38
39
|
|
|
39
40
|
@end
|
|
@@ -541,8 +541,8 @@ RCT_EXPORT_METHOD(observeAllGlucoseData:(NSString *)token isForClearData:(BOOL)i
|
|
|
541
541
|
|
|
542
542
|
RCT_EXPORT_METHOD(observeTransmitterUnbindStatus:(NSString *)token
|
|
543
543
|
response:(NSString *)responseJsonString
|
|
544
|
-
patientId:
|
|
545
|
-
envType:
|
|
544
|
+
patientId:(NSString *)patientId
|
|
545
|
+
envType:(NSString *)envType
|
|
546
546
|
resolver:(RCTPromiseResolveBlock)resolve
|
|
547
547
|
rejecter:(RCTPromiseRejectBlock)reject) {
|
|
548
548
|
if (responseJsonString == nil || ![responseJsonString isKindOfClass:[NSString class]]) {
|
|
@@ -570,7 +570,7 @@ RCT_EXPORT_METHOD(observeTransmitterUnbindStatus:(NSString *)token
|
|
|
570
570
|
[defaults synchronize];
|
|
571
571
|
|
|
572
572
|
FinalViewModelManager *manager = [FinalViewModelManager shared];
|
|
573
|
-
[manager
|
|
573
|
+
[manager callForObserveTransmitterUnbindStatusWithCompletionWithPatientId:patientId completion:^(NSDictionary *response, NSError *error) {
|
|
574
574
|
if (error) {
|
|
575
575
|
reject([NSString stringWithFormat:@"%ld", (long)error.code], error.localizedDescription, error);
|
|
576
576
|
} else {
|
|
@@ -582,4 +582,5 @@ RCT_EXPORT_METHOD(observeTransmitterUnbindStatus:(NSString *)token
|
|
|
582
582
|
}
|
|
583
583
|
|
|
584
584
|
|
|
585
|
+
|
|
585
586
|
@end
|
|
@@ -24,7 +24,10 @@ import Foundation
|
|
|
24
24
|
// }
|
|
25
25
|
// }
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
|
|
28
|
+
@objc(callForObserveTransmitterUnbindStatusWithCompletionWithPatientId:completion:)
|
|
29
|
+
public func callForObserveTransmitterUnbindStatusWithCompletion(
|
|
30
|
+
patientId: String,
|
|
28
31
|
_ completion: @escaping (_ finalResponse: [String: Any]?, _ error: Error?) -> Void
|
|
29
32
|
) {
|
|
30
33
|
// Load JSON data from UserDefaults
|
|
@@ -41,7 +44,7 @@ import Foundation
|
|
|
41
44
|
do {
|
|
42
45
|
let json = try JSONSerialization.jsonObject(with: data, options: [])
|
|
43
46
|
// Forward to actual handler, which includes a safety check
|
|
44
|
-
self.callForObserveTransmitterUnbindStatusWithResponse(json, completion: completion)
|
|
47
|
+
self.callForObserveTransmitterUnbindStatusWithResponse(patientId: patientId, json, completion: completion)
|
|
45
48
|
} catch {
|
|
46
49
|
completion(nil, NSError(domain: "SensorData", code: 405, userInfo: [NSLocalizedDescriptionKey: "Failed to parse cached JSON"]))
|
|
47
50
|
}
|
|
@@ -49,6 +52,7 @@ import Foundation
|
|
|
49
52
|
|
|
50
53
|
|
|
51
54
|
@objc public func callForObserveTransmitterUnbindStatusWithResponse(
|
|
55
|
+
patientId: String,
|
|
52
56
|
_ response: Any, // Changed from [String: Any] to Any to add type safety
|
|
53
57
|
completion: @escaping (_ finalResponse: [String: Any]?, _ error: Error?) -> Void
|
|
54
58
|
) {
|
|
@@ -97,7 +101,7 @@ import Foundation
|
|
|
97
101
|
"daysToExpire": daysToExpire
|
|
98
102
|
]
|
|
99
103
|
|
|
100
|
-
let finalResponse = self.evaluateUnbindStatus(response: baseResponse, startDate: startDate, endDate: endDate)
|
|
104
|
+
let finalResponse = self.evaluateUnbindStatus(response: baseResponse, startDate: startDate, endDate: endDate, sensorId: sensorId, patientId: patientId)
|
|
101
105
|
completion(finalResponse, nil)
|
|
102
106
|
}
|
|
103
107
|
|
|
@@ -105,7 +109,9 @@ import Foundation
|
|
|
105
109
|
@objc public func evaluateUnbindStatus(
|
|
106
110
|
response: [String: Any],
|
|
107
111
|
startDate: String,
|
|
108
|
-
endDate: String
|
|
112
|
+
endDate: String,
|
|
113
|
+
sensorId: String,
|
|
114
|
+
patientId: String
|
|
109
115
|
) -> [String: Any] {
|
|
110
116
|
let updatedResponse = response
|
|
111
117
|
|
|
@@ -124,7 +130,8 @@ import Foundation
|
|
|
124
130
|
viewModel.manager.startScan()
|
|
125
131
|
viewModel.debouncer.update(with: .transmitterDisconnect)
|
|
126
132
|
} else {
|
|
127
|
-
|
|
133
|
+
UserDefaults.standard.set(sensorId, forKey: "sensorId")
|
|
134
|
+
UserDefaults.standard.set(patientId, forKey: "patientId")
|
|
128
135
|
}
|
|
129
136
|
} else {
|
|
130
137
|
print("⚠️ currentDevice is nil")
|
|
@@ -155,6 +162,7 @@ class FinalViewModel: NSObject {
|
|
|
155
162
|
super.init()
|
|
156
163
|
debouncer.onDebounceSuccess = { value in
|
|
157
164
|
print("Blutooth is------------------->>>>>>>>>> \(value)")
|
|
165
|
+
let envType = UserDefaults.standard.string(forKey: "envType") ?? "uat"
|
|
158
166
|
API.shared.sendStatus(environment: .stage, status: value)
|
|
159
167
|
// if value == .errorCommon {
|
|
160
168
|
// self.manager.startScan()
|
|
@@ -349,6 +357,7 @@ class FinalViewModel: NSObject {
|
|
|
349
357
|
private func uploadBatch(batches: [[GlucoseData]], index: Int) {
|
|
350
358
|
guard index < batches.count else {
|
|
351
359
|
if index != 0 {
|
|
360
|
+
print("Last batch ===>>> \(batches.last?.last)")
|
|
352
361
|
NotificationCenter.default.post(name: Notification.Name("CheckErrorStatusFromLastBatchData"), object: batches.last?.last)
|
|
353
362
|
}
|
|
354
363
|
print("✅ All batches uploaded")
|
|
@@ -356,7 +365,16 @@ class FinalViewModel: NSObject {
|
|
|
356
365
|
}
|
|
357
366
|
|
|
358
367
|
let batch = batches[index]
|
|
359
|
-
|
|
368
|
+
|
|
369
|
+
// Filter out data where gluADC is 0
|
|
370
|
+
let filteredBatch = batch.filter {
|
|
371
|
+
if let gluADC = $0.gluADC as? Int {
|
|
372
|
+
return gluADC != 0
|
|
373
|
+
}
|
|
374
|
+
return false
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
let cgmLogs = filteredBatch.map { ReceiveDataToLog(data: $0) }
|
|
360
378
|
let payload = Payload(logs: cgmLogs)
|
|
361
379
|
|
|
362
380
|
print("====================================> called uploadBatch")
|
|
@@ -370,19 +388,34 @@ class FinalViewModel: NSObject {
|
|
|
370
388
|
// Optionally retry or stop here
|
|
371
389
|
}
|
|
372
390
|
}
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
// private func uploadBatch(batches: [[GlucoseData]], index: Int) {
|
|
394
|
+
// guard index < batches.count else {
|
|
395
|
+
// if index != 0 {
|
|
396
|
+
// print("Last batch ===>>> \(batches.last?.last)")
|
|
397
|
+
// NotificationCenter.default.post(name: Notification.Name("CheckErrorStatusFromLastBatchData"), object: batches.last?.last)
|
|
398
|
+
// }
|
|
399
|
+
// print("✅ All batches uploaded")
|
|
400
|
+
// return
|
|
401
|
+
// }
|
|
373
402
|
//
|
|
374
|
-
//
|
|
375
|
-
// let
|
|
376
|
-
//
|
|
377
|
-
//
|
|
378
|
-
|
|
379
|
-
//
|
|
380
|
-
//
|
|
381
|
-
// print(
|
|
382
|
-
//
|
|
383
|
-
// self.
|
|
403
|
+
// let batch = batches[index]
|
|
404
|
+
// let cgmLogs = batch.map { ReceiveDataToLog(data: $0) }
|
|
405
|
+
// let payload = Payload(logs: cgmLogs)
|
|
406
|
+
//
|
|
407
|
+
// print("====================================> called uploadBatch")
|
|
408
|
+
// API.shared.postCGMData(data: payload, environment: .stage) {
|
|
409
|
+
// print("====================================> uploaded successfully")
|
|
410
|
+
// print("✅ Batch \(index + 1) uploaded successfully")
|
|
411
|
+
// KLTDatabaseHandler.shared().deleteReceiveDataArray(batch)
|
|
412
|
+
// self.uploadBatch(batches: batches, index: index + 1)
|
|
413
|
+
// } onFailure: { error in
|
|
414
|
+
// print("❌ Failed to upload batch \(index + 1): \(String(describing: error?.localizedDescription))")
|
|
415
|
+
// // Optionally retry or stop here
|
|
384
416
|
// }
|
|
385
417
|
// }
|
|
418
|
+
|
|
386
419
|
|
|
387
420
|
@objc func updateData(_ notification: Notification) {
|
|
388
421
|
// Safely cast to [ReceiveData]
|
|
@@ -608,7 +641,6 @@ class FinalViewModel: NSObject {
|
|
|
608
641
|
default:
|
|
609
642
|
break
|
|
610
643
|
}
|
|
611
|
-
|
|
612
644
|
}
|
|
613
645
|
|
|
614
646
|
|