@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
@@ -1 +1 @@
1
- {"version":3,"names":["sentryLogger","DeviceStatus","BTConnectionHandler","BTDataProcessor","BTManagedDevice","constructor","device","deviceName","onError","onErrorCallback","onDeviceStatusChanged","onDeviceStatusChangedCallback","onResult","onResultCallback","onDeviceDisconnected","onDeviceDisconnectedCallback","deviceId","id","deviceData","name","localName","manufacturerData","sn","measurementTypes","status","measurementTypeKey","error","Error","message","caseType","_","data","diagramPoints","length","undefined","destroy","connectionHandler","dataProcessor","connect","getSupportedMeasurementTypeKeys","mainServices","onStatusChanged","bind","DISCONNECTED","onDataReceived","uuid","hexValue","processData","preferredMtu","stuckDataTimeout","onStreamStart","validatePackage","parsedData","collectedValues","handleSuccessResult","onSendCommandToDevice","sendCommandToDevice","handleDependentResult","frameReader","flatMap","service","monitorUuids","parsingModel","cases","map","c","filter","type","uniqueMeasurementTypes","Set","flat"],"sourceRoot":"../../../../../../src","sources":["modules/bt-management/services/devices/bt-managed-device.ts"],"mappings":";;AAGA,SAASA,YAAY,QAAQ,yCAAsC;AAMnE,SAASC,YAAY,QAAQ,8BAA2B;AAOxD,SAASC,mBAAmB,QAAQ,4BAAyB;AAC7D,SAASC,eAAe,QAAQ,wBAAqB;AAErD,OAAO,MAAeC,eAAe,CAErC;EASE;AACF;AACA;;EAGE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;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AAU,EACVC,eACF,CAAC;QACH,CAAC,CAAC,OAAO3B,KAAK,EAAE;UACd,IAAI,CAAClB,OAAO,EAAEkC,IAAI,CAAC,IAAI,CAAC,CAAChB,KAAyB,CAAC;QACrD;MACF,CAAC;MACD6B,qBAAqB,EACnB,IAAI,CAACnB,iBAAiB,EAAEoB,mBAAmB,EAAEd,IAAI,CAAC,IAAI,CAAC;MACzDlC,OAAO,EAAE,IAAI,CAACA,OAAO,EAAEkC,IAAI,CAAC,IAAI,CAAC;MACjCe,qBAAqB,EAAE,IAAI,CAACA,qBAAqB,EAAEf,IAAI,CAAC,IAAI;IAC9D,CAAC,EACD,IAAI,CAACgB,WACP,CAAC;IAED,MAAM,IAAI,CAACtB,iBAAiB,CAACE,OAAO,CAAC,CAAC;EACxC,CAAC;EAEOC,+BAA+B,GAAGA,CAAA,KAA4B;IACpE,MAAMhB,gBAAgB,GAAG,IAAI,CAACiB,YAAY,CACvCmB,OAAO,CAAEC,OAAO,IAAK;MACpB,OAAOA,OAAO,CAACC,YAAY,CAACF,OAAO,CAChCd,IAAI,IACHA,IAAI,CAACiB,YAAY,CAACC,KAAK,CAACC,GAAG,CAAEC,CAAC,IAAKA,CAAC,CAACxC,kBAAkB,CAAC,IAAI,EAChE,CAAC;IACH,CAAC,CAAC,CACDyC,MAAM,CAAEC,IAAI,IAAKA,IAAI,KAAKjC,SAAS,CAAC;IAEvC,MAAMkC,sBAAsB,GAAG,CAAC,GAAG,IAAIC,GAAG,CAAC9C,gBAAgB,CAAC+C,IAAI,CAAC,CAAC,CAAC,CAAC;IAEpE,OAAOF,sBAAsB;EAC/B,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"names":["sentryLogger","DeviceStatus","summariseMeasurementForLog","supportedMeasurementTypeKeys","BTConnectionHandler","BTDataProcessor","pollingSequencerFor","BTManagedDevice","constructor","device","deviceName","onError","onErrorCallback","onDeviceStatusChanged","onDeviceStatusChangedCallback","onResult","onResultCallback","onDeviceDisconnected","onDeviceDisconnectedCallback","deviceId","id","deviceData","name","localName","manufacturerData","sn","measurementTypes","status","measurementTypeKey","error","Error","message","caseType","_","data","destroy","connectionHandler","dataProcessor","undefined","connect","mainServices","sequencer","createCommandSequencer","onStatusChanged","bind","DISCONNECTED","onDataReceived","uuid","hexValue","processData","initialCommands","preferredMtu","stuckDataTimeout","onStreamStart","validatePackage","parsedData","collectedValues","handleSuccessResult","nextCommand","frame","sendCommands","commands","handleDependentResult","frameReader"],"sourceRoot":"../../../../../../src","sources":["modules/bt-management/services/devices/bt-managed-device.ts"],"mappings":";;AAGA,SAASA,YAAY,QAAQ,yCAAsC;AAOnE,SAASC,YAAY,QAAQ,8BAA2B;AAMxD,SAASC,0BAA0B,QAAQ,8CAA2C;AACtF,SAASC,4BAA4B,QAAQ,gDAA6C;AAE1F,SAASC,mBAAmB,QAAQ,4BAAyB;AAC7D,SAASC,eAAe,QAAQ,wBAAqB;AACrD,SAASC,mBAAmB,QAAQ,gCAA6B;AAEjE,OAAO,MAAeC,eAAe,CAErC;EASE;AACF;AACA;;EAGE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;;EAOE;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;EAGE;AACF;AACA;AACA;AACA;AACA;AACA;;EAGE;AACF;AACA;AACA;AACA;AACA;;EAGE;AACF;AACA;AACA;AACA;AACA;;EAiBEC,WAAWA,CACOC,MAAc,EAE9B;IACEC,UAAU;IACVC,OAAO,EAAEC,eAAe;IACxBC,qBAAqB,EAAEC,6BAA6B;IACpDC,QAAQ,EAAEC,gBAAgB;IAC1BC,oBAAoB,EAAEC;EACD,CAAC,EACxB;IAAA,KATgBT,MAAc,GAAdA,MAAc;IAU9BT,YAAY,CAAC,MAAM,EAAE,sCAAsC,EAAE;MAC3DmB,QAAQ,EAAEV,MAAM,CAACW,EAAE;MACnBV,UAAU,EAAEA;IACd,CAAC,CAAC;IACF,IAAI,CAACW,UAAU,GAAG;MAChBD,EAAE,EAAEX,MAAM,CAACW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AAqB,EAAE,IAAI,CAACA,qBAAqB,EAAElB,IAAI,CAAC,IAAI;IAC9D,CAAC,EACD,IAAI,CAACmB,WACP,CAAC;IAED,MAAM,IAAI,CAAC3B,iBAAiB,CAACG,OAAO,CAAC,CAAC;EACxC,CAAC;AAEH","ignoreList":[]}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ import { LepuCommandBuilder } from "../lepu/lepu.command-builder.js";
4
+ import { LepuIdentityGate } from "../lepu/lepu.identity-gate.js";
5
+
6
+ /** Registration guarantees at least one start byte; this keeps the indexed read total. */
7
+ const DEFAULT_START_BYTE = "a5";
8
+ /**
9
+ * Builds the gate a Lepu declaration asks for.
10
+ *
11
+ * A fresh builder each time, because its sequence number is per connection: one shared
12
+ * across devices would interleave their counters, which is a defect the vendor's own global
13
+ * counter has.
14
+ *
15
+ * Frames are built with the first declared start byte. A device that accepts either still
16
+ * answers on the one it is addressed with, so the list matters for reading and its head for
17
+ * writing.
18
+ */
19
+ export const createLepuSequencer = (lepu, report) => new LepuIdentityGate({
20
+ write: {
21
+ serviceUuid: lepu.write.serviceUuid,
22
+ characteristicUuid: lepu.write.characteristicUuid
23
+ },
24
+ builder: new LepuCommandBuilder(lepu.startBytes[0] ?? DEFAULT_START_BYTE),
25
+ expectedDeviceTypes: lepu.expectedDeviceTypes,
26
+ ...(lepu.pollCommand === undefined ? {} : {
27
+ pollCommand: lepu.pollCommand
28
+ }),
29
+ onIdentified: report.onIdentified,
30
+ onRefused: report.onRefused
31
+ });
32
+ //# sourceMappingURL=custom-lepu-sequencer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["LepuCommandBuilder","LepuIdentityGate","DEFAULT_START_BYTE","createLepuSequencer","lepu","report","write","serviceUuid","characteristicUuid","builder","startBytes","expectedDeviceTypes","pollCommand","undefined","onIdentified","onRefused"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/custom/custom-lepu-sequencer.ts"],"mappings":";;AAEA,SAASA,kBAAkB,QAAQ,iCAA8B;AAEjE,SAASC,gBAAgB,QAAQ,+BAA4B;;AAE7D;AACA,MAAMC,kBAAkB,GAAG,IAAI;AAO/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,mBAAmB,GAAGA,CACjCC,IAAoB,EACpBC,MAAsB,KAEtB,IAAIJ,gBAAgB,CAAC;EACnBK,KAAK,EAAE;IACLC,WAAW,EAAEH,IAAI,CAACE,KAAK,CAACC,WAAW;IACnCC,kBAAkB,EAAEJ,IAAI,CAACE,KAAK,CAACE;EACjC,CAAC;EACDC,OAAO,EAAE,IAAIT,kBAAkB,CAACI,IAAI,CAACM,UAAU,CAAC,CAAC,CAAC,IAAIR,kBAAkB,CAAC;EACzES,mBAAmB,EAAEP,IAAI,CAACO,mBAAmB;EAC7C,IAAIP,IAAI,CAACQ,WAAW,KAAKC,SAAS,GAAG,CAAC,CAAC,GAAG;IAAED,WAAW,EAAER,IAAI,CAACQ;EAAY,CAAC,CAAC;EAC5EE,YAAY,EAAET,MAAM,CAACS,YAAY;EACjCC,SAAS,EAAEV,MAAM,CAACU;AACpB,CAAC,CAAC","ignoreList":[]}
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ import { sentryLogger } from "../../../../helpers/utils/sentry-logger.js";
3
4
  import { CaseType } from "../../../types/case-type.js";
4
5
  import { createFrameValidator } from "../../../utils/create-frame-validator.js";
5
6
  import { BTManagedDevice } from "../bt-managed-device.js";
6
- const RESERVED_KEYS = ["measurementTypeKey", "caseType"];
7
-
7
+ import { LepuFrameReader } from "../lepu/lepu.frame-reader.js";
8
+ import { createLepuSequencer } from "./custom-lepu-sequencer.js";
8
9
  /**
9
10
  * Runs a device registered with defineCustomDevice.
10
11
  *
@@ -21,10 +22,59 @@ export class CustomDevice extends BTManagedDevice {
21
22
  this.definition = definition;
22
23
  this.mainServices = definition.mainServices;
23
24
  this.stuckDataTimeout = definition.stuckDataTimeout;
25
+ if (definition.preferredMtu !== undefined) {
26
+ this.preferredMtu = definition.preferredMtu;
27
+ }
28
+ this.declareLepuProtocol(definition);
24
29
  definition.frames.forEach((frame, uuid) => {
25
30
  this.validators.set(uuid, createFrameValidator(frame));
26
31
  });
27
32
  }
33
+
34
+ /**
35
+ * Gives a Lepu declaration its frame reader and its command sequence.
36
+ *
37
+ * Both or neither: the reader finds frame edges the family's own way, and the gate is
38
+ * what decides anything may be sent at all. A declaration that had the reader without the
39
+ * gate would poll hardware it had not identified, which is the case the gate exists for.
40
+ */
41
+ declareLepuProtocol(definition) {
42
+ const lepu = definition.lepu;
43
+ if (!lepu) {
44
+ return;
45
+ }
46
+ this.frameReader = new LepuFrameReader(lepu.startBytes);
47
+ this.createCommandSequencer = () => createLepuSequencer(lepu, {
48
+ onIdentified: this.onIdentified,
49
+ onRefused: this.onIdentityRefused
50
+ });
51
+ }
52
+
53
+ /**
54
+ * Records what the device said it was.
55
+ *
56
+ * The model number is logged because it is the only place one exists: the vendor's SDK
57
+ * never reads the field back, so a declaration written without it is completed by
58
+ * connecting once and reading this line.
59
+ */
60
+ onIdentified = info => {
61
+ this.deviceData.sn = info.serialNumber;
62
+ sentryLogger("info", "BT_MANAGER: Device identified itself", {
63
+ deviceId: this.deviceData.id,
64
+ deviceName: this.deviceData.name,
65
+ deviceType: info.deviceType,
66
+ branchCode: info.branchCode,
67
+ protocolMaxLength: info.protocolMaxLength
68
+ });
69
+ };
70
+
71
+ /**
72
+ * Nothing is sent to a device that could not be identified, because the same opcode means
73
+ * different things on different models in this family.
74
+ */
75
+ onIdentityRefused = reason => {
76
+ this.onError?.(new Error(`Custom device "${this.definition.id}" was not addressed: ${reason}.`));
77
+ };
28
78
  validatePackage = (pkg, uuid) => {
29
79
  const validate = this.validators.get(String(uuid ?? "").toLowerCase());
30
80
  if (!validate) {
@@ -40,7 +90,7 @@ export class CustomDevice extends BTManagedDevice {
40
90
  */
41
91
  handleDependentResult = data => {
42
92
  try {
43
- this.report(data.parsedData);
93
+ this.report(data.parsedData, data.parsingCase);
44
94
  } catch (error) {
45
95
  this.onError?.(error);
46
96
  }
@@ -60,23 +110,40 @@ export class CustomDevice extends BTManagedDevice {
60
110
  handleSuccessResult() {
61
111
  return;
62
112
  }
63
- report(parsedData) {
64
- const measurementTypeKey = parsedData.measurementTypeKey;
65
- if (!measurementTypeKey) {
113
+
114
+ /**
115
+ * Reports every reading the frame carried.
116
+ *
117
+ * One frame is often one reading, but a multi-parameter monitor sends a heart rate, an
118
+ * oxygen saturation and a temperature together. Those are separate measurements, so they
119
+ * are reported separately rather than merged into one object whose properties came from
120
+ * different instruments.
121
+ *
122
+ * A reading that fails its checks is discarded on its own. A temperature the device could
123
+ * not take is no reason to withhold the heart rate in the same frame.
124
+ */
125
+ report(parsedData, parsingCase) {
126
+ const measurements = parsingCase.measurements ?? [];
127
+ if (measurements.length === 0) {
66
128
  this.fail("a result frame carries no measurement type", parsedData);
67
129
  return;
68
130
  }
69
- const names = Object.keys(parsedData).filter(key => !RESERVED_KEYS.includes(key));
70
- if (names.length === 0) {
71
- this.fail("a result frame decoded no properties", parsedData);
72
- return;
73
- }
74
- const rejection = names.map(name => this.reject(measurementTypeKey, name, parsedData[name])).find(message => message !== undefined);
131
+ measurements.forEach(measurement => this.reportMeasurement(parsedData, measurement));
132
+ }
133
+ reportMeasurement(parsedData, measurement) {
134
+ const reading = {
135
+ caseType: parsedData.caseType,
136
+ measurementTypeKey: measurement.measurementTypeKey
137
+ };
138
+ measurement.fieldNames.forEach(name => {
139
+ reading[name] = parsedData[name];
140
+ });
141
+ const rejection = measurement.fieldNames.map(name => this.reject(measurement.measurementTypeKey, name, reading[name])).find(message => message !== undefined);
75
142
  if (rejection) {
76
- this.fail(rejection, parsedData);
143
+ this.fail(rejection, reading);
77
144
  return;
78
145
  }
79
- this.onResult?.(parsedData);
146
+ this.onResult?.(reading);
80
147
  }
81
148
  reject(measurementTypeKey, name, value) {
82
149
  const field = this.definition.fields.get(`${measurementTypeKey}:${name}`);
@@ -1 +1 @@
1
- {"version":3,"names":["CaseType","createFrameValidator","BTManagedDevice","RESERVED_KEYS","CustomDevice","validators","Map","constructor","device","params","definition","mainServices","stuckDataTimeout","frames","forEach","frame","uuid","set","validatePackage","pkg","validate","get","String","toLowerCase","handleDependentResult","data","report","parsedData","error","onError","parsingCase","caseType","OTHER","handleSuccessResult","measurementTypeKey","fail","names","Object","keys","filter","key","includes","length","rejection","map","name","reject","find","message","undefined","onResult","value","field","fields","Number","isFinite","min","max","unit","reason","Error","id","JSON","stringify"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/custom/custom.device.ts"],"mappings":";;AAEA,SAASA,QAAQ,QAAQ,6BAA0B;AAQnD,SAASC,oBAAoB,QAAQ,0CAAuC;AAC5E,SAASC,eAAe,QAAQ,yBAAsB;AAKtD,MAAMC,aAAa,GAAG,CAAC,oBAAoB,EAAE,UAAU,CAAC;;AAExD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,YAAY,SAASF,eAAe,CAAiB;EAM/CG,UAAU,GAAG,IAAIC,GAAG,CAAqC,CAAC;EAE3EC,WAAWA,CACTC,MAAc,EACdC,MAA0C,EAC1CC,UAAkC,EAClC;IACA,KAAK,CAACF,MAAM,EAAEC,MAAM,CAAC;IAErB,IAAI,CAACC,UAAU,GAAGA,UAAU;IAC5B,IAAI,CAACC,YAAY,GAAGD,UAAU,CAACC,YAAY;IAC3C,IAAI,CAACC,gBAAgB,GAAGF,UAAU,CAACE,gBAAgB;IAEnDF,UAAU,CAACG,MAAM,CAACC,OAAO,CAAC,CAACC,KAAK,EAAEC,IAAI,KAAK;MACzC,IAAI,CAACX,UAAU,CAACY,GAAG,CAACD,IAAI,EAAEf,oBAAoB,CAACc,KAAK,CAAC,CAAC;IACxD,CAAC,CAAC;EACJ;EAEUG,eAAe,GAAGA,CAACC,GAAa,EAAEH,IAAY,KAAc;IACpE,MAAMI,QAAQ,GAAG,IAAI,CAACf,UAAU,CAACgB,G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AAO,IAAKA,OAAO,KAAKC,SAAS,CAAC;IAE3C,IAAIN,SAAS,EAAE;MACb,IAAI,CAACR,IAAI,CAACQ,SAAS,EAAEhB,UAAU,CAAC;MAEhC;IACF;IAEA,IAAI,CAACuB,QAAQ,GAAGvB,UAAU,CAAC;EAC7B;EAEQmB,MAAMA,CACZZ,kBAA0B,EAC1BW,IAAY,EACZM,KAAc,EACM;IACpB,MAAMC,KAAK,GAAG,IAAI,CAAC1C,UAAU,CAAC2C,MAAM,CAAChC,GAAG,CAAC,GAAGa,kBAAkB,IAAIW,IAAI,EAAE,CAAC;IAEzE,IAAI,CAACO,KAAK,EAAE;MACV,OAAO,YAAYP,IAAI,gCAAgCX,kBAAkB,EAAE;IAC7E;IAEA,IAAI,OAAOiB,KAAK,KAAK,QAAQ,IAAI,CAACG,MAAM,CAACC,QAAQ,CAACJ,KAAK,CAAC,EAAE;MACxD,OAAO,oBAAoBN,IAAI,sDAAsD;IACvF;IAEA,IAAIM,KAAK,GAAGC,KAAK,CAACI,GAAG,IAAIL,KAAK,GAAGC,KAAK,CAACK,GAAG,EAAE;MAC1C,OAAO,WAAWZ,IAAI,MAAMM,KAAK,IAAIC,KAAK,CAACM,IAAI,gCAAgCN,KAAK,CAACI,GAAG,IAAIJ,KAAK,CAACK,GAAG,IAAIL,KAAK,CAACM,IAAI,EAAE;IACvH;IAEA,OAAOT,SAAS;EAClB;EAEQd,IAAIA,CAACwB,MAAc,EAAEhC,UAAwB,EAAQ;IAC3D,IAAI,CAACE,OAAO,GACV,IAAI+B,KAAK,CACP,kBAAkB,IAAI,CAAClD,UAAU,CAACmD,EAAE,MAAMF,MAAM,wCAAwCG,IAAI,CAACC,SAAS,CAACpC,UAAU,CAAC,IACpH,CACF,CAAC;EACH;AACF","ignoreList":[]}
1
+ {"version":3,"names":["sentryLogger","CaseType","createFrameValidator","BTManagedDevice","LepuFrameReader","createLepuSequencer","CustomDevice","validators","Map","constructor","device","params","definition","mainServices","stuckDataTimeout","preferredMtu","undefined","declareLepuProtocol","frames","forEach","frame","uuid","set","lepu","frameReader","startBytes","createCommandSequencer","onIdentified","onRefused","onIdentityRefused","info","deviceData","sn","serialNumber","deviceId","id","deviceName","name","deviceType","branchCode","protocolMaxLength","reason","onError","Error","validatePackage","pkg","validate","get","String","toLowerCase","handleDependentResult","data","report","parsedData","parsingCase","error","caseType","OTHER","handleSuccessResult","measurements","length","fail","measurement","reportMeasurement","reading","measurementTypeKey","fieldNames","rejection","map","reject","find","message","onResult","value","field","fields","Number","isFinite","min","max","unit","JSON","stringify"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/custom/custom.device.ts"],"mappings":";;AAEA,SAASA,YAAY,QAAQ,4CAAyC;AACtE,SAASC,QAAQ,QAAQ,6BAA0B;AAUnD,SAASC,oBAAoB,QAAQ,0CAAuC;AAC5E,SAASC,eAAe,QAAQ,yBAAsB;AAEtD,SAASC,eAAe,QAAQ,8BAA2B;AAE3D,SAASC,mBAAmB,QAAQ,4BAAyB;AAK7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,YAAY,SAASH,eAAe,CAAiB;EAM/CI,UAAU,GAAG,IAAIC,GAAG,CAAqC,CAAC;EAE3EC,WAAWA,CACTC,MAAc,EACdC,MAA0C,EAC1CC,UAAkC,EAClC;IACA,KAAK,CAACF,MAAM,EAAEC,MAAM,CAAC;IAErB,IAAI,CAACC,UAAU,GAAGA,UAAU;IAC5B,IAAI,CAACC,YAAY,GAAGD,UAAU,CAACC,YAAY;IAC3C,IAAI,CAACC,gBAAgB,GAAGF,UAAU,CAACE,gBAAgB;IAEnD,IAAIF,UAAU,CAACG,YAAY,KAAKC,SAAS,EAAE;MACzC,IAAI,CAACD,YAAY,GAAGH,UAAU,CAACG,YAAY;IAC7C;IAEA,IAAI,CAACE,mBAAmB,CAACL,UAAU,CAAC;IAEpCA,UAAU,CAACM,MAAM,CAACC,OAAO,CAAC,CAACC,KAAK,EAAEC,IAAI,KA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AAQ;IAC3D,IAAI,CAACX,OAAO,GACV,IAAIC,KAAK,CACP,kBAAkB,IAAI,CAAC/B,UAAU,CAACuB,EAAE,MAAMM,MAAM,wCAAwCwC,IAAI,CAACC,SAAS,CAAC7B,UAAU,CAAC,IACpH,CACF,CAAC;EACH;AACF","ignoreList":[]}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ import { calculateCrc8 } from "../../../utils/calculate-crc-8.js";
4
+ const REQUEST_TYPE = 0x00;
5
+ const BYTE_MASK = 0xff;
6
+ const BYTE_VALUES = 0x100;
7
+
8
+ /** The sequence number wraps here, matching the vendor's own counter. */
9
+ const MAX_SEQUENCE_NUMBER = 254;
10
+ const toHex = byte => (byte & BYTE_MASK).toString(16).padStart(2, "0");
11
+
12
+ /**
13
+ * Builds the commands a Lepu device accepts.
14
+ *
15
+ * Layout: `start | cmd | ~cmd | type | seq | lenLow lenHigh | payload | crc8`, the same frame
16
+ * the device answers with. The type byte is 0x00 on a request, and the checksum covers every
17
+ * byte before it.
18
+ *
19
+ * The sequence number is write-only bookkeeping: it wraps at 254 and nothing in the response
20
+ * path reads it back, so it cannot correlate a reply to its request. Correlation is by opcode,
21
+ * and the protocol relies on at most one command being outstanding - which is the constraint
22
+ * any sequencer built on this has to respect.
23
+ *
24
+ * The counter makes a builder stateful, so each connection needs its own. One builder shared
25
+ * across devices would interleave their sequence numbers, which is a defect the vendor's own
26
+ * global counter has and this avoids by construction.
27
+ */
28
+ export class LepuCommandBuilder {
29
+ sequenceNumber = 0;
30
+ constructor(startByte = "a5") {
31
+ this.startByte = startByte;
32
+ }
33
+ build(command, payload = []) {
34
+ const header = [this.startByte, toHex(command), toHex(~command), toHex(REQUEST_TYPE), toHex(this.sequenceNumber), toHex(payload.length), toHex(Math.floor(payload.length / BYTE_VALUES))];
35
+ const frame = [...header, ...payload.map(toHex)];
36
+ this.advanceSequence();
37
+ return [...frame, toHex(calculateCrc8(frame, frame.length))];
38
+ }
39
+ advanceSequence() {
40
+ this.sequenceNumber = this.sequenceNumber >= MAX_SEQUENCE_NUMBER ? 0 : this.sequenceNumber + 1;
41
+ }
42
+ }
43
+ //# sourceMappingURL=lepu.command-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["calculateCrc8","REQUEST_TYPE","BYTE_MASK","BYTE_VALUES","MAX_SEQUENCE_NUMBER","toHex","byte","toString","padStart","LepuCommandBuilder","sequenceNumber","constructor","startByte","build","command","payload","header","length","Math","floor","frame","map","advanceSequence"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/lepu/lepu.command-builder.ts"],"mappings":";;AAAA,SAASA,aAAa,QAAQ,mCAAgC;AAE9D,MAAMC,YAAY,GAAG,IAAI;AACzB,MAAMC,SAAS,GAAG,IAAI;AACtB,MAAMC,WAAW,GAAG,KAAK;;AAEzB;AACA,MAAMC,mBAAmB,GAAG,GAAG;AAE/B,MAAMC,KAAK,GAAIC,IAAY,IACzB,CAACA,IAAI,GAAGJ,SAAS,EAAEK,QAAQ,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;;AAElD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,kBAAkB,CAAC;EACtBC,cAAc,GAAG,CAAC;EAEnBC,WAAWA,CAAkBC,SAAiB,GAAG,IAAI,EAAE;IAAA,KAA1BA,SAAiB,GAAjBA,SAAiB;EAAU;EAExDC,KAAKA,CAACC,OAAe,EAAEC,OAA0B,GAAG,EAAE,EAAY;IACvE,MAAMC,MAAM,GAAG,CACb,IAAI,CAACJ,SAAS,EACdP,KAAK,CAACS,OAAO,CAAC,EACdT,KAAK,CAAC,CAACS,OAAO,CAAC,EACfT,KAAK,CAACJ,YAAY,CAAC,EACnBI,KAAK,CAAC,IAAI,CAACK,cAAc,CAAC,EAC1BL,KAAK,CAACU,OAAO,CAACE,MAAM,CAAC,EACrBZ,KAAK,CAACa,IAAI,CAACC,KAAK,CAACJ,OAAO,CAACE,MAAM,GAAGd,WAAW,CAAC,CAAC,CAChD;IAED,MAAMiB,KAAK,GAAG,CAAC,GAAGJ,MAAM,EAAE,GAAGD,OAAO,CAACM,GAAG,CAAChB,KAAK,CAAC,CAAC;IAEhD,IAAI,CAACiB,eAAe,CAAC,CAAC;IAEtB,OAAO,CAAC,GAAGF,KAAK,EAAEf,KAAK,CAACL,aAAa,CAACoB,KAAK,EAAEA,KAAK,CAACH,MAAM,CAAC,CAAC,CAAC;EAC9D;EAEQK,eAAeA,CAAA,EAAS;IAC9B,IAAI,CAACZ,cAAc,GACjB,IAAI,CAACA,cAAc,IAAIN,mBAAmB,GAAG,CAAC,GAAG,IAAI,CAACM,cAAc,GAAG,CAAC;EAC5E;AACF","ignoreList":[]}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * The commands every Lepu device understands.
5
+ *
6
+ * These are the generic opcodes, shared across the whole family. Device-specific opcodes live
7
+ * below 0x40 and belong with their driver, because the same number means different things on
8
+ * different hardware - 0x08 polls realtime data on a BP2 and starts a measurement on others.
9
+ * That collision is why this module holds only the opcodes that are genuinely common, and why
10
+ * a driver must never assume a low opcode is safe to send to an unidentified device.
11
+ */
12
+ export const LepuCommand = {
13
+ /** Link keepalive and round-trip test. Inert. */
14
+ ECHO: 0xe0,
15
+ /**
16
+ * Device information, including the model string.
17
+ *
18
+ * Inert and identical family-wide, which makes it the one command safe to send before a
19
+ * device has been identified - and therefore the way to confirm what something is before
20
+ * addressing it with an opcode that means something else on the wrong hardware.
21
+ */
22
+ GET_INFO: 0xe1,
23
+ GET_BATTERY: 0xe4,
24
+ /** Enumerate the records stored on the device. */
25
+ GET_FILE_LIST: 0xf1,
26
+ /** Begin a read: a 20-byte payload of file name plus a 32-bit offset. */
27
+ READ_FILE_START: 0xf2,
28
+ /** Fetch the next chunk of the file being read. */
29
+ READ_FILE_DATA: 0xf3,
30
+ /** End the read and release the device's file handle. */
31
+ READ_FILE_END: 0xf4
32
+ };
33
+ //# sourceMappingURL=lepu.commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["LepuCommand","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;AACA,OAAO,MAAMA,WAAW,GAAG;EACzB;EACAC,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,79 @@
1
+ "use strict";
2
+
3
+ import { hexToByte } from "../../../utils/hex-to-byte.js";
4
+ import { le16FromHex } from "../../../utils/le-16-from-hex.js";
5
+ import { LepuCommand } from "./lepu.commands.js";
6
+ import { isLepuSuccess } from "./lepu.response-type.js";
7
+ const COMMAND_INDEX = 1;
8
+ const HEADER_BYTES = 7;
9
+
10
+ /** Offsets within the payload, per the vendor's own `Bp2DeviceInfo` layout. */
11
+ const BRANCH_CODE_OFFSET = 9;
12
+ const BRANCH_CODE_BYTES = 8;
13
+ const DEVICE_TYPE_OFFSET = 20;
14
+ const PROTOCOL_MAX_LENGTH_OFFSET = 31;
15
+ const SERIAL_LENGTH_OFFSET = 37;
16
+ const SERIAL_OFFSET = 38;
17
+
18
+ /** The vendor clamps the reported serial length, implying firmware has overstated it. */
19
+ const MAX_SERIAL_BYTES = 18;
20
+
21
+ /** Everything up to and including the serial length. Less than this is not device info. */
22
+ const MIN_PAYLOAD_BYTES = SERIAL_OFFSET;
23
+ const NUL = 0;
24
+
25
+ /**
26
+ * Reads a zero-padded ASCII field.
27
+ *
28
+ * These fields are fixed width rather than length-prefixed, so the padding is where the
29
+ * value ends. Reading the full width would append NULs to every string.
30
+ */
31
+ const asciiAt = (frame, start, length) => {
32
+ let text = "";
33
+ for (let index = start; index < start + length; index++) {
34
+ const byte = hexToByte(frame[index] ?? "0");
35
+ if (byte === NUL) {
36
+ return text;
37
+ }
38
+ text += String.fromCharCode(byte);
39
+ }
40
+ return text;
41
+ };
42
+
43
+ /** What a Lepu device says it is, in answer to `GET_INFO`. */
44
+
45
+ /**
46
+ * Reads the reply to `GET_INFO`, or nothing if the frame is not one.
47
+ *
48
+ * The command byte is checked rather than assumed, because this is the answer a driver
49
+ * decides its identity on: parsing some other frame as device info would produce a model
50
+ * number out of whatever bytes happened to sit at offset 20, and the gate would then pass
51
+ * on a coincidence.
52
+ *
53
+ * A frame too short to hold the layout is refused for the same reason, as is one whose
54
+ * response type is anything but success: an error reply carries a reason where the device
55
+ * information would be, and reading it as a model number would identify the hardware from
56
+ * an error code. The vendor's own struct is at least 56 bytes; anything shorter than the
57
+ * serial length field cannot be read without inventing the parts that are missing.
58
+ */
59
+ const parseLepuDeviceInfo = frame => {
60
+ if (hexToByte(frame[COMMAND_INDEX] ?? "0") !== LepuCommand.GET_INFO) {
61
+ return undefined;
62
+ }
63
+ if (!isLepuSuccess(frame)) {
64
+ return undefined;
65
+ }
66
+ if (frame.length < HEADER_BYTES + MIN_PAYLOAD_BYTES) {
67
+ return undefined;
68
+ }
69
+ const payload = HEADER_BYTES;
70
+ const serialLength = Math.min(hexToByte(frame[payload + SERIAL_LENGTH_OFFSET] ?? "0"), MAX_SERIAL_BYTES);
71
+ return {
72
+ deviceType: le16FromHex(frame, payload + DEVICE_TYPE_OFFSET),
73
+ protocolMaxLength: le16FromHex(frame, payload + PROTOCOL_MAX_LENGTH_OFFSET),
74
+ branchCode: asciiAt(frame, payload + BRANCH_CODE_OFFSET, BRANCH_CODE_BYTES),
75
+ serialNumber: asciiAt(frame, payload + SERIAL_OFFSET, serialLength)
76
+ };
77
+ };
78
+ export { parseLepuDeviceInfo };
79
+ //# sourceMappingURL=lepu.device-info.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["hexToByte","le16FromHex","LepuCommand","isLepuSuccess","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","String","fromCharCode","parseLepuDeviceInfo","GET_INFO","undefined","payload","serialLength","Math","min","deviceType","protocolMaxLength","branchCode","serialNumber"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/lepu/lepu.device-info.ts"],"mappings":";;AAAA,SAASA,SAAS,QAAQ,+BAA4B;AACtD,SAASC,WAAW,QAAQ,kCAA+B;AAE3D,SAASC,WAAW,QAAQ,oBAAiB;AAC7C,SAASC,aAAa,QAAQ,yBAAsB;AAEpD,MAAMC,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;AACA,MAAMC,iBAAiB,GAAGF,aAAa;AAEvC,MAAMG,GAAG,GAAG,CAAC;;AAEb;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,OAAO,GAAGA,CACdC,KAAwB,EACxBC,KAAa,EACbC,MAAc,KACH;EACX,IAAIC,IAAI,GAAG,EAAE;EAEb,KAAK,IAAIC,KAAK,GAAGH,KAAK,EAAE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,YAAY;EACpE,CAAC;AACH,CAAC;AAED,SAASJ,mBAAmB","ignoreList":[]}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * The names the Lepu/Viatom family advertises, as its own SDK matches them.
5
+ *
6
+ * Taken from the vendor's `getDeviceModel`, a 732-line cascade of substring checks that is
7
+ * the whole of how that SDK decides which product it is talking to. The order there matters,
8
+ * because 27 of these names are a prefix of another - `BP2` of `BP2A`, `BP2T`, `BP2W` and
9
+ * three more - so a check that ran in the wrong order would bind a BP2W as a BP2 and poll it
10
+ * with an opcode written for different hardware.
11
+ *
12
+ * It is that function's vocabulary, not a catalogue of everything the vendor sells: a few
13
+ * products - the ER3 and the M12 among them - are identified elsewhere in that app and never
14
+ * reach this list. `lepuNameMatch` accepts a name that is absent, and derives no exclusions
15
+ * for it, which is correct exactly when no name here extends it.
16
+ *
17
+ * They are held here as a flat vocabulary rather than an ordered cascade, because
18
+ * `lepuNameMatch` derives the exclusions from the list itself. Adding a name automatically
19
+ * narrows every name it extends, which an ordered list would leave to whoever inserted it.
20
+ */
21
+ export const 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"];
22
+ //# sourceMappingURL=lepu.device-names.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["LEPU_DEVICE_NAMES"],"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;AACA,OAAO,MAAMA,iBAAoC,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,EACX,WAAW,EACX,QAAQ,EACR,SAAS,EACT,cAAc,EACd,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,SAAS,EACT,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,UAAU,EACV,MAAM,EACN,MAAM,EACN,KAAK,EACL,OAAO,EACP,OAAO,EACP,OAAO,EACP,QAAQ,EACR,OAAO,EACP,MAAM,EACN,KAAK,EACL,OAAO,EACP,WAAW,EACX,YAAY,EACZ,WAAW,EACX,eAAe,EACf,YAAY,EACZ,OAAO,EACP,OAAO,EACP,MAAM,EACN,MAAM,EACN,MAAM,EACN,MAAM,EACN,SAAS,E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,EACT,OAAO,EACP,SAAS,EACT,OAAO,EACP,OAAO,CACR","ignoreList":[]}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ import { hexToByte } from "../../../utils/hex-to-byte.js";
4
+
5
+ /** Names are a fixed sixteen bytes, zero padded, in both the listing and the request. */
6
+ const NAME_BYTES = 16;
7
+ const BYTE_MASK = 0xff;
8
+ const NUL = 0;
9
+
10
+ /**
11
+ * A file name as the device expects it: sixteen bytes, zero padded, truncated.
12
+ *
13
+ * The truncation is the device's, not ours - it copies at most sixteen bytes and pads the
14
+ * rest - so two names that agree in their first sixteen bytes are the same file as far as
15
+ * the protocol is concerned.
16
+ */
17
+ const lepuNameBytes = name => Array.from({
18
+ length: NAME_BYTES
19
+ }, (_, index) => index < name.length ? name.charCodeAt(index) & BYTE_MASK : NUL);
20
+
21
+ /** The names in a file listing: a count, then that many fixed-width padded names. */
22
+ const lepuNamesFrom = payload => {
23
+ const count = hexToByte(payload[0] ?? "0");
24
+ return Array.from({
25
+ length: count
26
+ }, (_, index) => {
27
+ const start = 1 + index * NAME_BYTES;
28
+ return payload.slice(start, start + NAME_BYTES).map(byte => hexToByte(byte)).filter(byte => byte !== NUL).map(byte => String.fromCharCode(byte)).join("").trim();
29
+ }).filter(name => name.length > 0);
30
+ };
31
+ export { lepuNameBytes, lepuNamesFrom, NAME_BYTES };
32
+ //# sourceMappingURL=lepu.file-names.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["hexToByte","NAME_BYTES","BYTE_MASK","NUL","lepuNameBytes","name","Array","from","length","_","index","charCodeAt","lepuNamesFrom","payload","count","start","slice","map","byte","filter","String","fromCharCode","join","trim"],"sourceRoot":"../../../../../../../src","sources":["modules/bt-management/services/devices/lepu/lepu.file-names.ts"],"mappings":";;AAAA,SAASA,SAAS,QAAQ,+BAA4B;;AAEtD;AACA,MAAMC,UAAU,GAAG,EAAE;AACrB,MAAMC,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,EAAEP;AAAW,CAAC,EAAE,CAACQ,CAAC,EAAEC,KAAK,KAC1CA,KAAK,GAAGL,IAAI,CAACG,MAAM,GAAGH,IAAI,CAACM,UAAU,CAACD,KAAK,CAAC,GAAGR,SAAS,GAAGC,GAC7D,CAAC;;AAEH;AACA,MAAMS,aAAa,GAAIC,OAA0B,IAAe;EAC9D,MAAMC,KAAK,GAAGd,SAAS,CAACa,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,MAAMK,KAAK,GAAG,CAAC,GAAGL,KAAK,GAAGT,UAAU;IAEpC,OAAOY,OAAO,CACXG,KAAK,CAACD,KAAK,EAAEA,KAAK,GAAGd,UAAU,CAAC,CAChCgB,GAAG,CAAEC,IAAI,IAAKlB,SAAS,CAACkB,IAAI,CAAC,CAAC,CAC9BC,MAAM,CAAED,IAAI,IAAKA,IAAI,KAAKf,GAAG,CAAC,CAC9Bc,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,CAAEd,IAAI,IAAKA,IAAI,CAACG,MAAM,GAAG,CAAC,CAAC;AACtC,CAAC;AAED,SAASJ,aAAa,EAAEQ,aAAa,EAAEX,UAAU","ignoreList":[]}
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+
3
+ import { le32FromHex } from "../../../utils/le-32-from-hex.js";
4
+ import { le32ToBytes } from "../../../utils/le-32-to-bytes.js";
5
+ import { LepuCommand } from "./lepu.commands.js";
6
+ import { lepuNameBytes, lepuNamesFrom } from "./lepu.file-names.js";
7
+ import { lepuCommandOf, lepuPayloadOf } from "./lepu.frame.js";
8
+ import { describeLepuResponseType, isLepuSuccess } from "./lepu.response-type.js";
9
+ const FILE_SIZE_OFFSET = 0;
10
+
11
+ /**
12
+ * A hex-byte array costs far more memory than the file it describes, so the cap sits well
13
+ * below what a device could offer. A stored ECG is tens of kilobytes; a length near this one
14
+ * is a length to refuse rather than try to hold on a low-memory tablet.
15
+ */
16
+ const MAX_FILE_BYTES = 262_144;
17
+ const TRANSFER_COMMANDS = [LepuCommand.GET_FILE_LIST, LepuCommand.READ_FILE_START, LepuCommand.READ_FILE_DATA, LepuCommand.READ_FILE_END];
18
+ /**
19
+ * Downloads the records a Lepu device has stored.
20
+ *
21
+ * Every opcode this uses is generic and inert - list, open, read, close - so unlike a
22
+ * realtime poll it is safe on hardware whose model is not known. That is what makes it the
23
+ * one thing the whole family can be asked for without identifying it first.
24
+ *
25
+ * The exchange is self-clocking and has no windowing: each reply decides the next request,
26
+ * and the device chooses how much to send, so the offset advances by what actually arrived
27
+ * rather than by an assumed chunk size. There is no retry in the protocol either - a single
28
+ * dropped reply stalls the transfer with nothing to resume it - which is what the data
29
+ * processor's stuck-data timeout is the watchdog for.
30
+ *
31
+ * A short read is an error, not a truncated success: the device is asked to close the file
32
+ * and the reading is discarded, because half an ECG that looks like a whole one is worse
33
+ * than none.
34
+ */
35
+ export class LepuFileTransfer {
36
+ files = [];
37
+ fileIndex = 0;
38
+ name = "";
39
+ totalBytes = 0;
40
+ content = [];
41
+ isSessionOpen = false;
42
+ isDone = false;
43
+ constructor(params) {
44
+ this.params = params;
45
+ }
46
+ initialCommands = () => [this.commandFor(LepuCommand.GET_FILE_LIST)];
47
+ nextCommand = frame => {
48
+ const command = lepuCommandOf(frame);
49
+ if (this.isDone || !TRANSFER_COMMANDS.includes(command)) {
50
+ return undefined;
51
+ }
52
+ if (!isLepuSuccess(frame)) {
53
+ return this.fail(`the device refused it: ${describeLepuResponseType(frame)}`);
54
+ }
55
+ if (command === LepuCommand.GET_FILE_LIST) {
56
+ this.files = lepuNamesFrom(lepuPayloadOf(frame));
57
+ this.fileIndex = 0;
58
+ return this.openNextFile();
59
+ }
60
+ if (command === LepuCommand.READ_FILE_START) {
61
+ return this.openedFile(lepuPayloadOf(frame));
62
+ }
63
+ if (command === LepuCommand.READ_FILE_DATA) {
64
+ return this.appendChunk(lepuPayloadOf(frame));
65
+ }
66
+ return this.closedFile();
67
+ };
68
+ openNextFile = () => {
69
+ const name = this.files[this.fileIndex];
70
+ if (name === undefined) {
71
+ this.isDone = true;
72
+ return undefined;
73
+ }
74
+ this.name = name;
75
+ this.totalBytes = 0;
76
+ this.content = [];
77
+ return [this.commandFor(LepuCommand.READ_FILE_START, [...lepuNameBytes(name), ...le32ToBytes(0)])];
78
+ };
79
+
80
+ /** The reply to opening a file states its whole length, which bounds everything after. */
81
+ openedFile = payload => {
82
+ this.isSessionOpen = true;
83
+ this.totalBytes = le32FromHex([...payload], FILE_SIZE_OFFSET);
84
+ const limit = this.params.maxFileBytes ?? MAX_FILE_BYTES;
85
+ if (this.totalBytes > limit) {
86
+ return this.fail(`"${this.name}" is ${this.totalBytes} bytes, more than the ${limit} this transfer will hold`);
87
+ }
88
+ if (this.totalBytes === 0) {
89
+ return this.closeFile();
90
+ }
91
+ return [this.commandFor(LepuCommand.READ_FILE_DATA, le32ToBytes(0))];
92
+ };
93
+
94
+ /**
95
+ * A reply with no bytes in it ends the transfer rather than asking again from the same
96
+ * offset, which is a request the device would answer the same way for as long as the link
97
+ * stayed up.
98
+ */
99
+ appendChunk = payload => {
100
+ if (payload.length === 0) {
101
+ return this.fail(`"${this.name}" stopped sending at ${this.content.length} of ${this.totalBytes} bytes`);
102
+ }
103
+ this.content.push(...payload);
104
+ this.params.onProgress?.({
105
+ name: this.name,
106
+ receivedBytes: this.content.length,
107
+ totalBytes: this.totalBytes
108
+ });
109
+ if (this.content.length >= this.totalBytes) {
110
+ return this.closeFile();
111
+ }
112
+ return [this.commandFor(LepuCommand.READ_FILE_DATA, le32ToBytes(this.content.length))];
113
+ };
114
+ closedFile = () => {
115
+ this.isSessionOpen = false;
116
+ if (this.totalBytes > 0 && this.content.length !== this.totalBytes) {
117
+ return this.fail(`"${this.name}" ended at ${this.content.length} of ${this.totalBytes} bytes`);
118
+ }
119
+ if (this.totalBytes > 0) {
120
+ this.params.onFile({
121
+ name: this.name,
122
+ content: this.content
123
+ });
124
+ }
125
+ this.fileIndex++;
126
+ return this.openNextFile();
127
+ };
128
+ closeFile = () => [this.commandFor(LepuCommand.READ_FILE_END)];
129
+
130
+ /**
131
+ * Stops, and releases the device's file handle if one is open.
132
+ *
133
+ * The device holds that handle from the moment a file is opened until it is closed, so
134
+ * walking away from a failed read can leave it open until the device times out or resets.
135
+ */
136
+ fail = reason => {
137
+ this.params.onError(reason);
138
+ this.isDone = true;
139
+ if (!this.isSessionOpen) {
140
+ return undefined;
141
+ }
142
+ this.isSessionOpen = false;
143
+ return this.closeFile();
144
+ };
145
+ commandFor = (command, payload = []) => ({
146
+ ...this.params.write,
147
+ frame: this.params.builder.build(command, payload)
148
+ });
149
+ }
150
+ //# sourceMappingURL=lepu.file-transfer.js.map