react-native-mytatva-rn-sdk 1.2.93 → 1.2.94

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.
@@ -7,43 +7,76 @@
7
7
 
8
8
  import Foundation
9
9
 
10
+ // MARK: - POC safe accessors: use SDK value when present, otherwise default
11
+
12
+ private func pocInt(_ value: NSNumber?) -> Int {
13
+ value?.intValue ?? 0
14
+ }
15
+
16
+ private func pocInt32(_ value: NSNumber?) -> Int32 {
17
+ value?.int32Value ?? 0
18
+ }
19
+
20
+ private func pocFloat(_ value: NSNumber?) -> Float {
21
+ value?.floatValue ?? 0
22
+ }
23
+
24
+ private func pocName(from data: GlucoseData) -> String {
25
+ data.device?.advertise?.localName ?? ""
26
+ }
27
+
28
+ private func pocTimeInMillis(from data: GlucoseData) -> Double {
29
+ if let receiveDateTime = data.receiveDateTime,
30
+ let date = KLTDateFormatter.shared.getDateFromWholeString(receiveDateTime) {
31
+ return date.timeIntervalSince1970 * 1000
32
+ }
33
+ return Date().timeIntervalSince1970 * 1000
34
+ }
35
+
36
+ private func pocErrorId(from data: GlucoseData) -> Int {
37
+ let fromError = pocInt(data.error)
38
+ if fromError != 0 {
39
+ return fromError
40
+ }
41
+ return pocInt(data.errorCode)
42
+ }
43
+
10
44
  func ReceiveDataToLog(data: GlucoseData) -> CGMLog {
11
- let cgmLogs = CGMLog(
12
- timeInMillis: Double(Date().timeIntervalSince1970 * 1000),
13
- countdownMinutes: (data.countdownMinutes as? Int) ?? 0,
14
- countdownDays: (data.countdownDays as? Int) ?? 0,
15
- hypoglycemiaEarlyWarnMinutes: 0, // still missing, you can map if available
16
- showGlucoseMG: (data.gluADC as? Int) ?? 0,
17
- glucoseId: Int(truncating: data.glucoseId ?? 0),
18
- name: data.device?.advertise?.localName ?? "",
19
- bytes: [], // still missing: need raw data source
20
- showGlucose: (data.glu as? Float) ?? 0,
21
- Ib: (data.blankCurrent as? Float) ?? 0,
22
- Iw: (data.operatingCurrent as? Float) ?? 0,
23
- countdownHours: (data.countdownHours as? Int) ?? 0,
24
- T: (data.temperature as? Float) ?? 0.0,
25
- year: (data.year as? Int32) ?? 0,
26
- month: (data.month as? Int32) ?? 0,
27
- day: (data.day as? Int32) ?? 0,
28
- hour: (data.hour as? Int32) ?? 0,
29
- minute: (data.minute as? Int32) ?? 0,
30
-
45
+ let trendId = pocInt(data.trend)
46
+ let statusId = pocInt(data.calibrationStatus)
47
+ let resolvedStatusId = statusId != 0 ? statusId : 1
48
+
49
+ return CGMLog(
50
+ timeInMillis: pocTimeInMillis(from: data),
51
+ countdownMinutes: pocInt(data.countdownMinutes),
52
+ countdownDays: pocInt(data.countdownDays),
53
+ hypoglycemiaEarlyWarnMinutes: 0,
54
+ showGlucoseMG: pocInt(data.gluADC),
55
+ glucoseId: pocInt(data.glucoseId),
56
+ name: pocName(from: data),
57
+ bytes: [],
58
+ showGlucose: pocFloat(data.glu),
59
+ Ib: pocFloat(data.blankCurrent),
60
+ Iw: pocFloat(data.operatingCurrent),
61
+ countdownHours: pocInt(data.countdownHours),
62
+ T: pocFloat(data.temperature),
63
+ year: pocInt32(data.year),
64
+ month: pocInt32(data.month),
65
+ day: pocInt32(data.day),
66
+ hour: pocInt32(data.hour),
67
+ minute: pocInt32(data.minute),
31
68
  trendObject: TrendObject(
32
- trendId: (data.trend as? Int) ?? 0,
33
- drawableId: 2103818652, // customize if needed
69
+ trendId: trendId,
70
+ drawableId: 2103818652,
34
71
  widgetImg: -1,
35
- apsChangeRate: "FLAT" // you could map a real value if available
72
+ apsChangeRate: "FLAT"
36
73
  ),
37
-
38
74
  glucoseStatusObject: GlucoseStatusObject(
39
- statusId: 1 // you may derive this from a field like `calibrationStatus`
75
+ statusId: resolvedStatusId
40
76
  ),
41
-
42
77
  errorObject: ErrorObject(
43
- errorId: (data.errorCode as? Int) ?? 0,
78
+ errorId: pocErrorId(from: data),
44
79
  sound: "None"
45
80
  )
46
81
  )
47
-
48
- return cgmLogs
49
82
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-mytatva-rn-sdk",
3
- "version": "1.2.93",
3
+ "version": "1.2.94",
4
4
  "description": "a package to inject data into visit health pwa",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",