react-native-mytatva-rn-sdk 1.2.20 → 1.2.22
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/activity/ConnectSensorActivity.kt +300 -247
- package/android/src/main/java/com/mytatvarnsdk/activity/SearchTransmitterActivity.kt +371 -427
- package/ios/MyReactNativeBridge.m +7 -1
- package/ios/Support/API.swift +4 -3
- package/ios/Support/EnumDebouncer.swift +1 -0
- package/ios/ViewControllers/ConnectToSensorViewController.swift +50 -38
- package/ios/ViewControllers/ConnectToTransmitterViewController.swift +46 -49
- package/ios/ViewModel/FinalViewModel.swift +17 -11
- package/lib/commonjs/CGMConnect.js +9 -4
- package/lib/commonjs/CGMConnect.js.map +1 -1
- package/lib/module/CGMConnect.js +9 -4
- package/lib/module/CGMConnect.js.map +1 -1
- package/package.json +1 -1
- package/src/CGMConnect.ts +18 -12
- package/ios/Support/BluetoothManager.swift +0 -472
|
@@ -117,8 +117,14 @@ RCT_EXPORT_METHOD(reconnectCgmTracky:(NSString *)token)
|
|
|
117
117
|
[reconnectVC setValue:@(YES) forKey:@"isForReconnect"];
|
|
118
118
|
}
|
|
119
119
|
// Present it directly without navigation
|
|
120
|
+
// if (reconnectVC) {
|
|
121
|
+
// [rootVC presentViewController:reconnectVC animated:YES completion:nil];
|
|
122
|
+
// }
|
|
123
|
+
|
|
124
|
+
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:reconnectVC];
|
|
125
|
+
navController.modalPresentationStyle = UIModalPresentationOverFullScreen;
|
|
120
126
|
if (reconnectVC) {
|
|
121
|
-
[rootVC presentViewController:
|
|
127
|
+
[rootVC presentViewController:navController animated:YES completion:nil];
|
|
122
128
|
}
|
|
123
129
|
});
|
|
124
130
|
}
|
package/ios/Support/API.swift
CHANGED
|
@@ -278,9 +278,10 @@ class API {
|
|
|
278
278
|
|
|
279
279
|
if self.isCurrentDateInRange(startDate: startDateStr, endDate: endDateStr) {
|
|
280
280
|
print("Current date is in range")
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
281
|
+
|
|
282
|
+
//if KLTBluetoothManager.shared().currentDevice.initialEndDate != nil {
|
|
283
|
+
//self.sendStatus(status: .transmitterDisconnect)
|
|
284
|
+
// }
|
|
284
285
|
}
|
|
285
286
|
}
|
|
286
287
|
}
|
|
@@ -18,6 +18,7 @@ class EnumDebouncer<T: Equatable> {
|
|
|
18
18
|
func update(with newValue: T) {
|
|
19
19
|
if storedValue == nil || storedValue != newValue {
|
|
20
20
|
reset(newValue: newValue)
|
|
21
|
+
onDebounceSuccess?(newValue)
|
|
21
22
|
} else if let startTime = startTime {
|
|
22
23
|
let elapsed = Date().timeIntervalSince(startTime)
|
|
23
24
|
if elapsed >= debounceInterval {
|
|
@@ -36,14 +36,15 @@ class ConnectToSensorViewController: UIViewController {
|
|
|
36
36
|
case image
|
|
37
37
|
case watchVideo
|
|
38
38
|
}
|
|
39
|
-
|
|
39
|
+
|
|
40
40
|
enum enumScreenType {
|
|
41
41
|
case camera
|
|
42
42
|
case success
|
|
43
43
|
case error
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
|
|
46
|
+
var isFromReconnect: Bool = false
|
|
47
|
+
var connectedTime: Date?
|
|
47
48
|
var connected:(()->())?
|
|
48
49
|
var screenType: enumScreenType = .camera
|
|
49
50
|
var isCodeDetected = false
|
|
@@ -58,7 +59,7 @@ class ConnectToSensorViewController: UIViewController {
|
|
|
58
59
|
|
|
59
60
|
func setupLayout() {
|
|
60
61
|
manager?.addObserver(self, forKeyPath: "status", options: [.new], context: nil)
|
|
61
|
-
|
|
62
|
+
|
|
62
63
|
|
|
63
64
|
tableView.delegate = self
|
|
64
65
|
tableView.dataSource = self
|
|
@@ -87,7 +88,7 @@ class ConnectToSensorViewController: UIViewController {
|
|
|
87
88
|
let vc = PutOnTheSensorViewController.instantiate(fromStoryboard: Enum_stroyboard.Main.rawValue)
|
|
88
89
|
self.navigationController?.pushViewController(vc, animated: false)
|
|
89
90
|
}
|
|
90
|
-
|
|
91
|
+
|
|
91
92
|
customTopView.onCloseTapped = {
|
|
92
93
|
let vc = ExitJourneyViewController.instantiate(fromStoryboard: Enum_stroyboard.Main.rawValue)
|
|
93
94
|
vc.modalPresentationStyle = .overFullScreen
|
|
@@ -103,7 +104,7 @@ class ConnectToSensorViewController: UIViewController {
|
|
|
103
104
|
|
|
104
105
|
func checkCameraPermission() {
|
|
105
106
|
let status = AVCaptureDevice.authorizationStatus(for: .video)
|
|
106
|
-
|
|
107
|
+
|
|
107
108
|
switch status {
|
|
108
109
|
case .authorized:
|
|
109
110
|
self.isPermissionGiven = true
|
|
@@ -146,7 +147,7 @@ class ConnectToSensorViewController: UIViewController {
|
|
|
146
147
|
UIApplication.shared.open(settingsURL)
|
|
147
148
|
}
|
|
148
149
|
})
|
|
149
|
-
|
|
150
|
+
|
|
150
151
|
DispatchQueue.main.async {
|
|
151
152
|
self.present(alert, animated: true)
|
|
152
153
|
}
|
|
@@ -155,10 +156,10 @@ class ConnectToSensorViewController: UIViewController {
|
|
|
155
156
|
func connectSensor(value: String, controller: ConnectToSensorViewController) {
|
|
156
157
|
UserDefaults.standard.set(value, forKey: "sensorId")
|
|
157
158
|
var isMatch = false
|
|
158
|
-
|
|
159
|
+
|
|
159
160
|
var regex = #"^[A-Z0-9][0-9](0[1-9]|[1-9][0-9]|[A-Z][1-9A-Z])(00[1-9]|0[1-9][0-9]|[1-9][0-9][0-9]){2}[0-9]{4,5}[0-9A-Z]{3}$"#
|
|
160
161
|
var predicate = NSPredicate(format: "SELF MATCHES %@", regex)
|
|
161
|
-
|
|
162
|
+
|
|
162
163
|
if predicate.evaluate(with: value) {
|
|
163
164
|
isMatch = true
|
|
164
165
|
} else {
|
|
@@ -168,10 +169,10 @@ class ConnectToSensorViewController: UIViewController {
|
|
|
168
169
|
isMatch = true
|
|
169
170
|
}
|
|
170
171
|
}
|
|
171
|
-
|
|
172
|
+
|
|
172
173
|
if isMatch {
|
|
173
174
|
let data = AlgorithmTools.decodeCT(value)
|
|
174
|
-
|
|
175
|
+
|
|
175
176
|
if data.k > 0 || data.r > 0 {
|
|
176
177
|
//KLTLocalSettingManager.shareInstance.deviceInfoSensor = value
|
|
177
178
|
UserDefaults.standard.set(data.k, forKey: "algo_k")
|
|
@@ -184,17 +185,17 @@ class ConnectToSensorViewController: UIViewController {
|
|
|
184
185
|
return
|
|
185
186
|
}
|
|
186
187
|
}
|
|
187
|
-
|
|
188
|
+
|
|
188
189
|
//controller.resumeScanning()
|
|
189
190
|
}
|
|
190
191
|
func connectThisSensor() {
|
|
191
192
|
// Connect the transmitter
|
|
192
193
|
manager?.connectPeripheral(manager?.readyToConnectedPeripheral)
|
|
193
194
|
}
|
|
194
|
-
|
|
195
|
+
|
|
195
196
|
func showConfirmInsulinUser() {
|
|
196
197
|
let typeOfDiabetes = UserDefaults.standard.object(forKey: "profilePatientType") as? NSNumber
|
|
197
|
-
|
|
198
|
+
|
|
198
199
|
if let diabetesType = typeOfDiabetes {
|
|
199
200
|
// LocalizedString(@"user_diabete_no") index is 0
|
|
200
201
|
if diabetesType.intValue == 0 {
|
|
@@ -208,9 +209,9 @@ class ConnectToSensorViewController: UIViewController {
|
|
|
208
209
|
// Not selected
|
|
209
210
|
UserDefaults.standard.set(0, forKey: "algo_user_type")
|
|
210
211
|
}
|
|
211
|
-
|
|
212
|
+
|
|
212
213
|
UserDefaults.standard.synchronize() // Optional, rarely needed in modern iOS
|
|
213
|
-
|
|
214
|
+
|
|
214
215
|
connectThisSensor()
|
|
215
216
|
}
|
|
216
217
|
override func observeValue(forKeyPath keyPath: String?,
|
|
@@ -221,16 +222,27 @@ class ConnectToSensorViewController: UIViewController {
|
|
|
221
222
|
if let newValue = change?[.newKey] as? Int {
|
|
222
223
|
//let btStatus = newValue
|
|
223
224
|
let btStatus: BluetoothManagerStatus = BluetoothManagerStatus(rawValue: newValue) ?? .scanStart
|
|
224
|
-
|
|
225
|
+
|
|
225
226
|
if btStatus == .initialStart {
|
|
226
|
-
|
|
227
|
+
self.connectedTime = Date()
|
|
227
228
|
print("Success")
|
|
228
229
|
screenType = .success
|
|
229
230
|
tableView.reloadData()
|
|
230
231
|
bottomButton.enable()
|
|
232
|
+
if self.isFromReconnect {
|
|
233
|
+
let _ = FinalViewModelManager.shared
|
|
234
|
+
NotificationCenter.default.post(name: Notification.Name("cgmDeviceEvent"), object: nil, userInfo: ["a":"a"])
|
|
235
|
+
if let rootVC = UIApplication.shared.connectedScenes
|
|
236
|
+
.compactMap({ ($0 as? UIWindowScene)?.windows.first?.rootViewController })
|
|
237
|
+
.first {
|
|
238
|
+
rootVC.dismiss(animated: true, completion: nil)
|
|
239
|
+
} else if let rootViewController = UIApplication.shared.keyWindow?.rootViewController {
|
|
240
|
+
rootViewController.dismiss(animated: true, completion: nil)
|
|
241
|
+
}
|
|
242
|
+
}
|
|
231
243
|
} else if btStatus == .closed || btStatus == .modifyVoltageFailed {
|
|
232
244
|
// Handle failed or closed status
|
|
233
|
-
|
|
245
|
+
|
|
234
246
|
navigationController?.popToRootViewController(animated: true)
|
|
235
247
|
}
|
|
236
248
|
}
|
|
@@ -238,7 +250,7 @@ class ConnectToSensorViewController: UIViewController {
|
|
|
238
250
|
if let playerItem = object as? AVPlayerItem {
|
|
239
251
|
if playerItem.status == .readyToPlay {
|
|
240
252
|
if UserDefaults.standard.integer(forKey: "bgmode") == 0 {
|
|
241
|
-
|
|
253
|
+
// player?.play()
|
|
242
254
|
}
|
|
243
255
|
}
|
|
244
256
|
}
|
|
@@ -246,7 +258,7 @@ class ConnectToSensorViewController: UIViewController {
|
|
|
246
258
|
super.observeValue(forKeyPath: keyPath, of: object, change: change, context: context)
|
|
247
259
|
}
|
|
248
260
|
}
|
|
249
|
-
|
|
261
|
+
|
|
250
262
|
}
|
|
251
263
|
|
|
252
264
|
extension ConnectToSensorViewController: UITableViewDelegate, UITableViewDataSource {
|
|
@@ -330,24 +342,24 @@ extension ConnectToSensorViewController: UITableViewDelegate, UITableViewDataSou
|
|
|
330
342
|
return cell
|
|
331
343
|
}
|
|
332
344
|
case .success:
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
+
switch enumSuccessTableRow(rawValue: indexPath.row)! {
|
|
346
|
+
case .success:
|
|
347
|
+
let cell: ConnectSuccessTVC = tableView.dequeueReusableCell(for: indexPath)
|
|
348
|
+
let dateFormatter = DateFormatter()
|
|
349
|
+
dateFormatter.dateFormat = "dd-MM-yyyy hh:mm a"
|
|
350
|
+
dateFormatter.timeZone = TimeZone.current
|
|
351
|
+
if let connectedTime = connectedTime {
|
|
352
|
+
// Convert the Date to a String
|
|
353
|
+
let dateString = dateFormatter.string(from: connectedTime)
|
|
354
|
+
cell.labelDate.text = "Connected on \(String(describing: dateString))"
|
|
355
|
+
} else {
|
|
356
|
+
cell.labelDate.text = ""
|
|
357
|
+
}
|
|
358
|
+
cell.labelDesc.isHidden = true
|
|
359
|
+
cell.labelTitle.text = "Sensor Connected Successfully"
|
|
360
|
+
cell.setImageForCGM()
|
|
361
|
+
return cell
|
|
345
362
|
}
|
|
346
|
-
cell.labelDesc.isHidden = true
|
|
347
|
-
cell.labelTitle.text = "Sensor Connected Successfully"
|
|
348
|
-
cell.setImageForCGM()
|
|
349
|
-
return cell
|
|
350
|
-
}
|
|
351
363
|
case .error:
|
|
352
364
|
switch enumFailureTableRow(rawValue: indexPath.row)! {
|
|
353
365
|
case .failAnimation:
|
|
@@ -95,14 +95,20 @@ class ConnectToTransmitterViewController: UIViewController, KLTBluetoothDelegate
|
|
|
95
95
|
}
|
|
96
96
|
bottomButton.buttonTapCallback = {
|
|
97
97
|
if self.isForReconnect {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
.
|
|
101
|
-
.first {
|
|
102
|
-
rootVC.dismiss(animated: true, completion: nil)
|
|
103
|
-
} else if let rootViewController = UIApplication.shared.keyWindow?.rootViewController {
|
|
104
|
-
rootViewController.dismiss(animated: true, completion: nil)
|
|
98
|
+
let vc = ConnectToSensorViewController.instantiate(fromStoryboard: Enum_stroyboard.Main.rawValue)
|
|
99
|
+
vc.connected = {
|
|
100
|
+
//self.showConfirmInsulinUser()
|
|
105
101
|
}
|
|
102
|
+
vc.isFromReconnect = true
|
|
103
|
+
self.navigationController?.pushViewController(vc, animated: false)
|
|
104
|
+
// NotificationCenter.default.post(name: Notification.Name("cgmDeviceEvent"), object: nil, userInfo: ["a":"a"])
|
|
105
|
+
// if let rootVC = UIApplication.shared.connectedScenes
|
|
106
|
+
// .compactMap({ ($0 as? UIWindowScene)?.windows.first?.rootViewController })
|
|
107
|
+
// .first {
|
|
108
|
+
// rootVC.dismiss(animated: true, completion: nil)
|
|
109
|
+
// } else if let rootViewController = UIApplication.shared.keyWindow?.rootViewController {
|
|
110
|
+
// rootViewController.dismiss(animated: true, completion: nil)
|
|
111
|
+
// }
|
|
106
112
|
} else {
|
|
107
113
|
if self.screenType == .error {
|
|
108
114
|
self.bottomButton.disable()
|
|
@@ -130,9 +136,9 @@ class ConnectToTransmitterViewController: UIViewController, KLTBluetoothDelegate
|
|
|
130
136
|
}
|
|
131
137
|
|
|
132
138
|
if isForReconnect {
|
|
133
|
-
customTopView.showOnlyClose()
|
|
134
|
-
customStepProgressBar.isHidden = true
|
|
135
|
-
customStepProgressHeightConstraint.constant = 0
|
|
139
|
+
//customTopView.showOnlyClose()
|
|
140
|
+
//customStepProgressBar.isHidden = true
|
|
141
|
+
//customStepProgressHeightConstraint.constant = 0
|
|
136
142
|
bottomButton.labelText = "Complete"
|
|
137
143
|
bottomButton.showRightArrow()
|
|
138
144
|
|
|
@@ -176,6 +182,20 @@ class ConnectToTransmitterViewController: UIViewController, KLTBluetoothDelegate
|
|
|
176
182
|
super.observeValue(forKeyPath: keyPath, of: object, change: change, context: context)
|
|
177
183
|
}
|
|
178
184
|
}
|
|
185
|
+
|
|
186
|
+
func sensorForceEnd() {
|
|
187
|
+
if let manager = manager {
|
|
188
|
+
if ((manager.connectedPeripheral) != nil) {
|
|
189
|
+
if (manager.status == .resendEnd || manager.status == .getGLU || manager.status == .initialStart) {
|
|
190
|
+
manager.closeBleSensor()
|
|
191
|
+
}
|
|
192
|
+
} else {
|
|
193
|
+
if (manager.currentDevice != nil) {
|
|
194
|
+
manager.forceEndBleSensor()
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
179
199
|
}
|
|
180
200
|
|
|
181
201
|
extension ConnectToTransmitterViewController: UITableViewDelegate, UITableViewDataSource {
|
|
@@ -270,22 +290,27 @@ extension ConnectToTransmitterViewController: UITableViewDelegate, UITableViewDa
|
|
|
270
290
|
|
|
271
291
|
//cell.labelDesc.text = "Sno:\(devices[indexPath.row].name)"
|
|
272
292
|
cell.button.buttonTapCallback = {
|
|
293
|
+
if self.isForReconnect {
|
|
294
|
+
self.sensorForceEnd()
|
|
295
|
+
}
|
|
296
|
+
|
|
273
297
|
if !KLTLocalSettingManager.shareInstance().canConnectOtherDevice {
|
|
274
298
|
return
|
|
275
299
|
}
|
|
276
300
|
|
|
277
301
|
self.manager?.stopScan()
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
302
|
+
if self.foundDevices.count > indexPath.row {
|
|
303
|
+
let peripheral = self.foundDevices[indexPath.row] as! CBPeripheral
|
|
304
|
+
if let device = KLTDatabaseHandler.shared().queryDevice(withId: peripheral.identifier.uuidString) {
|
|
305
|
+
//let snLocalName = device.advertise?.localName?.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
306
|
+
self.connectedTime = Date()
|
|
307
|
+
print("Connected device", device)
|
|
308
|
+
self.manager?.readyToConnectedPeripheral = peripheral
|
|
309
|
+
self.screenType = .success
|
|
310
|
+
//API.shared.sendStatus(status: .connected)
|
|
311
|
+
self.bottomButton.enable()
|
|
312
|
+
tableView.reloadData()
|
|
313
|
+
}
|
|
289
314
|
}
|
|
290
315
|
}
|
|
291
316
|
return cell
|
|
@@ -340,31 +365,3 @@ extension ConnectToTransmitterViewController: UITableViewDelegate, UITableViewDa
|
|
|
340
365
|
}
|
|
341
366
|
|
|
342
367
|
}
|
|
343
|
-
|
|
344
|
-
extension ConnectToTransmitterViewController: BluetoothManagerDelegate {
|
|
345
|
-
func didDiscoverDevice(_ device: CBPeripheral) {
|
|
346
|
-
DispatchQueue.main.async {
|
|
347
|
-
self.devices = BluetoothManager.shared.discoveredDevices
|
|
348
|
-
self.screenType = .listOfDevice
|
|
349
|
-
self.tableView.reloadData()
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
func didConnectDevice(_ device: CBPeripheral) {
|
|
354
|
-
DispatchQueue.main.async {
|
|
355
|
-
self.screenType = .success
|
|
356
|
-
self.tableView.reloadData()
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
func didFailToConnect(_ device: CBPeripheral, error: Error?) {
|
|
361
|
-
DispatchQueue.main.async {
|
|
362
|
-
self.screenType = .error
|
|
363
|
-
self.tableView.reloadData()
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
func didDisconnectDevice(_ device: CBPeripheral, error: Error?) {
|
|
368
|
-
print("Disconnected from device: \(device.name ?? "Unknown")")
|
|
369
|
-
}
|
|
370
|
-
}
|
|
@@ -48,7 +48,7 @@ class FinalViewModel: NSObject {
|
|
|
48
48
|
manager.startScan()
|
|
49
49
|
} else {
|
|
50
50
|
debouncer.update(with: .connected)
|
|
51
|
-
API.shared.sendStatus(status: .connected)
|
|
51
|
+
//API.shared.sendStatus(status: .connected)
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
func startCountDown() {
|
|
@@ -147,14 +147,18 @@ class FinalViewModel: NSObject {
|
|
|
147
147
|
|
|
148
148
|
let errorCode = ErrorCode(rawValue: Int32(receiveData.error?.intValue ?? 0))
|
|
149
149
|
if errorCode == ErrorCode.ERROR_CODE_FLOODING_WATER {
|
|
150
|
-
|
|
150
|
+
debouncer.update(with: CGMConnectionStatus.moistureDetect)
|
|
151
|
+
//API.shared.sendStatus(status: .moistureDetect)
|
|
151
152
|
} else if errorCode == ErrorCode.ERROR_CODE_CURRENT_SMALL || errorCode == ErrorCode.ERROR_CODE_NOISE || errorCode == ErrorCode.ERROR_CODE_SENSITIVITY_ATTENUATION {
|
|
152
|
-
|
|
153
|
+
debouncer.update(with: CGMConnectionStatus.weakSignal)
|
|
154
|
+
//API.shared.sendStatus(status: .weakSignal)
|
|
153
155
|
} else if errorCode != ErrorCode.ERROR_CODE_NONE {
|
|
154
|
-
|
|
156
|
+
debouncer.update(with: CGMConnectionStatus.errorCommon)
|
|
157
|
+
//API.shared.sendStatus(status: .errorCommon)
|
|
155
158
|
}
|
|
156
159
|
if receiveData.countdownDays == 0 && receiveData.countdownHours == 0 && receiveData.countdownMinutes == 0 {
|
|
157
|
-
|
|
160
|
+
debouncer.update(with: CGMConnectionStatus.expired)
|
|
161
|
+
//API.shared.sendStatus(status: .expired)
|
|
158
162
|
}
|
|
159
163
|
}
|
|
160
164
|
|
|
@@ -190,7 +194,8 @@ class FinalViewModel: NSObject {
|
|
|
190
194
|
@objc func bluetoothEnable(_ notification: Notification) {
|
|
191
195
|
if let isBluetoothEnabled = notification.object as? Bool {
|
|
192
196
|
if !isBluetoothEnabled {
|
|
193
|
-
|
|
197
|
+
debouncer.update(with: CGMConnectionStatus.bluetoothOff)
|
|
198
|
+
//API.shared.sendStatus(status: .bluetoothOff)
|
|
194
199
|
}
|
|
195
200
|
}
|
|
196
201
|
if ((manager.connectedPeripheral == nil) && !KLTLocalSettingManager.shareInstance().canConnectOtherDevice) {
|
|
@@ -244,17 +249,17 @@ class FinalViewModel: NSObject {
|
|
|
244
249
|
manager.startScan()
|
|
245
250
|
}
|
|
246
251
|
}
|
|
247
|
-
API.shared.sendStatus(status: .disconnected)
|
|
252
|
+
//API.shared.sendStatus(status: .disconnected)
|
|
248
253
|
print("===>device is disconnected")
|
|
249
|
-
debouncer.update(with: CGMConnectionStatus.
|
|
254
|
+
debouncer.update(with: CGMConnectionStatus.disconnected)
|
|
250
255
|
case .connected:
|
|
251
256
|
if let timer = startScanTimer {
|
|
252
257
|
timer.invalidate()
|
|
253
258
|
startScanTimer = nil
|
|
254
259
|
}
|
|
255
|
-
API.shared.sendStatus(status: .connected)
|
|
260
|
+
//API.shared.sendStatus(status: .connected)
|
|
256
261
|
print("===>device is connected")
|
|
257
|
-
debouncer.update(with: CGMConnectionStatus.
|
|
262
|
+
debouncer.update(with: CGMConnectionStatus.connected)
|
|
258
263
|
case .timeOut:
|
|
259
264
|
if !KLTLocalSettingManager.shareInstance().canConnectOtherDevice {
|
|
260
265
|
startScanTimer = Timer.scheduledTimer(timeInterval: 20,
|
|
@@ -271,7 +276,8 @@ class FinalViewModel: NSObject {
|
|
|
271
276
|
//KLTLaunchConfiguration.sharedManager.bindSuccessRootViewController()
|
|
272
277
|
print("Success done")
|
|
273
278
|
case .closed:
|
|
274
|
-
|
|
279
|
+
debouncer.update(with: CGMConnectionStatus.transmitterDisconnectBox)
|
|
280
|
+
//API.shared.sendStatus(status: .transmitterDisconnectBox)
|
|
275
281
|
default:
|
|
276
282
|
break
|
|
277
283
|
}
|
|
@@ -77,10 +77,15 @@ exports.reconnectCGM = reconnectCGM;
|
|
|
77
77
|
const observeAllGlucoseDataHandler = async token => {
|
|
78
78
|
console.log('observeAllGlucoseDataHandler====');
|
|
79
79
|
try {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
if (_reactNative.Platform.OS === 'android') {
|
|
81
|
+
const result = await cgmLib.observeAllGlucoseData(token);
|
|
82
|
+
const deviceStatus = await cgmLib.observeDeviceStatus(token);
|
|
83
|
+
console.log(result);
|
|
84
|
+
console.log(deviceStatus);
|
|
85
|
+
} else if (_reactNative.Platform.OS === 'ios') {
|
|
86
|
+
const result = await cgmLib.observeAllGlucoseData(token);
|
|
87
|
+
console.log(result);
|
|
88
|
+
}
|
|
84
89
|
} catch (error) {
|
|
85
90
|
console.log('error====', error);
|
|
86
91
|
console.error(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","eventSubscription","LINKING_ERROR","Platform","select","ios","default","cgmLib","NativeModules","CgmTrackyLib","Proxy","get","Error","initializeCGMEventListener","callback","iosEventEmitter","NativeEventEmitter","remove","OS","DeviceEventEmitter","addListener","eventData","status","removeCGMEventListener","startCGM","token","console","log","result","startCgmTracky","error","exports","reconnectCGM","reconnectCgmTracky","observeAllGlucoseDataHandler","observeAllGlucoseData","deviceStatus","observeDeviceStatus","helpCGM","openHelpSupport","observeTransmitterUnbindStatusHandler","observeTransmitterUnbindStatus","stopCGM"],"sources":["CGMConnect.ts"],"sourcesContent":["import { DeviceEventEmitter, EmitterSubscription, NativeEventEmitter, NativeModules, Platform } from \"react-native\";\n\n\n\n\nlet eventSubscription: EmitterSubscription | null = null;\n\nconst LINKING_ERROR =\n `The package 'react-native-mytatva-rn-sdk' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo Go\\n';\n\nconst cgmLib = NativeModules.CgmTrackyLib\n ? NativeModules.CgmTrackyLib\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\n\n\nfunction initializeCGMEventListener(\n callback: (eventData: any) => void\n) {\n const iosEventEmitter = new NativeEventEmitter(cgmLib);\n if (eventSubscription) {\n eventSubscription.remove();\n }\n\n if (Platform.OS === 'android') {\n eventSubscription = DeviceEventEmitter.addListener(\n 'cgmDeviceEvent',\n (eventData: any) => {\n const { status } = eventData;\n if (status === 'WARM_PERIOD_STARTED') {\n callback(eventData);\n } else {\n callback(eventData);\n }\n }\n );\n } \n else if (Platform.OS === 'ios' && iosEventEmitter) {\n eventSubscription = iosEventEmitter.addListener(\n 'cgmDeviceEvent',\n (eventData: any) => {\n const { status } = eventData;\n if (status === 'WARM_PERIOD_STARTED') {\n callback(eventData);\n } else {\n callback(eventData);\n }\n }\n );\n }\n}\n\nfunction removeCGMEventListener() {\n if (eventSubscription) {\n eventSubscription.remove();\n eventSubscription = null;\n }\n}\n\n\n\nconst startCGM = async (token: string) => {\n console.log('token====startCGM', token);\n try {\n const result = await cgmLib.startCgmTracky(token);\n console.log(result);\n } catch (error) {\n console.error(error);\n }\n };\n\n const reconnectCGM = async (token: string) => {\n console.log('reconnectCGM====');\n try {\n const result = await cgmLib.reconnectCgmTracky(token);\n console.log(result);\n } catch (error) {\n console.error(error);\n }\n };\n\n\n
|
|
1
|
+
{"version":3,"names":["_reactNative","require","eventSubscription","LINKING_ERROR","Platform","select","ios","default","cgmLib","NativeModules","CgmTrackyLib","Proxy","get","Error","initializeCGMEventListener","callback","iosEventEmitter","NativeEventEmitter","remove","OS","DeviceEventEmitter","addListener","eventData","status","removeCGMEventListener","startCGM","token","console","log","result","startCgmTracky","error","exports","reconnectCGM","reconnectCgmTracky","observeAllGlucoseDataHandler","observeAllGlucoseData","deviceStatus","observeDeviceStatus","helpCGM","openHelpSupport","observeTransmitterUnbindStatusHandler","observeTransmitterUnbindStatus","stopCGM"],"sources":["CGMConnect.ts"],"sourcesContent":["import { DeviceEventEmitter, EmitterSubscription, NativeEventEmitter, NativeModules, Platform } from \"react-native\";\n\n\n\n\nlet eventSubscription: EmitterSubscription | null = null;\n\nconst LINKING_ERROR =\n `The package 'react-native-mytatva-rn-sdk' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo Go\\n';\n\nconst cgmLib = NativeModules.CgmTrackyLib\n ? NativeModules.CgmTrackyLib\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\n\n\nfunction initializeCGMEventListener(\n callback: (eventData: any) => void\n) {\n const iosEventEmitter = new NativeEventEmitter(cgmLib);\n if (eventSubscription) {\n eventSubscription.remove();\n }\n\n if (Platform.OS === 'android') {\n eventSubscription = DeviceEventEmitter.addListener(\n 'cgmDeviceEvent',\n (eventData: any) => {\n const { status } = eventData;\n if (status === 'WARM_PERIOD_STARTED') {\n callback(eventData);\n } else {\n callback(eventData);\n }\n }\n );\n } \n else if (Platform.OS === 'ios' && iosEventEmitter) {\n eventSubscription = iosEventEmitter.addListener(\n 'cgmDeviceEvent',\n (eventData: any) => {\n const { status } = eventData;\n if (status === 'WARM_PERIOD_STARTED') {\n callback(eventData);\n } else {\n callback(eventData);\n }\n }\n );\n }\n}\n\nfunction removeCGMEventListener() {\n if (eventSubscription) {\n eventSubscription.remove();\n eventSubscription = null;\n }\n}\n\n\n\nconst startCGM = async (token: string) => {\n console.log('token====startCGM', token);\n try {\n const result = await cgmLib.startCgmTracky(token);\n console.log(result);\n } catch (error) {\n console.error(error);\n }\n };\n\n const reconnectCGM = async (token: string) => {\n console.log('reconnectCGM====');\n try {\n const result = await cgmLib.reconnectCgmTracky(token);\n console.log(result);\n } catch (error) {\n console.error(error);\n }\n };\n\n\n const observeAllGlucoseDataHandler = async (token: string) => {\n console.log('observeAllGlucoseDataHandler====');\n try {\n if(Platform.OS === 'android') { \n const result = await cgmLib.observeAllGlucoseData(token);\n const deviceStatus = await cgmLib.observeDeviceStatus(token);\n console.log(result);\n console.log(deviceStatus);\n }\n else if(Platform.OS === 'ios') {\n const result = await cgmLib.observeAllGlucoseData(token);\n console.log(result);\n }\n } catch (error) {\n console.log('error====', error);\n console.error(error);\n }\n };\n\n\nconst helpCGM = async (token: string) => {\n console.log('helpCGM====');\n try {\n const result = await cgmLib.openHelpSupport();\n console.log(result);\n } catch (error) {\n console.error(error);\n }\n};\n\nconst observeTransmitterUnbindStatusHandler = async (token: string) => {\n console.log('observeTransmitterUnbindStatusHandler====');\n try {\n const result = await cgmLib.observeTransmitterUnbindStatus(token);\n console.log(result);\n } catch (error) {\n console.error(error);\n }\n};\n\n\n\nconst stopCGM = async () => {\n // Implementation\n};\n\nexport { startCGM, stopCGM, initializeCGMEventListener, removeCGMEventListener, observeAllGlucoseDataHandler, reconnectCGM, helpCGM, observeTransmitterUnbindStatusHandler };"],"mappings":";;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAKA,IAAIC,iBAA6C,GAAG,IAAI;AAExD,MAAMC,aAAa,GACjB,sFAAsF,GACtFC,qBAAQ,CAACC,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACvE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,MAAM,GAAGC,0BAAa,CAACC,YAAY,GACrCD,0BAAa,CAACC,YAAY,GAC1B,IAAIC,KAAK,CACP,CAAC,CAAC,EACF;EACEC,GAAGA,CAAA,EAAG;IACJ,MAAM,IAAIC,KAAK,CAACV,aAAa,CAAC;EAChC;AACF,CACF,CAAC;AAIL,SAASW,0BAA0BA,CACjCC,QAAkC,EAClC;EACA,MAAMC,eAAe,GAAG,IAAIC,+BAAkB,CAACT,MAAM,CAAC;EACtD,IAAIN,iBAAiB,EAAE;IACrBA,iBAAiB,CAACgB,MAAM,CAAC,CAAC;EAC5B;EAEA,IAAId,qBAAQ,CAACe,EAAE,KAAK,SAAS,EAAE;IAC7BjB,iBAAiB,GAAGkB,+BAAkB,CAACC,WAAW,CAChD,gBAAgB,EACfC,SAAc,IAAK;MAClB,MAAM;QAAEC;MAAO,CAAC,GAAGD,SAAS;MAC5B,IAAIC,MAAM,KAAK,qBAAqB,EAAE;QACpCR,QAAQ,CAACO,SAAS,CAAC;MACrB,CAAC,MAAM;QACLP,QAAQ,CAACO,SAA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,CAAC;EACxD,IAAI;IACF,MAAMC,MAAM,GAAG,MAAMrB,MAAM,CAACkC,8BAA8B,CAAChB,KAAK,CAAC;IACjEC,OAAO,CAACC,GAAG,CAACC,MAAM,CAAC;EACrB,CAAC,CAAC,OAAOE,KAAK,EAAE;IACdJ,OAAO,CAACI,KAAK,CAACA,KAAK,CAAC;EACtB;AACF,CAAC;AAACC,OAAA,CAAAS,qCAAA,GAAAA,qCAAA;AAIF,MAAME,OAAO,GAAG,MAAAA,CAAA,KAAY;EAC1B;AAAA,CACD;AAACX,OAAA,CAAAW,OAAA,GAAAA,OAAA","ignoreList":[]}
|
package/lib/module/CGMConnect.js
CHANGED
|
@@ -65,10 +65,15 @@ const reconnectCGM = async token => {
|
|
|
65
65
|
const observeAllGlucoseDataHandler = async token => {
|
|
66
66
|
console.log('observeAllGlucoseDataHandler====');
|
|
67
67
|
try {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
if (Platform.OS === 'android') {
|
|
69
|
+
const result = await cgmLib.observeAllGlucoseData(token);
|
|
70
|
+
const deviceStatus = await cgmLib.observeDeviceStatus(token);
|
|
71
|
+
console.log(result);
|
|
72
|
+
console.log(deviceStatus);
|
|
73
|
+
} else if (Platform.OS === 'ios') {
|
|
74
|
+
const result = await cgmLib.observeAllGlucoseData(token);
|
|
75
|
+
console.log(result);
|
|
76
|
+
}
|
|
72
77
|
} catch (error) {
|
|
73
78
|
console.log('error====', error);
|
|
74
79
|
console.error(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DeviceEventEmitter","NativeEventEmitter","NativeModules","Platform","eventSubscription","LINKING_ERROR","select","ios","default","cgmLib","CgmTrackyLib","Proxy","get","Error","initializeCGMEventListener","callback","iosEventEmitter","remove","OS","addListener","eventData","status","removeCGMEventListener","startCGM","token","console","log","result","startCgmTracky","error","reconnectCGM","reconnectCgmTracky","observeAllGlucoseDataHandler","observeAllGlucoseData","deviceStatus","observeDeviceStatus","helpCGM","openHelpSupport","observeTransmitterUnbindStatusHandler","observeTransmitterUnbindStatus","stopCGM"],"sources":["CGMConnect.ts"],"sourcesContent":["import { DeviceEventEmitter, EmitterSubscription, NativeEventEmitter, NativeModules, Platform } from \"react-native\";\n\n\n\n\nlet eventSubscription: EmitterSubscription | null = null;\n\nconst LINKING_ERROR =\n `The package 'react-native-mytatva-rn-sdk' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo Go\\n';\n\nconst cgmLib = NativeModules.CgmTrackyLib\n ? NativeModules.CgmTrackyLib\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\n\n\nfunction initializeCGMEventListener(\n callback: (eventData: any) => void\n) {\n const iosEventEmitter = new NativeEventEmitter(cgmLib);\n if (eventSubscription) {\n eventSubscription.remove();\n }\n\n if (Platform.OS === 'android') {\n eventSubscription = DeviceEventEmitter.addListener(\n 'cgmDeviceEvent',\n (eventData: any) => {\n const { status } = eventData;\n if (status === 'WARM_PERIOD_STARTED') {\n callback(eventData);\n } else {\n callback(eventData);\n }\n }\n );\n } \n else if (Platform.OS === 'ios' && iosEventEmitter) {\n eventSubscription = iosEventEmitter.addListener(\n 'cgmDeviceEvent',\n (eventData: any) => {\n const { status } = eventData;\n if (status === 'WARM_PERIOD_STARTED') {\n callback(eventData);\n } else {\n callback(eventData);\n }\n }\n );\n }\n}\n\nfunction removeCGMEventListener() {\n if (eventSubscription) {\n eventSubscription.remove();\n eventSubscription = null;\n }\n}\n\n\n\nconst startCGM = async (token: string) => {\n console.log('token====startCGM', token);\n try {\n const result = await cgmLib.startCgmTracky(token);\n console.log(result);\n } catch (error) {\n console.error(error);\n }\n };\n\n const reconnectCGM = async (token: string) => {\n console.log('reconnectCGM====');\n try {\n const result = await cgmLib.reconnectCgmTracky(token);\n console.log(result);\n } catch (error) {\n console.error(error);\n }\n };\n\n\n
|
|
1
|
+
{"version":3,"names":["DeviceEventEmitter","NativeEventEmitter","NativeModules","Platform","eventSubscription","LINKING_ERROR","select","ios","default","cgmLib","CgmTrackyLib","Proxy","get","Error","initializeCGMEventListener","callback","iosEventEmitter","remove","OS","addListener","eventData","status","removeCGMEventListener","startCGM","token","console","log","result","startCgmTracky","error","reconnectCGM","reconnectCgmTracky","observeAllGlucoseDataHandler","observeAllGlucoseData","deviceStatus","observeDeviceStatus","helpCGM","openHelpSupport","observeTransmitterUnbindStatusHandler","observeTransmitterUnbindStatus","stopCGM"],"sources":["CGMConnect.ts"],"sourcesContent":["import { DeviceEventEmitter, EmitterSubscription, NativeEventEmitter, NativeModules, Platform } from \"react-native\";\n\n\n\n\nlet eventSubscription: EmitterSubscription | null = null;\n\nconst LINKING_ERROR =\n `The package 'react-native-mytatva-rn-sdk' doesn't seem to be linked. Make sure: \\n\\n` +\n Platform.select({ ios: \"- You have run 'pod install'\\n\", default: '' }) +\n '- You rebuilt the app after installing the package\\n' +\n '- You are not using Expo Go\\n';\n\nconst cgmLib = NativeModules.CgmTrackyLib\n ? NativeModules.CgmTrackyLib\n : new Proxy(\n {},\n {\n get() {\n throw new Error(LINKING_ERROR);\n },\n }\n );\n\n\n\nfunction initializeCGMEventListener(\n callback: (eventData: any) => void\n) {\n const iosEventEmitter = new NativeEventEmitter(cgmLib);\n if (eventSubscription) {\n eventSubscription.remove();\n }\n\n if (Platform.OS === 'android') {\n eventSubscription = DeviceEventEmitter.addListener(\n 'cgmDeviceEvent',\n (eventData: any) => {\n const { status } = eventData;\n if (status === 'WARM_PERIOD_STARTED') {\n callback(eventData);\n } else {\n callback(eventData);\n }\n }\n );\n } \n else if (Platform.OS === 'ios' && iosEventEmitter) {\n eventSubscription = iosEventEmitter.addListener(\n 'cgmDeviceEvent',\n (eventData: any) => {\n const { status } = eventData;\n if (status === 'WARM_PERIOD_STARTED') {\n callback(eventData);\n } else {\n callback(eventData);\n }\n }\n );\n }\n}\n\nfunction removeCGMEventListener() {\n if (eventSubscription) {\n eventSubscription.remove();\n eventSubscription = null;\n }\n}\n\n\n\nconst startCGM = async (token: string) => {\n console.log('token====startCGM', token);\n try {\n const result = await cgmLib.startCgmTracky(token);\n console.log(result);\n } catch (error) {\n console.error(error);\n }\n };\n\n const reconnectCGM = async (token: string) => {\n console.log('reconnectCGM====');\n try {\n const result = await cgmLib.reconnectCgmTracky(token);\n console.log(result);\n } catch (error) {\n console.error(error);\n }\n };\n\n\n const observeAllGlucoseDataHandler = async (token: string) => {\n console.log('observeAllGlucoseDataHandler====');\n try {\n if(Platform.OS === 'android') { \n const result = await cgmLib.observeAllGlucoseData(token);\n const deviceStatus = await cgmLib.observeDeviceStatus(token);\n console.log(result);\n console.log(deviceStatus);\n }\n else if(Platform.OS === 'ios') {\n const result = await cgmLib.observeAllGlucoseData(token);\n console.log(result);\n }\n } catch (error) {\n console.log('error====', error);\n console.error(error);\n }\n };\n\n\nconst helpCGM = async (token: string) => {\n console.log('helpCGM====');\n try {\n const result = await cgmLib.openHelpSupport();\n console.log(result);\n } catch (error) {\n console.error(error);\n }\n};\n\nconst observeTransmitterUnbindStatusHandler = async (token: string) => {\n console.log('observeTransmitterUnbindStatusHandler====');\n try {\n const result = await cgmLib.observeTransmitterUnbindStatus(token);\n console.log(result);\n } catch (error) {\n console.error(error);\n }\n};\n\n\n\nconst stopCGM = async () => {\n // Implementation\n};\n\nexport { startCGM, stopCGM, initializeCGMEventListener, removeCGMEventListener, observeAllGlucoseDataHandler, reconnectCGM, helpCGM, observeTransmitterUnbindStatusHandler };"],"mappings":"AAAA,SAASA,kBAAkB,EAAuBC,kBAAkB,EAAEC,aAAa,EAAEC,QAAQ,QAAQ,cAAc;AAKnH,IAAIC,iBAA6C,GAAG,IAAI;AAExD,MAAMC,aAAa,GACjB,sFAAsF,GACtFF,QAAQ,CAACG,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CA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,CAAC,OAAOE,KAAK,EAAE;IACdJ,OAAO,CAACC,GAAG,CAAC,WAAW,EAAEG,KAAK,CAAC;IAC/BJ,OAAO,CAACI,KAAK,CAACA,KAAK,CAAC;EACtB;AACF,CAAC;AAGP,MAAMO,OAAO,GAAG,MAAOZ,KAAa,IAAK;EACvCC,OAAO,CAACC,GAAG,CAAC,aAAa,CAAC;EAC1B,IAAI;IACF,MAAMC,MAAM,GAAG,MAAMlB,MAAM,CAAC4B,eAAe,CAAC,CAAC;IAC7CZ,OAAO,CAACC,GAAG,CAACC,MAAM,CAAC;EACrB,CAAC,CAAC,OAAOE,KAAK,EAAE;IACdJ,OAAO,CAACI,KAAK,CAACA,KAAK,CAAC;EACtB;AACF,CAAC;AAED,MAAMS,qCAAqC,GAAG,MAAOd,KAAa,IAAK;EACrEC,OAAO,CAACC,GAAG,CAAC,2CAA2C,CAAC;EACxD,IAAI;IACF,MAAMC,MAAM,GAAG,MAAMlB,MAAM,CAAC8B,8BAA8B,CAACf,KAAK,CAAC;IACjEC,OAAO,CAACC,GAAG,CAACC,MAAM,CAAC;EACrB,CAAC,CAAC,OAAOE,KAAK,EAAE;IACdJ,OAAO,CAACI,KAAK,CAACA,KAAK,CAAC;EACtB;AACF,CAAC;AAID,MAAMW,OAAO,GAAG,MAAAA,CAAA,KAAY;EAC1B;AAAA,CACD;AAED,SAASjB,QAAQ,EAAEiB,OAAO,EAAE1B,0BAA0B,EAAEQ,sBAAsB,EAAEU,4BAA4B,EAAEF,YAAY,EAAEM,OAAO,EAAEE,qCAAqC","ignoreList":[]}
|
package/package.json
CHANGED
package/src/CGMConnect.ts
CHANGED
|
@@ -90,18 +90,24 @@ const startCGM = async (token: string) => {
|
|
|
90
90
|
};
|
|
91
91
|
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
93
|
+
const observeAllGlucoseDataHandler = async (token: string) => {
|
|
94
|
+
console.log('observeAllGlucoseDataHandler====');
|
|
95
|
+
try {
|
|
96
|
+
if(Platform.OS === 'android') {
|
|
97
|
+
const result = await cgmLib.observeAllGlucoseData(token);
|
|
98
|
+
const deviceStatus = await cgmLib.observeDeviceStatus(token);
|
|
99
|
+
console.log(result);
|
|
100
|
+
console.log(deviceStatus);
|
|
101
|
+
}
|
|
102
|
+
else if(Platform.OS === 'ios') {
|
|
103
|
+
const result = await cgmLib.observeAllGlucoseData(token);
|
|
104
|
+
console.log(result);
|
|
105
|
+
}
|
|
106
|
+
} catch (error) {
|
|
107
|
+
console.log('error====', error);
|
|
108
|
+
console.error(error);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
105
111
|
|
|
106
112
|
|
|
107
113
|
const helpCGM = async (token: string) => {
|