@ovok/native 1.6.23 → 1.6.25

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 (136) hide show
  1. package/lib/commonjs/modules/bt-device/constants/supported-device-catalog-entries.js +1 -1
  2. package/lib/commonjs/modules/bt-device/constants/supported-device-catalog-entries.js.map +1 -1
  3. package/lib/commonjs/modules/bt-device/constants/supported-devices.js +1 -1
  4. package/lib/commonjs/modules/bt-device/constants/supported-devices.js.map +1 -1
  5. package/lib/commonjs/modules/bt-management/services/devices/bp2/bp2.device.js +7 -1
  6. package/lib/commonjs/modules/bt-management/services/devices/bp2/bp2.device.js.map +1 -1
  7. package/lib/commonjs/modules/bt-management/services/devices/bt-data-processor.js +37 -0
  8. package/lib/commonjs/modules/bt-management/services/devices/bt-data-processor.js.map +1 -1
  9. package/lib/commonjs/modules/bt-management/services/devices/bt-managed-device.js +7 -1
  10. package/lib/commonjs/modules/bt-management/services/devices/bt-managed-device.js.map +1 -1
  11. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.device-names.js +13 -4
  12. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.device-names.js.map +1 -1
  13. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.name-match.js +3 -0
  14. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.name-match.js.map +1 -1
  15. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.transports.js +2 -0
  16. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.transports.js.map +1 -1
  17. package/lib/commonjs/modules/bt-management/services/devices/standard-gatt/standard-gatt.blood-pressure-status.js +31 -0
  18. package/lib/commonjs/modules/bt-management/services/devices/standard-gatt/standard-gatt.blood-pressure-status.js.map +1 -0
  19. package/lib/commonjs/modules/bt-management/services/devices/standard-gatt/standard-gatt.devices.js +4 -1
  20. package/lib/commonjs/modules/bt-management/services/devices/standard-gatt/standard-gatt.devices.js.map +1 -1
  21. package/lib/commonjs/modules/bt-management/services/devices/standard-gatt/standard-gatt.profile.js +9 -4
  22. package/lib/commonjs/modules/bt-management/services/devices/standard-gatt/standard-gatt.profile.js.map +1 -1
  23. package/lib/commonjs/modules/bt-management/services/devices/veroval/veroval.bp-monitors.js +28 -0
  24. package/lib/commonjs/modules/bt-management/services/devices/veroval/veroval.bp-monitors.js.map +1 -1
  25. package/lib/commonjs/modules/bt-management/services/devices/veroval/veroval.ecg-device.js +24 -3
  26. package/lib/commonjs/modules/bt-management/services/devices/veroval/veroval.ecg-device.js.map +1 -1
  27. package/lib/commonjs/modules/bt-management/services/devices/veroval/veroval.ecg-record.js +98 -0
  28. package/lib/commonjs/modules/bt-management/services/devices/veroval/veroval.ecg-record.js.map +1 -0
  29. package/lib/commonjs/modules/bt-management/services/devices/veroval/veroval.ecg-transfer.js +215 -55
  30. package/lib/commonjs/modules/bt-management/services/devices/veroval/veroval.ecg-transfer.js.map +1 -1
  31. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.bp-monitors.js +16 -3
  32. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.bp-monitors.js.map +1 -1
  33. package/lib/commonjs/modules/bt-management/types/clock-sync.js +1 -0
  34. package/lib/commonjs/modules/bt-management/types/clock-sync.js.map +1 -1
  35. package/lib/commonjs/modules/bt-management/utils/convert-ecg-diagnostic-flag.js +19 -27
  36. package/lib/commonjs/modules/bt-management/utils/convert-ecg-diagnostic-flag.js.map +1 -1
  37. package/lib/module/modules/bt-device/constants/supported-device-catalog-entries.js +2 -2
  38. package/lib/module/modules/bt-device/constants/supported-device-catalog-entries.js.map +1 -1
  39. package/lib/module/modules/bt-device/constants/supported-devices.js +1 -1
  40. package/lib/module/modules/bt-device/constants/supported-devices.js.map +1 -1
  41. package/lib/module/modules/bt-management/services/devices/bp2/bp2.device.js +7 -1
  42. package/lib/module/modules/bt-management/services/devices/bp2/bp2.device.js.map +1 -1
  43. package/lib/module/modules/bt-management/services/devices/bt-data-processor.js +37 -0
  44. package/lib/module/modules/bt-management/services/devices/bt-data-processor.js.map +1 -1
  45. package/lib/module/modules/bt-management/services/devices/bt-managed-device.js +7 -1
  46. package/lib/module/modules/bt-management/services/devices/bt-managed-device.js.map +1 -1
  47. package/lib/module/modules/bt-management/services/devices/lepu/lepu.device-names.js +13 -3
  48. package/lib/module/modules/bt-management/services/devices/lepu/lepu.device-names.js.map +1 -1
  49. package/lib/module/modules/bt-management/services/devices/lepu/lepu.name-match.js +4 -1
  50. package/lib/module/modules/bt-management/services/devices/lepu/lepu.name-match.js.map +1 -1
  51. package/lib/module/modules/bt-management/services/devices/lepu/lepu.transports.js +2 -0
  52. package/lib/module/modules/bt-management/services/devices/lepu/lepu.transports.js.map +1 -1
  53. package/lib/module/modules/bt-management/services/devices/standard-gatt/standard-gatt.blood-pressure-status.js +27 -0
  54. package/lib/module/modules/bt-management/services/devices/standard-gatt/standard-gatt.blood-pressure-status.js.map +1 -0
  55. package/lib/module/modules/bt-management/services/devices/standard-gatt/standard-gatt.devices.js +4 -1
  56. package/lib/module/modules/bt-management/services/devices/standard-gatt/standard-gatt.devices.js.map +1 -1
  57. package/lib/module/modules/bt-management/services/devices/standard-gatt/standard-gatt.profile.js +4 -5
  58. package/lib/module/modules/bt-management/services/devices/standard-gatt/standard-gatt.profile.js.map +1 -1
  59. package/lib/module/modules/bt-management/services/devices/veroval/veroval.bp-monitors.js +28 -0
  60. package/lib/module/modules/bt-management/services/devices/veroval/veroval.bp-monitors.js.map +1 -1
  61. package/lib/module/modules/bt-management/services/devices/veroval/veroval.ecg-device.js +24 -3
  62. package/lib/module/modules/bt-management/services/devices/veroval/veroval.ecg-device.js.map +1 -1
  63. package/lib/module/modules/bt-management/services/devices/veroval/veroval.ecg-record.js +92 -0
  64. package/lib/module/modules/bt-management/services/devices/veroval/veroval.ecg-record.js.map +1 -0
  65. package/lib/module/modules/bt-management/services/devices/veroval/veroval.ecg-transfer.js +211 -50
  66. package/lib/module/modules/bt-management/services/devices/veroval/veroval.ecg-transfer.js.map +1 -1
  67. package/lib/module/modules/bt-management/services/devices/viatom/viatom.bp-monitors.js +16 -3
  68. package/lib/module/modules/bt-management/services/devices/viatom/viatom.bp-monitors.js.map +1 -1
  69. package/lib/module/modules/bt-management/types/clock-sync.js +1 -0
  70. package/lib/module/modules/bt-management/types/clock-sync.js.map +1 -1
  71. package/lib/module/modules/bt-management/types/device-measurement-map.js.map +1 -1
  72. package/lib/module/modules/bt-management/utils/convert-ecg-diagnostic-flag.js +19 -27
  73. package/lib/module/modules/bt-management/utils/convert-ecg-diagnostic-flag.js.map +1 -1
  74. package/lib/typescript/commonjs/src/modules/bt-device/constants/supported-device-catalog-entries.d.ts.map +1 -1
  75. package/lib/typescript/commonjs/src/modules/bt-device/constants/supported-devices.d.ts.map +1 -1
  76. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bp2/bp2.device.d.ts.map +1 -1
  77. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-data-processor.d.ts +8 -0
  78. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-data-processor.d.ts.map +1 -1
  79. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-managed-device.d.ts.map +1 -1
  80. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.device-names.d.ts +9 -3
  81. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.device-names.d.ts.map +1 -1
  82. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.name-match.d.ts.map +1 -1
  83. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.transports.d.ts +3 -1
  84. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.transports.d.ts.map +1 -1
  85. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/standard-gatt/standard-gatt.blood-pressure-status.d.ts +3 -0
  86. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/standard-gatt/standard-gatt.blood-pressure-status.d.ts.map +1 -0
  87. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/standard-gatt/standard-gatt.devices.d.ts.map +1 -1
  88. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/standard-gatt/standard-gatt.profile.d.ts +2 -1
  89. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/standard-gatt/standard-gatt.profile.d.ts.map +1 -1
  90. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/veroval/veroval.bp-monitors.d.ts +11 -0
  91. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/veroval/veroval.bp-monitors.d.ts.map +1 -1
  92. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/veroval/veroval.ecg-device.d.ts +2 -1
  93. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/veroval/veroval.ecg-device.d.ts.map +1 -1
  94. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/veroval/veroval.ecg-record.d.ts +41 -0
  95. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/veroval/veroval.ecg-record.d.ts.map +1 -0
  96. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/veroval/veroval.ecg-transfer.d.ts +50 -18
  97. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/veroval/veroval.ecg-transfer.d.ts.map +1 -1
  98. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.bp-monitors.d.ts.map +1 -1
  99. package/lib/typescript/commonjs/src/modules/bt-management/types/clock-sync.d.ts.map +1 -1
  100. package/lib/typescript/commonjs/src/modules/bt-management/types/command-sequencer.d.ts +10 -0
  101. package/lib/typescript/commonjs/src/modules/bt-management/types/command-sequencer.d.ts.map +1 -1
  102. package/lib/typescript/commonjs/src/modules/bt-management/types/device-measurement-map.d.ts +4 -1
  103. package/lib/typescript/commonjs/src/modules/bt-management/types/device-measurement-map.d.ts.map +1 -1
  104. package/lib/typescript/commonjs/src/modules/bt-management/utils/convert-ecg-diagnostic-flag.d.ts.map +1 -1
  105. package/lib/typescript/module/src/modules/bt-device/constants/supported-device-catalog-entries.d.ts.map +1 -1
  106. package/lib/typescript/module/src/modules/bt-device/constants/supported-devices.d.ts.map +1 -1
  107. package/lib/typescript/module/src/modules/bt-management/services/devices/bp2/bp2.device.d.ts.map +1 -1
  108. package/lib/typescript/module/src/modules/bt-management/services/devices/bt-data-processor.d.ts +8 -0
  109. package/lib/typescript/module/src/modules/bt-management/services/devices/bt-data-processor.d.ts.map +1 -1
  110. package/lib/typescript/module/src/modules/bt-management/services/devices/bt-managed-device.d.ts.map +1 -1
  111. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.device-names.d.ts +9 -3
  112. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.device-names.d.ts.map +1 -1
  113. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.name-match.d.ts.map +1 -1
  114. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.transports.d.ts +3 -1
  115. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.transports.d.ts.map +1 -1
  116. package/lib/typescript/module/src/modules/bt-management/services/devices/standard-gatt/standard-gatt.blood-pressure-status.d.ts +3 -0
  117. package/lib/typescript/module/src/modules/bt-management/services/devices/standard-gatt/standard-gatt.blood-pressure-status.d.ts.map +1 -0
  118. package/lib/typescript/module/src/modules/bt-management/services/devices/standard-gatt/standard-gatt.devices.d.ts.map +1 -1
  119. package/lib/typescript/module/src/modules/bt-management/services/devices/standard-gatt/standard-gatt.profile.d.ts +2 -1
  120. package/lib/typescript/module/src/modules/bt-management/services/devices/standard-gatt/standard-gatt.profile.d.ts.map +1 -1
  121. package/lib/typescript/module/src/modules/bt-management/services/devices/veroval/veroval.bp-monitors.d.ts +11 -0
  122. package/lib/typescript/module/src/modules/bt-management/services/devices/veroval/veroval.bp-monitors.d.ts.map +1 -1
  123. package/lib/typescript/module/src/modules/bt-management/services/devices/veroval/veroval.ecg-device.d.ts +2 -1
  124. package/lib/typescript/module/src/modules/bt-management/services/devices/veroval/veroval.ecg-device.d.ts.map +1 -1
  125. package/lib/typescript/module/src/modules/bt-management/services/devices/veroval/veroval.ecg-record.d.ts +41 -0
  126. package/lib/typescript/module/src/modules/bt-management/services/devices/veroval/veroval.ecg-record.d.ts.map +1 -0
  127. package/lib/typescript/module/src/modules/bt-management/services/devices/veroval/veroval.ecg-transfer.d.ts +50 -18
  128. package/lib/typescript/module/src/modules/bt-management/services/devices/veroval/veroval.ecg-transfer.d.ts.map +1 -1
  129. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.bp-monitors.d.ts.map +1 -1
  130. package/lib/typescript/module/src/modules/bt-management/types/clock-sync.d.ts.map +1 -1
  131. package/lib/typescript/module/src/modules/bt-management/types/command-sequencer.d.ts +10 -0
  132. package/lib/typescript/module/src/modules/bt-management/types/command-sequencer.d.ts.map +1 -1
  133. package/lib/typescript/module/src/modules/bt-management/types/device-measurement-map.d.ts +4 -1
  134. package/lib/typescript/module/src/modules/bt-management/types/device-measurement-map.d.ts.map +1 -1
  135. package/lib/typescript/module/src/modules/bt-management/utils/convert-ecg-diagnostic-flag.d.ts.map +1 -1
  136. package/package.json +1 -1
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { BloodPressureStates } from "../../../types/blood-pressure-states.js";
4
4
  import { defineCustomDevice } from "../../custom/define-custom-device.js";
