react-native-mytatva-rn-sdk 1.2.70 → 1.2.72
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 +60 -57
- package/android/src/main/java/com/mytatvarnsdk/activity/StartCGMActivity.kt +3 -0
- package/android/src/main/java/com/mytatvarnsdk/network/AuthenticateSDKService.kt +8 -0
- package/ios/Database/KLTDatabaseHandler.m +46 -1
- package/ios/MyReactNativeBridge.m +53 -36
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.js +1 -1
|
@@ -363,7 +363,9 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
|
|
|
363
363
|
fun startCgmTracky(token: String, envType: String) {
|
|
364
364
|
try {
|
|
365
365
|
userToken = token
|
|
366
|
+
env = envType.lowercase()
|
|
366
367
|
val intent = Intent(currentActivity, StartCGMActivity::class.java)
|
|
368
|
+
intent.putExtra("envType", env)
|
|
367
369
|
currentActivity?.startActivity(intent)
|
|
368
370
|
} catch (e: Exception) {
|
|
369
371
|
Log.e("startCgmTracky", "startCgmTracky: ${e.message}")
|
|
@@ -385,11 +387,12 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
|
|
|
385
387
|
fun reconnectCgmTracky(token: String, envType: String) {
|
|
386
388
|
try {
|
|
387
389
|
userToken = token
|
|
390
|
+
env = envType.lowercase()
|
|
388
391
|
currentActivity?.startActivity(
|
|
389
392
|
Intent(currentActivity, StartCGMActivity::class.java).putExtra(
|
|
390
393
|
"IsForReconnect",
|
|
391
394
|
true
|
|
392
|
-
)
|
|
395
|
+
).putExtra("envType", env)
|
|
393
396
|
)
|
|
394
397
|
} catch (e: Exception) {
|
|
395
398
|
Log.e("reconnectCgmTracky", "reconnectCgmTracky: ${e.message}")
|
|
@@ -495,7 +498,7 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
|
|
|
495
498
|
|
|
496
499
|
// Check for duplicate using glucoseId
|
|
497
500
|
val glucoseId = pocGlucose.glucoseId ?: continue
|
|
498
|
-
|
|
501
|
+
|
|
499
502
|
if (!processedGlucoseIds.add(glucoseId)) {
|
|
500
503
|
Log.d("triggerDataUpload", "Already processed: $glucoseId, skipping")
|
|
501
504
|
continue
|
|
@@ -518,7 +521,7 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
|
|
|
518
521
|
// Put it back in queue for batch to handle
|
|
519
522
|
pendingDataQueue.offer(pocGlucose)
|
|
520
523
|
Log.d("triggerDataUpload", "Old data detected, triggering batch: $glucoseId")
|
|
521
|
-
|
|
524
|
+
|
|
522
525
|
// Trigger batch process on main thread
|
|
523
526
|
withContext(Dispatchers.Main) {
|
|
524
527
|
observeAllGlucoseData(userToken, false, envType)
|
|
@@ -543,40 +546,40 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
|
|
|
543
546
|
Log.d("handleGlucoseData", "Processing glucose data: ${pocGlucose.glucoseId}")
|
|
544
547
|
|
|
545
548
|
if (pocGlucose.errorCode == enumError.NONE) {
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
val request: GlucoseLogRequest =
|
|
552
|
-
GlucoseLogRequest(vendor = "GoodFlip", logs = logs)
|
|
553
|
-
val gson: Gson = GsonBuilder().create()
|
|
554
|
-
val json = gson.toJson(request)
|
|
555
|
-
|
|
556
|
-
Log.d("Glucose data 3 min==> ", "Glucose data 3 min==> final Json: $json")
|
|
557
|
-
|
|
558
|
-
authenticateSDKService.postCGMData(
|
|
559
|
-
environment = if (envType.lowercase() == "uat") TATVA_ENVIRONMENT.STAGE else TATVA_ENVIRONMENT.PROD,
|
|
560
|
-
data = json,
|
|
561
|
-
token = userToken,
|
|
562
|
-
responseListener = object : AuthenticateSDKService.ResponseListener {
|
|
563
|
-
override fun onResponseSuccess(response: String) {
|
|
564
|
-
updateSyncMetadata(pocGlucose)
|
|
565
|
-
Log.d("CGM Data", "Single glucose data uploaded successfully")
|
|
566
|
-
}
|
|
549
|
+
/* if (pocGlucose.showGlucoseMG > 0) { */
|
|
550
|
+
val dto: GlucoseLog = mapToDto(pocGlucose)
|
|
551
|
+
val logs: ArrayList<GlucoseLog> = ArrayList()
|
|
552
|
+
logs.add(dto)
|
|
567
553
|
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
554
|
+
val request: GlucoseLogRequest =
|
|
555
|
+
GlucoseLogRequest(vendor = "GoodFlip", logs = logs)
|
|
556
|
+
val gson: Gson = GsonBuilder().create()
|
|
557
|
+
val json = gson.toJson(request)
|
|
558
|
+
|
|
559
|
+
Log.d("Glucose data 3 min==> ", "Glucose data 3 min==> final Json: $json")
|
|
560
|
+
|
|
561
|
+
authenticateSDKService.postCGMData(
|
|
562
|
+
environment = if (envType.lowercase() == "uat") TATVA_ENVIRONMENT.STAGE else TATVA_ENVIRONMENT.PROD,
|
|
563
|
+
data = json,
|
|
564
|
+
token = userToken,
|
|
565
|
+
responseListener = object : AuthenticateSDKService.ResponseListener {
|
|
566
|
+
override fun onResponseSuccess(response: String) {
|
|
567
|
+
updateSyncMetadata(pocGlucose)
|
|
568
|
+
Log.d("CGM Data", "Single glucose data uploaded successfully")
|
|
571
569
|
}
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
570
|
+
|
|
571
|
+
override fun onResponseFail() {
|
|
572
|
+
Log.e("CGM Data", "Failed to upload single glucose data")
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
)
|
|
576
|
+
/* } */
|
|
577
|
+
/* else {
|
|
578
|
+
Log.d(
|
|
579
|
+
"handleGlucoseData",
|
|
580
|
+
"Glucose value is 0 or negative: ${pocGlucose.showGlucoseMG}"
|
|
581
|
+
)
|
|
582
|
+
} */
|
|
580
583
|
} else {
|
|
581
584
|
Log.d("handleGlucoseData", "Glucose data has error: ${pocGlucose.errorCode}")
|
|
582
585
|
handleGlucoseError(pocGlucose, envType)
|
|
@@ -653,7 +656,7 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
|
|
|
653
656
|
while (pendingDataQueue.isNotEmpty()) {
|
|
654
657
|
pendingDataQueue.poll()?.let { pendingData.add(it) }
|
|
655
658
|
}
|
|
656
|
-
|
|
659
|
+
|
|
657
660
|
if (pendingData.isNotEmpty()) {
|
|
658
661
|
Log.d("observeAllGlucoseData", "Found ${pendingData.size} items in pending queue")
|
|
659
662
|
}
|
|
@@ -668,7 +671,7 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
|
|
|
668
671
|
val glucoseData = mModel.getGlucoseBetweenTime(lastSyncData.timeInMillis)
|
|
669
672
|
|
|
670
673
|
Log.d("observeAllGlucoseData", "Retrieved ${glucoseData?.size ?: 0} records from DB")
|
|
671
|
-
|
|
674
|
+
|
|
672
675
|
// Combine database data with pending queue data
|
|
673
676
|
val allData = mutableListOf<PocGlucose>()
|
|
674
677
|
glucoseData?.let { allData.addAll(it) }
|
|
@@ -687,7 +690,7 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
|
|
|
687
690
|
sortedGlucoseData.take(5).forEachIndexed { i, data ->
|
|
688
691
|
Log.d("AFTER Sort [$i]", "timeInMillis: ${data.timeInMillis}, glucoseId: ${data.glucoseId}")
|
|
689
692
|
}
|
|
690
|
-
|
|
693
|
+
|
|
691
694
|
if (sortedGlucoseData.isNotEmpty()) {
|
|
692
695
|
Log.d("observeAllGlucoseData", "✅ Sorted ${sortedGlucoseData.size} records chronologically")
|
|
693
696
|
Log.d("observeAllGlucoseData", "Oldest: ${sortedGlucoseData.first().timeInMillis}")
|
|
@@ -722,7 +725,7 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
|
|
|
722
725
|
}
|
|
723
726
|
}
|
|
724
727
|
}
|
|
725
|
-
|
|
728
|
+
|
|
726
729
|
withContext(Dispatchers.Main) {
|
|
727
730
|
if (!isObserving) {
|
|
728
731
|
observeGlucoseData(userToken, isForClear, envType)
|
|
@@ -760,7 +763,7 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
|
|
|
760
763
|
}
|
|
761
764
|
|
|
762
765
|
// Don't reset flag here - it's reset in observeAllGlucoseData's finally block
|
|
763
|
-
|
|
766
|
+
|
|
764
767
|
// Ensure we're on main thread and not already observing
|
|
765
768
|
withContext(Dispatchers.Main) {
|
|
766
769
|
if (!isObserving) {
|
|
@@ -813,7 +816,7 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
|
|
|
813
816
|
// Cancel all coroutines
|
|
814
817
|
debounceJob?.cancel()
|
|
815
818
|
debounceJob = null
|
|
816
|
-
|
|
819
|
+
|
|
817
820
|
uploadJob?.cancel()
|
|
818
821
|
uploadJob = null
|
|
819
822
|
|
|
@@ -826,7 +829,7 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
|
|
|
826
829
|
// Clear processed IDs and pending queue
|
|
827
830
|
processedGlucoseIds.clear()
|
|
828
831
|
pendingDataQueue.clear()
|
|
829
|
-
|
|
832
|
+
|
|
830
833
|
// Reset batch processing flag
|
|
831
834
|
isBatchProcessing.set(false)
|
|
832
835
|
|
|
@@ -847,20 +850,20 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
|
|
|
847
850
|
try {
|
|
848
851
|
val context = reactApplicationContext
|
|
849
852
|
val logFiles = mutableListOf<String>()
|
|
850
|
-
|
|
853
|
+
|
|
851
854
|
// Get the primary log folder path
|
|
852
855
|
val externalFilesDir = context.getExternalFilesDir(android.os.Environment.DIRECTORY_DOCUMENTS)
|
|
853
856
|
val primaryFolder = externalFilesDir?.absolutePath
|
|
854
|
-
|
|
857
|
+
|
|
855
858
|
// Get the fallback log folder path
|
|
856
|
-
val fallbackFolder = android.os.Environment.getExternalStorageDirectory().absolutePath +
|
|
857
|
-
|
|
858
|
-
|
|
859
|
+
val fallbackFolder = android.os.Environment.getExternalStorageDirectory().absolutePath +
|
|
860
|
+
File.separatorChar + "PocData" + File.separatorChar + "logger"
|
|
861
|
+
|
|
859
862
|
// Check primary folder
|
|
860
863
|
if (primaryFolder != null) {
|
|
861
864
|
val primaryDir = File(primaryFolder)
|
|
862
865
|
if (primaryDir.exists() && primaryDir.isDirectory) {
|
|
863
|
-
val files = primaryDir.listFiles { file ->
|
|
866
|
+
val files = primaryDir.listFiles { file ->
|
|
864
867
|
file.isFile && file.name.endsWith(".csv")
|
|
865
868
|
}
|
|
866
869
|
files?.forEach { file ->
|
|
@@ -868,11 +871,11 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
|
|
|
868
871
|
}
|
|
869
872
|
}
|
|
870
873
|
}
|
|
871
|
-
|
|
874
|
+
|
|
872
875
|
// Check fallback folder
|
|
873
876
|
val fallbackDir = File(fallbackFolder)
|
|
874
877
|
if (fallbackDir.exists() && fallbackDir.isDirectory) {
|
|
875
|
-
val files = fallbackDir.listFiles { file ->
|
|
878
|
+
val files = fallbackDir.listFiles { file ->
|
|
876
879
|
file.isFile && file.name.endsWith(".csv")
|
|
877
880
|
}
|
|
878
881
|
files?.forEach { file ->
|
|
@@ -882,17 +885,17 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
|
|
|
882
885
|
}
|
|
883
886
|
}
|
|
884
887
|
}
|
|
885
|
-
|
|
888
|
+
|
|
886
889
|
Log.d("getCgmLogFiles", "Found ${logFiles.size} log files")
|
|
887
|
-
|
|
890
|
+
|
|
888
891
|
// Convert list to WritableArray
|
|
889
892
|
val resultArray = Arguments.createArray()
|
|
890
893
|
logFiles.forEach { path ->
|
|
891
894
|
resultArray.pushString(path)
|
|
892
895
|
}
|
|
893
|
-
|
|
896
|
+
|
|
894
897
|
promise.resolve(resultArray)
|
|
895
|
-
|
|
898
|
+
|
|
896
899
|
} catch (e: Exception) {
|
|
897
900
|
Log.e("getCgmLogFiles", "Error getting log files: ${e.message}")
|
|
898
901
|
promise.reject("ERROR_GET_LOG_FILES", e.message, e)
|
|
@@ -1035,7 +1038,7 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
|
|
|
1035
1038
|
fun stopObservingGlucoseData() {
|
|
1036
1039
|
stopObservingGlucoseDataInternal()
|
|
1037
1040
|
}
|
|
1038
|
-
|
|
1041
|
+
|
|
1039
1042
|
// Internal method that doesn't clear the queue (used during restarts)
|
|
1040
1043
|
private fun stopObservingGlucoseDataInternal() {
|
|
1041
1044
|
Log.d("stopObservingGlucoseData", "Stopping glucose data observation")
|
|
@@ -1110,10 +1113,10 @@ class CgmTrackyLibModule(reactContext: ReactApplicationContext) :
|
|
|
1110
1113
|
it.glucoseId
|
|
1111
1114
|
)
|
|
1112
1115
|
prefsHelper?.lastSyncData = syncData
|
|
1113
|
-
|
|
1116
|
+
|
|
1114
1117
|
// Mark this glucose ID as processed
|
|
1115
1118
|
it.glucoseId?.let { id -> processedGlucoseIds.add(id) }
|
|
1116
|
-
|
|
1119
|
+
|
|
1117
1120
|
Log.d(
|
|
1118
1121
|
"Sync Metadata",
|
|
1119
1122
|
"Sync metadata updated: glucoseId=${it.glucoseId}, time=${it.timeInMillis}"
|
|
@@ -54,6 +54,9 @@ class StartCGMActivity : AppCompatActivity() {
|
|
|
54
54
|
|
|
55
55
|
private fun init() {
|
|
56
56
|
isForReconnect = intent.getBooleanExtra("IsForReconnect", false)
|
|
57
|
+
val envType = intent.getStringExtra("envType") ?: "prod"
|
|
58
|
+
|
|
59
|
+
// Use envType as needed
|
|
57
60
|
|
|
58
61
|
sendDataToRN("", "cgm_start_connection_landing")
|
|
59
62
|
|
|
@@ -19,6 +19,7 @@ import kotlinx.coroutines.CoroutineScope
|
|
|
19
19
|
import kotlinx.coroutines.launch
|
|
20
20
|
import okhttp3.MediaType.Companion.toMediaType
|
|
21
21
|
import okhttp3.RequestBody.Companion.toRequestBody
|
|
22
|
+
import retrofit2.HttpException
|
|
22
23
|
|
|
23
24
|
class AuthenticateSDKService(val scope: CoroutineScope) {
|
|
24
25
|
|
|
@@ -158,6 +159,13 @@ class AuthenticateSDKService(val scope: CoroutineScope) {
|
|
|
158
159
|
|
|
159
160
|
Log.d("API Response", "API response: $decryptedResponse")
|
|
160
161
|
|
|
162
|
+
} catch (e: HttpException) {
|
|
163
|
+
if (e.code() == 401) {
|
|
164
|
+
Log.d("API Error", "401 Unauthorized - Token: $token")
|
|
165
|
+
// Further handling if necessary
|
|
166
|
+
} else {
|
|
167
|
+
throw e
|
|
168
|
+
}
|
|
161
169
|
} catch (e: Exception) {
|
|
162
170
|
e.printStackTrace()
|
|
163
171
|
Log.d("API Response", "Exception: ${e.message}")
|
|
@@ -159,6 +159,29 @@
|
|
|
159
159
|
|
|
160
160
|
KLTLog(@"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));
|
|
161
161
|
currentGlucose = [AlgorithmTools algorithmLatestGlucose:d];
|
|
162
|
+
NSString *logString = [NSString stringWithFormat:@"glucoseId=%@, Iw=%@, Ib=%@, T=%@,dayCount=%@, hour=%@, minute=%@, milles=%@, GluMG=%@,BGCount=%@, BGICount=%@, errorCode=%@ trend=%@ calibrationStatus=%@, countdownDays=%@, countdownHours=%@, countdownMinutes=%@ ",
|
|
163
|
+
@(d.glucoseId),
|
|
164
|
+
@(d.Iw),
|
|
165
|
+
@(d.Ib),
|
|
166
|
+
@(d.T),
|
|
167
|
+
@(d.day),
|
|
168
|
+
@(d.hour),
|
|
169
|
+
@(d.minute),
|
|
170
|
+
@(d.timeMillis),
|
|
171
|
+
@(currentGlucose.GluMG),
|
|
172
|
+
@(currentGlucose.BGCount),
|
|
173
|
+
@(currentGlucose.BGICount),
|
|
174
|
+
@(currentGlucose.errorCode),
|
|
175
|
+
@(currentGlucose.trend),
|
|
176
|
+
@(currentGlucose.BGMG),
|
|
177
|
+
@(currentGlucose.countdownDays),
|
|
178
|
+
@(currentGlucose.countdownHours),
|
|
179
|
+
@(currentGlucose.countdownHours)
|
|
180
|
+
|
|
181
|
+
];
|
|
182
|
+
KLTRunLog *runLog = [KLTAppDelegate getCurrentKLTRunLog];
|
|
183
|
+
[runLog useCurrentCSV:localName];
|
|
184
|
+
KLTRunWarn(logString);
|
|
162
185
|
}
|
|
163
186
|
|
|
164
187
|
glucose.errorCode = @(currentGlucose.errorCode);
|
|
@@ -192,7 +215,29 @@
|
|
|
192
215
|
|
|
193
216
|
// [Notification_Center postNotificationName:@"ErrorStatusFromTransmitter" object: glucose];
|
|
194
217
|
[Notification_Center postNotificationName:@"CheckErrorStatusFromLastBatchData" object: glucose];
|
|
195
|
-
|
|
218
|
+
NSString *logString = [NSString stringWithFormat:@"glucoseId=%@, Iw=%@, Ib=%@, T=%@,dayCount=%@, hour=%@, minute=%@, milles=%@, GluMG=%@,BGCount=%@, BGICount=%@, errorCode=%@ trend=%@ calibrationStatus=%@, countdownDays=%@, countdownHours=%@, countdownMinutes=%@ ",
|
|
219
|
+
@(d.glucoseId),
|
|
220
|
+
@(d.Iw),
|
|
221
|
+
@(d.Ib),
|
|
222
|
+
@(d.T),
|
|
223
|
+
@(d.day),
|
|
224
|
+
@(d.hour),
|
|
225
|
+
@(d.minute),
|
|
226
|
+
@(d.timeMillis),
|
|
227
|
+
@(currentGlucose.GluMG),
|
|
228
|
+
@(currentGlucose.BGCount),
|
|
229
|
+
@(currentGlucose.BGICount),
|
|
230
|
+
@(currentGlucose.errorCode),
|
|
231
|
+
@(currentGlucose.trend),
|
|
232
|
+
@(currentGlucose.BGMG),
|
|
233
|
+
@(currentGlucose.countdownDays),
|
|
234
|
+
@(currentGlucose.countdownHours),
|
|
235
|
+
@(currentGlucose.countdownHours)
|
|
236
|
+
|
|
237
|
+
];
|
|
238
|
+
KLTRunLog *runLog = [KLTAppDelegate getCurrentKLTRunLog];
|
|
239
|
+
[runLog useCurrentCSV:localName];
|
|
240
|
+
KLTRunWarn(logString);
|
|
196
241
|
[self.appDelegate saveContext];
|
|
197
242
|
return glucose;
|
|
198
243
|
}
|
|
@@ -204,6 +204,8 @@
|
|
|
204
204
|
#import <React/RCTEventEmitter.h>
|
|
205
205
|
#import "react_native_mytatva_rn_sdk-Swift.h"
|
|
206
206
|
#import "KLTDatabaseHandler.h"
|
|
207
|
+
#import "KLTRunLog.h"
|
|
208
|
+
#import "KLTAppDelegate.h"
|
|
207
209
|
|
|
208
210
|
@implementation MyEventEmitterManager
|
|
209
211
|
|
|
@@ -608,52 +610,67 @@ RCT_EXPORT_METHOD(observeTransmitterUnbindStatus:(NSString *)token
|
|
|
608
610
|
* Get all CGM log file paths
|
|
609
611
|
* Returns array of absolute file paths to CGM log files (CSV format)
|
|
610
612
|
*/
|
|
611
|
-
|
|
612
|
-
|
|
613
|
+
RCT_REMAP_METHOD(getCgmLogFiles,
|
|
614
|
+
getCgmLogFilesWithResolver:(RCTPromiseResolveBlock)resolve
|
|
615
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
613
616
|
{
|
|
614
617
|
@try {
|
|
615
618
|
NSMutableArray *logFilePaths = [NSMutableArray array];
|
|
616
|
-
|
|
617
|
-
//
|
|
618
|
-
NSArray *
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
NSError *error = [NSError errorWithDomain:@"CgmTrackyLib"
|
|
623
|
-
code:1002
|
|
624
|
-
userInfo:@{NSLocalizedDescriptionKey: @"Could not access Documents directory"}];
|
|
619
|
+
|
|
620
|
+
// Use the same base path strategy as getTrackLibDbPath
|
|
621
|
+
NSArray<NSURL *> *urls = [[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask];
|
|
622
|
+
NSURL *documentsURL = [urls lastObject];
|
|
623
|
+
if (documentsURL.path.length == 0) {
|
|
624
|
+
NSError *error = [NSError errorWithDomain:@"CgmTrackyLib" code:1002 userInfo:@{NSLocalizedDescriptionKey: @"Could not access Documents directory"}];
|
|
625
625
|
reject(@"ERROR_DOCUMENTS_DIR", @"Failed to get documents directory", error);
|
|
626
626
|
return;
|
|
627
627
|
}
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
NSArray *fileList = [fileManager contentsOfDirectoryAtPath:logFolderPath error:&error];
|
|
641
|
-
|
|
642
|
-
if (error) {
|
|
643
|
-
reject(@"ERROR_READ_DIRECTORY", @"Failed to read log directory", error);
|
|
644
|
-
return;
|
|
628
|
+
|
|
629
|
+
NSLog(@"CGM Documents path: %@", documentsURL.path);
|
|
630
|
+
|
|
631
|
+
// Ensure runLog directory exists (SDK may not create it before first write)
|
|
632
|
+
NSURL *logFolderURL = [documentsURL URLByAppendingPathComponent:@"runLog" isDirectory:YES];
|
|
633
|
+
NSFileManager *fm = [NSFileManager defaultManager];
|
|
634
|
+
BOOL isDir = NO;
|
|
635
|
+
if (![fm fileExistsAtPath:logFolderURL.path isDirectory:&isDir]) {
|
|
636
|
+
NSError *mkErr = nil;
|
|
637
|
+
[fm createDirectoryAtURL:logFolderURL withIntermediateDirectories:YES attributes:nil error:&mkErr];
|
|
638
|
+
if (mkErr) {
|
|
639
|
+
NSLog(@"CGM could not create runLog dir: %@", mkErr.localizedDescription);
|
|
645
640
|
}
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
NSLog(@"CGM runLog path: %@", logFolderURL.path);
|
|
644
|
+
|
|
645
|
+
// Use exactly what the SDK uses first: current runlog absolute path
|
|
646
|
+
KLTRunLog *current = [KLTAppDelegate getCurrentKLTRunLog];
|
|
647
|
+
NSString *currentPath = current.path; // absolute path the SDK writes to
|
|
648
|
+
NSLog(@"CGM current runlog path: %@", currentPath);
|
|
649
|
+
if (currentPath.length > 0) {
|
|
650
|
+
BOOL isDir3 = NO;
|
|
651
|
+
if ([fm fileExistsAtPath:currentPath isDirectory:&isDir3] && !isDir3) {
|
|
652
|
+
[logFilePaths addObject:currentPath];
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
// If current file isn’t there yet, list the runLog dir contents
|
|
657
|
+
if (logFilePaths.count == 0) {
|
|
658
|
+
NSError *dirErr = nil;
|
|
659
|
+
NSArray<NSString *> *runLogList = [fm contentsOfDirectoryAtPath:logFolderURL.path error:&dirErr];
|
|
660
|
+
if (dirErr) {
|
|
661
|
+
NSLog(@"CGM failed reading runLog dir: %@", dirErr.localizedDescription);
|
|
662
|
+
} else {
|
|
663
|
+
for (NSString *name in runLogList) {
|
|
664
|
+
NSString *fullPath = [logFolderURL.path stringByAppendingPathComponent:name];
|
|
665
|
+
BOOL isDirLocal = NO;
|
|
666
|
+
if ([fm fileExistsAtPath:fullPath isDirectory:&isDirLocal] && !isDirLocal) {
|
|
667
|
+
[logFilePaths addObject:fullPath];
|
|
668
|
+
}
|
|
652
669
|
}
|
|
653
670
|
}
|
|
654
671
|
}
|
|
655
|
-
|
|
656
|
-
NSLog(@"
|
|
672
|
+
|
|
673
|
+
NSLog(@"CGM runLog resolved %lu file(s)", (unsigned long)logFilePaths.count);
|
|
657
674
|
resolve(logFilePaths);
|
|
658
675
|
|
|
659
676
|
} @catch (NSException *exception) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_MyTatvaRnSdkView","_interopRequireDefault","require","_MyTatvaRnSdkView2","_reactNative","_CGMConnect","e","__esModule","default","MyTatvaRnSdkView","exports","Platform","select","ios","MyTatvaRnSdkViewIOS","android","MyTatvaRnSdkViewAndroid","_default","startCGM","initializeCGMEventListener","removeCGMEventListener","observeAllGlucoseDataHandler","reconnectCGM","helpCGM","observeTransmitterUnbindStatusHandler","observeResetLogoutHandler","getSqliteDBPath","getCgmLogFilePaths"],"sources":["index.js"],"sourcesContent":["import MyTatvaRnSdkViewAndroid from './MyTatvaRnSdkView.android';\nimport MyTatvaRnSdkViewIOS from './MyTatvaRnSdkView.ios';\nimport { Platform } from 'react-native';\nimport { startCGM, initializeCGMEventListener, removeCGMEventListener, observeAllGlucoseDataHandler, reconnectCGM, helpCGM, observeTransmitterUnbindStatusHandler, observeResetLogoutHandler, getSqliteDBPath, getCgmLogFilePaths } from './CGMConnect';\n// ... other imports\n\n// Export the platform-specific component\nexport const MyTatvaRnSdkView = Platform.select({\n ios: MyTatvaRnSdkViewIOS,\n android: MyTatvaRnSdkViewAndroid,\n});\n\n// Export individual functions\nexport {\n startCGM,\n initializeCGMEventListener,\n removeCGMEventListener,\n observeAllGlucoseDataHandler,\n reconnectCGM,\n helpCGM,\n observeTransmitterUnbindStatusHandler,\n observeResetLogoutHandler,\n getSqliteDBPath,\n getCgmLogFilePaths\n // ... other functions\n};\n\n// Export a default object with everything\nexport default {\n MyTatvaRnSdkView,\n startCGM,\n initializeCGMEventListener,\n removeCGMEventListener,\n observeAllGlucoseDataHandler,\n reconnectCGM,\n helpCGM,\n observeTransmitterUnbindStatusHandler,\n observeResetLogoutHandler,\n getSqliteDBPath,\n getCgmLogFilePaths
|
|
1
|
+
{"version":3,"names":["_MyTatvaRnSdkView","_interopRequireDefault","require","_MyTatvaRnSdkView2","_reactNative","_CGMConnect","e","__esModule","default","MyTatvaRnSdkView","exports","Platform","select","ios","MyTatvaRnSdkViewIOS","android","MyTatvaRnSdkViewAndroid","_default","startCGM","initializeCGMEventListener","removeCGMEventListener","observeAllGlucoseDataHandler","reconnectCGM","helpCGM","observeTransmitterUnbindStatusHandler","observeResetLogoutHandler","getSqliteDBPath","getCgmLogFilePaths"],"sources":["index.js"],"sourcesContent":["import MyTatvaRnSdkViewAndroid from './MyTatvaRnSdkView.android';\nimport MyTatvaRnSdkViewIOS from './MyTatvaRnSdkView.ios';\nimport { Platform } from 'react-native';\nimport { startCGM, initializeCGMEventListener, removeCGMEventListener, observeAllGlucoseDataHandler, reconnectCGM, helpCGM, observeTransmitterUnbindStatusHandler, observeResetLogoutHandler, getSqliteDBPath, getCgmLogFilePaths } from './CGMConnect';\n// ... other imports\n\n// Export the platform-specific component\nexport const MyTatvaRnSdkView = Platform.select({\n ios: MyTatvaRnSdkViewIOS,\n android: MyTatvaRnSdkViewAndroid,\n});\n\n// Export individual functions\nexport {\n startCGM,\n initializeCGMEventListener,\n removeCGMEventListener,\n observeAllGlucoseDataHandler,\n reconnectCGM,\n helpCGM,\n observeTransmitterUnbindStatusHandler,\n observeResetLogoutHandler,\n getSqliteDBPath,\n getCgmLogFilePaths\n // ... other functions\n};\n\n// Export a default object with everything\nexport default {\n MyTatvaRnSdkView,\n startCGM,\n initializeCGMEventListener,\n removeCGMEventListener,\n observeAllGlucoseDataHandler,\n reconnectCGM,\n helpCGM,\n observeTransmitterUnbindStatusHandler,\n observeResetLogoutHandler,\n getSqliteDBPath,\n getCgmLogFilePaths,\n};"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAAwP,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AACxP;;AAEA;AACO,MAAMG,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAGE,qBAAQ,CAACC,MAAM,CAAC;EAC9CC,GAAG,EAAEC,0BAAmB;EACxBC,OAAO,EAAEC;AACX,CAAC,CAAC;;AAEF;AAeA;AAAA,IAAAC,QAAA,GAAAP,OAAA,CAAAF,OAAA,GACe;EACbC,gBAAgB;EAChBS,QAAQ,EAARA,oBAAQ;EACRC,0BAA0B,EAA1BA,sCAA0B;EAC1BC,sBAAsB,EAAtBA,kCAAsB;EACtBC,4BAA4B,EAA5BA,wCAA4B;EAC5BC,YAAY,EAAZA,wBAAY;EACZC,OAAO,EAAPA,mBAAO;EACPC,qCAAqC,EAArCA,iDAAqC;EACrCC,yBAAyB,EAAzBA,qCAAyB;EACzBC,eAAe,EAAfA,2BAAe;EACfC,kBAAkB,EAAlBA;AACF,CAAC","ignoreList":[]}
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["MyTatvaRnSdkViewAndroid","MyTatvaRnSdkViewIOS","Platform","startCGM","initializeCGMEventListener","removeCGMEventListener","observeAllGlucoseDataHandler","reconnectCGM","helpCGM","observeTransmitterUnbindStatusHandler","observeResetLogoutHandler","getSqliteDBPath","getCgmLogFilePaths","MyTatvaRnSdkView","select","ios","android"],"sources":["index.js"],"sourcesContent":["import MyTatvaRnSdkViewAndroid from './MyTatvaRnSdkView.android';\nimport MyTatvaRnSdkViewIOS from './MyTatvaRnSdkView.ios';\nimport { Platform } from 'react-native';\nimport { startCGM, initializeCGMEventListener, removeCGMEventListener, observeAllGlucoseDataHandler, reconnectCGM, helpCGM, observeTransmitterUnbindStatusHandler, observeResetLogoutHandler, getSqliteDBPath, getCgmLogFilePaths } from './CGMConnect';\n// ... other imports\n\n// Export the platform-specific component\nexport const MyTatvaRnSdkView = Platform.select({\n ios: MyTatvaRnSdkViewIOS,\n android: MyTatvaRnSdkViewAndroid,\n});\n\n// Export individual functions\nexport {\n startCGM,\n initializeCGMEventListener,\n removeCGMEventListener,\n observeAllGlucoseDataHandler,\n reconnectCGM,\n helpCGM,\n observeTransmitterUnbindStatusHandler,\n observeResetLogoutHandler,\n getSqliteDBPath,\n getCgmLogFilePaths\n // ... other functions\n};\n\n// Export a default object with everything\nexport default {\n MyTatvaRnSdkView,\n startCGM,\n initializeCGMEventListener,\n removeCGMEventListener,\n observeAllGlucoseDataHandler,\n reconnectCGM,\n helpCGM,\n observeTransmitterUnbindStatusHandler,\n observeResetLogoutHandler,\n getSqliteDBPath,\n getCgmLogFilePaths
|
|
1
|
+
{"version":3,"names":["MyTatvaRnSdkViewAndroid","MyTatvaRnSdkViewIOS","Platform","startCGM","initializeCGMEventListener","removeCGMEventListener","observeAllGlucoseDataHandler","reconnectCGM","helpCGM","observeTransmitterUnbindStatusHandler","observeResetLogoutHandler","getSqliteDBPath","getCgmLogFilePaths","MyTatvaRnSdkView","select","ios","android"],"sources":["index.js"],"sourcesContent":["import MyTatvaRnSdkViewAndroid from './MyTatvaRnSdkView.android';\nimport MyTatvaRnSdkViewIOS from './MyTatvaRnSdkView.ios';\nimport { Platform } from 'react-native';\nimport { startCGM, initializeCGMEventListener, removeCGMEventListener, observeAllGlucoseDataHandler, reconnectCGM, helpCGM, observeTransmitterUnbindStatusHandler, observeResetLogoutHandler, getSqliteDBPath, getCgmLogFilePaths } from './CGMConnect';\n// ... other imports\n\n// Export the platform-specific component\nexport const MyTatvaRnSdkView = Platform.select({\n ios: MyTatvaRnSdkViewIOS,\n android: MyTatvaRnSdkViewAndroid,\n});\n\n// Export individual functions\nexport {\n startCGM,\n initializeCGMEventListener,\n removeCGMEventListener,\n observeAllGlucoseDataHandler,\n reconnectCGM,\n helpCGM,\n observeTransmitterUnbindStatusHandler,\n observeResetLogoutHandler,\n getSqliteDBPath,\n getCgmLogFilePaths\n // ... other functions\n};\n\n// Export a default object with everything\nexport default {\n MyTatvaRnSdkView,\n startCGM,\n initializeCGMEventListener,\n removeCGMEventListener,\n observeAllGlucoseDataHandler,\n reconnectCGM,\n helpCGM,\n observeTransmitterUnbindStatusHandler,\n observeResetLogoutHandler,\n getSqliteDBPath,\n getCgmLogFilePaths,\n};"],"mappings":"AAAA,OAAOA,uBAAuB,MAAM,4BAA4B;AAChE,OAAOC,mBAAmB,MAAM,wBAAwB;AACxD,SAASC,QAAQ,QAAQ,cAAc;AACvC,SAASC,QAAQ,EAAEC,0BAA0B,EAAEC,sBAAsB,EAAEC,4BAA4B,EAAEC,YAAY,EAAEC,OAAO,EAAEC,qCAAqC,EAAEC,yBAAyB,EAAEC,eAAe,EAAEC,kBAAkB,QAAQ,cAAc;AACvP;;AAEA;AACA,OAAO,MAAMC,gBAAgB,GAAGX,QAAQ,CAACY,MAAM,CAAC;EAC9CC,GAAG,EAAEd,mBAAmB;EACxBe,OAAO,EAAEhB;AACX,CAAC,CAAC;;AAEF;AACA,SACEG,QAAQ,EACRC,0BAA0B,EAC1BC,sBAAsB,EACtBC,4BAA4B,EAC5BC,YAAY,EACZC,OAAO,EACPC,qCAAqC,EACrCC,yBAAyB,EACzBC,eAAe,EACfC;AACA;AAAA;;AAGF;AACA,eAAe;EACbC,gBAAgB;EAChBV,QAAQ;EACRC,0BAA0B;EAC1BC,sBAAsB;EACtBC,4BAA4B;EAC5BC,YAAY;EACZC,OAAO;EACPC,qCAAqC;EACrCC,yBAAyB;EACzBC,eAAe;EACfC;AACF,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
package/src/index.js
CHANGED