react-native-mytatva-rn-sdk 1.2.48 → 1.2.49

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.
Files changed (28) hide show
  1. package/android/src/main/java/com/mytatvarnsdk/CgmTrackyLibModule.kt +17 -25
  2. package/android/src/main/java/com/mytatvarnsdk/activity/BtManageActivity.java +345 -345
  3. package/android/src/main/java/com/mytatvarnsdk/activity/ConnectSensorActivity.kt +17 -38
  4. package/android/src/main/java/com/mytatvarnsdk/activity/ExitJourneyBottomSheet.kt +51 -51
  5. package/android/src/main/java/com/mytatvarnsdk/activity/PermissionActivity.kt +10 -5
  6. package/android/src/main/java/com/mytatvarnsdk/activity/PlaceSensorActivity.kt +4 -5
  7. package/android/src/main/java/com/mytatvarnsdk/activity/PlaceTransmitterActivity.kt +4 -5
  8. package/android/src/main/java/com/mytatvarnsdk/activity/QRActivity.kt +96 -92
  9. package/android/src/main/java/com/mytatvarnsdk/activity/SearchTransmitterActivity.kt +1 -1
  10. package/android/src/main/java/com/mytatvarnsdk/activity/SensorConnectSuccessActivity.kt +1 -1
  11. package/android/src/main/java/com/mytatvarnsdk/activity/StartCGMActivity.kt +4 -2
  12. package/android/src/main/java/com/mytatvarnsdk/activity/VideoActivity.kt +0 -1
  13. package/android/src/main/java/com/mytatvarnsdk/utils/TatvaEncryptionConfig.kt +0 -5
  14. package/ios/Database/KLTBluetoothManager.m +9 -4
  15. package/ios/Database/KLTDatabaseHandler.m +53 -6
  16. package/ios/MyReactNativeBridge.h +4 -1
  17. package/ios/MyReactNativeBridge.m +433 -191
  18. package/ios/Support/API.swift +0 -1
  19. package/ios/Support/Global.swift +12 -0
  20. package/ios/ViewControllers/AttachTransmitterViewController.swift +33 -2
  21. package/ios/ViewControllers/ChatWithExpertViewController.swift +33 -3
  22. package/ios/ViewControllers/ConnectToSensorViewController.swift +101 -12
  23. package/ios/ViewControllers/ConnectToTransmitterViewController.swift +121 -5
  24. package/ios/ViewControllers/ProvidePermissionViewController.swift +37 -5
  25. package/ios/ViewControllers/PutOnTheSensorViewController.swift +22 -2
  26. package/ios/ViewControllers/StartConnectionViewController.swift +31 -3
  27. package/ios/ViewModel/FinalViewModel.swift +155 -48
  28. package/package.json +1 -1
@@ -363,13 +363,13 @@
363
363
  }
364
364
 
365
365
  if ([command isEqualToString:@"11"]) {
366
- // CT3 CT4重传数据完毕调用重置协议(响应)
366
+ // Reset response received from CT3/CT4
367
367
  TransmitterReset *resetData = [ProtocalTools reset_response2:characteristic.value andEDevice:self.eDevice];
368
368
  if (resetData.isBind) {
369
- //重置成功-->CT3发射低功耗协议
369
+ // Transmitter is still bound → send low-power mode command
370
370
  [peripheral writeValue:[ProtocalTools lowPower_request:self.eDevice] forCharacteristic:self.writeReadCharacteristic type:CBCharacteristicWriteWithoutResponse];
371
371
  } else {
372
- // CT3发射器解除绑定(如场景:发射器进行充电重启后再连接时发现为未绑定状态)
372
+ // Transmitter is unbound (e.g., reset + power cycle)
373
373
  self.status = BluetoothManagerStatusSensorLostPower;
374
374
  }
375
375
  }
@@ -391,6 +391,10 @@
391
391
  GlucoseData *glucose = [[KLTDatabaseHandler shared] addCT3GlucoseDataWithReceiveData:receiveData];
392
392
  KLTLog(@"计算glucose.gluADC = %@, glucose.errorCode = %@", glucose.gluADC, glucose.errorCode);
393
393
  [currentDevice addGlucoseDatasObject:glucose];
