react-native-mytatva-rn-sdk 1.2.52 → 1.2.53

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 (24) hide show
  1. package/android/src/main/java/com/mytatvarnsdk/CgmTrackyLibModule.kt +113 -73
  2. package/android/src/main/java/com/mytatvarnsdk/activity/ConnectSensorActivity.kt +1 -1
  3. package/android/src/main/java/com/mytatvarnsdk/activity/PermissionActivity.kt +1 -1
  4. package/android/src/main/java/com/mytatvarnsdk/activity/PlaceSensorActivity.kt +1 -1
  5. package/android/src/main/java/com/mytatvarnsdk/activity/PlaceTransmitterActivity.kt +1 -1
  6. package/android/src/main/java/com/mytatvarnsdk/activity/SearchTransmitterActivity.kt +3 -4
  7. package/android/src/main/java/com/mytatvarnsdk/activity/SensorConnectSuccessActivity.kt +8 -5
  8. package/android/src/main/java/com/mytatvarnsdk/activity/StartCGMActivity.kt +1 -1
  9. package/android/src/main/java/com/mytatvarnsdk/network/AuthenticateSDKService.kt +197 -197
  10. package/android/src/main/java/com/mytatvarnsdk/utils/TatvaEncryptionConfig.kt +1 -1
  11. package/ios/Database/KLTBluetoothManager.m +4 -0
  12. package/ios/Database/KLTDatabaseHandler.m +50 -103
  13. package/ios/Database/KLTLocalSettingManager.h +3 -0
  14. package/ios/MyReactNativeBridge.m +27 -15
  15. package/ios/Support/API.swift +8 -8
  16. package/ios/ViewControllers/AttachTransmitterViewController.swift +1 -1
  17. package/ios/ViewModel/FinalViewModel.swift +12 -15
  18. package/lib/commonjs/CGMConnect.js +12 -12
  19. package/lib/commonjs/CGMConnect.js.map +1 -1
  20. package/lib/module/CGMConnect.js +12 -12
  21. package/lib/module/CGMConnect.js.map +1 -1
  22. package/lib/typescript/CGMConnect.d.ts +5 -5
  23. package/package.json +2 -2
  24. package/src/CGMConnect.ts +26 -12
