@ovok/native 1.6.43 → 1.6.44

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 (158) hide show
  1. package/lib/commonjs/modules/bt-device/constants/device-instruction-pdfs.js +6 -1
  2. package/lib/commonjs/modules/bt-device/constants/device-instruction-pdfs.js.map +1 -1
  3. package/lib/commonjs/modules/bt-device/constants/supported-devices.js +30 -0
  4. package/lib/commonjs/modules/bt-device/constants/supported-devices.js.map +1 -1
  5. package/lib/commonjs/modules/bt-management/constants/integrated-devices-map.js +1 -1
  6. package/lib/commonjs/modules/bt-management/constants/integrated-devices-map.js.map +1 -1
  7. package/lib/commonjs/modules/bt-management/services/device-creator.js +11 -1
  8. package/lib/commonjs/modules/bt-management/services/device-creator.js.map +1 -1
  9. package/lib/commonjs/modules/bt-management/services/devices/viatom/bioland.bgm.device.js +50 -0
  10. package/lib/commonjs/modules/bt-management/services/devices/viatom/bioland.bgm.device.js.map +1 -0
  11. package/lib/commonjs/modules/bt-management/services/devices/viatom/bioland.bgm.protocol.js +115 -0
  12. package/lib/commonjs/modules/bt-management/services/devices/viatom/bioland.bgm.protocol.js.map +1 -0
  13. package/lib/commonjs/modules/bt-management/services/devices/viatom/bioland.bgm.sequencer.js +58 -0
  14. package/lib/commonjs/modules/bt-management/services/devices/viatom/bioland.bgm.sequencer.js.map +1 -0
  15. package/lib/commonjs/modules/bt-management/services/devices/viatom/poctor.m3102.device.js +41 -0
  16. package/lib/commonjs/modules/bt-management/services/devices/viatom/poctor.m3102.device.js.map +1 -0
  17. package/lib/commonjs/modules/bt-management/services/devices/viatom/poctor.m3102.protocol.js +61 -0
  18. package/lib/commonjs/modules/bt-management/services/devices/viatom/poctor.m3102.protocol.js.map +1 -0
  19. package/lib/commonjs/modules/bt-management/services/devices/viatom/poctor.m3102.sequencer.js +41 -0
  20. package/lib/commonjs/modules/bt-management/services/devices/viatom/poctor.m3102.sequencer.js.map +1 -0
  21. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.bpm188.device.js +50 -0
  22. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.bpm188.device.js.map +1 -0
  23. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.bpm188.protocol.js +141 -0
  24. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.bpm188.protocol.js.map +1 -0
  25. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.bpm188.sequencer.js +76 -0
  26. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.bpm188.sequencer.js.map +1 -0
  27. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.pc100.device.js +50 -0
  28. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.pc100.device.js.map +1 -0
  29. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.pc100.protocol.js +149 -0
  30. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.pc100.protocol.js.map +1 -0
  31. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.pc100.sequencer.js +81 -0
  32. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.pc100.sequencer.js.map +1 -0
  33. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.pc300.device.js +50 -0
  34. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.pc300.device.js.map +1 -0
  35. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.pc300.protocol.js +228 -0
  36. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.pc300.protocol.js.map +1 -0
  37. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.pc300.sequencer.js +122 -0
  38. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.pc300.sequencer.js.map +1 -0
  39. package/lib/commonjs/modules/bt-management/types/integrated-devices.js +5 -0
  40. package/lib/commonjs/modules/bt-management/types/integrated-devices.js.map +1 -1
  41. package/lib/module/modules/bt-device/constants/device-instruction-pdfs.js +6 -1
  42. package/lib/module/modules/bt-device/constants/device-instruction-pdfs.js.map +1 -1
  43. package/lib/module/modules/bt-device/constants/supported-devices.js +30 -0
  44. package/lib/module/modules/bt-device/constants/supported-devices.js.map +1 -1
  45. package/lib/module/modules/bt-management/constants/integrated-devices-map.js +1 -1
  46. package/lib/module/modules/bt-management/constants/integrated-devices-map.js.map +1 -1
  47. package/lib/module/modules/bt-management/services/device-creator.js +11 -1
  48. package/lib/module/modules/bt-management/services/device-creator.js.map +1 -1
  49. package/lib/module/modules/bt-management/services/devices/viatom/bioland.bgm.device.js +45 -0
  50. package/lib/module/modules/bt-management/services/devices/viatom/bioland.bgm.device.js.map +1 -0
  51. package/lib/module/modules/bt-management/services/devices/viatom/bioland.bgm.protocol.js +106 -0
  52. package/lib/module/modules/bt-management/services/devices/viatom/bioland.bgm.protocol.js.map +1 -0
  53. package/lib/module/modules/bt-management/services/devices/viatom/bioland.bgm.sequencer.js +53 -0
  54. package/lib/module/modules/bt-management/services/devices/viatom/bioland.bgm.sequencer.js.map +1 -0
  55. package/lib/module/modules/bt-management/services/devices/viatom/poctor.m3102.device.js +36 -0
  56. package/lib/module/modules/bt-management/services/devices/viatom/poctor.m3102.device.js.map +1 -0
  57. package/lib/module/modules/bt-management/services/devices/viatom/poctor.m3102.protocol.js +55 -0
  58. package/lib/module/modules/bt-management/services/devices/viatom/poctor.m3102.protocol.js.map +1 -0
  59. package/lib/module/modules/bt-management/services/devices/viatom/poctor.m3102.sequencer.js +36 -0
  60. package/lib/module/modules/bt-management/services/devices/viatom/poctor.m3102.sequencer.js.map +1 -0
  61. package/lib/module/modules/bt-management/services/devices/viatom/viatom.bpm188.device.js +45 -0
  62. package/lib/module/modules/bt-management/services/devices/viatom/viatom.bpm188.device.js.map +1 -0
  63. package/lib/module/modules/bt-management/services/devices/viatom/viatom.bpm188.protocol.js +130 -0
  64. package/lib/module/modules/bt-management/services/devices/viatom/viatom.bpm188.protocol.js.map +1 -0
  65. package/lib/module/modules/bt-management/services/devices/viatom/viatom.bpm188.sequencer.js +71 -0
  66. package/lib/module/modules/bt-management/services/devices/viatom/viatom.bpm188.sequencer.js.map +1 -0
  67. package/lib/module/modules/bt-management/services/devices/viatom/viatom.pc100.device.js +45 -0
  68. package/lib/module/modules/bt-management/services/devices/viatom/viatom.pc100.device.js.map +1 -0
  69. package/lib/module/modules/bt-management/services/devices/viatom/viatom.pc100.protocol.js +136 -0
  70. package/lib/module/modules/bt-management/services/devices/viatom/viatom.pc100.protocol.js.map +1 -0
  71. package/lib/module/modules/bt-management/services/devices/viatom/viatom.pc100.sequencer.js +76 -0
  72. package/lib/module/modules/bt-management/services/devices/viatom/viatom.pc100.sequencer.js.map +1 -0
  73. package/lib/module/modules/bt-management/services/devices/viatom/viatom.pc300.device.js +45 -0
  74. package/lib/module/modules/bt-management/services/devices/viatom/viatom.pc300.device.js.map +1 -0
  75. package/lib/module/modules/bt-management/services/devices/viatom/viatom.pc300.protocol.js +209 -0
  76. package/lib/module/modules/bt-management/services/devices/viatom/viatom.pc300.protocol.js.map +1 -0
  77. package/lib/module/modules/bt-management/services/devices/viatom/viatom.pc300.sequencer.js +117 -0
  78. package/lib/module/modules/bt-management/services/devices/viatom/viatom.pc300.sequencer.js.map +1 -0
  79. package/lib/module/modules/bt-management/types/device-measurement-map.js.map +1 -1
  80. package/lib/module/modules/bt-management/types/integrated-devices.js +5 -0
  81. package/lib/module/modules/bt-management/types/integrated-devices.js.map +1 -1
  82. package/lib/typescript/commonjs/src/modules/bt-device/constants/device-instruction-pdfs.d.ts.map +1 -1
  83. package/lib/typescript/commonjs/src/modules/bt-device/constants/supported-devices.d.ts.map +1 -1
  84. package/lib/typescript/commonjs/src/modules/bt-management/constants/integrated-devices-map.d.ts.map +1 -1
  85. package/lib/typescript/commonjs/src/modules/bt-management/services/device-creator.d.ts.map +1 -1
  86. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/bioland.bgm.device.d.ts +16 -0
  87. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/bioland.bgm.device.d.ts.map +1 -0
  88. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/bioland.bgm.protocol.d.ts +26 -0
  89. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/bioland.bgm.protocol.d.ts.map +1 -0
  90. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/bioland.bgm.sequencer.d.ts +24 -0
  91. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/bioland.bgm.sequencer.d.ts.map +1 -0
  92. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/poctor.m3102.device.d.ts +15 -0
  93. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/poctor.m3102.device.d.ts.map +1 -0
  94. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/poctor.m3102.protocol.d.ts +16 -0
  95. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/poctor.m3102.protocol.d.ts.map +1 -0
  96. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/poctor.m3102.sequencer.d.ts +17 -0
  97. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/poctor.m3102.sequencer.d.ts.map +1 -0
  98. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.bpm188.device.d.ts +16 -0
  99. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.bpm188.device.d.ts.map +1 -0
  100. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.bpm188.protocol.d.ts +36 -0
  101. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.bpm188.protocol.d.ts.map +1 -0
  102. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.bpm188.sequencer.d.ts +26 -0
  103. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.bpm188.sequencer.d.ts.map +1 -0
  104. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.pc100.device.d.ts +16 -0
  105. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.pc100.device.d.ts.map +1 -0
  106. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.pc100.protocol.d.ts +43 -0
  107. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.pc100.protocol.d.ts.map +1 -0
  108. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.pc100.sequencer.d.ts +26 -0
  109. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.pc100.sequencer.d.ts.map +1 -0
  110. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.pc300.device.d.ts +16 -0
  111. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.pc300.device.d.ts.map +1 -0
  112. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.pc300.protocol.d.ts +73 -0
  113. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.pc300.protocol.d.ts.map +1 -0
  114. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.pc300.sequencer.d.ts +25 -0
  115. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.pc300.sequencer.d.ts.map +1 -0
  116. package/lib/typescript/commonjs/src/modules/bt-management/types/device-measurement-map.d.ts +5 -0
  117. package/lib/typescript/commonjs/src/modules/bt-management/types/device-measurement-map.d.ts.map +1 -1
  118. package/lib/typescript/commonjs/src/modules/bt-management/types/integrated-devices.d.ts +6 -1
  119. package/lib/typescript/commonjs/src/modules/bt-management/types/integrated-devices.d.ts.map +1 -1
  120. package/lib/typescript/module/src/modules/bt-device/constants/device-instruction-pdfs.d.ts.map +1 -1
  121. package/lib/typescript/module/src/modules/bt-device/constants/supported-devices.d.ts.map +1 -1
  122. package/lib/typescript/module/src/modules/bt-management/constants/integrated-devices-map.d.ts.map +1 -1
  123. package/lib/typescript/module/src/modules/bt-management/services/device-creator.d.ts.map +1 -1
  124. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/bioland.bgm.device.d.ts +16 -0
  125. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/bioland.bgm.device.d.ts.map +1 -0
  126. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/bioland.bgm.protocol.d.ts +26 -0
  127. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/bioland.bgm.protocol.d.ts.map +1 -0
  128. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/bioland.bgm.sequencer.d.ts +24 -0
  129. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/bioland.bgm.sequencer.d.ts.map +1 -0
  130. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/poctor.m3102.device.d.ts +15 -0
  131. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/poctor.m3102.device.d.ts.map +1 -0
  132. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/poctor.m3102.protocol.d.ts +16 -0
  133. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/poctor.m3102.protocol.d.ts.map +1 -0
  134. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/poctor.m3102.sequencer.d.ts +17 -0
  135. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/poctor.m3102.sequencer.d.ts.map +1 -0
  136. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.bpm188.device.d.ts +16 -0
  137. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.bpm188.device.d.ts.map +1 -0
  138. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.bpm188.protocol.d.ts +36 -0
  139. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.bpm188.protocol.d.ts.map +1 -0
  140. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.bpm188.sequencer.d.ts +26 -0
  141. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.bpm188.sequencer.d.ts.map +1 -0
  142. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.pc100.device.d.ts +16 -0
  143. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.pc100.device.d.ts.map +1 -0
  144. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.pc100.protocol.d.ts +43 -0
  145. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.pc100.protocol.d.ts.map +1 -0
  146. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.pc100.sequencer.d.ts +26 -0
  147. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.pc100.sequencer.d.ts.map +1 -0
  148. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.pc300.device.d.ts +16 -0
  149. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.pc300.device.d.ts.map +1 -0
  150. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.pc300.protocol.d.ts +73 -0
  151. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.pc300.protocol.d.ts.map +1 -0
  152. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.pc300.sequencer.d.ts +25 -0
  153. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.pc300.sequencer.d.ts.map +1 -0
  154. package/lib/typescript/module/src/modules/bt-management/types/device-measurement-map.d.ts +5 -0
  155. package/lib/typescript/module/src/modules/bt-management/types/device-measurement-map.d.ts.map +1 -1
  156. package/lib/typescript/module/src/modules/bt-management/types/integrated-devices.d.ts +6 -1
  157. package/lib/typescript/module/src/modules/bt-management/types/integrated-devices.d.ts.map +1 -1
  158. package/package.json +1 -1
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ /* eslint-disable import/group-exports */
4
+
5
+ import { BTManagedDevice } from "../bt-managed-device.js";
6
+ import { BPM188_NOTIFY, BPM188_SERVICE, BPM188_WRITE, Bpm188FrameReader } from "./viatom.bpm188.protocol.js";
7
+ import { Bpm188Sequencer } from "./viatom.bpm188.sequencer.js";
8
+ const acceptNothing = {
9
+ caseValuePosition: [],
10
+ cases: []
11
+ };
12
+ export const bpm188MainServices = [{
13
+ uuid: BPM188_SERVICE,
14
+ monitorUuids: [{
15
+ uuid: BPM188_NOTIFY,
16
+ parsingModel: acceptNothing
17
+ }],
18
+ writeUuid: {
19
+ uuid: BPM188_WRITE,
20
+ mainCommandUuid: "0240dc"
21
+ }
22
+ }];
23
+
24
+ /** Viatom B02T/B02S blood-pressure history, exposed as BPM-188. */
25
+ export class Bpm188Device extends BTManagedDevice {
26
+ mainServices = bpm188MainServices;
27
+ stuckDataTimeout = 180_000;
28
+ onStreamStart = undefined;
29
+ preferredMtu = 247;
30
+ constructor(device, params) {
31
+ super(device, params);
32
+ this.frameReader = new Bpm188FrameReader();
33
+ this.createCommandSequencer = () => new Bpm188Sequencer({
34
+ write: {
35
+ serviceUuid: BPM188_SERVICE,
36
+ characteristicUuid: BPM188_WRITE
37
+ },
38
+ onResult: result => this.onResult?.(result)
39
+ });
40
+ }
41
+ handleSuccessResult() {
42
+ return;
43
+ }
44
+ }
45
+ //# sourceMappingURL=viatom.bpm188.device.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["BTManagedDevice","BPM188_NOTIFY","BPM188_SERVICE","BPM188_WRITE","Bpm188FrameReader","Bpm188Sequencer","acceptNothing","caseValuePosition","cases","bpm188MainServices","uuid","monitorUuids","parsingModel","writeUuid","mainCommandUuid","Bpm188Device","mainServices","stuckDataTimeout","onStreamStart","undefined","preferredMtu","constructor","device","params","frameReader","createCommandSequencer","write","serviceUuid","characteristicUuid","onResult","result","handleSuccessResult"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/viatom/viatom.bpm188.device.ts"],"mappings":";;AAAA;;AASA,SAASA,eAAe,QAAQ,yBAAsB;AAEtD,SACEC,aAAa,EACbC,cAAc,EACdC,YAAY,EACZC,iBAAiB,QACZ,6BAA0B;AACjC,SAASC,eAAe,QAAQ,8BAA2B;AAE3D,MAAMC,aAAa,GAAG;EAAEC,iBAAiB,EAAE,EAAE;EAAEC,KAAK,EAAE;AAAG,CAAC;AAE1D,OAAO,MAAMC,kBAA8B,GAAG,CAC5C;EACEC,IAAI,EAAER,cAAc;EACpBS,YAAY,EAAE,CAAC;IAAED,IAAI,EAAET,aAAa;IAAEW,YAAY,EAAEN;EAAc,CAAC,CAAC;EACpEO,SAAS,EAAE;IACTH,IAAI,EAAEP,YAAY;IAClBW,eAAe,EAAE;EACnB;AACF,CAAC,CACF;;AAED;AACA,OAAO,MAAMC,YAAY,SAASf,eAAe,CAA2B;EAChEgB,YAAY,GAAGP,kBAAkB;EACjCQ,gBAAgB,GAAG,OAAO;EAC1BC,aAAa,GAAGC,SAAS;EAChBC,YAAY,GAAG,GAAG;EAE9BC,WAAWA,CAChBC,MAAc,EACdC,MAAoD,EACpD;IACA,KAAK,CAACD,MAAM,EAAEC,MAAM,CAAC;IACrB,IAAI,CAACC,WAAW,GAAG,IAAIpB,iBAAiB,CAAC,CAAC;IAC1C,IAAI,CAACqB,sBAAsB,GAAG,MAC5B,IAAIpB,eAAe,CAAC;MAClBqB,KAAK,EAAE;QACLC,WAAW,EAAEzB,cAAc;QAC3B0B,kBAAkB,EAAEzB;MACtB,CAAC;MACD0B,QAAQ,EAAGC,MAAM,IACf,IAAI,CAACD,QAAQ,GACXC,MAGF;IACJ,CAAC,CAAC;EACN;EAEUC,mBAAmBA,CAAA,EAAS;IACpC;EACF;AACF","ignoreList":[]}
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+
3
+ /* eslint-disable import/group-exports */
4
+
5
+ import { FrameReadStatus } from "../../../types/frame-read-status.js";
6
+ import { hexToByte } from "../../../utils/hex-to-byte.js";
7
+ export const BPM188_SERVICE = "000018f0-0000-1000-8000-00805f9b34fb";
8
+ export const BPM188_WRITE = "00002af1-0000-1000-8000-00805f9b34fb";
9
+ export const BPM188_NOTIFY = "00002af0-0000-1000-8000-00805f9b34fb";
10
+ export const Bpm188MessageType = {
11
+ info: 0xab,
12
+ syncTime: 0xb0,
13
+ records: 0xb1,
14
+ recordsEnd: 0xb3
15
+ };
16
+ const byte = value => (value & 0xff).toString(16).padStart(2, "0");
17
+
18
+ /** The B02T/B02S checksum starts with 0x40 and XORs bytes 2 through n-2. */
19
+ export const calculateBpm188Checksum = bytes => {
20
+ let checksum = 0x40;
21
+ for (let index = 2; index < bytes.length - 1; index += 1) {
22
+ checksum ^= hexToByte(bytes[index] ?? "00");
23
+ }
24
+ return byte(checksum);
25
+ };
26
+ const command = (type, payload = []) => {
27
+ const frame = ["02", "40", "dc", byte(payload.length + 1), byte(type), ...payload, "00"];
28
+ frame[frame.length - 1] = calculateBpm188Checksum(frame);
29
+ return frame;
30
+ };
31
+ export const bpm188GetInfo = () => command(Bpm188MessageType.info);
32
+ export const bpm188SyncTime = (now = new Date()) => command(Bpm188MessageType.syncTime, [byte(now.getFullYear() - 2000), byte(now.getMonth() + 1), byte(now.getDate()), byte(now.getHours()), byte(now.getMinutes()), byte(now.getSeconds())]);
33
+ export const bpm188GetRecords = () => command(Bpm188MessageType.records, ["00", "00", "00", "00"]);
34
+ export const decodeBpm188Response = bytes => {
35
+ if (hexToByte(bytes[0] ?? "00") !== 0x02 || hexToByte(bytes[1] ?? "00") !== 0x40 || hexToByte(bytes[2] ?? "00") !== 0xdd) {
36
+ return undefined;
37
+ }
38
+ const payloadLength = hexToByte(bytes[3] ?? "00");
39
+ const expectedLength = payloadLength + 5;
40
+ if (payloadLength < 1 || bytes.length < expectedLength) {
41
+ return undefined;
42
+ }
43
+ const frame = bytes.slice(0, expectedLength);
44
+ if (frame.at(-1) !== calculateBpm188Checksum(frame)) {
45
+ return undefined;
46
+ }
47
+ return {
48
+ type: hexToByte(frame[4] ?? "00"),
49
+ content: frame.slice(5, -1)
50
+ };
51
+ };
52
+ const validDate = content => {
53
+ const year = 2000 + hexToByte(content[9] ?? "00");
54
+ const month = hexToByte(content[10] ?? "00");
55
+ const day = hexToByte(content[11] ?? "00");
56
+ const hour = hexToByte(content[12] ?? "00");
57
+ const minute = hexToByte(content[13] ?? "00");
58
+ const date = new Date(year, month - 1, day, hour, minute, 0, 0);
59
+ if (month < 1 || month > 12 || day < 1 || day > 31 || hour > 23 || minute > 59 || date.getFullYear() !== year || date.getMonth() !== month - 1 || date.getDate() !== day || date.getHours() !== hour || date.getMinutes() !== minute) {
60
+ return undefined;
61
+ }
62
+ return date;
63
+ };
64
+ export const parseBpm188Record = content => {
65
+ if (content.length < 14) {
66
+ return undefined;
67
+ }
68
+ const systolic = hexToByte(content[0] ?? "00") << 8 | hexToByte(content[1] ?? "00");
69
+ const diastolic = hexToByte(content[2] ?? "00") << 8 | hexToByte(content[3] ?? "00");
70
+ const heartRate = hexToByte(content[5] ?? "00");
71
+ const recordedAt = validDate(content);
72
+ if (!recordedAt || systolic < 20 || systolic > 300 || diastolic < 10 || diastolic > 200) {
73
+ return undefined;
74
+ }
75
+ return {
76
+ systolic,
77
+ diastolic,
78
+ heartRate,
79
+ userId: hexToByte(content[6] ?? "00"),
80
+ storeId: hexToByte(content[7] ?? "00") << 8 | hexToByte(content[8] ?? "00"),
81
+ recordedAt
82
+ };
83
+ };
84
+
85
+ /** Reads the split and concatenated 02 40 dd history responses. */
86
+ export class Bpm188FrameReader {
87
+ readFrame(buffer) {
88
+ const start = this.findStart(buffer);
89
+ if (start < 0) {
90
+ return {
91
+ status: FrameReadStatus.INCOMPLETE,
92
+ consumedBytes: Math.max(0, buffer.length - 1)
93
+ };
94
+ }
95
+ const length = hexToByte(buffer[start + 3] ?? "00") + 5;
96
+ if (length < 6) {
97
+ return {
98
+ status: FrameReadStatus.CORRUPT,
99
+ consumedBytes: start + 1
100
+ };
101
+ }
102
+ if (start + length > buffer.length) {
103
+ return {
104
+ status: FrameReadStatus.INCOMPLETE,
105
+ consumedBytes: start
106
+ };
107
+ }
108
+ const frame = buffer.slice(start, start + length);
109
+ if (frame.at(-1) !== calculateBpm188Checksum(frame)) {
110
+ return {
111
+ status: FrameReadStatus.CORRUPT,
112
+ consumedBytes: start + 1
113
+ };
114
+ }
115
+ return {
116
+ status: FrameReadStatus.COMPLETE,
117
+ consumedBytes: start + length,
118
+ frame
119
+ };
120
+ }
121
+ findStart(buffer) {
122
+ for (let index = 0; index + 3 < buffer.length; index += 1) {
123
+ if (hexToByte(buffer[index] ?? "00") === 0x02 && hexToByte(buffer[index + 1] ?? "00") === 0x40 && hexToByte(buffer[index + 2] ?? "00") === 0xdd) {
124
+ return index;
125
+ }
126
+ }
127
+ return -1;
128
+ }
129
+ }
130
+ //# sourceMappingURL=viatom.bpm188.protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["FrameReadStatus","hexToByte","BPM188_SERVICE","BPM188_WRITE","BPM188_NOTIFY","Bpm188MessageType","info","syncTime","records","recordsEnd","byte","value","toString","padStart","calculateBpm188Checksum","bytes","checksum","index","length","command","type","payload","frame","bpm188GetInfo","bpm188SyncTime","now","Date","getFullYear","getMonth","getDate","getHours","getMinutes","getSeconds","bpm188GetRecords","decodeBpm188Response","undefined","payloadLength","expectedLength","slice","at","content","validDate","year","month","day","hour","minute","date","parseBpm188Record","systolic","diastolic","heartRate","recordedAt","userId","storeId","Bpm188FrameReader","readFrame","buffer","start","findStart","status","INCOMPLETE","consumedBytes","Math","max","CORRUPT","COMPLETE"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/viatom/viatom.bpm188.protocol.ts"],"mappings":";;AAAA;;AAGA,SAASA,eAAe,QAAQ,qCAAkC;AAElE,SAASC,SAAS,QAAQ,+BAA4B;AAEtD,OAAO,MAAMC,cAAc,GAAG,sCAAsC;AACpE,OAAO,MAAMC,YAAY,GAAG,sCAAsC;AAClE,OAAO,MAAMC,aAAa,GAAG,sCAAsC;AAEnE,OAAO,MAAMC,iBAAiB,GAAG;EAC/BC,IAAI,EAAE,IAAI;EACVC,QAAQ,EAAE,IAAI;EACdC,OAAO,EAAE,IAAI;EACbC,UAAU,EAAE;AACd,CAAU;AAEV,MAAMC,IAAI,GA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ACwD,MAAM,CAACxC,KAAK,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,IAAI,EAC7C;QACA,OAAOA,KAAK;MACd;IACF;IAEA,OAAO,CAAC,CAAC;EACX;AACF","ignoreList":[]}
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ import { MeasurementTypeKey } from "@ovok/core";
4
+ import { CaseType } from "../../../types/case-type.js";
5
+ import { Bpm188MessageType, bpm188GetInfo, bpm188GetRecords, bpm188SyncTime, decodeBpm188Response, parseBpm188Record } from "./viatom.bpm188.protocol.js";
6
+ const command = (write, frame) => ({
7
+ ...write,
8
+ frame,
9
+ withoutResponse: true
10
+ });
11
+
12
+ /** Drives the BPM-188 info -> clock -> two-user history exchange. */
13
+ export class Bpm188Sequencer {
14
+ phase = "info";
15
+ endedUsers = new Set();
16
+ constructor(params) {
17
+ this.params = params;
18
+ }
19
+ initialCommands = () => this.remember(this.write(bpm188GetInfo()));
20
+ isHistoryTransfer = () => true;
21
+ isNormalDisconnect = () => this.phase === "done";
22
+ commandTimeoutMs = () => this.phase === "done" ? undefined : 5_000;
23
+ onCommandTimeout = () => {
24
+ this.phase = "done";
25
+ return {
26
+ terminal: true
27
+ };
28
+ };
29
+ nextCommand = frame => {
30
+ const response = decodeBpm188Response(frame);
31
+ if (!response || this.phase === "done") {
32
+ return undefined;
33
+ }
34
+ if (this.phase === "info") {
35
+ this.phase = "sync";
36
+ return this.remember(this.write(bpm188SyncTime(this.params.now?.())));
37
+ }
38
+ if (this.phase === "sync") {
39
+ this.phase = "records";
40
+ return this.remember(this.write(bpm188GetRecords()));
41
+ }
42
+ if (response.type === Bpm188MessageType.records || response.type === Bpm188MessageType.recordsEnd) {
43
+ const record = parseBpm188Record(response.content);
44
+ if (record) {
45
+ this.params.onResult({
46
+ caseType: CaseType.RESULT,
47
+ measurementTypeKey: MeasurementTypeKey.bloodPressure,
48
+ systolic: record.systolic,
49
+ diastolic: record.diastolic,
50
+ heartRate: record.heartRate,
51
+ recordedAt: record.recordedAt
52
+ });
53
+ }
54
+ if (response.type === Bpm188MessageType.recordsEnd) {
55
+ const userId = record?.userId ?? response.content[6];
56
+ if (userId !== undefined) {
57
+ this.endedUsers.add(typeof userId === "number" ? userId : Number.parseInt(userId, 16));
58
+ }
59
+ if (this.endedUsers.has(0) && this.endedUsers.has(1)) {
60
+ this.phase = "done";
61
+ }
62
+ }
63
+ }
64
+ return undefined;
65
+ };
66
+ write = frame => command(this.params.write, frame);
67
+ remember = next => {
68
+ return [next];
69
+ };
70
+ }
71
+ //# sourceMappingURL=viatom.bpm188.sequencer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["MeasurementTypeKey","CaseType","Bpm188MessageType","bpm188GetInfo","bpm188GetRecords","bpm188SyncTime","decodeBpm188Response","parseBpm188Record","command","write","frame","withoutResponse","Bpm188Sequencer","phase","endedUsers","Set","constructor","params","initialCommands","remember","isHistoryTransfer","isNormalDisconnect","commandTimeoutMs","undefined","onCommandTimeout","terminal","nextCommand","response","now","type","records","recordsEnd","record","content","onResult","caseType","RESULT","measurementTypeKey","bloodPressure","systolic","diastolic","heartRate","recordedAt","userId","add","Number","parseInt","has","next"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/viatom/viatom.bpm188.sequencer.ts"],"mappings":";;AAAA,SAAmCA,kBAAkB,QAAQ,YAAY;AAEzE,SAASC,QAAQ,QAAQ,6BAA0B;AAQnD,SACEC,iBAAiB,EACjBC,aAAa,EACbC,gBAAgB,EAChBC,cAAc,EACdC,oBAAoB,EACpBC,iBAAiB,QACZ,6BAA0B;AAUjC,MAAMC,OAAO,GAAGA,CACdC,KAAmC,EACnCC,KAAwB,MACL;EAAE,GAAGD,KAAK;EAAEC,KAAK;EAAEC,eAAe,EAAE;AAAK,CAAC,CAAC;;AAEhE;AACA,OAAO,MAAMC,eAAe,CAA6B;EAC/CC,KAAK,GAAyC,MAAM;EAC3CC,UAAU,GAAG,IAAIC,GAAG,CAAS,CAAC;EAExCC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5
+ import { BTManagedDevice } from "../bt-managed-device.js";
6
+ import { PC100_NOTIFY, PC100_SERVICE, PC100_WRITE, Pc100FrameReader } from "./viatom.pc100.protocol.js";
7
+ import { Pc100Sequencer } from "./viatom.pc100.sequencer.js";
8
+ const acceptNothing = {
9
+ caseValuePosition: [],
10
+ cases: []
11
+ };
12
+ export const pc100MainServices = [{
13
+ uuid: PC100_SERVICE,
14
+ monitorUuids: [{
15
+ uuid: PC100_NOTIFY,
16
+ parsingModel: acceptNothing
17
+ }],
18
+ writeUuid: {
19
+ uuid: PC100_WRITE,
20
+ mainCommandUuid: "aa55"
21
+ }
22
+ }];
23
+
24
+ /** Viatom PC-100 spot-check monitor over the FFF0 AA55 protocol. */
25
+ export class Pc100Device extends BTManagedDevice {
26
+ mainServices = pc100MainServices;
27
+ stuckDataTimeout = 60_000;
28
+ onStreamStart = undefined;
29
+ preferredMtu = 247;
30
+ constructor(device, params) {
31
+ super(device, params);
32
+ this.frameReader = new Pc100FrameReader();
33
+ this.createCommandSequencer = () => new Pc100Sequencer({
34
+ write: {
35
+ serviceUuid: PC100_SERVICE,
36
+ characteristicUuid: PC100_WRITE
37
+ },
38
+ onResult: result => this.onResult?.(result)
39
+ });
40
+ }
41
+ handleSuccessResult() {
42
+ return;
43
+ }
44
+ }
45
+ //# sourceMappingURL=viatom.pc100.device.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["BTManagedDevice","PC100_NOTIFY","PC100_SERVICE","PC100_WRITE","Pc100FrameReader","Pc100Sequencer","acceptNothing","caseValuePosition","cases","pc100MainServices","uuid","monitorUuids","parsingModel","writeUuid","mainCommandUuid","Pc100Device","mainServices","stuckDataTimeout","onStreamStart","undefined","preferredMtu","constructor","device","params","frameReader","createCommandSequencer","write","serviceUuid","characteristicUuid","onResult","result","handleSuccessResult"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/viatom/viatom.pc100.device.ts"],"mappings":";;AAAA;;AASA,SAASA,eAAe,QAAQ,yBAAsB;AAEtD,SACEC,YAAY,EACZC,aAAa,EACbC,WAAW,EACXC,gBAAgB,QACX,4BAAyB;AAChC,SAASC,cAAc,QAAQ,6BAA0B;AAEzD,MAAMC,aAAa,GAAG;EAAEC,iBAAiB,EAAE,EAAE;EAAEC,KAAK,EAAE;AAAG,CAAC;AAE1D,OAAO,MAAMC,iBAA6B,GAAG,CAC3C;EACEC,IAAI,EAAER,aAAa;EACnBS,YAAY,EAAE,CAAC;IAAED,IAAI,EAAET,YAAY;IAAEW,YAAY,EAAEN;EAAc,CAAC,CAAC;EACnEO,SAAS,EAAE;IACTH,IAAI,EAAEP,WAAW;IACjBW,eAAe,EAAE;EACnB;AACF,CAAC,CACF;;AAED;AACA,OAAO,MAAMC,WAAW,SAASf,eAAe,CAA0B;EAC9DgB,YAAY,GAAGP,iBAAiB;EAChCQ,gBAAgB,GAAG,MAAM;EACzBC,aAAa,GAAGC,SAAS;EAChBC,YAAY,GAAG,GAAG;EAE9BC,WAAWA,CAChBC,MAAc,EACdC,MAAmD,EACnD;IACA,KAAK,CAACD,MAAM,EAAEC,MAAM,CAAC;IACrB,IAAI,CAACC,WAAW,GAAG,IAAIpB,gBAAgB,CAAC,CAAC;IACzC,IAAI,CAACqB,sBAAsB,GAAG,MAC5B,IAAIpB,cAAc,CAAC;MACjBqB,KAAK,EAAE;QACLC,WAAW,EAAEzB,aAAa;QAC1B0B,kBAAkB,EAAEzB;MACtB,CAAC;MACD0B,QAAQ,EAAGC,MAAM,IACf,IAAI,CAACD,QAAQ,GACXC,MAGF;IACJ,CAAC,CAAC;EACN;EAEUC,mBAAmBA,CAAA,EAAS;IACpC;EACF;AACF","ignoreList":[]}
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+
3
+ /* eslint-disable import/group-exports */
4
+
5
+ import { FrameReadStatus } from "../../../types/frame-read-status.js";
6
+ import { calculateCrc8Pc } from "../../../utils/calculate-crc-8-pc.js";
7
+ import { hexToByte } from "../../../utils/hex-to-byte.js";
8
+ export const PC100_SERVICE = "0000fff0-0000-1000-8000-00805f9b34fb";
9
+ export const PC100_WRITE = "0000fff2-0000-1000-8000-00805f9b34fb";
10
+ export const PC100_NOTIFY = "0000fff1-0000-1000-8000-00805f9b34fb";
11
+ export const Pc100Command = {
12
+ handshake: 0xff,
13
+ deviceId: 0xff,
14
+ deviceInfo: 0x51,
15
+ bloodPressureResult: 0x43,
16
+ bloodOxygenParameters: 0x53
17
+ };
18
+ const byte = value => (value & 0xff).toString(16).padStart(2, "0");
19
+
20
+ /** Builds the PC-100 AA55 frame used by Pc100BleCmd. */
21
+ export const pc100Command = (command, type, payload = []) => {
22
+ const frame = ["aa", "55", byte(command), byte(payload.length + 2), byte(type), ...payload, "00"];
23
+ frame[frame.length - 1] = byte(calculateCrc8Pc(frame));
24
+ return frame;
25
+ };
26
+ export const pc100Handshake = () => pc100Command(Pc100Command.handshake, 0x01);
27
+ export const pc100GetDeviceId = () => pc100Command(Pc100Command.deviceId, 0x10);
28
+ export const pc100GetDeviceInfo = () => pc100Command(Pc100Command.deviceInfo, 0x01);
29
+ export const pc100GetBloodPressureResult = () => pc100Command(Pc100Command.bloodPressureResult, 0x01);
30
+ export const decodePc100Response = bytes => {
31
+ if (hexToByte(bytes[0] ?? "00") !== 0xaa || hexToByte(bytes[1] ?? "00") !== 0x55) {
32
+ return undefined;
33
+ }
34
+ const length = hexToByte(bytes[3] ?? "00");
35
+ const expectedLength = length + 4;
36
+ if (length < 2 || bytes.length < expectedLength) {
37
+ return undefined;
38
+ }
39
+ const frame = bytes.slice(0, expectedLength);
40
+ if (hexToByte(frame.at(-1) ?? "00") !== calculateCrc8Pc(frame)) {
41
+ return undefined;
42
+ }
43
+ return {
44
+ command: hexToByte(frame[2] ?? "00"),
45
+ type: hexToByte(frame[4] ?? "00"),
46
+ content: frame.slice(5, -1)
47
+ };
48
+ };
49
+ export const parsePc100BloodPressureResult = content => {
50
+ if (content.length < 5) {
51
+ return undefined;
52
+ }
53
+ const first = hexToByte(content[0] ?? "00");
54
+ const systolic = (first & 0x7f) << 8 | hexToByte(content[1] ?? "00");
55
+ const diastolic = hexToByte(content[3] ?? "00");
56
+ const heartRate = hexToByte(content[4] ?? "00");
57
+ if (systolic < 20 || systolic > 300 || diastolic < 10 || diastolic > 200 || heartRate < 20 || heartRate > 300) {
58
+ return undefined;
59
+ }
60
+ return {
61
+ systolic,
62
+ diastolic,
63
+ heartRate,
64
+ irregularHeartbeat: (first & 0x80) !== 0
65
+ };
66
+ };
67
+ export const parsePc100BloodOxygenResult = content => {
68
+ if (content.length < 5) {
69
+ return undefined;
70
+ }
71
+ const bloodOxygen = hexToByte(content[0] ?? "00");
72
+ const pulseRate = hexToByte(content[1] ?? "00") | hexToByte(content[2] ?? "00") << 8;
73
+ const perfusionIndex = hexToByte(content[3] ?? "00");
74
+ const state = hexToByte(content[4] ?? "00");
75
+ if (bloodOxygen < 50 || bloodOxygen > 100 || pulseRate < 20 || pulseRate > 300 || (state & 0x02) === 0) {
76
+ return undefined;
77
+ }
78
+ return {
79
+ bloodOxygen,
80
+ pulseRate,
81
+ perfusionIndex
82
+ };
83
+ };
84
+
85
+ /** Reads split and concatenated PC-100 AA55 frames. */
86
+ export class Pc100FrameReader {
87
+ readFrame(buffer) {
88
+ const start = this.findStart(buffer);
89
+ if (start < 0) {
90
+ return {
91
+ status: FrameReadStatus.INCOMPLETE,
92
+ consumedBytes: Math.max(0, buffer.length - 1)
93
+ };
94
+ }
95
+ if (start + 4 > buffer.length) {
96
+ return {
97
+ status: FrameReadStatus.INCOMPLETE,
98
+ consumedBytes: start
99
+ };
100
+ }
101
+ const length = hexToByte(buffer[start + 3] ?? "00") + 4;
102
+ if (length < 6) {
103
+ return {
104
+ status: FrameReadStatus.CORRUPT,
105
+ consumedBytes: start + 1
106
+ };
107
+ }
108
+ if (start + length > buffer.length) {
109
+ return {
110
+ status: FrameReadStatus.INCOMPLETE,
111
+ consumedBytes: start
112
+ };
113
+ }
114
+ const frame = buffer.slice(start, start + length);
115
+ if (hexToByte(frame.at(-1) ?? "00") !== calculateCrc8Pc(frame)) {
116
+ return {
117
+ status: FrameReadStatus.CORRUPT,
118
+ consumedBytes: start + 1
119
+ };
120
+ }
121
+ return {
122
+ status: FrameReadStatus.COMPLETE,
123
+ consumedBytes: start + length,
124
+ frame
125
+ };
126
+ }
127
+ findStart = buffer => {
128
+ for (let index = 0; index + 1 < buffer.length; index += 1) {
129
+ if (hexToByte(buffer[index] ?? "00") === 0xaa && hexToByte(buffer[index + 1] ?? "00") === 0x55) {
130
+ return index;
131
+ }
132
+ }
133
+ return -1;
134
+ };
135
+ }
136
+ //# sourceMappingURL=viatom.pc100.protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["FrameReadStatus","calculateCrc8Pc","hexToByte","PC100_SERVICE","PC100_WRITE","PC100_NOTIFY","Pc100Command","handshake","deviceId","deviceInfo","bloodPressureResult","bloodOxygenParameters","byte","value","toString","padStart","pc100Command","command","type","payload","frame","length","pc100Handshake","pc100GetDeviceId","pc100GetDeviceInfo","pc100GetBloodPressureResult","decodePc100Response","bytes","undefined","expectedLength","slice","at","content","parsePc100BloodPressureResult","first","systolic","diastolic","heartRate","irregularHeartbeat","parsePc100BloodOxygenResult","bloodOxygen","pulseRate","perfusionIndex","state","Pc100FrameReader","readFrame","buffer","start","findStart","status","INCOMPLETE","consumedBytes","Math","max","CORRUPT","COMPLETE","index"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/viatom/viatom.pc100.protocol.ts"],"mappings":";;AAAA;;AAGA,SAASA,eAAe,QAAQ,qCAAkC;AAElE,SAASC,eAAe,QAAQ,sCAAmC;AACnE,SAASC,SAAS,QAAQ,+BAA4B;AAEtD,OAAO,MAAMC,aAAa,GAAG,sCAAsC;AACnE,OAAO,MAAMC,WAAW,GAAG,sCAAsC;AACjE,OAAO,MAAMC,YAAY,GAAG,sCAAsC;AAElE,OAAO,MAAMC,YAAY,GAAG;EAC1BC,SAAS,EAAE,IAAI;EACfC,QAAQ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KAAK,GAAG1B,MAAM;MAC7BD;IACF,CAAC;EACH;EAEQ4B,SAAS,GAAIF,MAAyB,IAAa;IACzD,KAAK,IAAIU,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAG,CAAC,GAAGV,MAAM,CAACzB,MAAM,EAAEmC,KAAK,IAAI,CAAC,EAAE;MACzD,IACEtD,SAAS,CAAC4C,MAAM,CAACU,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,IAAI,IACzCtD,SAAS,CAAC4C,MAAM,CAACU,KAAK,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,IAAI,EAC7C;QACA,OAAOA,KAAK;MACd;IACF;IAEA,OAAO,CAAC,CAAC;EACX,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+
3
+ import { MeasurementTypeKey } from "@ovok/core";
4
+ import { CaseType } from "../../../types/case-type.js";
5
+ import { decodePc100Response, parsePc100BloodOxygenResult, parsePc100BloodPressureResult, pc100GetBloodPressureResult, pc100GetDeviceId, pc100GetDeviceInfo, pc100Handshake, Pc100Command } from "./viatom.pc100.protocol.js";
6
+ const command = (write, frame) => ({
7
+ ...write,
8
+ frame,
9
+ withoutResponse: true
10
+ });
11
+
12
+ /** Reads the last PC-100 BP result and accepts live oxygen frames when present. */
13
+ export class Pc100Sequencer {
14
+ phase = "handshake";
15
+ constructor(params) {
16
+ this.params = params;
17
+ }
18
+ initialCommands = () => [this.write(pc100Handshake())];
19
+ isNormalDisconnect = () => this.phase === "done";
20
+ commandTimeoutMs = () => this.phase === "done" ? undefined : 5_000;
21
+ nextCommand = frame => {
22
+ const response = decodePc100Response(frame);
23
+ if (!response) {
24
+ return undefined;
25
+ }
26
+ const recordedAt = this.params.now?.() ?? new Date();
27
+ if (response.command === Pc100Command.bloodOxygenParameters) {
28
+ const result = parsePc100BloodOxygenResult(response.content);
29
+ if (result) {
30
+ this.params.onResult({
31
+ caseType: CaseType.RESULT,
32
+ measurementTypeKey: MeasurementTypeKey.bloodOxygenPulseRate,
33
+ ...result,
34
+ recordedAt
35
+ });
36
+ }
37
+ return undefined;
38
+ }
39
+ if (this.phase === "handshake" && response.command === 0xff) {
40
+ this.phase = "device-id";
41
+ return [this.write(pc100GetDeviceId())];
42
+ }
43
+ if (this.phase === "device-id" && response.command === 0xff) {
44
+ this.phase = "info";
45
+ return [this.write(pc100GetDeviceInfo())];
46
+ }
47
+ if (this.phase === "info" && response.command === Pc100Command.deviceInfo) {
48
+ this.phase = "result";
49
+ return [this.write(pc100GetBloodPressureResult())];
50
+ }
51
+ if (this.phase === "result" && response.command === Pc100Command.bloodPressureResult && response.type === 1) {
52
+ const result = parsePc100BloodPressureResult(response.content);
53
+ if (result) {
54
+ this.params.onResult({
55
+ caseType: CaseType.RESULT,
56
+ measurementTypeKey: MeasurementTypeKey.bloodPressure,
57
+ systolic: result.systolic,
58
+ diastolic: result.diastolic,
59
+ heartRate: result.heartRate,
60
+ irregularHeartbeat: result.irregularHeartbeat,
61
+ recordedAt
62
+ });
63
+ }
64
+ this.phase = "done";
65
+ }
66
+ return undefined;
67
+ };
68
+ onCommandTimeout = () => {
69
+ this.phase = "done";
70
+ return {
71
+ terminal: true
72
+ };
73
+ };
74
+ write = frame => command(this.params.write, frame);
75
+ }
76
+ //# sourceMappingURL=viatom.pc100.sequencer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["MeasurementTypeKey","CaseType","decodePc100Response","parsePc100BloodOxygenResult","parsePc100BloodPressureResult","pc100GetBloodPressureResult","pc100GetDeviceId","pc100GetDeviceInfo","pc100Handshake","Pc100Command","command","write","frame","withoutResponse","Pc100Sequencer","phase","constructor","params","initialCommands","isNormalDisconnect","commandTimeoutMs","undefined","nextCommand","response","recordedAt","now","Date","bloodOxygenParameters","result","content","onResult","caseType","RESULT","measurementTypeKey","bloodOxygenPulseRate","deviceInfo","bloodPressureResult","type","bloodPressure","systolic","diastolic","heartRate","irregularHeartbeat","onCommandTimeout","terminal"],"sourceRoot":"../../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,CAACW,QAAQ;UACzBC,SAAS,EAAEZ,MAAM,CAACY,SAAS;UAC3BC,SAAS,EAAEb,MAAM,CAACa,SAAS;UAC3BC,kBAAkB,EAAEd,MAAM,CAACc,kBAAkB;UAC7ClB;QACF,CAAC,CAAC;MACJ;MAEA,IAAI,CAACT,KAAK,GAAG,MAAM;IACrB;IAEA,OAAOM,SAAS;EAClB,CAAC;EAEMsB,gBAAgB,GAAGA,CAAA,KAAM;IAC9B,IAAI,CAAC5B,KAAK,GAAG,MAAM;IAEnB,OAAO;MAAE6B,QAAQ,EAAE;IAAK,CAAC;EAC3B,CAAC;EAEOjC,KAAK,GAAIC,KAAwB,IACvCF,OAAO,CAAC,IAAI,CAACO,MAAM,CAACN,KAAK,EAAEC,KAAK,CAAC;AACrC","ignoreList":[]}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ /* eslint-disable import/group-exports */
4
+
5
+ import { BTManagedDevice } from "../bt-managed-device.js";
6
+ import { PC300_NOTIFY, PC300_SERVICE, PC300_WRITE, Pc300FrameReader } from "./viatom.pc300.protocol.js";
7
+ import { Pc300Sequencer } from "./viatom.pc300.sequencer.js";
8
+ const acceptNothing = {
9
+ caseValuePosition: [],
10
+ cases: []
11
+ };
12
+ export const pc300MainServices = [{
13
+ uuid: PC300_SERVICE,
14
+ monitorUuids: [{
15
+ uuid: PC300_NOTIFY,
16
+ parsingModel: acceptNothing
17
+ }],
18
+ writeUuid: {
19
+ uuid: PC300_WRITE,
20
+ mainCommandUuid: "aa55"
21
+ }
22
+ }];
23
+
24
+ /** Viatom PC-300/PC-200 spot-check family over the FFF0 AA55 protocol. */
25
+ export class Pc300Device extends BTManagedDevice {
26
+ mainServices = pc300MainServices;
27
+ stuckDataTimeout = 60_000;
28
+ onStreamStart = undefined;
29
+ preferredMtu = 247;
30
+ constructor(device, params) {
31
+ super(device, params);
32
+ this.frameReader = new Pc300FrameReader();
33
+ this.createCommandSequencer = () => new Pc300Sequencer({
34
+ write: {
35
+ serviceUuid: PC300_SERVICE,
36
+ characteristicUuid: PC300_WRITE
37
+ },
38
+ onResult: result => this.onResult?.(result)
39
+ });
40
+ }
41
+ handleSuccessResult() {
42
+ return;
43
+ }
44
+ }
45
+ //# sourceMappingURL=viatom.pc300.device.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["BTManagedDevice","PC300_NOTIFY","PC300_SERVICE","PC300_WRITE","Pc300FrameReader","Pc300Sequencer","acceptNothing","caseValuePosition","cases","pc300MainServices","uuid","monitorUuids","parsingModel","writeUuid","mainCommandUuid","Pc300Device","mainServices","stuckDataTimeout","onStreamStart","undefined","preferredMtu","constructor","device","params","frameReader","createCommandSequencer","write","serviceUuid","characteristicUuid","onResult","result","handleSuccessResult"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/viatom/viatom.pc300.device.ts"],"mappings":";;AAAA;;AASA,SAASA,eAAe,QAAQ,yBAAsB;AAEtD,SACEC,YAAY,EACZC,aAAa,EACbC,WAAW,EACXC,gBAAgB,QACX,4BAAyB;AAChC,SAASC,cAAc,QAAQ,6BAA0B;AAEzD,MAAMC,aAAa,GAAG;EAAEC,iBAAiB,EAAE,EAAE;EAAEC,KAAK,EAAE;AAAG,CAAC;AAE1D,OAAO,MAAMC,iBAA6B,GAAG,CAC3C;EACEC,IAAI,EAAER,aAAa;EACnBS,YAAY,EAAE,CAAC;IAAED,IAAI,EAAET,YAAY;IAAEW,YAAY,EAAEN;EAAc,CAAC,CAAC;EACnEO,SAAS,EAAE;IACTH,IAAI,EAAEP,WAAW;IACjBW,eAAe,EAAE;EACnB;AACF,CAAC,CACF;;AAED;AACA,OAAO,MAAMC,WAAW,SAASf,eAAe,CAA0B;EAC9DgB,YAAY,GAAGP,iBAAiB;EAChCQ,gBAAgB,GAAG,MAAM;EACzBC,aAAa,GAAGC,SAAS;EAChBC,YAAY,GAAG,GAAG;EAE9BC,WAAWA,CAChBC,MAAc,EACdC,MAAmD,EACnD;IACA,KAAK,CAACD,MAAM,EAAEC,MAAM,CAAC;IACrB,IAAI,CAACC,WAAW,GAAG,IAAIpB,gBAAgB,CAAC,CAAC;IACzC,IAAI,CAACqB,sBAAsB,GAAG,MAC5B,IAAIpB,cAAc,CAAC;MACjBqB,KAAK,EAAE;QACLC,WAAW,EAAEzB,aAAa;QAC1B0B,kBAAkB,EAAEzB;MACtB,CAAC;MACD0B,QAAQ,EAAGC,MAAM,IACf,IAAI,CAACD,QAAQ,GACXC,MAGF;IACJ,CAAC,CAAC;EACN;EAEUC,mBAAmBA,CAAA,EAAS;IACpC;EACF;AACF","ignoreList":[]}