@ovok/native 0.4.6 → 0.4.7

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 (380) hide show
  1. package/lib/commonjs/modules/bt-management/index.js +176 -0
  2. package/lib/commonjs/modules/bt-management/index.js.map +1 -1
  3. package/lib/commonjs/modules/bt-management/services/custom/compile-case-fields.js +49 -0
  4. package/lib/commonjs/modules/bt-management/services/custom/compile-case-fields.js.map +1 -0
  5. package/lib/commonjs/modules/bt-management/services/custom/compile-custom-case.js +47 -41
  6. package/lib/commonjs/modules/bt-management/services/custom/compile-custom-case.js.map +1 -1
  7. package/lib/commonjs/modules/bt-management/services/custom/compile-custom-frame.js +48 -2
  8. package/lib/commonjs/modules/bt-management/services/custom/compile-custom-frame.js.map +1 -1
  9. package/lib/commonjs/modules/bt-management/services/custom/compile-custom-lepu.js +98 -0
  10. package/lib/commonjs/modules/bt-management/services/custom/compile-custom-lepu.js.map +1 -0
  11. package/lib/commonjs/modules/bt-management/services/custom/define-custom-device.js +24 -1
  12. package/lib/commonjs/modules/bt-management/services/custom/define-custom-device.js.map +1 -1
  13. package/lib/commonjs/modules/bt-management/services/device-creator.js +15 -8
  14. package/lib/commonjs/modules/bt-management/services/device-creator.js.map +1 -1
  15. package/lib/commonjs/modules/bt-management/services/devices/aoj/aoj.thermometers.js +85 -0
  16. package/lib/commonjs/modules/bt-management/services/devices/aoj/aoj.thermometers.js.map +1 -0
  17. package/lib/commonjs/modules/bt-management/services/devices/bp2/bp2.frame-reader.js +8 -74
  18. package/lib/commonjs/modules/bt-management/services/devices/bp2/bp2.frame-reader.js.map +1 -1
  19. package/lib/commonjs/modules/bt-management/services/devices/bt-command-writer.js +141 -0
  20. package/lib/commonjs/modules/bt-management/services/devices/bt-command-writer.js.map +1 -0
  21. package/lib/commonjs/modules/bt-management/services/devices/bt-connection-handler.js +9 -49
  22. package/lib/commonjs/modules/bt-management/services/devices/bt-connection-handler.js.map +1 -1
  23. package/lib/commonjs/modules/bt-management/services/devices/bt-data-processor.js +17 -6
  24. package/lib/commonjs/modules/bt-management/services/devices/bt-data-processor.js.map +1 -1
  25. package/lib/commonjs/modules/bt-management/services/devices/bt-managed-device.js +21 -14
  26. package/lib/commonjs/modules/bt-management/services/devices/bt-managed-device.js.map +1 -1
  27. package/lib/commonjs/modules/bt-management/services/devices/custom/custom-lepu-sequencer.js +36 -0
  28. package/lib/commonjs/modules/bt-management/services/devices/custom/custom-lepu-sequencer.js.map +1 -0
  29. package/lib/commonjs/modules/bt-management/services/devices/custom/custom.device.js +81 -14
  30. package/lib/commonjs/modules/bt-management/services/devices/custom/custom.device.js.map +1 -1
  31. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.command-builder.js +48 -0
  32. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.command-builder.js.map +1 -0
  33. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.commands.js +37 -0
  34. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.commands.js.map +1 -0
  35. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.device-info.js +83 -0
  36. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.device-info.js.map +1 -0
  37. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.device-names.js +26 -0
  38. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.device-names.js.map +1 -0
  39. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.file-names.js +36 -0
  40. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.file-names.js.map +1 -0
  41. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.file-transfer.js +155 -0
  42. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.file-transfer.js.map +1 -0
  43. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.frame-reader.js +98 -0
  44. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.frame-reader.js.map +1 -0
  45. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.frame.js +29 -0
  46. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.frame.js.map +1 -0
  47. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.identity-gate.js +103 -0
  48. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.identity-gate.js.map +1 -0
  49. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.name-match.js +32 -0
  50. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.name-match.js.map +1 -0
  51. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.response-type.js +64 -0
  52. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.response-type.js.map +1 -0
  53. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.transports.js +143 -0
  54. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.transports.js.map +1 -0
  55. package/lib/commonjs/modules/bt-management/services/devices/polling-command-sequencer.js +38 -0
  56. package/lib/commonjs/modules/bt-management/services/devices/polling-command-sequencer.js.map +1 -0
  57. package/lib/commonjs/modules/bt-management/services/devices/standard-gatt/standard-gatt.devices.js +156 -0
  58. package/lib/commonjs/modules/bt-management/services/devices/standard-gatt/standard-gatt.devices.js.map +1 -0
  59. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.bp-monitors.js +124 -0
  60. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.bp-monitors.js.map +1 -0
  61. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.ecg-recorders.js +113 -0
  62. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.ecg-recorders.js.map +1 -0
  63. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.lepod.js +117 -0
  64. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.lepod.js.map +1 -0
  65. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.oximeters.js +82 -0
  66. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.oximeters.js.map +1 -0
  67. package/lib/commonjs/modules/bt-management/types/command-sequencer.js +6 -0
  68. package/lib/commonjs/modules/bt-management/types/command-sequencer.js.map +1 -0
  69. package/lib/commonjs/modules/bt-management/types/custom-checksum-algorithm.js +2 -0
  70. package/lib/commonjs/modules/bt-management/types/custom-checksum-algorithm.js.map +1 -0
  71. package/lib/commonjs/modules/bt-management/types/custom-checksum-spec.js +6 -0
  72. package/lib/commonjs/modules/bt-management/types/custom-checksum-spec.js.map +1 -0
  73. package/lib/commonjs/modules/bt-management/types/custom-lepu-spec.js +2 -0
  74. package/lib/commonjs/modules/bt-management/types/custom-lepu-spec.js.map +1 -0
  75. package/lib/commonjs/modules/bt-management/types/custom-measurement-spec.js +6 -0
  76. package/lib/commonjs/modules/bt-management/types/custom-measurement-spec.js.map +1 -0
  77. package/lib/commonjs/modules/bt-management/types/device-command.js +2 -0
  78. package/lib/commonjs/modules/bt-management/types/device-command.js.map +1 -0
  79. package/lib/commonjs/modules/bt-management/types/measurement-group.js +6 -0
  80. package/lib/commonjs/modules/bt-management/types/measurement-group.js.map +1 -0
  81. package/lib/commonjs/modules/bt-management/utils/calculate-checksum.js +49 -0
  82. package/lib/commonjs/modules/bt-management/utils/calculate-checksum.js.map +1 -0
  83. package/lib/commonjs/modules/bt-management/utils/create-frame-validator.js +9 -0
  84. package/lib/commonjs/modules/bt-management/utils/create-frame-validator.js.map +1 -1
  85. package/lib/commonjs/modules/bt-management/utils/hex-to-bytes.js +19 -0
  86. package/lib/commonjs/modules/bt-management/utils/hex-to-bytes.js.map +1 -0
  87. package/lib/commonjs/modules/bt-management/utils/le-32-to-bytes.js +13 -0
  88. package/lib/commonjs/modules/bt-management/utils/le-32-to-bytes.js.map +1 -0
  89. package/lib/commonjs/modules/bt-management/utils/summarise-measurement-for-log.js +22 -0
  90. package/lib/commonjs/modules/bt-management/utils/summarise-measurement-for-log.js.map +1 -0
  91. package/lib/commonjs/modules/bt-management/utils/supported-measurement-type-keys.js +18 -0
  92. package/lib/commonjs/modules/bt-management/utils/supported-measurement-type-keys.js.map +1 -0
  93. package/lib/module/modules/bt-management/index.js +16 -0
  94. package/lib/module/modules/bt-management/index.js.map +1 -1
  95. package/lib/module/modules/bt-management/services/custom/compile-case-fields.js +44 -0
  96. package/lib/module/modules/bt-management/services/custom/compile-case-fields.js.map +1 -0
  97. package/lib/module/modules/bt-management/services/custom/compile-custom-case.js +47 -41
  98. package/lib/module/modules/bt-management/services/custom/compile-custom-case.js.map +1 -1
  99. package/lib/module/modules/bt-management/services/custom/compile-custom-frame.js +48 -2
  100. package/lib/module/modules/bt-management/services/custom/compile-custom-frame.js.map +1 -1
  101. package/lib/module/modules/bt-management/services/custom/compile-custom-lepu.js +93 -0
  102. package/lib/module/modules/bt-management/services/custom/compile-custom-lepu.js.map +1 -0
  103. package/lib/module/modules/bt-management/services/custom/define-custom-device.js +24 -1
  104. package/lib/module/modules/bt-management/services/custom/define-custom-device.js.map +1 -1
  105. package/lib/module/modules/bt-management/services/device-creator.js +16 -8
  106. package/lib/module/modules/bt-management/services/device-creator.js.map +1 -1
  107. package/lib/module/modules/bt-management/services/devices/aoj/aoj.thermometers.js +81 -0
  108. package/lib/module/modules/bt-management/services/devices/aoj/aoj.thermometers.js.map +1 -0
  109. package/lib/module/modules/bt-management/services/devices/bp2/bp2.frame-reader.js +8 -73
  110. package/lib/module/modules/bt-management/services/devices/bp2/bp2.frame-reader.js.map +1 -1
  111. package/lib/module/modules/bt-management/services/devices/bt-command-writer.js +136 -0
  112. package/lib/module/modules/bt-management/services/devices/bt-command-writer.js.map +1 -0
  113. package/lib/module/modules/bt-management/services/devices/bt-connection-handler.js +9 -49
  114. package/lib/module/modules/bt-management/services/devices/bt-connection-handler.js.map +1 -1
  115. package/lib/module/modules/bt-management/services/devices/bt-data-processor.js +17 -6
  116. package/lib/module/modules/bt-management/services/devices/bt-data-processor.js.map +1 -1
  117. package/lib/module/modules/bt-management/services/devices/bt-managed-device.js +21 -14
  118. package/lib/module/modules/bt-management/services/devices/bt-managed-device.js.map +1 -1
  119. package/lib/module/modules/bt-management/services/devices/custom/custom-lepu-sequencer.js +32 -0
  120. package/lib/module/modules/bt-management/services/devices/custom/custom-lepu-sequencer.js.map +1 -0
  121. package/lib/module/modules/bt-management/services/devices/custom/custom.device.js +81 -14
  122. package/lib/module/modules/bt-management/services/devices/custom/custom.device.js.map +1 -1
  123. package/lib/module/modules/bt-management/services/devices/lepu/lepu.command-builder.js +43 -0
  124. package/lib/module/modules/bt-management/services/devices/lepu/lepu.command-builder.js.map +1 -0
  125. package/lib/module/modules/bt-management/services/devices/lepu/lepu.commands.js +33 -0
  126. package/lib/module/modules/bt-management/services/devices/lepu/lepu.commands.js.map +1 -0
  127. package/lib/module/modules/bt-management/services/devices/lepu/lepu.device-info.js +79 -0
  128. package/lib/module/modules/bt-management/services/devices/lepu/lepu.device-info.js.map +1 -0
  129. package/lib/module/modules/bt-management/services/devices/lepu/lepu.device-names.js +22 -0
  130. package/lib/module/modules/bt-management/services/devices/lepu/lepu.device-names.js.map +1 -0
  131. package/lib/module/modules/bt-management/services/devices/lepu/lepu.file-names.js +32 -0
  132. package/lib/module/modules/bt-management/services/devices/lepu/lepu.file-names.js.map +1 -0
  133. package/lib/module/modules/bt-management/services/devices/lepu/lepu.file-transfer.js +150 -0
  134. package/lib/module/modules/bt-management/services/devices/lepu/lepu.file-transfer.js.map +1 -0
  135. package/lib/module/modules/bt-management/services/devices/lepu/lepu.frame-reader.js +93 -0
  136. package/lib/module/modules/bt-management/services/devices/lepu/lepu.frame-reader.js.map +1 -0
  137. package/lib/module/modules/bt-management/services/devices/lepu/lepu.frame.js +24 -0
  138. package/lib/module/modules/bt-management/services/devices/lepu/lepu.frame.js.map +1 -0
  139. package/lib/module/modules/bt-management/services/devices/lepu/lepu.identity-gate.js +98 -0
  140. package/lib/module/modules/bt-management/services/devices/lepu/lepu.identity-gate.js.map +1 -0
  141. package/lib/module/modules/bt-management/services/devices/lepu/lepu.name-match.js +27 -0
  142. package/lib/module/modules/bt-management/services/devices/lepu/lepu.name-match.js.map +1 -0
  143. package/lib/module/modules/bt-management/services/devices/lepu/lepu.response-type.js +59 -0
  144. package/lib/module/modules/bt-management/services/devices/lepu/lepu.response-type.js.map +1 -0
  145. package/lib/module/modules/bt-management/services/devices/lepu/lepu.transports.js +140 -0
  146. package/lib/module/modules/bt-management/services/devices/lepu/lepu.transports.js.map +1 -0
  147. package/lib/module/modules/bt-management/services/devices/polling-command-sequencer.js +34 -0
  148. package/lib/module/modules/bt-management/services/devices/polling-command-sequencer.js.map +1 -0
  149. package/lib/module/modules/bt-management/services/devices/standard-gatt/standard-gatt.devices.js +149 -0
  150. package/lib/module/modules/bt-management/services/devices/standard-gatt/standard-gatt.devices.js.map +1 -0
  151. package/lib/module/modules/bt-management/services/devices/viatom/viatom.bp-monitors.js +118 -0
  152. package/lib/module/modules/bt-management/services/devices/viatom/viatom.bp-monitors.js.map +1 -0
  153. package/lib/module/modules/bt-management/services/devices/viatom/viatom.ecg-recorders.js +108 -0
  154. package/lib/module/modules/bt-management/services/devices/viatom/viatom.ecg-recorders.js.map +1 -0
  155. package/lib/module/modules/bt-management/services/devices/viatom/viatom.lepod.js +114 -0
  156. package/lib/module/modules/bt-management/services/devices/viatom/viatom.lepod.js.map +1 -0
  157. package/lib/module/modules/bt-management/services/devices/viatom/viatom.oximeters.js +79 -0
  158. package/lib/module/modules/bt-management/services/devices/viatom/viatom.oximeters.js.map +1 -0
  159. package/lib/module/modules/bt-management/types/command-sequencer.js +4 -0
  160. package/lib/module/modules/bt-management/types/command-sequencer.js.map +1 -0
  161. package/lib/module/modules/bt-management/types/custom-checksum-algorithm.js +2 -0
  162. package/lib/module/modules/bt-management/types/custom-checksum-algorithm.js.map +1 -0
  163. package/lib/module/modules/bt-management/types/custom-checksum-spec.js +4 -0
  164. package/lib/module/modules/bt-management/types/custom-checksum-spec.js.map +1 -0
  165. package/lib/module/modules/bt-management/types/custom-device-definition.js.map +1 -1
  166. package/lib/module/modules/bt-management/types/custom-lepu-spec.js +2 -0
  167. package/lib/module/modules/bt-management/types/custom-lepu-spec.js.map +1 -0
  168. package/lib/module/modules/bt-management/types/custom-measurement-spec.js +4 -0
  169. package/lib/module/modules/bt-management/types/custom-measurement-spec.js.map +1 -0
  170. package/lib/module/modules/bt-management/types/device-command.js +2 -0
  171. package/lib/module/modules/bt-management/types/device-command.js.map +1 -0
  172. package/lib/module/modules/bt-management/types/measurement-group.js +4 -0
  173. package/lib/module/modules/bt-management/types/measurement-group.js.map +1 -0
  174. package/lib/module/modules/bt-management/utils/calculate-checksum.js +44 -0
  175. package/lib/module/modules/bt-management/utils/calculate-checksum.js.map +1 -0
  176. package/lib/module/modules/bt-management/utils/create-frame-validator.js +9 -0
  177. package/lib/module/modules/bt-management/utils/create-frame-validator.js.map +1 -1
  178. package/lib/module/modules/bt-management/utils/hex-to-bytes.js +14 -0
  179. package/lib/module/modules/bt-management/utils/hex-to-bytes.js.map +1 -0
  180. package/lib/module/modules/bt-management/utils/le-32-to-bytes.js +8 -0
  181. package/lib/module/modules/bt-management/utils/le-32-to-bytes.js.map +1 -0
  182. package/lib/module/modules/bt-management/utils/summarise-measurement-for-log.js +17 -0
  183. package/lib/module/modules/bt-management/utils/summarise-measurement-for-log.js.map +1 -0
  184. package/lib/module/modules/bt-management/utils/supported-measurement-type-keys.js +13 -0
  185. package/lib/module/modules/bt-management/utils/supported-measurement-type-keys.js.map +1 -0
  186. package/lib/typescript/commonjs/src/modules/bt-management/index.d.ts +16 -0
  187. package/lib/typescript/commonjs/src/modules/bt-management/index.d.ts.map +1 -1
  188. package/lib/typescript/commonjs/src/modules/bt-management/services/custom/compile-case-fields.d.ts +13 -0
  189. package/lib/typescript/commonjs/src/modules/bt-management/services/custom/compile-case-fields.d.ts.map +1 -0
  190. package/lib/typescript/commonjs/src/modules/bt-management/services/custom/compile-custom-case.d.ts.map +1 -1
  191. package/lib/typescript/commonjs/src/modules/bt-management/services/custom/compile-custom-frame.d.ts.map +1 -1
  192. package/lib/typescript/commonjs/src/modules/bt-management/services/custom/compile-custom-lepu.d.ts +11 -0
  193. package/lib/typescript/commonjs/src/modules/bt-management/services/custom/compile-custom-lepu.d.ts.map +1 -0
  194. package/lib/typescript/commonjs/src/modules/bt-management/services/custom/define-custom-device.d.ts.map +1 -1
  195. package/lib/typescript/commonjs/src/modules/bt-management/services/device-creator.d.ts.map +1 -1
  196. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/aoj/aoj.thermometers.d.ts +24 -0
  197. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/aoj/aoj.thermometers.d.ts.map +1 -0
  198. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bp2/bp2.frame-reader.d.ts +5 -8
  199. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bp2/bp2.frame-reader.d.ts.map +1 -1
  200. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-command-writer.d.ts +67 -0
  201. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-command-writer.d.ts.map +1 -0
  202. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-connection-handler.d.ts +6 -4
  203. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-connection-handler.d.ts.map +1 -1
  204. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-data-processor.d.ts +20 -1
  205. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-data-processor.d.ts.map +1 -1
  206. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-managed-device.d.ts +12 -1
  207. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-managed-device.d.ts.map +1 -1
  208. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/custom/custom-lepu-sequencer.d.ts +21 -0
  209. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/custom/custom-lepu-sequencer.d.ts.map +1 -0
  210. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/custom/custom.device.d.ts +33 -0
  211. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/custom/custom.device.d.ts.map +1 -1
  212. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.command-builder.d.ts +24 -0
  213. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.command-builder.d.ts.map +1 -0
  214. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.commands.d.ts +32 -0
  215. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.commands.d.ts.map +1 -0
  216. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.device-info.d.ts +27 -0
  217. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.device-info.d.ts.map +1 -0
  218. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.device-names.d.ts +20 -0
  219. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.device-names.d.ts.map +1 -0
  220. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.file-names.d.ts +14 -0
  221. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.file-names.d.ts.map +1 -0
  222. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.file-transfer.d.ts +75 -0
  223. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.file-transfer.d.ts.map +1 -0
  224. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.frame-reader.d.ts +28 -0
  225. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.frame-reader.d.ts.map +1 -0
  226. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.frame.d.ts +12 -0
  227. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.frame.d.ts.map +1 -0
  228. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.identity-gate.d.ts +81 -0
  229. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.identity-gate.d.ts.map +1 -0
  230. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.name-match.d.ts +17 -0
  231. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.name-match.d.ts.map +1 -0
  232. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.response-type.d.ts +33 -0
  233. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.response-type.d.ts.map +1 -0
  234. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.transports.d.ts +85 -0
  235. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.transports.d.ts.map +1 -0
  236. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/polling-command-sequencer.d.ts +27 -0
  237. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/polling-command-sequencer.d.ts.map +1 -0
  238. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/standard-gatt/standard-gatt.devices.d.ts +44 -0
  239. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/standard-gatt/standard-gatt.devices.d.ts.map +1 -0
  240. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.bp-monitors.d.ts +44 -0
  241. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.bp-monitors.d.ts.map +1 -0
  242. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.ecg-recorders.d.ts +32 -0
  243. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.ecg-recorders.d.ts.map +1 -0
  244. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.lepod.d.ts +25 -0
  245. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.lepod.d.ts.map +1 -0
  246. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.oximeters.d.ts +39 -0
  247. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.oximeters.d.ts.map +1 -0
  248. package/lib/typescript/commonjs/src/modules/bt-management/types/command-sequencer.d.ts +26 -0
  249. package/lib/typescript/commonjs/src/modules/bt-management/types/command-sequencer.d.ts.map +1 -0
  250. package/lib/typescript/commonjs/src/modules/bt-management/types/custom-case-spec.d.ts +13 -0
  251. package/lib/typescript/commonjs/src/modules/bt-management/types/custom-case-spec.d.ts.map +1 -1
  252. package/lib/typescript/commonjs/src/modules/bt-management/types/custom-checksum-algorithm.d.ts +10 -0
  253. package/lib/typescript/commonjs/src/modules/bt-management/types/custom-checksum-algorithm.d.ts.map +1 -0
  254. package/lib/typescript/commonjs/src/modules/bt-management/types/custom-checksum-spec.d.ts +23 -0
  255. package/lib/typescript/commonjs/src/modules/bt-management/types/custom-checksum-spec.d.ts.map +1 -0
  256. package/lib/typescript/commonjs/src/modules/bt-management/types/custom-device-definition.d.ts +5 -0
  257. package/lib/typescript/commonjs/src/modules/bt-management/types/custom-device-definition.d.ts.map +1 -1
  258. package/lib/typescript/commonjs/src/modules/bt-management/types/custom-device-spec.d.ts +12 -0
  259. package/lib/typescript/commonjs/src/modules/bt-management/types/custom-device-spec.d.ts.map +1 -1
  260. package/lib/typescript/commonjs/src/modules/bt-management/types/custom-frame-spec.d.ts +8 -0
  261. package/lib/typescript/commonjs/src/modules/bt-management/types/custom-frame-spec.d.ts.map +1 -1
  262. package/lib/typescript/commonjs/src/modules/bt-management/types/custom-lepu-spec.d.ts +44 -0
  263. package/lib/typescript/commonjs/src/modules/bt-management/types/custom-lepu-spec.d.ts.map +1 -0
  264. package/lib/typescript/commonjs/src/modules/bt-management/types/custom-measurement-spec.d.ts +9 -0
  265. package/lib/typescript/commonjs/src/modules/bt-management/types/custom-measurement-spec.d.ts.map +1 -0
  266. package/lib/typescript/commonjs/src/modules/bt-management/types/device-command.d.ts +18 -0
  267. package/lib/typescript/commonjs/src/modules/bt-management/types/device-command.d.ts.map +1 -0
  268. package/lib/typescript/commonjs/src/modules/bt-management/types/measurement-group.d.ts +14 -0
  269. package/lib/typescript/commonjs/src/modules/bt-management/types/measurement-group.d.ts.map +1 -0
  270. package/lib/typescript/commonjs/src/modules/bt-management/types/parsing-case.d.ts +9 -0
  271. package/lib/typescript/commonjs/src/modules/bt-management/types/parsing-case.d.ts.map +1 -1
  272. package/lib/typescript/commonjs/src/modules/bt-management/utils/calculate-checksum.d.ts +13 -0
  273. package/lib/typescript/commonjs/src/modules/bt-management/utils/calculate-checksum.d.ts.map +1 -0
  274. package/lib/typescript/commonjs/src/modules/bt-management/utils/create-frame-validator.d.ts.map +1 -1
  275. package/lib/typescript/commonjs/src/modules/bt-management/utils/hex-to-bytes.d.ts +10 -0
  276. package/lib/typescript/commonjs/src/modules/bt-management/utils/hex-to-bytes.d.ts.map +1 -0
  277. package/lib/typescript/commonjs/src/modules/bt-management/utils/le-32-to-bytes.d.ts +3 -0
  278. package/lib/typescript/commonjs/src/modules/bt-management/utils/le-32-to-bytes.d.ts.map +1 -0
  279. package/lib/typescript/commonjs/src/modules/bt-management/utils/summarise-measurement-for-log.d.ts +9 -0
  280. package/lib/typescript/commonjs/src/modules/bt-management/utils/summarise-measurement-for-log.d.ts.map +1 -0
  281. package/lib/typescript/commonjs/src/modules/bt-management/utils/supported-measurement-type-keys.d.ts +10 -0
  282. package/lib/typescript/commonjs/src/modules/bt-management/utils/supported-measurement-type-keys.d.ts.map +1 -0
  283. package/lib/typescript/module/src/modules/bt-management/index.d.ts +16 -0
  284. package/lib/typescript/module/src/modules/bt-management/index.d.ts.map +1 -1
  285. package/lib/typescript/module/src/modules/bt-management/services/custom/compile-case-fields.d.ts +13 -0
  286. package/lib/typescript/module/src/modules/bt-management/services/custom/compile-case-fields.d.ts.map +1 -0
  287. package/lib/typescript/module/src/modules/bt-management/services/custom/compile-custom-case.d.ts.map +1 -1
  288. package/lib/typescript/module/src/modules/bt-management/services/custom/compile-custom-frame.d.ts.map +1 -1
  289. package/lib/typescript/module/src/modules/bt-management/services/custom/compile-custom-lepu.d.ts +11 -0
  290. package/lib/typescript/module/src/modules/bt-management/services/custom/compile-custom-lepu.d.ts.map +1 -0
  291. package/lib/typescript/module/src/modules/bt-management/services/custom/define-custom-device.d.ts.map +1 -1
  292. package/lib/typescript/module/src/modules/bt-management/services/device-creator.d.ts.map +1 -1
  293. package/lib/typescript/module/src/modules/bt-management/services/devices/aoj/aoj.thermometers.d.ts +24 -0
  294. package/lib/typescript/module/src/modules/bt-management/services/devices/aoj/aoj.thermometers.d.ts.map +1 -0
  295. package/lib/typescript/module/src/modules/bt-management/services/devices/bp2/bp2.frame-reader.d.ts +5 -8
  296. package/lib/typescript/module/src/modules/bt-management/services/devices/bp2/bp2.frame-reader.d.ts.map +1 -1
  297. package/lib/typescript/module/src/modules/bt-management/services/devices/bt-command-writer.d.ts +67 -0
  298. package/lib/typescript/module/src/modules/bt-management/services/devices/bt-command-writer.d.ts.map +1 -0
  299. package/lib/typescript/module/src/modules/bt-management/services/devices/bt-connection-handler.d.ts +6 -4
  300. package/lib/typescript/module/src/modules/bt-management/services/devices/bt-connection-handler.d.ts.map +1 -1
  301. package/lib/typescript/module/src/modules/bt-management/services/devices/bt-data-processor.d.ts +20 -1
  302. package/lib/typescript/module/src/modules/bt-management/services/devices/bt-data-processor.d.ts.map +1 -1
  303. package/lib/typescript/module/src/modules/bt-management/services/devices/bt-managed-device.d.ts +12 -1
  304. package/lib/typescript/module/src/modules/bt-management/services/devices/bt-managed-device.d.ts.map +1 -1
  305. package/lib/typescript/module/src/modules/bt-management/services/devices/custom/custom-lepu-sequencer.d.ts +21 -0
  306. package/lib/typescript/module/src/modules/bt-management/services/devices/custom/custom-lepu-sequencer.d.ts.map +1 -0
  307. package/lib/typescript/module/src/modules/bt-management/services/devices/custom/custom.device.d.ts +33 -0
  308. package/lib/typescript/module/src/modules/bt-management/services/devices/custom/custom.device.d.ts.map +1 -1
  309. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.command-builder.d.ts +24 -0
  310. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.command-builder.d.ts.map +1 -0
  311. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.commands.d.ts +32 -0
  312. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.commands.d.ts.map +1 -0
  313. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.device-info.d.ts +27 -0
  314. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.device-info.d.ts.map +1 -0
  315. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.device-names.d.ts +20 -0
  316. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.device-names.d.ts.map +1 -0
  317. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.file-names.d.ts +14 -0
  318. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.file-names.d.ts.map +1 -0
  319. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.file-transfer.d.ts +75 -0
  320. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.file-transfer.d.ts.map +1 -0
  321. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.frame-reader.d.ts +28 -0
  322. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.frame-reader.d.ts.map +1 -0
  323. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.frame.d.ts +12 -0
  324. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.frame.d.ts.map +1 -0
  325. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.identity-gate.d.ts +81 -0
  326. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.identity-gate.d.ts.map +1 -0
  327. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.name-match.d.ts +17 -0
  328. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.name-match.d.ts.map +1 -0
  329. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.response-type.d.ts +33 -0
  330. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.response-type.d.ts.map +1 -0
  331. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.transports.d.ts +85 -0
  332. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.transports.d.ts.map +1 -0
  333. package/lib/typescript/module/src/modules/bt-management/services/devices/polling-command-sequencer.d.ts +27 -0
  334. package/lib/typescript/module/src/modules/bt-management/services/devices/polling-command-sequencer.d.ts.map +1 -0
  335. package/lib/typescript/module/src/modules/bt-management/services/devices/standard-gatt/standard-gatt.devices.d.ts +44 -0
  336. package/lib/typescript/module/src/modules/bt-management/services/devices/standard-gatt/standard-gatt.devices.d.ts.map +1 -0
  337. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.bp-monitors.d.ts +44 -0
  338. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.bp-monitors.d.ts.map +1 -0
  339. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.ecg-recorders.d.ts +32 -0
  340. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.ecg-recorders.d.ts.map +1 -0
  341. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.lepod.d.ts +25 -0
  342. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.lepod.d.ts.map +1 -0
  343. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.oximeters.d.ts +39 -0
  344. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.oximeters.d.ts.map +1 -0
  345. package/lib/typescript/module/src/modules/bt-management/types/command-sequencer.d.ts +26 -0
  346. package/lib/typescript/module/src/modules/bt-management/types/command-sequencer.d.ts.map +1 -0
  347. package/lib/typescript/module/src/modules/bt-management/types/custom-case-spec.d.ts +13 -0
  348. package/lib/typescript/module/src/modules/bt-management/types/custom-case-spec.d.ts.map +1 -1
  349. package/lib/typescript/module/src/modules/bt-management/types/custom-checksum-algorithm.d.ts +10 -0
  350. package/lib/typescript/module/src/modules/bt-management/types/custom-checksum-algorithm.d.ts.map +1 -0
  351. package/lib/typescript/module/src/modules/bt-management/types/custom-checksum-spec.d.ts +23 -0
  352. package/lib/typescript/module/src/modules/bt-management/types/custom-checksum-spec.d.ts.map +1 -0
  353. package/lib/typescript/module/src/modules/bt-management/types/custom-device-definition.d.ts +5 -0
  354. package/lib/typescript/module/src/modules/bt-management/types/custom-device-definition.d.ts.map +1 -1
  355. package/lib/typescript/module/src/modules/bt-management/types/custom-device-spec.d.ts +12 -0
  356. package/lib/typescript/module/src/modules/bt-management/types/custom-device-spec.d.ts.map +1 -1
  357. package/lib/typescript/module/src/modules/bt-management/types/custom-frame-spec.d.ts +8 -0
  358. package/lib/typescript/module/src/modules/bt-management/types/custom-frame-spec.d.ts.map +1 -1
  359. package/lib/typescript/module/src/modules/bt-management/types/custom-lepu-spec.d.ts +44 -0
  360. package/lib/typescript/module/src/modules/bt-management/types/custom-lepu-spec.d.ts.map +1 -0
  361. package/lib/typescript/module/src/modules/bt-management/types/custom-measurement-spec.d.ts +9 -0
  362. package/lib/typescript/module/src/modules/bt-management/types/custom-measurement-spec.d.ts.map +1 -0
  363. package/lib/typescript/module/src/modules/bt-management/types/device-command.d.ts +18 -0
  364. package/lib/typescript/module/src/modules/bt-management/types/device-command.d.ts.map +1 -0
  365. package/lib/typescript/module/src/modules/bt-management/types/measurement-group.d.ts +14 -0
  366. package/lib/typescript/module/src/modules/bt-management/types/measurement-group.d.ts.map +1 -0
  367. package/lib/typescript/module/src/modules/bt-management/types/parsing-case.d.ts +9 -0
  368. package/lib/typescript/module/src/modules/bt-management/types/parsing-case.d.ts.map +1 -1
  369. package/lib/typescript/module/src/modules/bt-management/utils/calculate-checksum.d.ts +13 -0
  370. package/lib/typescript/module/src/modules/bt-management/utils/calculate-checksum.d.ts.map +1 -0
  371. package/lib/typescript/module/src/modules/bt-management/utils/create-frame-validator.d.ts.map +1 -1
  372. package/lib/typescript/module/src/modules/bt-management/utils/hex-to-bytes.d.ts +10 -0
  373. package/lib/typescript/module/src/modules/bt-management/utils/hex-to-bytes.d.ts.map +1 -0
  374. package/lib/typescript/module/src/modules/bt-management/utils/le-32-to-bytes.d.ts +3 -0
  375. package/lib/typescript/module/src/modules/bt-management/utils/le-32-to-bytes.d.ts.map +1 -0
  376. package/lib/typescript/module/src/modules/bt-management/utils/summarise-measurement-for-log.d.ts +9 -0
  377. package/lib/typescript/module/src/modules/bt-management/utils/summarise-measurement-for-log.d.ts.map +1 -0
  378. package/lib/typescript/module/src/modules/bt-management/utils/supported-measurement-type-keys.d.ts +10 -0
  379. package/lib/typescript/module/src/modules/bt-management/utils/supported-measurement-type-keys.d.ts.map +1 -0
  380. package/package.json +1 -1
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.LepuCommand = void 0;
7
+ /**
8
+ * The commands every Lepu device understands.
9
+ *
10
+ * These are the generic opcodes, shared across the whole family. Device-specific opcodes live
11
+ * below 0x40 and belong with their driver, because the same number means different things on
12
+ * different hardware - 0x08 polls realtime data on a BP2 and starts a measurement on others.
13
+ * That collision is why this module holds only the opcodes that are genuinely common, and why
14
+ * a driver must never assume a low opcode is safe to send to an unidentified device.
15
+ */
16
+ const LepuCommand = exports.LepuCommand = {
17
+ /** Link keepalive and round-trip test. Inert. */
18
+ ECHO: 0xe0,
19
+ /**
20
+ * Device information, including the model string.
21
+ *
22
+ * Inert and identical family-wide, which makes it the one command safe to send before a
23
+ * device has been identified - and therefore the way to confirm what something is before
24
+ * addressing it with an opcode that means something else on the wrong hardware.
25
+ */
26
+ GET_INFO: 0xe1,
27
+ GET_BATTERY: 0xe4,
28
+ /** Enumerate the records stored on the device. */
29
+ GET_FILE_LIST: 0xf1,
30
+ /** Begin a read: a 20-byte payload of file name plus a 32-bit offset. */
31
+ READ_FILE_START: 0xf2,
32
+ /** Fetch the next chunk of the file being read. */
33
+ READ_FILE_DATA: 0xf3,
34
+ /** End the read and release the device's file handle. */
35
+ READ_FILE_END: 0xf4
36
+ };
37
+ //# sourceMappingURL=lepu.commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["LepuCommand","exports","ECHO","GET_INFO","GET_BATTERY","GET_FILE_LIST","READ_FILE_START","READ_FILE_DATA","READ_FILE_END"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/lepu/lepu.commands.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG;EACzB;EACAE,IAAI,EAAE,IAAI;EAEV;AACF;AACA;AACA;AACA;AACA;AACA;EACEC,QAAQ,EAAE,IAAI;EAEdC,WAAW,EAAE,IAAI;EAEjB;EACAC,aAAa,EAAE,IAAI;EAEnB;EACAC,eAAe,EAAE,IAAI;EAErB;EACAC,cAAc,EAAE,IAAI;EAEpB;EACAC,aAAa,EAAE;AACjB,CAAU","ignoreList":[]}
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.parseLepuDeviceInfo = void 0;
7
+ var _hexToByte = require("../../../utils/hex-to-byte.js");
8
+ var _le16FromHex = require("../../../utils/le-16-from-hex.js");
9
+ var _lepuCommands = require("./lepu.commands.js");
10
+ var _lepuResponseType = require("./lepu.response-type.js");
11
+ const COMMAND_INDEX = 1;
12
+ const HEADER_BYTES = 7;
13
+
14
+ /** Offsets within the payload, per the vendor's own `Bp2DeviceInfo` layout. */
15
+ const BRANCH_CODE_OFFSET = 9;
16
+ const BRANCH_CODE_BYTES = 8;
17
+ const DEVICE_TYPE_OFFSET = 20;
18
+ const PROTOCOL_MAX_LENGTH_OFFSET = 31;
19
+ const SERIAL_LENGTH_OFFSET = 37;
20
+ const SERIAL_OFFSET = 38;
21
+
22
+ /** The vendor clamps the reported serial length, implying firmware has overstated it. */
23
+ const MAX_SERIAL_BYTES = 18;
24
+
25
+ /** Everything up to and including the serial length. Less than this is not device info. */
26
+ const MIN_PAYLOAD_BYTES = SERIAL_OFFSET;
27
+ const NUL = 0;
28
+
29
+ /**
30
+ * Reads a zero-padded ASCII field.
31
+ *
32
+ * These fields are fixed width rather than length-prefixed, so the padding is where the
33
+ * value ends. Reading the full width would append NULs to every string.
34
+ */
35
+ const asciiAt = (frame, start, length) => {
36
+ let text = "";
37
+ for (let index = start; index < start + length; index++) {
38
+ const byte = (0, _hexToByte.hexToByte)(frame[index] ?? "0");
39
+ if (byte === NUL) {
40
+ return text;
41
+ }
42
+ text += String.fromCharCode(byte);
43
+ }
44
+ return text;
45
+ };
46
+
47
+ /** What a Lepu device says it is, in answer to `GET_INFO`. */
48
+
49
+ /**
50
+ * Reads the reply to `GET_INFO`, or nothing if the frame is not one.
51
+ *
52
+ * The command byte is checked rather than assumed, because this is the answer a driver
53
+ * decides its identity on: parsing some other frame as device info would produce a model
54
+ * number out of whatever bytes happened to sit at offset 20, and the gate would then pass
55
+ * on a coincidence.
56
+ *
57
+ * A frame too short to hold the layout is refused for the same reason, as is one whose
58
+ * response type is anything but success: an error reply carries a reason where the device
59
+ * information would be, and reading it as a model number would identify the hardware from
60
+ * an error code. The vendor's own struct is at least 56 bytes; anything shorter than the
61
+ * serial length field cannot be read without inventing the parts that are missing.
62
+ */
63
+ const parseLepuDeviceInfo = frame => {
64
+ if ((0, _hexToByte.hexToByte)(frame[COMMAND_INDEX] ?? "0") !== _lepuCommands.LepuCommand.GET_INFO) {
65
+ return undefined;
66
+ }
67
+ if (!(0, _lepuResponseType.isLepuSuccess)(frame)) {
68
+ return undefined;
69
+ }
70
+ if (frame.length < HEADER_BYTES + MIN_PAYLOAD_BYTES) {
71
+ return undefined;
72
+ }
73
+ const payload = HEADER_BYTES;
74
+ const serialLength = Math.min((0, _hexToByte.hexToByte)(frame[payload + SERIAL_LENGTH_OFFSET] ?? "0"), MAX_SERIAL_BYTES);
75
+ return {
76
+ deviceType: (0, _le16FromHex.le16FromHex)(frame, payload + DEVICE_TYPE_OFFSET),
77
+ protocolMaxLength: (0, _le16FromHex.le16FromHex)(frame, payload + PROTOCOL_MAX_LENGTH_OFFSET),
78
+ branchCode: asciiAt(frame, payload + BRANCH_CODE_OFFSET, BRANCH_CODE_BYTES),
79
+ serialNumber: asciiAt(frame, payload + SERIAL_OFFSET, serialLength)
80
+ };
81
+ };
82
+ exports.parseLepuDeviceInfo = parseLepuDeviceInfo;
83
+ //# sourceMappingURL=lepu.device-info.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_hexToByte","require","_le16FromHex","_lepuCommands","_lepuResponseType","COMMAND_INDEX","HEADER_BYTES","BRANCH_CODE_OFFSET","BRANCH_CODE_BYTES","DEVICE_TYPE_OFFSET","PROTOCOL_MAX_LENGTH_OFFSET","SERIAL_LENGTH_OFFSET","SERIAL_OFFSET","MAX_SERIAL_BYTES","MIN_PAYLOAD_BYTES","NUL","asciiAt","frame","start","length","text","index","byte","hexToByte","String","fromCharCode","parseLepuDeviceInfo","LepuCommand","GET_INFO","undefined","isLepuSuccess","payload","serialLength","Math","min","deviceType","le16FromHex","protocolMaxLength","branchCode","serialNumber","exports"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/lepu/lepu.device-info.ts"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AAEA,MAAMI,aAAa,GAAG,CAAC;AACvB,MAAMC,YAAY,GAAG,CAAC;;AAEtB;AACA,MAAMC,kBAAkB,GAAG,CAAC;AAC5B,MAAMC,iBAAiB,GAAG,CAAC;AAC3B,MAAMC,kBAAkB,GAAG,EAAE;AAC7B,MAAMC,0BAA0B,GAAG,EAAE;AACrC,MAAMC,oBAAoB,GAAG,EAAE;AAC/B,MAAMC,aAAa,GAAG,EAAE;;AAExB;AACA,MAAMC,gBAAgB,GAAG,EAAE;;AAE3B;AAC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,kBAAkB,CAAC;IAC5D4B,iBAAiB,EAAE,IAAAD,wBAAW,EAACnB,KAAK,EAAEc,OAAO,GAAGrB,0BAA0B,CAAC;IAC3E4B,UAAU,EAAEtB,OAAO,CAACC,KAAK,EAAEc,OAAO,GAAGxB,kBAAkB,EAAEC,iBAAiB,CAAC;IAC3E+B,YAAY,EAAEvB,OAAO,CAACC,KAAK,EAAEc,OAAO,GAAGnB,aAAa,EAAEoB,YAAY;EACpE,CAAC;AACH,CAAC;AAACQ,OAAA,CAAAd,mBAAA,GAAAA,mBAAA","ignoreList":[]}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.LEPU_DEVICE_NAMES = void 0;
7
+ /**
8
+ * The names the Lepu/Viatom family advertises, as its own SDK matches them.
9
+ *
10
+ * Taken from the vendor's `getDeviceModel`, a 732-line cascade of substring checks that is
11
+ * the whole of how that SDK decides which product it is talking to. The order there matters,
12
+ * because 27 of these names are a prefix of another - `BP2` of `BP2A`, `BP2T`, `BP2W` and
13
+ * three more - so a check that ran in the wrong order would bind a BP2W as a BP2 and poll it
14
+ * with an opcode written for different hardware.
15
+ *
16
+ * It is that function's vocabulary, not a catalogue of everything the vendor sells: a few
17
+ * products - the ER3 and the M12 among them - are identified elsewhere in that app and never
18
+ * reach this list. `lepuNameMatch` accepts a name that is absent, and derives no exclusions
19
+ * for it, which is correct exactly when no name here extends it.
20
+ *
21
+ * They are held here as a flat vocabulary rather than an ordered cascade, because
22
+ * `lepuNameMatch` derives the exclusions from the list itself. Adding a name automatically
23
+ * narrows every name it extends, which an ordered list would leave to whoever inserted it.
24
+ */
25
+ const LEPU_DEVICE_NAMES = exports.LEPU_DEVICE_NAMES = ["AI-S100", "AITele", "AIView VS", "AP-20", "AP-20-WPS", "AirBP", "Aura_BP2", "BBSM BS1", "BBSM P1", "BBSM S1", "BBSM S2", "BBSM S3", "BM10", "BP2", "BP2A", "BP2A Nexus", "BP2B", "BP2T", "BP2V", "BP2W", "BP3", "BP3-B", "BP3-C1", "BP3-C2", "BP3A", "BP3B", "BP3C", "BP3D", "BP3E", "BP3F", "BP3G", "BP3H", "BP3K", "BP3L", "BP3Z", "BP4 Flex", "BPWATCH", "BUZUD-CML", "Band-WU", "Bioland-BGM", "CB1L-1", "CMB590611", "CMB590840", "CMB592254", "CMI_PC303", "CMRing", "CMTouch", "CPR Feedback", "CPR-01", "CPR-02", "CheckADV", "Checkme", "Checkme EX", "Checkme Pod", "Checkme Pod-WPS", "Checkme lite A", "CheckmeLE", "CheckmeLP", "DUAL-SPP", "EM-B", "EM-W", "ER1", "ER1-H", "ER1-L", "ER1-S", "ER1-SP", "ER1-W", "ER1S", "ER2", "ER2-S", "EZY-HB-01", "EZY-HBB-02", "GM_300SNT", "GM_300SNT-BLE", "Genial-T31", "HDM3D", "HDM3G", "HHM1", "HHM2", "HHM3", "HHM4", "JFK1001", "JFR1001", "KCA", "KCB", "KS-60FW", "KardiaBP", "KidsO2-WPS", "LBM-1", "LEPU AED", "LEPU ER1", "LEPU-ER2", "LP ER2", "LP-BP2W", "LPM311", "LPRE", "Le S5", "Le-F2 Pro", "Le-W", "LeRes", "Lepod", "LepodPro", "Lepu PO6", "Lescale F3", "Lescale F4L", "Lescale F4P", "Lescale P3", "M5", "MY-SS2501", "N9+BP2", "O2 Intg", "O2M-WPS", "O2R WAVE", "O2RMed S", "O2Ring", "O2Ring S", "O2Ring SC", "O2Ring SF", "O2Ring SP", "O2Ring-RE", "O2RingF", "OxyU", "OxyU SE", "Oxyfit", "Oxyfit-WPS", "PC-100", "PC-200", "PC-200-BLE", "PC-60B_SN", "PC-60F_SN", "PC-60NW", "PC-60NW-1_SN", "PC-60NW-WPS", "PC-60NW_BLE", "PC-60NW_SN", "PC-66B", "PC-68B", "PC66B-VE", "PC80B", "PC80B-BLE", "PC80B_BLE:", "PC_300SNT", "PC_300SNT-BLE", "PF-10", "PF-10AW", "PF-10AW-1", "PF-10AW1", "PF-10BW", "PF-10BW1", "PF-10BWS", "PF-20", "PF-20AW", "PF-20B", "PF10AW-ME", "PF10BW-VE", "PM10", "PO6B-WE", "POD-1W-WU", "POD-1_SN", "POD-2B_SN", "PoctorM3102", "QC-200", "R10", "R11", "R20", "R200", "R21", "S5W-VU", "S5W_SN", "S6W", "S6W1", "S7BW", "S7W", "S8-AW", "SA10AW-PU", "SHQFlex", "SHQO2Pro", "SI PO2", "SI PO4", "SI PO6", "SP-20", "SP-20-BLE", "SP-20-WPS", "T-201", "TMB-2288", "TMB_2088", "VCOMIN", "VTM AD5", "W12c", "WBP-02", "ZH-SG", "ZH-SG-A606", "aed_box", "iGate", "int-ER2", "le B1", "le S1"];
26
+ //# sourceMappingURL=lepu.device-names.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["LEPU_DEVICE_NAMES","exports"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/lepu/lepu.device-names.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,iBAAoC,GAAAC,OAAA,CAAAD,iBAAA,GAAG,CAClD,SAAS,EACT,QAAQ,EACR,WAAW,EACX,OAAO,EACP,WAAW,EACX,OAAO,EACP,UAAU,EACV,UAAU,EACV,SAAS,EACT,SAAS,EACT,SAAS,EACT,SAAS,EACT,MAAM,EACN,KAAK,EACL,MAAM,EACN,YAAY,EACZ,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACN,KAAK,EACL,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACN,UAAU,EACV,SAAS,EACT,WAAW,EACX,SAAS,EACT,aAAa,EACb,QAAQ,EACR,WAAW,EACX,WAAW,EACX,WAAW,E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WAAW,EACX,MAAM,EACN,SAAS,EACT,WAAW,EACX,UAAU,EACV,WAAW,EACX,aAAa,EACb,QAAQ,EACR,KAAK,EACL,KAAK,EACL,KAAK,EACL,MAAM,EACN,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,MAAM,EACN,MAAM,EACN,KAAK,EACL,OAAO,EACP,WAAW,EACX,SAAS,EACT,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,WAAW,EACX,WAAW,EACX,OAAO,EACP,UAAU,EACV,UAAU,EACV,QAAQ,EACR,SAAS,EACT,MAAM,EACN,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,SAAS,EACT,OAAO,EACP,SAAS,EACT,OAAO,EACP,OAAO,CACR","ignoreList":[]}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.lepuNamesFrom = exports.lepuNameBytes = exports.NAME_BYTES = void 0;
7
+ var _hexToByte = require("../../../utils/hex-to-byte.js");
8
+ /** Names are a fixed sixteen bytes, zero padded, in both the listing and the request. */
9
+ const NAME_BYTES = exports.NAME_BYTES = 16;
10
+ const BYTE_MASK = 0xff;
11
+ const NUL = 0;
12
+
13
+ /**
14
+ * A file name as the device expects it: sixteen bytes, zero padded, truncated.
15
+ *
16
+ * The truncation is the device's, not ours - it copies at most sixteen bytes and pads the
17
+ * rest - so two names that agree in their first sixteen bytes are the same file as far as
18
+ * the protocol is concerned.
19
+ */
20
+ const lepuNameBytes = name => Array.from({
21
+ length: NAME_BYTES
22
+ }, (_, index) => index < name.length ? name.charCodeAt(index) & BYTE_MASK : NUL);
23
+
24
+ /** The names in a file listing: a count, then that many fixed-width padded names. */
25
+ exports.lepuNameBytes = lepuNameBytes;
26
+ const lepuNamesFrom = payload => {
27
+ const count = (0, _hexToByte.hexToByte)(payload[0] ?? "0");
28
+ return Array.from({
29
+ length: count
30
+ }, (_, index) => {
31
+ const start = 1 + index * NAME_BYTES;
32
+ return payload.slice(start, start + NAME_BYTES).map(byte => (0, _hexToByte.hexToByte)(byte)).filter(byte => byte !== NUL).map(byte => String.fromCharCode(byte)).join("").trim();
33
+ }).filter(name => name.length > 0);
34
+ };
35
+ exports.lepuNamesFrom = lepuNamesFrom;
36
+ //# sourceMappingURL=lepu.file-names.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_hexToByte","require","NAME_BYTES","exports","BYTE_MASK","NUL","lepuNameBytes","name","Array","from","length","_","index","charCodeAt","lepuNamesFrom","payload","count","hexToByte","start","slice","map","byte","filter","String","fromCharCode","join","trim"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/lepu/lepu.file-names.ts"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEA;AACA,MAAMC,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAG,EAAE;AACrB,MAAME,SAAS,GAAG,IAAI;AACtB,MAAMC,GAAG,GAAG,CAAC;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,aAAa,GAAIC,IAAY,IACjCC,KAAK,CAACC,IAAI,CAAC;EAAEC,MAAM,EAAER;AAAW,CAAC,EAAE,CAACS,CAAC,EAAEC,KAAK,KAC1CA,KAAK,GAAGL,IAAI,CAACG,MAAM,GAAGH,IAAI,CAACM,UAAU,CAACD,KAAK,CAAC,GAAGR,SAAS,GAAGC,GAC7D,CAAC;;AAEH;AAAAF,OAAA,CAAAG,aAAA,GAAAA,aAAA;AACA,MAAMQ,aAAa,GAAIC,OAA0B,IAAe;EAC9D,MAAMC,KAAK,GAAG,IAAAC,oBAAS,EAACF,OAAO,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC;EAE1C,OAAOP,KAAK,CAACC,IAAI,CAAC;IAAEC,MAAM,EAAEM;EAAM,CAAC,EAAE,CAACL,CAAC,EAAEC,KAAK,KAAK;IACjD,MAAMM,KAAK,GAAG,CAAC,GAAGN,KAAK,GAAGV,UAAU;IAEpC,OAAOa,OAAO,CACXI,KAAK,CAACD,KAAK,EAAEA,KAAK,GAAGhB,UAAU,CAAC,CAChCkB,GAAG,CAAEC,IAAI,IAAK,IAAAJ,oBAAS,EAACI,IAAI,CAAC,CAAC,CAC9BC,MAAM,CAAED,IAAI,IAAKA,IAAI,KAAKhB,GAAG,CAAC,CAC9Be,GAAG,CAAEC,IAAI,IAAKE,MAAM,CAACC,YAAY,CAACH,IAAI,CAAC,CAAC,CACxCI,IAAI,CAAC,EAAE,CAAC,CACRC,IAAI,CAAC,CAAC;EACX,CAAC,CAAC,CAACJ,MAAM,CAAEf,IAAI,IAAKA,IAAI,CAACG,MAAM,GAAG,CAAC,CAAC;AACtC,CAAC;AAACP,OAAA,CAAAW,aAAA,GAAAA,aAAA","ignoreList":[]}
@@ -0,0 +1,155 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.LepuFileTransfer = void 0;
7
+ var _le32FromHex = require("../../../utils/le-32-from-hex.js");
8
+ var _le32ToBytes = require("../../../utils/le-32-to-bytes.js");
9
+ var _lepuCommands = require("./lepu.commands.js");
10
+ var _lepuFileNames = require("./lepu.file-names.js");
11
+ var _lepuFrame = require("./lepu.frame.js");
12
+ var _lepuResponseType = require("./lepu.response-type.js");
13
+ const FILE_SIZE_OFFSET = 0;
14
+
15
+ /**
16
+ * A hex-byte array costs far more memory than the file it describes, so the cap sits well
17
+ * below what a device could offer. A stored ECG is tens of kilobytes; a length near this one
18
+ * is a length to refuse rather than try to hold on a low-memory tablet.
19
+ */
20
+ const MAX_FILE_BYTES = 262_144;
21
+ const TRANSFER_COMMANDS = [_lepuCommands.LepuCommand.GET_FILE_LIST, _lepuCommands.LepuCommand.READ_FILE_START, _lepuCommands.LepuCommand.READ_FILE_DATA, _lepuCommands.LepuCommand.READ_FILE_END];
22
+ /**
23
+ * Downloads the records a Lepu device has stored.
24
+ *
25
+ * Every opcode this uses is generic and inert - list, open, read, close - so unlike a
26
+ * realtime poll it is safe on hardware whose model is not known. That is what makes it the
27
+ * one thing the whole family can be asked for without identifying it first.
28
+ *
29
+ * The exchange is self-clocking and has no windowing: each reply decides the next request,
30
+ * and the device chooses how much to send, so the offset advances by what actually arrived
31
+ * rather than by an assumed chunk size. There is no retry in the protocol either - a single
32
+ * dropped reply stalls the transfer with nothing to resume it - which is what the data
33
+ * processor's stuck-data timeout is the watchdog for.
34
+ *
35
+ * A short read is an error, not a truncated success: the device is asked to close the file
36
+ * and the reading is discarded, because half an ECG that looks like a whole one is worse
37
+ * than none.
38
+ */
39
+ class LepuFileTransfer {
40
+ files = [];
41
+ fileIndex = 0;
42
+ name = "";
43
+ totalBytes = 0;
44
+ content = [];
45
+ isSessionOpen = false;
46
+ isDone = false;
47
+ constructor(params) {
48
+ this.params = params;
49
+ }
50
+ initialCommands = () => [this.commandFor(_lepuCommands.LepuCommand.GET_FILE_LIST)];
51
+ nextCommand = frame => {
52
+ const command = (0, _lepuFrame.lepuCommandOf)(frame);
53
+ if (this.isDone || !TRANSFER_COMMANDS.includes(command)) {
54
+ return undefined;
55
+ }
56
+ if (!(0, _lepuResponseType.isLepuSuccess)(frame)) {
57
+ return this.fail(`the device refused it: ${(0, _lepuResponseType.describeLepuResponseType)(frame)}`);
58
+ }
59
+ if (command === _lepuCommands.LepuCommand.GET_FILE_LIST) {
60
+ this.files = (0, _lepuFileNames.lepuNamesFrom)((0, _lepuFrame.lepuPayloadOf)(frame));
61
+ this.fileIndex = 0;
62
+ return this.openNextFile();
63
+ }
64
+ if (command === _lepuCommands.LepuCommand.READ_FILE_START) {
65
+ return this.openedFile((0, _lepuFrame.lepuPayloadOf)(frame));
66
+ }
67
+ if (command === _lepuCommands.LepuCommand.READ_FILE_DATA) {
68
+ return this.appendChunk((0, _lepuFrame.lepuPayloadOf)(frame));
69
+ }
70
+ return this.closedFile();
71
+ };
72
+ openNextFile = () => {
73
+ const name = this.files[this.fileIndex];
74
+ if (name === undefined) {
75
+ this.isDone = true;
76
+ return undefined;
77
+ }
78
+ this.name = name;
79
+ this.totalBytes = 0;
80
+ this.content = [];
81
+ return [this.commandFor(_lepuCommands.LepuCommand.READ_FILE_START, [...(0, _lepuFileNames.lepuNameBytes)(name), ...(0, _le32ToBytes.le32ToBytes)(0)])];
82
+ };
83
+
84
+ /** The reply to opening a file states its whole length, which bounds everything after. */
85
+ openedFile = payload => {
86
+ this.isSessionOpen = true;
87
+ this.totalBytes = (0, _le32FromHex.le32FromHex)([...payload], FILE_SIZE_OFFSET);
88
+ const limit = this.params.maxFileBytes ?? MAX_FILE_BYTES;
89
+ if (this.totalBytes > limit) {
90
+ return this.fail(`"${this.name}" is ${this.totalBytes} bytes, more than the ${limit} this transfer will hold`);
91
+ }
92
+ if (this.totalBytes === 0) {
93
+ return this.closeFile();
94
+ }
95
+ return [this.commandFor(_lepuCommands.LepuCommand.READ_FILE_DATA, (0, _le32ToBytes.le32ToBytes)(0))];
96
+ };
97
+
98
+ /**
99
+ * A reply with no bytes in it ends the transfer rather than asking again from the same
100
+ * offset, which is a request the device would answer the same way for as long as the link
101
+ * stayed up.
102
+ */
103
+ appendChunk = payload => {
104
+ if (payload.length === 0) {
105
+ return this.fail(`"${this.name}" stopped sending at ${this.content.length} of ${this.totalBytes} bytes`);
106
+ }
107
+ this.content.push(...payload);
108
+ this.params.onProgress?.({
109
+ name: this.name,
110
+ receivedBytes: this.content.length,
111
+ totalBytes: this.totalBytes
112
+ });
113
+ if (this.content.length >= this.totalBytes) {
114
+ return this.closeFile();
115
+ }
116
+ return [this.commandFor(_lepuCommands.LepuCommand.READ_FILE_DATA, (0, _le32ToBytes.le32ToBytes)(this.content.length))];
117
+ };
118
+ closedFile = () => {
119
+ this.isSessionOpen = false;
120
+ if (this.totalBytes > 0 && this.content.length !== this.totalBytes) {
121
+ return this.fail(`"${this.name}" ended at ${this.content.length} of ${this.totalBytes} bytes`);
122
+ }
123
+ if (this.totalBytes > 0) {
124
+ this.params.onFile({
125
+ name: this.name,
126
+ content: this.content
127
+ });
128
+ }
129
+ this.fileIndex++;
130
+ return this.openNextFile();
131
+ };
132
+ closeFile = () => [this.commandFor(_lepuCommands.LepuCommand.READ_FILE_END)];
133
+
134
+ /**
135
+ * Stops, and releases the device's file handle if one is open.
136
+ *
137
+ * The device holds that handle from the moment a file is opened until it is closed, so
138
+ * walking away from a failed read can leave it open until the device times out or resets.
139
+ */
140
+ fail = reason => {
141
+ this.params.onError(reason);
142
+ this.isDone = true;
143
+ if (!this.isSessionOpen) {
144
+ return undefined;
145
+ }
146
+ this.isSessionOpen = false;
147
+ return this.closeFile();
148
+ };
149
+ commandFor = (command, payload = []) => ({
150
+ ...this.params.write,
151
+ frame: this.params.builder.build(command, payload)
152
+ });
153
+ }
154
+ exports.LepuFileTransfer = LepuFileTransfer;
155
+ //# sourceMappingURL=lepu.file-transfer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_le32FromHex","require","_le32ToBytes","_lepuCommands","_lepuFileNames","_lepuFrame","_lepuResponseType","FILE_SIZE_OFFSET","MAX_FILE_BYTES","TRANSFER_COMMANDS","LepuCommand","GET_FILE_LIST","READ_FILE_START","READ_FILE_DATA","READ_FILE_END","LepuFileTransfer","files","fileIndex","name","totalBytes","content","isSessionOpen","isDone","constructor","params","initialCommands","commandFor","nextCommand","frame","command","lepuCommandOf","includes","undefined","isLepuSuccess","fail","describeLepuResponseType","lepuNamesFrom","lepuPayloadOf","openNextFile","openedFile","appendChunk","closedFile","lepuNameBytes","le32ToBytes","payload","le32FromHex","limit","maxFileBytes","closeFile","length","push","onProgress","receivedBytes","onFile","reason","onError","write","builder","build","exports"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/lepu/lepu.file-transfer.ts"],"mappings":";;;;;;AAEA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAGA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AAC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oreList":[]}
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.LepuFrameReader = void 0;
7
+ var _frameReadStatus = require("../../../types/frame-read-status.js");
8
+ var _calculateCrc = require("../../../utils/calculate-crc-8.js");
9
+ var _hexToByte = require("../../../utils/hex-to-byte.js");
10
+ var _le16FromHex = require("../../../utils/le-16-from-hex.js");
11
+ const COMMAND_INDEX = 1;
12
+ const COMMAND_COMPLEMENT_INDEX = 2;
13
+ const PAYLOAD_LENGTH_INDEX = 5;
14
+ const HEADER_BYTES = 7;
15
+ const CHECKSUM_BYTES = 1;
16
+ const BYTE_MASK = 0xff;
17
+
18
+ /** Start byte, command and its complement: the shortest run that can identify a start. */
19
+ const START_PATTERN_BYTES = 3;
20
+
21
+ /**
22
+ * Reads the frame every Lepu device shares.
23
+ *
24
+ * Layout: `start | cmd | ~cmd | type | seq | lenLow lenHigh | payload | crc8`, where the
25
+ * checksum covers every byte before it. The complement of the command byte only narrows the
26
+ * search for a start; the checksum is what actually decides a frame is trustworthy.
27
+ *
28
+ * The start byte is the only part that varies across the family. Most devices use `a5`, a
29
+ * smaller group uses `55`, and a few accept either and settle on one at runtime - so it is a
30
+ * list rather than a single value. Everything else is identical on every device speaking this
31
+ * protocol, which is why it is worth having once rather than once per device.
32
+ */
33
+ class LepuFrameReader {
34
+ constructor(startBytes) {
35
+ this.startBytes = startBytes;
36
+ }
37
+ readFrame(buffer) {
38
+ const start = this.findFrameStart(buffer);
39
+ if (start === -1) {
40
+ return {
41
+ status: _frameReadStatus.FrameReadStatus.INCOMPLETE,
42
+ consumedBytes: this.droppableLeadingBytes(buffer)
43
+ };
44
+ }
45
+ const payloadLength = (0, _le16FromHex.le16FromHex)(buffer, start + PAYLOAD_LENGTH_INDEX);
46
+ const frameLength = HEADER_BYTES + payloadLength + CHECKSUM_BYTES;
47
+ if (start + frameLength > buffer.length) {
48
+ return {
49
+ status: _frameReadStatus.FrameReadStatus.INCOMPLETE,
50
+ consumedBytes: start
51
+ };
52
+ }
53
+ const frame = buffer.slice(start, start + frameLength);
54
+ if (!this.hasValidChecksum(frame)) {
55
+ return {
56
+ status: _frameReadStatus.FrameReadStatus.CORRUPT,
57
+ consumedBytes: start + START_PATTERN_BYTES
58
+ };
59
+ }
60
+ return {
61
+ status: _frameReadStatus.FrameReadStatus.COMPLETE,
62
+ consumedBytes: start + frameLength,
63
+ frame
64
+ };
65
+ }
66
+ isFrameStart(buffer, index) {
67
+ if (!this.startBytes.includes((buffer[index] || "").toLowerCase())) {
68
+ return false;
69
+ }
70
+ const command = (0, _hexToByte.hexToByte)(buffer[index + COMMAND_INDEX] || "0");
71
+ const complement = (0, _hexToByte.hexToByte)(buffer[index + COMMAND_COMPLEMENT_INDEX] || "0");
72
+ return command === (~complement & BYTE_MASK);
73
+ }
74
+ findFrameStart(buffer) {
75
+ const lastCandidate = buffer.length - START_PATTERN_BYTES;
76
+ for (let index = 0; index <= lastCandidate; index++) {
77
+ if (this.isFrameStart(buffer, index)) {
78
+ return index;
79
+ }
80
+ }
81
+ return -1;
82
+ }
83
+
84
+ /**
85
+ * Bytes that cannot begin a frame start, and are therefore safe to drop when no start was
86
+ * found. The trailing bytes are kept because a start pattern may still be arriving.
87
+ */
88
+ droppableLeadingBytes(buffer) {
89
+ return Math.max(0, buffer.length - (START_PATTERN_BYTES - 1));
90
+ }
91
+ hasValidChecksum(frame) {
92
+ const checksummedBytes = frame.length - CHECKSUM_BYTES;
93
+ const declared = (0, _hexToByte.hexToByte)(frame[checksummedBytes] || "0");
94
+ return declared === (0, _calculateCrc.calculateCrc8)(frame, checksummedBytes);
95
+ }
96
+ }
97
+ exports.LepuFrameReader = LepuFrameReader;
98
+ //# sourceMappingURL=lepu.frame-reader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_frameReadStatus","require","_calculateCrc","_hexToByte","_le16FromHex","COMMAND_INDEX","COMMAND_COMPLEMENT_INDEX","PAYLOAD_LENGTH_INDEX","HEADER_BYTES","CHECKSUM_BYTES","BYTE_MASK","START_PATTERN_BYTES","LepuFrameReader","constructor","startBytes","readFrame","buffer","start","findFrameStart","status","FrameReadStatus","INCOMPLETE","consumedBytes","droppableLeadingBytes","payloadLength","le16FromHex","frameLength","length","frame","slice","hasValidChecksum","CORRUPT","COMPLETE","isFrameStart","index","includes","toLowerCase","command","hexToByte","complement","lastCandidate","Math","max","checksummedBytes","declared","calculateCrc8","exports"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/lepu/lepu.frame-reader.ts"],"mappings":";;;;;;AACA,IAAAA,gBAAA,GAAAC,OAAA;AAEA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAEA,MAAMI,aAAa,GAAG,CAAC;AACvB,MAAMC,wBAAwB,GAAG,CAAC;AAClC,MAAMC,oBAAoB,GAAG,CAAC;AAC9B,MAAMC,YAAY,GAAG,CAAC;AACtB,MAAMC,cAAc,GAAG,CAAC;AACxB,MAAMC,SAAS,GAAG,IAAI;;AAEtB;AACA,MAAMC,mBAAmB,GAAG,CAAC;;AAE7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,eAAe,CAAwB;EAC3CC,WAAWA,CAAkBC,UAA6B,EAAE;IAAA,KAA/BA,UAA6B,GAA7BA,UAA6B;EAAG;EAE7DC,SAASA,CAACC,MAAyB,EAAmB;IAC3D,MAAMC,KAAK,GAAG,IAAI,CAACC,cAAc,CAACF,MAAM,CAAC;IAEzC,IAAIC,KAAK,KAAK,CAAC,CAAC,EAAE;MAChB,OAAO;QACLE,MAAM,EAAEC,gCAAe,CAACC,UAAU;QAClCC,aAAa,EAAE,IAAI,CAACC,qBAAqB,CAACP,MAAM;MAClD,CAAC;IACH;IAEA,MAAMQ,aAAa,GAAG,IAAAC,wBAAW,EAACT,MAAM,EAAEC,KAAK,GA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AAG,CAAC,EAAEA,KAAK,IAAIM,aAAa,EAAEN,KAAK,EAAE,EAAE;MACnD,IAAI,IAAI,CAACD,YAAY,CAACjB,MAAM,EAAEkB,KAAK,CAAC,EAAE;QACpC,OAAOA,KAAK;MACd;IACF;IAEA,OAAO,CAAC,CAAC;EACX;;EAEA;AACF;AACA;AACA;EACUX,qBAAqBA,CAACP,MAAyB,EAAU;IAC/D,OAAOyB,IAAI,CAACC,GAAG,CAAC,CAAC,EAAE1B,MAAM,CAACW,MAAM,IAAIhB,mBAAmB,GAAG,CAAC,CAAC,CAAC;EAC/D;EAEQmB,gBAAgBA,CAACF,KAAe,EAAW;IACjD,MAAMe,gBAAgB,GAAGf,KAAK,CAACD,MAAM,GAAGlB,cAAc;IACtD,MAAMmC,QAAQ,GAAG,IAAAN,oBAAS,EAACV,KAAK,CAACe,gBAAgB,CAAC,IAAI,GAAG,CAAC;IAE1D,OAAOC,QAAQ,KAAK,IAAAC,2BAAa,EAACjB,KAAK,EAAEe,gBAAgB,CAAC;EAC5D;AACF;AAACG,OAAA,CAAAlC,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.lepuPayloadOf = exports.lepuCommandOf = void 0;
7
+ var _hexToByte = require("../../../utils/hex-to-byte.js");
8
+ var _le16FromHex = require("../../../utils/le-16-from-hex.js");
9
+ const COMMAND_INDEX = 1;
10
+ const PAYLOAD_LENGTH_INDEX = 5;
11
+ const HEADER_BYTES = 7;
12
+
13
+ /** The opcode a frame answers, which is what correlates a reply to its request. */
14
+ const lepuCommandOf = frame => (0, _hexToByte.hexToByte)(frame[COMMAND_INDEX] ?? "0");
15
+
16
+ /**
17
+ * The bytes a frame carries, from its own declared length.
18
+ *
19
+ * Declared rather than derived from what arrived: the frame reader has already checked that
20
+ * the buffer holds the whole frame, so the length field is the payload's end, and trusting
21
+ * the array instead would fold the checksum byte into the data.
22
+ */
23
+ exports.lepuCommandOf = lepuCommandOf;
24
+ const lepuPayloadOf = frame => {
25
+ const length = (0, _le16FromHex.le16FromHex)(frame, PAYLOAD_LENGTH_INDEX);
26
+ return frame.slice(HEADER_BYTES, HEADER_BYTES + length);
27
+ };
28
+ exports.lepuPayloadOf = lepuPayloadOf;
29
+ //# sourceMappingURL=lepu.frame.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_hexToByte","require","_le16FromHex","COMMAND_INDEX","PAYLOAD_LENGTH_INDEX","HEADER_BYTES","lepuCommandOf","frame","hexToByte","exports","lepuPayloadOf","length","le16FromHex","slice"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/lepu/lepu.frame.ts"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,MAAME,aAAa,GAAG,CAAC;AACvB,MAAMC,oBAAoB,GAAG,CAAC;AAC9B,MAAMC,YAAY,GAAG,CAAC;;AAEtB;AACA,MAAMC,aAAa,GAAIC,KAAwB,IAC7C,IAAAC,oBAAS,EAACD,KAAK,CAACJ,aAAa,CAAC,IAAI,GAAG,CAAC;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;AANAM,OAAA,CAAAH,aAAA,GAAAA,aAAA;AAOA,MAAMI,aAAa,GAAIH,KAAwB,IAAe;EAC5D,MAAMI,MAAM,GAAG,IAAAC,wBAAW,EAACL,KAAK,EAAEH,oBAAoB,CAAC;EAEvD,OAAOG,KAAK,CAACM,KAAK,CAACR,YAAY,EAAEA,YAAY,GAAGM,MAAM,CAAC;AACzD,CAAC;AAACF,OAAA,CAAAC,aAAA,GAAAA,aAAA","ignoreList":[]}
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.LepuIdentityGate = void 0;
7
+ var _hexToByte = require("../../../utils/hex-to-byte.js");
8
+ var _lepuCommands = require("./lepu.commands.js");
9
+ var _lepuDeviceInfo = require("./lepu.device-info.js");
10
+ var _lepuResponseType = require("./lepu.response-type.js");
11
+ const COMMAND_INDEX = 1;
12
+
13
+ /**
14
+ * Asks a Lepu device what it is before sending it anything that acts.
15
+ *
16
+ * The family shares one frame format, one checksum and one opcode space, but not one
17
+ * meaning: `0x08` polls realtime data on a BP2, starts a blood-pressure measurement on an
18
+ * AirBp and starts an ECG on a Lepod. A frame built for the wrong device is therefore
19
+ * perfectly well-formed - the CRC is computed the same way on every one of them - so
20
+ * nothing in the protocol catches a driver bound to the wrong hardware. What comes back is
21
+ * a cuff inflating on someone's arm because a name matched during a scan.
22
+ *
23
+ * `GET_INFO` is the one command that cannot cause that: it is generic, inert, and answered
24
+ * identically family-wide. So it goes first, and everything else waits on its reply.
25
+ *
26
+ * A declaration that names the models it was written for is refused permanently when the
27
+ * device answers with a different one. A declaration that names none is identified by the
28
+ * advertised name it already matched, which is the basis the vendor's own SDK binds every
29
+ * one of its products on; it is asked what it is anyway, and the answer reported, because
30
+ * that is the only place these model numbers exist - the vendor never reads the field back,
31
+ * so there is no table of them to copy.
32
+ *
33
+ * A reply that never arrives leaves the gate closed and nothing sent, which the data
34
+ * processor's stuck-data timeout reports and disconnects on. That is the watchdog for this
35
+ * too - the protocol has no retry of its own, so a dropped reply is recovered by
36
+ * reconnecting rather than by asking again.
37
+ */
38
+ class LepuIdentityGate {
39
+ isIdentified = false;
40
+ isRefused = false;
41
+ constructor(params) {
42
+ this.params = params;
43
+ }
44
+ initialCommands = () => [this.commandFor(_lepuCommands.LepuCommand.GET_INFO)];
45
+ nextCommand = frame => {
46
+ if (this.isRefused) {
47
+ return undefined;
48
+ }
49
+ if (this.isIdentified) {
50
+ return this.poll();
51
+ }
52
+ return this.admit(frame);
53
+ };
54
+
55
+ /**
56
+ * Decides on the reply to `GET_INFO`.
57
+ *
58
+ * A frame that is not that reply leaves the gate as it was rather than provoking another
59
+ * command, because the only command outstanding is the one still being waited on.
60
+ *
61
+ * A reply that is that command but carries an error type is refused rather than parsed.
62
+ * The payload of an error is the reason for it, so reading a model number out of it would
63
+ * identify the hardware from an error code.
64
+ */
65
+ admit = frame => {
66
+ if ((0, _hexToByte.hexToByte)(frame[COMMAND_INDEX] ?? "0") !== _lepuCommands.LepuCommand.GET_INFO) {
67
+ return undefined;
68
+ }
69
+ if (!(0, _lepuResponseType.isLepuSuccess)(frame)) {
70
+ return this.refuse(`the device would not say what it is: ${(0, _lepuResponseType.describeLepuResponseType)(frame)}`);
71
+ }
72
+ const info = (0, _lepuDeviceInfo.parseLepuDeviceInfo)(frame);
73
+ if (!info) {
74
+ return this.refuse("the device answered with a frame too short to hold its own model number");
75
+ }
76
+ this.params.onIdentified?.(info);
77
+ if (this.params.pollCommand === undefined) {
78
+ return undefined;
79
+ }
80
+ const isNarrowed = this.params.expectedDeviceTypes.length > 0;
81
+ if (isNarrowed && !this.params.expectedDeviceTypes.includes(info.deviceType)) {
82
+ return this.refuse(`the hardware reported model ${info.deviceType} (branch "${info.branchCode}"), which this declaration was not written for`);
83
+ }
84
+ this.isIdentified = true;
85
+ return this.poll();
86
+ };
87
+
88
+ /** Closes the gate for good. There is no state a refused device can be talked back from. */
89
+ refuse = reason => {
90
+ this.isRefused = true;
91
+ this.params.onRefused(reason);
92
+ return undefined;
93
+ };
94
+
95
+ /** Nothing, for a declaration that asks what the device is and stops there. */
96
+ poll = () => this.params.pollCommand === undefined ? undefined : [this.commandFor(this.params.pollCommand)];
97
+ commandFor = command => ({
98
+ ...this.params.write,
99
+ frame: this.params.builder.build(command)
100
+ });
101
+ }
102
+ exports.LepuIdentityGate = LepuIdentityGate;
103
+ //# sourceMappingURL=lepu.identity-gate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_hexToByte","require","_lepuCommands","_lepuDeviceInfo","_lepuResponseType","COMMAND_INDEX","LepuIdentityGate","isIdentified","isRefused","constructor","params","initialCommands","commandFor","LepuCommand","GET_INFO","nextCommand","frame","undefined","poll","admit","hexToByte","isLepuSuccess","refuse","describeLepuResponseType","info","parseLepuDeviceInfo","onIdentified","pollCommand","isNarrowed","expectedDeviceTypes","length","includes","deviceType","branchCode","reason","onRefused","command","write","builder","build","exports"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/lepu/lepu.identity-gate.ts"],"mappings":";;;;;;AAEA,IAAAA,UAAA,GAAAC,OAAA;AAGA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AAsCA,MAAMI,aAAa,GAAG,CAAC;;AAEvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,gBAAgB,CAA6B;EAChDC,YAAY,GAAG,KAAK;EACpBC,SAAS,GAAG,KAAK;EAElBC,WAAWA,CAAkBC,MAA8B,EAAE;IAAA,KAAhCA,MAA8B,GAA9BA,MAA8B;EAAG;EAE9DC,eAAe,GAAGA,CAAA,KAAgC,CACvD,IAAI,CAACC,UAAU,CAACC,yBAAW,CAACC,QAAQ,CAAC,CACtC;EAEMC,WAAW,GAChBC,KAAwB,IACiB;IACzC,IAAI,IAAI,CAACR,SAAS,EAAE;MAClB,OAAOS,SAAS;IAClB;IAEA,IAAI,IAAI,CAACV,YAAY,EAAE;MACrB,OAAO,IAAI,CAACW,IAAI,CAAC,CAAC;IACpB;IAEA,OAAO,IAAI,CAACC,KAAK,CAACH,KAAK,CAAC;EAC1B,CAAC;;EAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACUG,KAAK,GACXH,KAAwB,IACiB;IACzC,IAAI,IAAAI,oBAAS,EAACJ,KAAK,CAACX,aAAa,CAAC,IAAI,GAAG,CAAC,KAAKQ,yBAAW,CAACC,QAAQ,EAAE;MACnE,OAAOG,SAAS;IAClB;IAEA,IAAI,CAAC,IAAA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