@@ -23,207 +23,207 @@ import okhttp3.RequestBody.Companion.toRequestBody
23
23
  class AuthenticateSDKService(val scope: CoroutineScope) {
24
24
 
25
25
 
26
- fun postCGMData(
27
- environment: TATVA_ENVIRONMENT,
28
- data: String,
29
- token: String,
30
- responseListener: ResponseListener
31
- ) {
32
- scope.launch {
33
- try {
34
-
35
- val apiServiceInterface = RetrofitInstance.getRetroInstance().create(
36
- ApiServiceInterface::class.java
37
- )
38
-
39
- val encryptionKey = getEncryptionKey(
40
- env = TATVA_ENVIRONMENT.PROD,
41
- prodEncKey = PROD_ENC_KEY,
42
- stagEncKey = STAGE_ENC_KEY
43
- )
44
-
45
- val encryptionIv = getEncryptionIv(
46
- env = TATVA_ENVIRONMENT.PROD, prodEncIv = PROD_ENC_IV, stagEncIv = STAGE_ENC_IV
47
- )
48
-
49
- Log.d("API Response", "data: $data")
50
-
51
- val encryptedString = getEncryptedText(
52
- data = data,
53
- encryptionKey = encryptionKey,
54
- encryptionIv = encryptionIv
55
- )
56
-
57
- Log.d("API Response", "encryptedString: $encryptedString")
58
-
59
- val decryptedString = getDecryptedData(
60
- cipherText = encryptedString,
61
- encryptionKey = encryptionKey,
62
- encryptionIv = encryptionIv
63
- )
64
-
65
- Log.d("API Response", "decryptedString: $decryptedString")
66
-
67
- val headers = mapOf(
68
- "api-key" to if (environment == TATVA_ENVIRONMENT.PROD) PROD_API_KEY else STAGE_API_KEY,
69
- "token" to token,
70
- "Content-Type" to "text/plain"
71
- )
72
-
73
- val url =
74
- "${if (environment == TATVA_ENVIRONMENT.PROD) PROD_BASE_URL else STAGE_BASE_URL}/cgm/logs"
75
-
76
- val requestBody = encryptedString.toRequestBody("text/plain".toMediaType())
77
-
78
- val response = apiServiceInterface.postCgmLogs(url, headers, requestBody).string()
79
-
80
- val decryptedResponse = getDecryptedData(
81
- cipherText = response.toString(),
82
- encryptionKey = encryptionKey,
83
- encryptionIv = encryptionIv
84
- )
85
-
86
- Log.d("API Response", "API response: $decryptedResponse")
87
-
88
- responseListener.onResponseSuccess(response)
89
- } catch (e: Exception) {
90
- responseListener.onResponseFail()
91
- e.printStackTrace()
92
- Log.d("API Response", "Exception: ${e.message}")
93
- }
26
+ fun postCGMData(
27
+ environment: TATVA_ENVIRONMENT,
28
+ data: String,
29
+ token: String,
30
+ responseListener: ResponseListener
31
+ ) {
32
+ scope.launch {
33
+ try {
34
+
35
+ val apiServiceInterface = RetrofitInstance.getRetroInstance().create(
36
+ ApiServiceInterface::class.java
37
+ )
38
+
39
+ val encryptionKey = getEncryptionKey(
40
+ env = TATVA_ENVIRONMENT.PROD,
41
+ prodEncKey = PROD_ENC_KEY,
42
+ stagEncKey = STAGE_ENC_KEY
43
+ )
44
+
45
+ val encryptionIv = getEncryptionIv(
46
+ env = TATVA_ENVIRONMENT.PROD, prodEncIv = PROD_ENC_IV, stagEncIv = STAGE_ENC_IV
47
+ )
48
+
49
+ Log.d("API Response", "data: $data")
50
+
51
+ val encryptedString = getEncryptedText(
52
+ data = data,
53
+ encryptionKey = encryptionKey,
54
+ encryptionIv = encryptionIv
55
+ )
56
+
57
+ Log.d("API Response", "encryptedString: $encryptedString")
58
+
59
+ val decryptedString = getDecryptedData(
60
+ cipherText = encryptedString,
61
+ encryptionKey = encryptionKey,
62
+ encryptionIv = encryptionIv
63
+ )
64
+
65
+ Log.d("API Response", "decryptedString: $decryptedString")
66
+
67
+ val headers = mapOf(
68
+ "api-key" to if (environment == TATVA_ENVIRONMENT.PROD) PROD_API_KEY else STAGE_API_KEY,
69
+ "token" to token,
70
+ "Content-Type" to "text/plain"
71
+ )
72
+
73
+ val url =
74
+ "${if (environment == TATVA_ENVIRONMENT.PROD) PROD_BASE_URL else STAGE_BASE_URL}/cgm/logs"
75
+
76
+ val requestBody = encryptedString.toRequestBody("text/plain".toMediaType())
77
+
78
+ val response = apiServiceInterface.postCgmLogs(url, headers, requestBody).string()
79
+
80
+ val decryptedResponse = getDecryptedData(
81
+ cipherText = response.toString(),
82
+ encryptionKey = encryptionKey,
83
+ encryptionIv = encryptionIv
84
+ )
85
+
86
+ Log.d("API Response", "API response: $decryptedResponse")
87
+
88
+ responseListener.onResponseSuccess(response)
89
+ } catch (e: Exception) {
90
+ responseListener.onResponseFail()
91
+ e.printStackTrace()
92
+ Log.d("API Response", "Exception: ${e.message}")
93
+ }
94
+ }
94
95
  }
95
- }
96
-
97
-
98
- fun postDeviceData(
99
- environment: TATVA_ENVIRONMENT,
100
- data: String,
101
- token: String,
102
- loaderListener: LoaderListener
103
- ) {
104
- scope.launch {
105
- try {
106
- loaderListener.onShowLoader()
107
-
108
- val apiServiceInterface = RetrofitInstance.getRetroInstance().create(
109
- ApiServiceInterface::class.java
110
- )
111
-
112
- val encryptionKey = getEncryptionKey(
113
- env = TATVA_ENVIRONMENT.PROD,
114
- prodEncKey = PROD_ENC_KEY,
115
- stagEncKey = STAGE_ENC_KEY
116
- )
117
-
118
- val encryptionIv = getEncryptionIv(
119
- env = TATVA_ENVIRONMENT.PROD, prodEncIv = PROD_ENC_IV, stagEncIv = STAGE_ENC_IV
120
- )
121
-
122
- Log.d("API Response", "data: $data")
123
-
124
- val encryptedString = getEncryptedText(
125
- data = data,
126
- encryptionKey = encryptionKey,
127
- encryptionIv = encryptionIv
128
- )
129
-
130
- Log.d("API Response", "encryptedString: $encryptedString")
131
-
132
- val decryptedString = getDecryptedData(
133
- cipherText = encryptedString,
134
- encryptionKey = encryptionKey,
135
- encryptionIv = encryptionIv
136
- )
137
-
138
- Log.d("API Response", "decryptedString: $decryptedString")
139
-
140
- val headers = mapOf(
141
- "api-key" to if (environment == TATVA_ENVIRONMENT.PROD) PROD_API_KEY else STAGE_API_KEY,
142
- "token" to token,
143
- "Content-Type" to "text/plain"
144
- )
145
-
146
- val url =
147
- "${if (environment == TATVA_ENVIRONMENT.PROD) PROD_BASE_URL else STAGE_BASE_URL}/cgm/connection"
148
-
149
- val requestBody = encryptedString.toRequestBody("text/plain".toMediaType())
150
-
151
- val response = apiServiceInterface.postCgmLogs(url, headers, requestBody).string()
152
-
153
- val decryptedResponse = getDecryptedData(
154
- cipherText = response.toString(),
155
- encryptionKey = encryptionKey,
156
- encryptionIv = encryptionIv
157
- )
158
-
159
- Log.d("API Response", "API response: $decryptedResponse")
160
-
161
- } catch (e: Exception) {
162
- e.printStackTrace()
163
- Log.d("API Response", "Exception: ${e.message}")
164
- } finally {
165
- loaderListener.onHideLoader()
166
- }
96
+
97
+
98
+ fun postDeviceData(
99
+ environment: TATVA_ENVIRONMENT,
100
+ data: String,
101
+ token: String,
102
+ loaderListener: LoaderListener
103
+ ) {
104
+ scope.launch {
105
+ try {
106
+ loaderListener.onShowLoader()
107
+
108
+ val apiServiceInterface = RetrofitInstance.getRetroInstance().create(
109
+ ApiServiceInterface::class.java
110
+ )
111
+
112
+ val encryptionKey = getEncryptionKey(
113
+ env = TATVA_ENVIRONMENT.PROD,
114
+ prodEncKey = PROD_ENC_KEY,
115
+ stagEncKey = STAGE_ENC_KEY
116
+ )
117
+
118
+ val encryptionIv = getEncryptionIv(
119
+ env = TATVA_ENVIRONMENT.PROD, prodEncIv = PROD_ENC_IV, stagEncIv = STAGE_ENC_IV
120
+ )
121
+
122
+ Log.d("API Response", "data: $data")
123
+
124
+ val encryptedString = getEncryptedText(
125
+ data = data,
126
+ encryptionKey = encryptionKey,
127
+ encryptionIv = encryptionIv
128
+ )
129
+
130
+ Log.d("API Response", "encryptedString: $encryptedString")
131
+
132
+ val decryptedString = getDecryptedData(
133
+ cipherText = encryptedString,
134
+ encryptionKey = encryptionKey,
135
+ encryptionIv = encryptionIv
136
+ )
137
+
138
+ Log.d("API Response", "decryptedString: $decryptedString")
139
+
140
+ val headers = mapOf(
141
+ "api-key" to if (environment == TATVA_ENVIRONMENT.PROD) PROD_API_KEY else STAGE_API_KEY,
142
+ "token" to token,
143
+ "Content-Type" to "text/plain"
144
+ )
145
+
146
+ val url =
147
+ "${if (environment == TATVA_ENVIRONMENT.PROD) PROD_BASE_URL else STAGE_BASE_URL}/cgm/connection"
148
+
149
+ val requestBody = encryptedString.toRequestBody("text/plain".toMediaType())
150
+
151
+ val response = apiServiceInterface.postCgmLogs(url, headers, requestBody).string()
152
+
153
+ val decryptedResponse = getDecryptedData(
154
+ cipherText = response.toString(),
155
+ encryptionKey = encryptionKey,
156
+ encryptionIv = encryptionIv
157
+ )
158
+
159
+ Log.d("API Response", "API response: $decryptedResponse")
160
+
161
+ } catch (e: Exception) {
162
+ e.printStackTrace()
163
+ Log.d("API Response", "Exception: ${e.message}")
164
+ } finally {
165
+ loaderListener.onHideLoader()
166
+ }
167
+ }
167
168
  }
168
- }
169
-
170
- fun getCGMData(
171
- environment: TATVA_ENVIRONMENT,
172
- token: String,
173
- responseListener: ResponseListener
174
- ) {
175
- scope.launch {
176
- try {
177
-
178
- val apiServiceInterface = RetrofitInstance.getRetroInstance().create(
179
- ApiServiceInterface::class.java
180
- )
181
-
182
- val encryptionKey = getEncryptionKey(
183
- env = TATVA_ENVIRONMENT.PROD,
184
- prodEncKey = PROD_ENC_KEY,
185
- stagEncKey = STAGE_ENC_KEY
186
- )
187
-
188
- val encryptionIv = getEncryptionIv(
189
- env = TATVA_ENVIRONMENT.PROD, prodEncIv = PROD_ENC_IV, stagEncIv = STAGE_ENC_IV
190
- )
191
-
192
- val headers = mapOf(
193
- "api-key" to if (environment == TATVA_ENVIRONMENT.PROD) PROD_API_KEY else STAGE_API_KEY,
194
- "token" to token
195
- )
196
-
197
- val url =
198
- "${if (environment == TATVA_ENVIRONMENT.PROD) PROD_BASE_URL else STAGE_BASE_URL}/cgm/status"
199
-
200
- val response = apiServiceInterface.getCgmStatus(url, headers).string()
201
-
202
- val decryptedResponse = getDecryptedData(
203
- cipherText = response.toString(),
204
- encryptionKey = encryptionKey,
205
- encryptionIv = encryptionIv
206
- )
207
-
208
- Log.d("API Response", "API Response: $decryptedResponse")
209
-
210
- responseListener.onResponseSuccess(decryptedResponse)
211
- } catch (e: Exception) {
212
- responseListener.onResponseFail()
213
- e.printStackTrace()
214
- Log.d("API Response", "Exception: ${e.message}")
215
- }
169
+
170
+ fun getCGMData(
171
+ environment: TATVA_ENVIRONMENT,
172
+ token: String,
173
+ responseListener: ResponseListener
174
+ ) {
175
+ scope.launch {
176
+ try {
177
+
178
+ val apiServiceInterface = RetrofitInstance.getRetroInstance().create(
179
+ ApiServiceInterface::class.java
180
+ )
181
+
182
+ val encryptionKey = getEncryptionKey(
183
+ env = TATVA_ENVIRONMENT.PROD,
184
+ prodEncKey = PROD_ENC_KEY,
185
+ stagEncKey = STAGE_ENC_KEY
186
+ )
187
+
188
+ val encryptionIv = getEncryptionIv(
189
+ env = TATVA_ENVIRONMENT.PROD, prodEncIv = PROD_ENC_IV, stagEncIv = STAGE_ENC_IV
190
+ )
191
+
192
+ val headers = mapOf(
193
+ "api-key" to if (environment == TATVA_ENVIRONMENT.PROD) PROD_API_KEY else STAGE_API_KEY,
194
+ "token" to token
195
+ )
196
+
197
+ val url =
198
+ "${if (environment == TATVA_ENVIRONMENT.PROD) PROD_BASE_URL else STAGE_BASE_URL}/cgm/status"
199
+
200
+ val response = apiServiceInterface.getCgmStatus(url, headers).string()
201
+
202
+ val decryptedResponse = getDecryptedData(
203
+ cipherText = response.toString(),
204
+ encryptionKey = encryptionKey,
205
+ encryptionIv = encryptionIv
206
+ )
207
+
208
+ Log.d("API Response", "API Response: $decryptedResponse")
209
+
210
+ responseListener.onResponseSuccess(decryptedResponse)
211
+ } catch (e: Exception) {
212
+ responseListener.onResponseFail()
213
+ e.printStackTrace()
214
+ Log.d("API Response", "Exception: ${e.message}")
215
+ }
216
+ }
216
217
  }
217
- }
218
218
 
219
- interface LoaderListener {
220
- fun onShowLoader()
221
- fun onHideLoader()
222
- }
219
+ interface LoaderListener {
220
+ fun onShowLoader()
221
+ fun onHideLoader()
222
+ }
223
223
 
224
- interface ResponseListener {
225
- fun onResponseSuccess(response: String)
226
- fun onResponseFail()
227
- }
224
+ interface ResponseListener {
225
+ fun onResponseSuccess(response: String)
226
+ fun onResponseFail()
227
+ }
228
228
 
229
229
  }
@@ -1,7 +1,7 @@
1
1
  package com.mytatvarnsdk.utils
2
2
 
3
3
  object TatvaEncryptionConfig {
4
- const val STAGE_BASE_URL = "https://api-feature2.mytatva.in/api/v8"
4
+ const val STAGE_BASE_URL = "https://api-uat.mytatva.in/api/v8"
5
5
  const val PROD_BASE_URL = "https://api.mytatva.in/api/v8"
6
6
 
7
7
  const val PROD_ENC_KEY = "9Ddyaf6rfywpiTvTiax2iq6ykKpaxgJ6"
@@ -298,6 +298,7 @@
298
298
 
299
299
  if ([command isEqualToString:@"22"]) {
300
300
  // CT4重传的数据,pullGlucose_series_request 0x22的返回
301
+ //CT4 retransmission data returned by the pullGlucose_series_request (0x22) command
301
302
  [self handleResendDataWithPrefix22:characteristic.value];
302
303
  }
303
304
 
@@ -347,6 +348,7 @@
347
348
 
348
349
  if ([command isEqualToString:@"07"]) {
349
350
  // CT3/CT4 每3分钟上来的数据
351
+ //Data uploaded every 3 minutes from CT3/CT4
350
352
  [self handleReceiveDataWithPrefix07:characteristic.value];
351
353
  }
352
354
 
@@ -409,6 +411,7 @@
409
411
  self.resendType = ResendDataBeforeSetUserBG;
410
412
 
411
413
  //初始化期间接收到的数据存数据库的ReceiveData表中,不做处理
414
+ //The data received during initialization is stored in the ReceiveData table in the database without any processing.
412
415
  [[KLTDatabaseHandler shared] updatePOCAlgoBeforeRef:receiveData];
413
416
  KLTLog(@"计算receive.gluADC = %@, receive.error = %@", receiveData.gluADC, receiveData.error);
414
417
  if (!self.isInResend) {
@@ -468,6 +471,7 @@
468
471
  }
469
472
 
470
473
  // CT3/CT4 每3分钟上来的数据
474
+ //Data uploaded every 3 minutes from CT3/CT4
471
475
  - (void)handleReceiveDataWithPrefix07:(NSData *)receiveData {
472
476
  if (self.status == BluetoothManagerStatusResendStart || self.isInResend) {
473
477
  // 重发数据期间不处理新收到的数据