394
+ KLTLog(@"==============>>> GlucoseData");
395
+ KLTLog(@"GlucoseData Details:\n""gluADC: %@\n""glu: %@\n""errorCode: %@\n""temperature: %@\n""trend: %@\n""dataId: %@\n""operatingCurrent: %@\n""blankCurrent: %@\n""k: %@\n""iw: %@\n""calibrationStatus: %@\n""initialBeginDate: %@\n""receiveDateTime: %@\n""userBG: %@\n""device: %@",
396
+ glucose.gluADC,glucose.glu,glucose.errorCode,glucose.temperature,glucose.trend,glucose.dataId,glucose.operatingCurrent,glucose.blankCurrent,glucose.k,glucose.iw,glucose.calibrationStatus,glucose.initialBeginDate,glucose.receiveDateTime,glucose.userBG,glucose.device.deviceName);
397
+
394
398
  if (!self.isInResend) {
395
399
  [Notification_Center postNotificationName:@"latestGluData" object:glucose];
396
400
  self.status = BluetoothManagerStatusGetGLU;
@@ -515,7 +519,7 @@
515
519
  }
516
520
 
517
521
  [Notification_Center postNotificationName:KLTUpdateDataNotify object:NULL];
518
-
522
+ NSLog(@"----------------------------------------------called handleResendDataWithPrefix22 for KLTUpdateDataNotify");
519
523
  NSInteger maxGlucoseId = [KLTDatabaseHandler.shared getLatestAndMaxGlucoseIdOfDevice:self.currentDevice];
520
524
  NSInteger remain_points = self.eDevice.endNumber - (maxGlucoseId + 1);
521
525
  if (remain_points <= 0) {
@@ -540,6 +544,7 @@
540
544
  [self handleCommonCT3GlucoseDataWithReceiveData:receive];
541
545
  [Notification_Center postNotificationName:@"DidHandleResendDataNoReload" object:nil];
542
546
  [Notification_Center postNotificationName:KLTUpdateDataNotify object:NULL];
547
+ NSLog(@"----------------------------------------------called handleReceiveDataWithPrefix07Glucose for KLTUpdateDataNotify");
543
548
  NSInteger remain_points = [KLTDatabaseHandler.shared numberOfLifeCycleSensorWithDevice:self.currentDevice endNumber:self.eDevice.endNumber];
544
549
  if (remain_points <= 0) {
545
550
  [self closeBleSensor];
@@ -191,18 +191,51 @@
191
191
  }
192
192
 
193
193
 
194
+ //- (NSArray<GlucoseData*> *)queryGlucoseDataWithDevice:(Device *)currentDevice {
195
+ // NSEntityDescription *entity = [NSEntityDescription entityForName:@"GlucoseData" inManagedObjectContext:self.context];
196
+ // NSFetchRequest *request = [[NSFetchRequest alloc] init];
197
+ // NSPredicate *predicate = [NSPredicate predicateWithFormat:@"device.identifier = %@ AND initialBeginDate = %@", currentDevice.identifier, currentDevice.initialBeginDate];
198
+ // request.entity = entity;
199
+ // request.predicate = predicate;
200
+ // NSArray *resendDatas = [self.context executeFetchRequest:request error:nil];
201
+ // resendDatas = [resendDatas sortedArrayUsingDescriptors:@[[NSSortDescriptor sortDescriptorWithKey:@"receiveDateTime" ascending:YES]]];
202
+ // return resendDatas;
203
+ //}
204
+
194
205
  - (NSArray<GlucoseData*> *)queryGlucoseDataWithDevice:(Device *)currentDevice {
195
206
  NSEntityDescription *entity = [NSEntityDescription entityForName:@"GlucoseData" inManagedObjectContext:self.context];
196
207
  NSFetchRequest *request = [[NSFetchRequest alloc] init];
197
208
  NSPredicate *predicate = [NSPredicate predicateWithFormat:@"device.identifier = %@ AND initialBeginDate = %@", currentDevice.identifier, currentDevice.initialBeginDate];
198
209
  request.entity = entity;
199
210
  request.predicate = predicate;
211
+
200
212
  NSArray *resendDatas = [self.context executeFetchRequest:request error:nil];
201
213
  resendDatas = [resendDatas sortedArrayUsingDescriptors:@[[NSSortDescriptor sortDescriptorWithKey:@"receiveDateTime" ascending:YES]]];
214
+
215
+ // 🖨️ Add single-line logging for each GlucoseData entry
216
+ NSLog(@"==== GlucoseData (Fetched %lu records) for Device: %@ ====", (unsigned long)resendDatas.count, currentDevice.identifier);
217
+ for (GlucoseData *g in resendDatas) {
218
+ NSLog(@"[ID:%@] Date:%@ | glu:%@ mmol/L | gluADC:%@ mg/dL | BG:%@ | T:%@°C | Ib:%@ | Iw:%@ | Trend:%@ | Err:%@ | CalStatus:%@",
219
+ g.dataId,
220
+ g.receiveDateTime,
221
+ g.glu,
222
+ g.gluADC,
223
+ g.userBG,
224
+ g.temperature,
225
+ g.blankCurrent,
226
+ g.operatingCurrent,
227
+ g.trend,
228
+ g.errorCode,
229
+ g.calibrationStatus
230
+ );
231
+ }
232
+
202
233
  return resendDatas;
203
234
  }
204
235
 
205
236
 
237
+
238
+
206
239
  // 如果不是第一次连接发射器,更新device连接次数和连接时间
207
240
  - (void)updateDeviceWithDeviceId:(NSString *)identify
208
241
  scannedTime:(NSString *)scannedTime
@@ -267,24 +300,38 @@
267
300
  NSLog(@"Core Data context is nil");
268
301
  return @[];
269
302
  }