5
+ import { bloodPressureStatusFromFrame } from "./standard-gatt.blood-pressure-status.js";
5
6
 
6
7
  /** Milliseconds a spot-check device may take to produce its reading. */
7
8
  const SPOT_CHECK_TIMEOUT_MS = 60_000;
@@ -105,10 +106,8 @@ const decorateBloodPressureReading = (reading, frame, recordOffset) => {
105
106
  cursor += 1;
106
107
  }
107
108
  if ((flags & 0x10) !== 0) {
108
- const statusLow = byteAt(frame, cursor, offset);
109
- const statusHigh = byteAt(frame, cursor + 1, offset);
110
- if (statusLow !== undefined && statusHigh !== undefined) {
111
- const status = statusLow | statusHigh << 8;
109
+ const status = bloodPressureStatusFromFrame(frame, offset);
110
+ if (status !== undefined) {
112
111
  metadata.status = (status & 0x01) !== 0 ? BloodPressureStates.DISTURB_DETECTED : (status & 0x02) !== 0 ? BloodPressureStates.LOOSE_SLEEVE : BloodPressureStates.REGULAR;
113
112
  if ((status & 0x04) !== 0) {
114
113
  metadata.irregularHeartbeat = true;
@@ -120,5 +119,5 @@ const decorateBloodPressureReading = (reading, frame, recordOffset) => {
120
119
  ...metadata
121
120
  } : reading;
122
121
  };
123
- export { decorateBloodPressureReading, declareProfile, littleEndian, recordedAtFromBloodPressureFrame, sigUuid };
122
+ export { bloodPressureStatusFromFrame, decorateBloodPressureReading, declareProfile, littleEndian, recordedAtFromBloodPressureFrame, sigUuid };
124
123
  //# sourceMappingURL=standard-gatt.profile.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["BloodPressureStates","defineCustomDevice","SPOT_CHECK_TIMEOUT_MS","sigUuid","assigned","declareProfile","params","profile","id","measurementTypeKey","nameMatch","matchByService","undefined","oneReadingPerConnection","stuckDataTimeoutMs","services","uuid","service","monitor","characteristic","frame","minLengthBytes","caseSelectorBytes","cases","selectors","map","selector","optional","optionalFields","fields","fieldsBySelector","kind","decorateReading","littleEndian","name","byteIndexes","unit","encoding","byteOrder","byteAt","index","offset","value","Number","parseInt","isInteger","recordedAtFromBloodPressureFrame","flags","yearLow","yearHigh","month","day","hour","minute","second","year","recordedAt","Date","getFullYear","getMonth","getDate","getHours","getMinutes","getSeconds","decorateBloodPressureReading","reading","recordOffset","cursor","metadata","userId","memorySlot","statusLow","statusHigh","status","DISTURB_DETECTED","LOOSE_SLEEVE","REGULAR","irregularHeartbeat","Object","keys","length"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/standard-gatt/standard-gatt.profile.ts"],"mappings":";;AAEA,SAASA,mBAAmB,QAAQ,yCAAsC;AAM1E,SAASC,kBAAkB,QAAQ,sCAAmC;;AAEtE;AACA,MAAMC,qBAAqB,GAAG,MAAM;AAkDpC,MAAMC,OAAO,GAAIC,QAAgB,IAC/B,OAAOA,QAAQ,8BAA8B;;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C2E,YAAY,GAChC3E,mBAAmB,CAAC4E,OAAO;MAEnC,IAAI,CAACH,MAAM,GAAG,IAAI,MAAM,CAAC,EAAE;QACzBL,QAAQ,CAACS,kBAAkB,GAAG,IAAI;MACpC;IACF;EACF;EAEA,OAAOC,MAAM,CAACC,IAAI,CAACX,QAAQ,CAAC,CAACY,MAAM,GAAG,CAAC,GAAG;IAAE,GAAGf,OAAO;IAAE,GAAGG;EAAS,CAAC,GAAGH,OAAO;AACjF,CAAC;AAED,SACED,4BAA4B,EAC5B3D,cAAc,EACd4B,YAAY,EACZa,gCAAgC,EAChC3C,OAAO","ignoreList":[]}
1
+ {"version":3,"names":["BloodPressureStates","defineCustomDevice","bloodPressureStatusFromFrame","SPOT_CHECK_TIMEOUT_MS","sigUuid","assigned","declareProfile","params","profile","id","measurementTypeKey","nameMatch","matchByService","undefined","oneReadingPerConnection","stuckDataTimeoutMs","services","uuid","service","monitor","characteristic","frame","minLengthBytes","caseSelectorBytes","cases","selectors","map","selector","optional","optionalFields","fields","fieldsBySelector","kind","decorateReading","littleEndian","name","byteIndexes","unit","encoding","byteOrder","byteAt","index","offset","value","Number","parseInt","isInteger","recordedAtFromBloodPressureFrame","flags","yearLow","yearHigh","month","day","hour","minute","second","year","recordedAt","Date","getFullYear","getMonth","getDate","getHours","getMinutes","getSeconds","decorateBloodPressureReading","reading","recordOffset","cursor","metadata","userId","memorySlot","status","DISTURB_DETECTED","LOOSE_SLEEVE","REGULAR","irregularHeartbeat","Object","keys","length"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/standard-gatt/standard-gatt.profile.ts"],"mappings":";;AAEA,SAASA,mBAAmB,QAAQ,yCAAsC;AAM1E,SAASC,kBAAkB,QAAQ,sCAAmC;AAEtE,SAASC,4BAA4B,QAAQ,0CAAuC;;AAEpF;AACA,MAAMC,qBAAqB,GAAG,MAAM;AAkDpC,MAAMC,OAAO,GAAIC,QAAgB,IAC/B,OAAOA,QAAQ,8BAA8B;;AAE/C;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CAACU,MAAM,GAAG,CAAC,GAAG;IAAE,GAAGb,OAAO;IAAE,GAAGG;EAAS,CAAC,GAAGH,OAAO;AACjF,CAAC;AAED,SACEhE,4BAA4B,EAC5B+D,4BAA4B,EAC5B3D,cAAc,EACd4B,YAAY,EACZa,gCAAgC,EAChC3C,OAAO","ignoreList":[]}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  import { standardBloodPressureDevice } from "../standard-gatt/standard-gatt.devices.js";
4
+ import { bloodPressureStatusFromFrame } from "../standard-gatt/standard-gatt.profile.js";
4
5
 
5
6
  /**
6
7
  * The Veroval compact+ blood-pressure monitors.
@@ -18,9 +19,36 @@ import { standardBloodPressureDevice } from "../standard-gatt/standard-gatt.devi
18
19
 
19
20
  const BPU_26 = "BPU26";
20
21
  const BPW_26 = "BPW26";
22
+ const VEROVAL_TRIPLE_MEASUREMENT = 1 << 13;
23
+ const VEROVAL_ATRIAL_FIBRILLATION = 1 << 14;
24
+ const VEROVAL_RESTING_MEASUREMENT = 1 << 15;
25
+ const verovalStatusDecorator = supportedBits => (reading, frame, recordOffset) => {
26
+ if (!frame) {
27
+ return reading;
28
+ }
29
+ const status = bloodPressureStatusFromFrame(frame, recordOffset);
30
+ if (status === undefined) {
31
+ return reading;
32
+ }
33
+ const metadata = {};
34
+ if ((supportedBits & VEROVAL_TRIPLE_MEASUREMENT) !== 0 && (status & VEROVAL_TRIPLE_MEASUREMENT) !== 0) {
35
+ metadata.tripleMeasurement = true;
36
+ }
37
+ if ((supportedBits & VEROVAL_ATRIAL_FIBRILLATION) !== 0 && (status & VEROVAL_ATRIAL_FIBRILLATION) !== 0) {
38
+ metadata.atrialFibrillation = true;
39
+ }
40
+ if ((supportedBits & VEROVAL_RESTING_MEASUREMENT) !== 0 && (status & VEROVAL_RESTING_MEASUREMENT) !== 0) {
41
+ metadata.restingMeasurement = true;
42
+ }
43
+ return Object.keys(metadata).length > 0 ? {
44
+ ...reading,
45
+ ...metadata
46
+ } : reading;
47
+ };
21
48
  const verovalCompactMonitor = (advertisedName, params) => standardBloodPressureDevice({
22
49
  id: params.id ?? `veroval-${advertisedName.toLowerCase().replace(/[^a-z0-9]+/g, "-")}`,
23
50
  nameMatch: params.nameMatch ?? new RegExp(`^${advertisedName}$`, "i"),
51
+ decorateReading: advertisedName === BPU_26 ? verovalStatusDecorator(VEROVAL_TRIPLE_MEASUREMENT | VEROVAL_ATRIAL_FIBRILLATION | VEROVAL_RESTING_MEASUREMENT) : verovalStatusDecorator(VEROVAL_TRIPLE_MEASUREMENT),
24
52
  ...(params.stuckDataTimeoutMs === undefined ? {} : {
25
53
  stuckDataTimeoutMs: params.stuckDataTimeoutMs
26
54
  })
@@ -1 +1 @@
1
- {"version":3,"names":["standardBloodPressureDevice","BPU_26","BPW_26","verovalCompactMonitor","advertisedName","params","id","toLowerCase","replace","nameMatch","RegExp","stuckDataTimeoutMs","undefined","bpu26Monitor","bpw26Monitor","VEROVAL_BP_MODEL_NAMES"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/veroval/veroval.bp-monitors.ts"],"mappings":";;AACA,SAASA,2BAA2B,QAAQ,2CAAwC;;AAEpF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMC,MAAM,GAAG,OAAO;AACtB,MAAMC,MAAM,GAAG,OAAO;AActB,MAAMC,qBAAqB,GAAGA,CAC5BC,cAAsB,EACtBC,MAAuB,KAEvBL,2BAA2B,CAAC;EAC1BM,EAAE,EAAED,MAAM,CAACC,EAAE,IAAI,WAAWF,cAAc,CAACG,WAAW,CAAC,CAAC,CAACC,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC,EAAE;EACtFC,SAAS,EAAEJ,MAAM,CAACI,SAAS,IAAI,IAAIC,MAAM,CAAC,IAAIN,cAAc,GAAG,EAAE,GAAG,CAAC;EACrE,IAAIC,MAAM,CAACM,kBAAkB,KAAKC,SAAS,GACvC,CAAC,CAAC,GACF;IAAED,kBAAkB,EAAEN,MAAM,CAACM;EAAmB,CAAC;AACvD,CAAC,CAAC;;AAEJ;AACA,MAAME,YAAY,GAAIR,MAAuB,IAC3CF,qBAAqB,CAACF,MAAM,EAAEI,MAAM,CAAC;;AAEvC;AACA,MAAMS,YAAY,GAAIT,MAAuB,IAC3CF,qBAAqB,CAACD,MAAM,EAAEG,MAAM,CAAC;;AAEvC;AACA,MAAMU,sBAAyC,GAAG,CAACd,MAAM,EAAEC,MAAM,CAAC;AAElE,SACEW,YAAY,EACZC,YAAY,EACZC,sBAAsB,EACtBZ,qBAAqB","ignoreList":[]}
1
+ {"version":3,"names":["standardBloodPressureDevice","bloodPressureStatusFromFrame","BPU_26","BPW_26","VEROVAL_TRIPLE_MEASUREMENT","VEROVAL_ATRIAL_FIBRILLATION","VEROVAL_RESTING_MEASUREMENT","verovalStatusDecorator","supportedBits","reading","frame","recordOffset","status","undefined","metadata","tripleMeasurement","atrialFibrillation","restingMeasurement","Object","keys","length","verovalCompactMonitor","advertisedName","params","id","toLowerCase","replace","nameMatch","RegExp","decorateReading","stuckDataTimeoutMs","bpu26Monitor","bpw26Monitor","VEROVAL_BP_MODEL_NAMES"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/veroval/veroval.bp-monitors.ts"],"mappings":";;AAOA,SAASA,2BAA2B,QAAQ,2CAAwC;AACpF,SAASC,4BAA4B,QAAQ,2CAAwC;;AAErF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMC,MAAM,GAAG,OAAO;AACtB,MAAMC,MAAM,GAAG,OAAO;AAEtB,MAAMC,0BAA0B,GAAG,CAAC,IAAI,EAAE;AAC1C,MAAMC,2BAA2B,GAAG,CAAC,IAAI,EAAE;AAC3C,MAAMC,2BAA2B,GAAG,CAAC,IAAI,EAAE;AAc3C,MAAMC,sBAAsB,GAC1BC,aAAqB,IACM,CAACC,OAAO,EAAEC,KAAK,EAAEC,YAAY,KAAK;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A2B,GAC3BC,2BACJ,CAAC,GACDC,sBAAsB,CAACH,0BAA0B,CAAC;EACxD,IAAImB,MAAM,CAACO,kBAAkB,KAAKjB,SAAS,GACvC,CAAC,CAAC,GACF;IAAEiB,kBAAkB,EAAEP,MAAM,CAACO;EAAmB,CAAC;AACvD,CAAC,CAAC;;AAEJ;AACA,MAAMC,YAAY,GAAIR,MAAuB,IAC3CF,qBAAqB,CAACnB,MAAM,EAAEqB,MAAM,CAAC;;AAEvC;AACA,MAAMS,YAAY,GAAIT,MAAuB,IAC3CF,qBAAqB,CAAClB,MAAM,EAAEoB,MAAM,CAAC;;AAEvC;AACA,MAAMU,sBAAyC,GAAG,CAAC/B,MAAM,EAAEC,MAAM,CAAC;AAElE,SACE4B,YAAY,EACZC,YAAY,EACZC,sBAAsB,EACtBZ,qBAAqB","ignoreList":[]}
@@ -3,6 +3,7 @@
3
3
  import { MeasurementTypeKey } from "@ovok/core";
4
4
  import { CaseType } from "../../../types/case-type.js";
5
5
  import { BTManagedDevice } from "../bt-managed-device.js";
6
+ import { parseVerovalBloodPressureRecord } from "./veroval.ecg-record.js";
6
7
  import { decodeVerovalEcgSamples, VEROVAL_ECG_SAMPLE_RATE_HZ } from "./veroval.ecg-samples.js";
7
8
  import { VerovalEcgTransfer } from "./veroval.ecg-transfer.js";
8
9
  const SERVICE = "0000a000-0000-1000-8000-00805f9b34fb";
@@ -60,18 +61,33 @@ export class VerovalEcgDevice extends BTManagedDevice {
60
61
  serviceUuid: SERVICE,
61
62
  characteristicUuid: CONTROL_POINT
62
63
  },
63
- onRecording: this.reportRecording
64
+ onRecord: this.reportRecord,
65
+ clockSync: this.clockSync
64
66
  });
65
67
  constructor(device, params) {
66
68
  super(device, params);
69
+ this.clockSync = params.clockSync;
67
70
  }
68
71
 
69
72
  /** Nothing is reported per packet; the transfer reports the recording when it is whole. */
70
73
  handleSuccessResult() {
71
74
  return;
72
75
  }
73
- reportRecording = bytes => {
74
- const diagramPoints = decodeVerovalEcgSamples(bytes);
76
+ reportRecord = record => {
77
+ if (!record.header.isEcg) {
78
+ const bloodPressure = parseVerovalBloodPressureRecord(record.header);
79
+ if (bloodPressure) {
80
+ this.onResult?.({
81
+ caseType: CaseType.RESULT,
82
+ ...bloodPressure
83
+ });
84
+ }
85
+ return;
86
+ }
87
+ if (!record.raw || record.header.heartRate === 0) {
88
+ return;
89
+ }
90
+ const diagramPoints = decodeVerovalEcgSamples(record.raw, record.header.calibration);
75
91
  if (diagramPoints.length === 0) {
76
92
  this.onError?.(new Error("Veroval ECG: the recording held no samples."));
77
93
  return;
@@ -79,6 +95,11 @@ export class VerovalEcgDevice extends BTManagedDevice {
79
95
  this.onResult?.({
80
96
  measurementTypeKey: MeasurementTypeKey.ecg,
81
97
  caseType: CaseType.RESULT,
98
+ id: `veroval-${record.header.memorySlot}-${record.header.sequence}-${record.header.recordedAt?.getTime() ?? "unknown"}`,
99
+ memorySlot: record.header.memorySlot,
100
+ recordedAt: record.header.recordedAt,
101
+ heartRate: record.header.heartRate,
102
+ diagnosticResult: record.header.diagnosticResult,
82
103
  diagramPoints,
83
104
  duration: diagramPoints.length / VEROVAL_ECG_SAMPLE_RATE_HZ
84
105
  });
@@ -1 +1 @@
1
- {"version":3,"names":["MeasurementTypeKey","CaseType","BTManagedDevice","decodeVerovalEcgSamples","VEROVAL_ECG_SAMPLE_RATE_HZ","VerovalEcgTransfer","SERVICE","CONTROL_POINT","NOTIFY","STUCK_TIMEOUT_MS","PREFERRED_MTU","acceptEverything","caseValuePosition","cases","caseValue","caseType","OTHER","parseDefinitions","description","VerovalEcgDevice","stuckDataTimeout","preferredMtu","onStreamStart","undefined","mainServices","uuid","monitorUuids","parsingModel","validatePackage","createCommandSequencer","write","serviceUuid","characteristicUuid","onRecording","reportRecording","constructor","device","params","handleSuccessResult","bytes","diagramPoints","length","onError","Error","onResult","measurementTypeKey","ecg","RESULT","duration"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/veroval/veroval.ecg-device.ts"],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,MAAc,EACdC,MAAyD,EACzD;IACA,KAAK,CAACD,MAAM,EAAEC,MAAM,CAAC;EACvB;;EAEA;EACUC,mBAAmBA,CAAA,EAAS;IACpC;EACF;EAEQJ,eAAe,GAAIK,KAAwB,IAAW;IAC5D,MAAMC,aAAa,GAAGrC,uBAAuB,CAACoC,KAAK,CAAC;IAEpD,IAAIC,aAAa,CAACC,MAAM,KAAK,CAAC,EAAE;MAC9B,IAAI,CAACC,OAAO,GAAG,IAAIC,KAAK,CAAC,6CAA6C,CAAC,CAAC;MAExE;IACF;IAEA,IAAI,CAACC,QAAQ,GAAG;MACdC,kBAAkB,EAAE7C,kBAAkB,CAAC8C,GAAG;MAC1C/B,QAAQ,EAAEd,QAAQ,CAAC8C,MAAM;MACzBP,aAAa;MACbQ,QAAQ,EAAER,aAAa,CAACC,MAAM,GAAGrC;IACnC,CAAC,CAAC;EACJ,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"names":["MeasurementTypeKey","CaseType","BTManagedDevice","parseVerovalBloodPressureRecord","decodeVerovalEcgSamples","VEROVAL_ECG_SAMPLE_RATE_HZ","VerovalEcgTransfer","SERVICE","CONTROL_POINT","NOTIFY","STUCK_TIMEOUT_MS","PREFERRED_MTU","acceptEverything","caseValuePosition","cases","caseValue","caseType","OTHER","parseDefinitions","description","VerovalEcgDevice","stuckDataTimeout","preferredMtu","onStreamStart","undefined","mainServices","uuid","monitorUuids","parsingModel","validatePackage","createCommandSequencer","write","serviceUuid","characteristicUuid","onRecord","reportRecord","clockSync","constructor","device","params","handleSuccessResult","record","header","isEcg","bloodPressure","onResult","RESULT","raw","heartRate","diagramPoints","calibration","length","onError","Error","measurementTypeKey","ecg","id","memorySlot","sequence","recordedAt","getTime","diagnosticResult","duration"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/veroval/veroval.ecg-device.ts"],"mappings":";;AAAA,SAASA,kBAAkB,QAAQ,YAAY;AAG/C,SAASC,QAAQ,QAAQ,6BAA0B;AAInD,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AM,CAACC,MAAM,CAACM,SAAS;MAClCa,gBAAgB,EAAEpB,MAAM,CAACC,MAAM,CAACmB,gBAAgB;MAChDZ,aAAa;MACba,QAAQ,EAAEb,aAAa,CAACE,MAAM,GAAG9C;IACnC,CAAC,CAAC;EACJ,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+
3
+ import { EcgDiagnosticFlag, MeasurementTypeKey } from "@ovok/core";
4
+ import { hexToByte } from "../../../utils/hex-to-byte.js";
5
+ const HEADER_BYTES = 80;
6
+ const ECG_RECORD_TYPE = 38;
7
+ const ECG_ERROR_OFFSET = 30;
8
+ const RECORD_TYPE_OFFSET = 71;
9
+ const RAW_SIZE_OFFSET = 40;
10
+ const USER_OFFSET = 44;
11
+ const HEART_RATE_OFFSET = 47;
12
+ const BP_ERROR_OFFSET = 62;
13
+ const BP_PULSE_OFFSET = 63;
14
+ const BP_SYSTOLIC_OFFSET = 64;
15
+ const BP_DIASTOLIC_OFFSET = 66;
16
+ const TIMESTAMP_OFFSET = 20;
17
+ const TIMESTAMP_BYTES = 6;
18
+ const byteAt = (bytes, offset) => {
19
+ const value = hexToByte(bytes[offset] ?? "00");
20
+ return Number.isFinite(value) ? value : 0;
21
+ };
22
+ const littleEndianAt = (bytes, offset, count) => bytes.slice(offset, offset + count).reduce((value, byte, index) => value | byteAt([byte], 0) << index * 8, 0);
23
+ const signed16At = (bytes, offset) => {
24
+ const value = littleEndianAt(bytes, offset, 2);
25
+ return value & 0x8000 ? value - 0x10000 : value;
26
+ };
27
+ const dateFromHeader = bytes => {
28
+ const [year = 0, month = 0, day = 0, hours = 0, minutes = 0, seconds = 0] = Array.from({
29
+ length: TIMESTAMP_BYTES
30
+ }, (_, index) => byteAt(bytes, TIMESTAMP_OFFSET + index));
31
+ const recordedAt = new Date(2000 + year, month - 1, day, hours, minutes, seconds);
32
+ return recordedAt.getFullYear() === 2000 + year && recordedAt.getMonth() === month - 1 && recordedAt.getDate() === day && recordedAt.getHours() === hours && recordedAt.getMinutes() === minutes && recordedAt.getSeconds() === seconds ? recordedAt : undefined;
33
+ };
34
+ const diagnosticFromHeader = bytes => {
35
+ if (byteAt(bytes, 48) > 0 || littleEndianAt(bytes, 56, 2) > 0) {
36
+ return EcgDiagnosticFlag.HIGH_HR;
37
+ }
38
+ if (byteAt(bytes, 49) > 0 || littleEndianAt(bytes, 58, 2) > 0) {
39
+ return EcgDiagnosticFlag.LOW_HR;
40
+ }
41
+ if (byteAt(bytes, 50) > 0 || byteAt(bytes, 52) > 0) {
42
+ return EcgDiagnosticFlag.RR_IRREGULAR;
43
+ }
44
+ return byteAt(bytes, 53) > 0 ? EcgDiagnosticFlag.POOR_WAVEFORM : undefined;
45
+ };
46
+ const calibrationFromHeader = bytes => {
47
+ const physicalMinimumMicrovolts = signed16At(bytes, 31);
48
+ const physicalMaximumMicrovolts = signed16At(bytes, 33);
49
+ const digitalMinimum = signed16At(bytes, 35);
50
+ const digitalMaximum = signed16At(bytes, 37);
51
+ return physicalMinimumMicrovolts < physicalMaximumMicrovolts && digitalMinimum < digitalMaximum ? {
52
+ physicalMinimumMicrovolts,
53
+ physicalMaximumMicrovolts,
54
+ digitalMinimum,
55
+ digitalMaximum
56
+ } : undefined;
57
+ };
58
+ const parseVerovalEcgHeader = bytes => {
59
+ if (bytes.length < HEADER_BYTES) {
60
+ return undefined;
61
+ }
62
+ const isEcg = byteAt(bytes, RECORD_TYPE_OFFSET) === ECG_RECORD_TYPE;
63
+ return {
64
+ bytes: [...bytes.slice(0, HEADER_BYTES)],
65
+ sequence: byteAt(bytes, 0),
66
+ recordedAt: dateFromHeader(bytes),
67
+ memorySlot: byteAt(bytes, USER_OFFSET) === 0 ? 1 : 2,
68
+ rawSize: littleEndianAt(bytes, RAW_SIZE_OFFSET, 4),
69
+ heartRate: byteAt(bytes, HEART_RATE_OFFSET),
70
+ diagnosticResult: diagnosticFromHeader(bytes),
71
+ calibration: calibrationFromHeader(bytes),
72
+ isEcg,
73
+ hasError: isEcg ? byteAt(bytes, ECG_ERROR_OFFSET) !== 0 : byteAt(bytes, BP_ERROR_OFFSET) !== 0
74
+ };
75
+ };
76
+ const verovalRecordId = header => `veroval-${header.memorySlot}-${header.sequence}-${header.recordedAt?.getTime() ?? "unknown"}`;
77
+ const parseVerovalBloodPressureRecord = header => {
78
+ if (header.isEcg || header.hasError) {
79
+ return undefined;
80
+ }
81
+ return {
82
+ id: verovalRecordId(header),
83
+ measurementTypeKey: MeasurementTypeKey.bloodPressure,
84
+ systolic: littleEndianAt(header.bytes, BP_SYSTOLIC_OFFSET, 2),
85
+ diastolic: littleEndianAt(header.bytes, BP_DIASTOLIC_OFFSET, 2),
86
+ heartRate: byteAt(header.bytes, BP_PULSE_OFFSET),
87
+ recordedAt: header.recordedAt,
88
+ memorySlot: header.memorySlot
89
+ };
90
+ };
91
+ export { BP_DIASTOLIC_OFFSET, BP_ERROR_OFFSET, BP_PULSE_OFFSET, BP_SYSTOLIC_OFFSET, ECG_RECORD_TYPE, HEADER_BYTES, parseVerovalBloodPressureRecord, parseVerovalEcgHeader, RECORD_TYPE_OFFSET, RAW_SIZE_OFFSET, USER_OFFSET, verovalRecordId };
92
+ //# sourceMappingURL=veroval.ecg-record.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["EcgDiagnosticFlag","MeasurementTypeKey","hexToByte","HEADER_BYTES","ECG_RECORD_TYPE","ECG_ERROR_OFFSET","RECORD_TYPE_OFFSET","RAW_SIZE_OFFSET","USER_OFFSET","HEART_RATE_OFFSET","BP_ERROR_OFFSET","BP_PULSE_OFFSET","BP_SYSTOLIC_OFFSET","BP_DIASTOLIC_OFFSET","TIMESTAMP_OFFSET","TIMESTAMP_BYTES","byteAt","bytes","offset","value","Number","isFinite","littleEndianAt","count","slice","reduce","byte","index","signed16At","dateFromHeader","year","month","day","hours","minutes","seconds","Array","from","length","_","recordedAt","Date","getFullYear","getMonth","getDate","getHours","getMinutes","getSeconds","undefined","diagnosticFromHeader","HIGH_HR","LOW_HR","RR_IRREGULAR","POOR_WAVEFORM","calibrationFromHeader","physicalMinimumMicrovolts","physicalMaximumMicrovolts","digitalMinimum","digitalMaximum","parseVerovalEcgHeader","isEcg","sequence","memorySlot","rawSize","heartRate","diagnosticResult","calibration","hasError","verovalRecordId","header","getTime","parseVerovalBloodPressureRecord","id","measurementTypeKey","bloodPressure","systolic","diastolic"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/veroval/veroval.ecg-record.ts"],"mappings":";;AAAA,SAEEA,iBAAiB,EAEjBC,kBAAkB,QACb,YAAY;AAEnB,SAASC,SAAS,QAAQ,+BAA4B;AAEtD,MAAMC,YAAY,GAAG,EAAE;AACvB,MAAMC,eAAe,GAAG,EAAE;AAC1B,MAAMC,gBAAgB,GAAG,EAAE;AAC3B,MAAMC,kBAAkB,GAAG,EAAE;AAC7B,MAAMC,eAAe,GAAG,EAAE;AAC1B,MAAMC,WAAW,GAAG,EAAE;AACtB,MAAMC,iBAAiB,GAAG,EAAE;AAC5B,MAAMC,eAAe,GAAG,EAAE;AAC1B,MAAMC,eAAe,GAAG,EAAE;AAC1B,MAAMC,kBAAkB,GAAG,EAAE;AAC7B,MAAMC,mBAAmB,GAAG,EAAE;AAC9B,MAAMC,gBAAgB,GAAG,EAAE;AAC3B,MAAMC,eAAe,GAAG,CAAC;AAEzB,MAAMC,MAAM,GAAGA,CAACC,KAAwB,EAAEC,MAAc,KAAa;EACnE,MAAMC,KAAK,GAAGjB,SAAS,CAACe,KAAK,CAACC,MAAM,CAAC,IAAI,IAAI,CAAC;EAE9C,OAAOE,MAAM,CAACC,QAAQ,CAACF,KAAK,CAAC,GAAGA,KAAK,GAAG,CAAC;AAC3C,CAAC;AAED,MAAMG,cAAc,GAAGA,CACrBL,KAAwB,EACxBC,MAAc,EACdK,KAAa,KAEbN,KAAK,CACFO,KAAK,CAACN,MAAM,EAAEA,MAAM,GAAGK,KAAK,CAAC,CAC7BE,MAAM,CAAC,CAACN,KAAK,EAAEO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ExE,kBAAkB,CAACyE,aAAa;IACpDC,QAAQ,EAAErD,cAAc,CAAC+C,MAAM,CAACpD,KAAK,EAAEL,kBAAkB,EAAE,CAAC,CAAC;IAC7DgE,SAAS,EAAEtD,cAAc,CAAC+C,MAAM,CAACpD,KAAK,EAAEJ,mBAAmB,EAAE,CAAC,CAAC;IAC/DmD,SAAS,EAAEhD,MAAM,CAACqD,MAAM,CAACpD,KAAK,EAAEN,eAAe,CAAC;IAChD6B,UAAU,EAAE6B,MAAM,CAAC7B,UAAU;IAC7BsB,UAAU,EAAEO,MAAM,CAACP;EACrB,CAAC;AACH,CAAC;AAED,SACEjD,mBAAmB,EACnBH,eAAe,EACfC,eAAe,EACfC,kBAAkB,EAClBR,eAAe,EACfD,YAAY,EACZoE,+BAA+B,EAC/BZ,qBAAqB,EACrBrD,kBAAkB,EAClBC,eAAe,EACfC,WAAW,EACX4D,eAAe","ignoreList":[]}
@@ -1,32 +1,49 @@
1
1
  "use strict";
2
2
 
3
- /** Every request is a fixed twenty-byte packet, zero filled but for its group and command. */
3
+ /* eslint-disable max-lines */
4
+ import { getClockParts, isClockSyncEnabled } from "../../../types/clock-sync.js";
5
+ import { hexToByte } from "../../../utils/hex-to-byte.js";
6
+ import { parseVerovalEcgHeader } from "./veroval.ecg-record.js";
7
+
8
+ /** Every request is a fixed twenty-byte packet, zero filled after its command data. */
4
9
  const PACKET_BYTES = 20;
5
10
  const GROUP_INDEX = 1;
6
11
  const COMMAND_INDEX = 2;
7
12
  const PARAMETER_INDEX = 3;
8
13
  const DOWNLOAD_GROUP = 4;
14
+ const DOWNLOAD_WAIT = 0;
9
15
  const DOWNLOAD_MODE = 1;
10
16
  const DOWNLOAD_HEADER = 2;
11
17
  const DOWNLOAD_RAW = 3;
18
+ const SETTINGS_GROUP = 7;
19
+ const SET_TIME_GROUP = 5;
20
+ const SETTINGS_COMMAND = 2;
12
21
  const FRAME_GROUP_INDEX = 1;
13
22
  const FRAME_COMMAND_INDEX = 2;
14
23
  const FRAME_PACKET_INDEX = 3;
24
+ const MODE_USER_ONE_COUNT_INDEX = 3;
25
+ const MODE_USER_TWO_COUNT_INDEX = 4;
15
26
 
16
- /** The transfer's shape, from the vendor's own device table. */
27
+ /** The device answers a header with five notifications of sixteen bytes each. */
17
28
  const PAYLOAD_FROM = 4;
18
29
  const PAYLOAD_BYTES = 16;
19
30
  const HEADER_PACKETS = 5;
20
31
  const PACKETS_PER_SEGMENT = 16;
21
- const SEGMENTS = 34;
32
+ const SEGMENT_BYTES = PAYLOAD_BYTES * PACKETS_PER_SEGMENT;
33
+ const COMMAND_TIMEOUT_MS = 3_000;
34
+ const RAW_TIMEOUT_MS = 2_000;
35
+ const MAX_RETRIES = 2;
36
+ const SET_TIME_DELAY_MS = 1_500;
22
37
  const BYTE_MASK = 0xff;
23
- const BYTE_BITS = 8;
38
+ const byteAt = (frame, index) => {
39
+ const value = hexToByte(frame[index] ?? "00");
40
+ return Number.isFinite(value) ? value : 0;
41
+ };
24
42
  const toHex = byte => (byte & BYTE_MASK).toString(16).padStart(2, "0");
25
- const isDownloadFrame = (frame, command) => frame[FRAME_GROUP_INDEX]?.toLowerCase() === toHex(DOWNLOAD_GROUP) && frame[FRAME_COMMAND_INDEX]?.toLowerCase() === toHex(command);
26
- const isExpectedRawPacket = (frame, packetIndex) => isDownloadFrame(frame, DOWNLOAD_RAW) && frame[FRAME_PACKET_INDEX]?.toLowerCase() === toHex(packetIndex);
27
- const packet = (write, command, parameters = []) => {
43
+ const isFrame = (frame, group, command) => byteAt(frame, FRAME_GROUP_INDEX) === group && byteAt(frame, FRAME_COMMAND_INDEX) === command;
44
+ const packet = (write, group, command, parameters = [], delayBeforeWriteMs) => {
28
45
  const bytes = new Array(PACKET_BYTES).fill(0);
29
- bytes[GROUP_INDEX] = DOWNLOAD_GROUP;
46
+ bytes[GROUP_INDEX] = group;
30
47
  bytes[COMMAND_INDEX] = command;
31
48
  parameters.forEach((value, index) => {
32
49
  bytes[PARAMETER_INDEX + index] = value;
@@ -34,72 +51,216 @@ const packet = (write, command, parameters = []) => {
34
51
  return {
35
52
  ...write,
36
53
  frame: bytes.map(toHex),
37
- withoutResponse: true
54
+ withoutResponse: true,
55
+ ...(delayBeforeWriteMs === undefined ? {} : {
56
+ delayBeforeWriteMs
57
+ })
38
58
  };
39
59
  };
40
- const segmentParameters = segment => [segment & BYTE_MASK, segment >> BYTE_BITS & BYTE_MASK, segment >> BYTE_BITS * 2 & BYTE_MASK];
60
+ const payloadOf = frame => [...frame.slice(PAYLOAD_FROM, PAYLOAD_FROM + PAYLOAD_BYTES)];
61
+ const settingsCommand = write => packet(write, SETTINGS_GROUP, SETTINGS_COMMAND, [], SET_TIME_DELAY_MS);
62
+ const setTimeCommand = (write, clockSync, settings) => {
63
+ const parts = getClockParts(clockSync?.now?.() ?? new Date(), clockSync?.timezone);
64
+ return packet(write, SET_TIME_GROUP, SETTINGS_COMMAND, [parts.year % 100, parts.month, parts.day, parts.hours, parts.minutes, parts.seconds, settings[0] ?? 0, settings[1] ?? 0, settings[2] ?? 0]);
65
+ };
41
66
  /**
42
- * Downloads a recording from the Veroval ECG.
43
- *
44
- * The exchange is a fixed walk rather than a conversation: ask for the download mode, then
45
- * the header, then each second of the recording in turn. The device answers each request
46
- * with a known number of twenty-byte packets, sixteen payload bytes each, so the transfer is
47
- * paced by counting them. Notifications for live measurements, standby and device settings
48
- * share the characteristic, so only the download group and command advance the transfer.
67
+ * Downloads all records from the Veroval ECG/BP monitor.
49
68
  *
50
- * A recording is thirty-four seconds at 128 Hz. Nothing is reported until all of it has
51
- * arrived: a partial ECG that looked whole would be worse than none, and the count is what
52
- * says it is whole.
69
+ * The mode reply gives the number of records in each user memory. Headers are collected first;
70
+ * only then does the device enter raw-download mode. This matters because a blood-pressure
71
+ * record is complete in its header while an ECG needs one or more raw segments.
53
72
  */
54
- export class VerovalEcgTransfer {
55
- phase = "mode";
56
- packets = 0;
57
- segment = 0;
58
- recording = [];
73
+ class VerovalEcgTransfer {
74
+ headerPacket = 0;
75
+ headerBytes = [];
76
+ recordIndex = 0;
77
+ expectedRecords = 0;
78
+ headers = [];
79
+ ecgHeaders = [];
80
+ ecgIndex = 0;
81
+ segment = 1;
82
+ rawPacket = 0;
83
+ segmentBytes = [];
84
+ rawBytes = [];
85
+ pendingTimeout = COMMAND_TIMEOUT_MS;
86
+ retries = 0;
87
+ settings = [0, 0, 0];
59
88
  constructor(params) {
60
89
  this.params = params;
90
+ this.phase = isClockSyncEnabled(params.clockSync) ? "settings" : "mode";
61
91
  }
62
- initialCommands = () => [packet(this.params.write, DOWNLOAD_MODE)];
92
+ initialCommands = () => this.phase === "settings" ? this.remember([settingsCommand(this.params.write)], COMMAND_TIMEOUT_MS, true) : this.requestMode();
63
93
  nextCommand = frame => {
64
94
  if (this.phase === "done") {
65
95
  return undefined;
66
96
  }
97
+ if (this.phase === "settings") {
98
+ return this.nextSettings(frame);
99
+ }
67
100
  if (this.phase === "mode") {
68
- if (!isDownloadFrame(frame, DOWNLOAD_MODE)) {
69
- return undefined;
70
- }
71
- this.phase = "header";
72
- this.packets = 0;
73
- return [packet(this.params.write, DOWNLOAD_HEADER)];
101
+ return this.nextMode(frame);
74
102
  }
75
103
  if (this.phase === "header") {
76
- if (!isDownloadFrame(frame, DOWNLOAD_HEADER)) {
77
- return undefined;
104
+ return this.nextHeader(frame);
105
+ }
106
+ return this.nextRaw(frame);
107
+ };
108
+ commandTimeoutMs = () => this.phase === "done" ? undefined : this.pendingTimeout;
109
+ onCommandTimeout = () => {
110
+ if (!this.lastCommand || this.phase === "done") {
111
+ return {
112
+ terminal: true
113
+ };
114
+ }
115
+ if (this.retries >= MAX_RETRIES) {
116
+ this.phase = "done";
117
+ return {
118
+ terminal: true
119
+ };
120
+ }
121
+ this.retries += 1;
122
+ if (this.phase === "header") {
123
+ this.headerPacket = 0;
124
+ this.headerBytes = [];
125
+ }
126
+ if (this.phase === "raw") {
127
+ this.rawPacket = 0;
128
+ this.segmentBytes = [];
129
+ }
130
+ return {
131
+ commands: [this.lastCommand]
132
+ };
133
+ };
134
+ commandProgress = frame => {
135
+ if (this.phase === "settings") {
136
+ return isFrame(frame, SETTINGS_GROUP, SETTINGS_COMMAND) ? "complete" : "ignored";
137
+ }
138
+ if (this.phase === "mode") {
139
+ return isFrame(frame, DOWNLOAD_GROUP, DOWNLOAD_MODE) ? "complete" : "ignored";
140
+ }
141
+ if (this.phase === "header") {
142
+ if (!isFrame(frame, DOWNLOAD_GROUP, DOWNLOAD_HEADER) || byteAt(frame, FRAME_PACKET_INDEX) !== this.headerPacket) {
143
+ return "ignored";
78
144
  }
79
- this.packets += 1;
80
- return this.packets < HEADER_PACKETS ? undefined : this.requestSegment(0);
145
+ return this.headerPacket + 1 === HEADER_PACKETS ? "complete" : "partial";
146
+ }
147
+ if (!isFrame(frame, DOWNLOAD_GROUP, DOWNLOAD_RAW) || byteAt(frame, FRAME_PACKET_INDEX) !== this.rawPacket) {
148
+ return "ignored";
81
149
  }
82
- if (!isExpectedRawPacket(frame, this.packets)) {
150
+ return this.rawPacket + 1 === PACKETS_PER_SEGMENT ? "complete" : "partial";
151
+ };
152
+ nextSettings = frame => {
153
+ if (!isFrame(frame, SETTINGS_GROUP, SETTINGS_COMMAND)) {
83
154
  return undefined;
84
155
  }
85
- this.packets += 1;
86
- this.recording.push(...frame.slice(PAYLOAD_FROM, PAYLOAD_FROM + PAYLOAD_BYTES));
87
- return this.packets < PACKETS_PER_SEGMENT ? undefined : this.finishSegment();
156
+ this.settings = [byteAt(frame, 5), byteAt(frame, 6), byteAt(frame, 7)];
157
+ this.phase = "mode";
158
+ return this.remember([setTimeCommand(this.params.write, this.params.clockSync, this.settings), packet(this.params.write, DOWNLOAD_GROUP, DOWNLOAD_MODE)], COMMAND_TIMEOUT_MS);
88
159
  };
89
- finishSegment = () => {
160
+ nextMode = frame => {
161
+ if (!isFrame(frame, DOWNLOAD_GROUP, DOWNLOAD_MODE)) {
162
+ return undefined;
163
+ }
164
+ const userOne = byteAt(frame, MODE_USER_ONE_COUNT_INDEX);
165
+ const userTwo = byteAt(frame, MODE_USER_TWO_COUNT_INDEX);
166
+ this.expectedRecords = userOne + userTwo;
167
+ if (this.expectedRecords === 0) {
168
+ this.phase = "done";
169
+ return undefined;
170
+ }
171
+ this.headers = [];
172
+ this.recordIndex = 0;
173
+ return this.requestHeader(this.recordIndex);
174
+ };
175
+ nextHeader = frame => {
176
+ if (!isFrame(frame, DOWNLOAD_GROUP, DOWNLOAD_HEADER) || byteAt(frame, FRAME_PACKET_INDEX) !== this.headerPacket) {
177
+ return undefined;
178
+ }
179
+ this.headerBytes.push(...payloadOf(frame));
180
+ this.headerPacket += 1;
181
+ if (this.headerPacket < HEADER_PACKETS) {
182
+ return undefined;
183
+ }
184
+ const header = parseVerovalEcgHeader(this.headerBytes);
185
+ if (header) {
186
+ this.headers.push(header);
187
+ }
188
+ this.recordIndex += 1;
189
+ if (this.recordIndex < this.expectedRecords) {
190
+ return this.requestHeader(this.recordIndex);
191
+ }
192
+ this.ecgHeaders = this.headers.filter(candidate => candidate.isEcg && !candidate.hasError && candidate.rawSize > 0);
193
+ this.headers.filter(candidate => !candidate.isEcg && !candidate.hasError).forEach(candidate => this.params.onRecord({
194
+ header: candidate
195
+ }));
196
+ if (this.ecgHeaders.length === 0) {
197
+ this.phase = "done";
198
+ return undefined;
199
+ }
200
+ this.ecgIndex = 0;
201
+ return this.remember([packet(this.params.write, DOWNLOAD_GROUP, DOWNLOAD_WAIT), ...this.requestRaw(this.ecgHeaders[0])], RAW_TIMEOUT_MS);
202
+ };
203
+ nextRaw = frame => {
204
+ if (!isFrame(frame, DOWNLOAD_GROUP, DOWNLOAD_RAW) || byteAt(frame, FRAME_PACKET_INDEX) !== this.rawPacket) {
205
+ return undefined;
206
+ }
207
+ this.segmentBytes.push(...payloadOf(frame));
208
+ this.rawPacket += 1;
209
+ if (this.rawPacket < PACKETS_PER_SEGMENT) {
210
+ return undefined;
211
+ }
212
+ this.rawBytes.push(...this.segmentBytes);
213
+ const header = this.ecgHeaders[this.ecgIndex];
214
+ if (!header) {
215
+ this.phase = "done";
216
+ return undefined;
217
+ }
218
+ if (this.rawBytes.length >= header.rawSize) {
219
+ this.params.onRecord({
220
+ header,
221
+ raw: this.rawBytes.slice(0, header.rawSize)
222
+ });
223
+ this.ecgIndex += 1;
224
+ if (this.ecgIndex >= this.ecgHeaders.length) {
225
+ this.phase = "done";
226
+ return undefined;
227
+ }
228
+ return this.remember(this.requestRaw(this.ecgHeaders[this.ecgIndex]), RAW_TIMEOUT_MS);
229
+ }
90
230
  this.segment += 1;
91
- if (this.segment < SEGMENTS) {
92
- return this.requestSegment(this.segment);
231
+ return this.remember(this.requestSegment(header), RAW_TIMEOUT_MS);
232
+ };
233
+ requestMode = () => this.remember([packet(this.params.write, DOWNLOAD_GROUP, DOWNLOAD_MODE)], COMMAND_TIMEOUT_MS);
234
+ requestHeader = index => {
235
+ this.phase = "header";
236
+ this.headerPacket = 0;
237
+ this.headerBytes = [];
238
+ return this.remember([packet(this.params.write, DOWNLOAD_GROUP, DOWNLOAD_HEADER, [index])], COMMAND_TIMEOUT_MS);
239
+ };
240
+ requestRaw = header => {
241
+ if (!header) {
242
+ this.phase = "done";
243
+ return [];
93
244
  }
94
- this.phase = "done";
95
- this.params.onRecording(this.recording);
96
- return undefined;
245
+ this.segment = 1;
246
+ this.rawBytes = [];
247
+ return this.requestSegment(header);
97
248
  };
98
- requestSegment = segment => {
249
+ requestSegment = header => {
99
250
  this.phase = "raw";
100
- this.packets = 0;
101
- this.segment = segment;
102
- return [packet(this.params.write, DOWNLOAD_RAW, segmentParameters(segment))];
251
+ this.rawPacket = 0;
252
+ this.segmentBytes = [];
253
+ return [packet(this.params.write, DOWNLOAD_GROUP, DOWNLOAD_RAW, [header.memorySlot - 1, header.sequence, this.segment])];
254
+ };
255
+ remember = (commands, timeout, preserveRetryCount = false) => {
256
+ const last = commands[commands.length - 1];
257
+ this.lastCommand = last;
258
+ this.pendingTimeout = timeout;
259
+ if (!preserveRetryCount) {
260
+ this.retries = 0;
261
+ }
262
+ return commands;
103
263
  };
104
264
  }
265
+ export { COMMAND_TIMEOUT_MS, DOWNLOAD_HEADER, DOWNLOAD_MODE, DOWNLOAD_RAW, DOWNLOAD_WAIT, HEADER_PACKETS, PACKETS_PER_SEGMENT, RAW_TIMEOUT_MS, SEGMENT_BYTES, SET_TIME_DELAY_MS, VerovalEcgTransfer };
105
266
  //# sourceMappingURL=veroval.ecg-transfer.js.map