303
+
270
304
  NSEntityDescription *entity = [NSEntityDescription entityForName:@"ReceiveDataInfo" inManagedObjectContext:self.context];
305
+ if (!entity) {
306
+ NSLog(@"Entity 'ReceiveDataInfo' not found in Core Data model");
307
+ return @[];
308
+ }
309
+
271
310
  NSFetchRequest *request = [[NSFetchRequest alloc] init];
311
+ request.entity = entity;
312
+
272
313
  NSPredicate *predicate;
273
314
  if (needUserBG) {
274
- predicate = [NSPredicate predicateWithFormat:@"device.identifier = %@ AND initialBeginDate = %@ && gluADC > 0 && gluADC != NIL AND isDelete == NIL",currentDevice.identifier, currentDevice.initialBeginDate];
315
+ predicate = [NSPredicate predicateWithFormat:@"device.identifier = %@ AND initialBeginDate = %@ AND gluADC > 0 AND gluADC != nil AND isDelete == nil", currentDevice.identifier, currentDevice.initialBeginDate];
275
316
  } else {
276
- predicate = [NSPredicate predicateWithFormat:@"device.identifier = %@ AND initialBeginDate = %@ AND isDelete == NIL",currentDevice.identifier, currentDevice.initialBeginDate];
317
+ predicate = [NSPredicate predicateWithFormat:@"device.identifier = %@ AND initialBeginDate = %@ AND isDelete == nil", currentDevice.identifier, currentDevice.initialBeginDate];
277
318
  }
278
- request.entity = entity;
279
319
  request.predicate = predicate;
280
- if (!entity) {
281
- NSLog(@"Entity 'ReceiveDataInfo' not found in Core Data model");
320
+
321
+ NSError *fetchError = nil;
322
+ NSArray *resendDatas = [self.context executeFetchRequest:request error:&fetchError];
323
+
324
+ if (fetchError) {
325
+ NSLog(@"❌ Fetch error: %@", fetchError.localizedDescription);
282
326
  return @[];
283
327
  }
284
- NSArray *resendDatas = [self.context executeFetchRequest:request error:nil];
328
+
285
329
  resendDatas = [resendDatas sortedArrayUsingDescriptors:@[[NSSortDescriptor sortDescriptorWithKey:@"receiveDateTime" ascending:YES]]];
330
+ NSLog(@"📡 resendDatas: %@", resendDatas);
331
+
286
332
  return resendDatas;
287
333
  }
334
+
288
335
  - (NSArray *)queryAllReceiveData {
289
336
  NSEntityDescription *entity = [NSEntityDescription entityForName:@"ReceiveDataInfo" inManagedObjectContext:self.context];
290
337
  NSFetchRequest *request = [[NSFetchRequest alloc] init];
@@ -8,13 +8,16 @@
8
8
  #ifndef MyReactNativeBridge_h
9
9
  #define MyReactNativeBridge_h
10
10
 
11
+ #import "GlucoseData+CoreDataClass.h"
12
+ #import "Device+CoreDataClass.h"
13
+
11
14
 
12
15
  #endif /* MyReactNativeBridge_h */
13
16
  #import "KLTAppDelegate.h"
14
17
  #import <Foundation/Foundation.h>
15
18
  #import <React/RCTBridgeModule.h>
16
19
  #import <React/RCTEventEmitter.h>
17
-
20
+ #import "KLTDatabaseHandler.h"
18
21
  @interface CgmTrackyLib : RCTEventEmitter <RCTBridgeModule>
19
22
 
20
23
  @end