@ovok/native 1.17.0-dev.2211 → 1.17.0-dev.2213

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 (127) hide show
  1. package/lib/commonjs/modules/next/bluetooth/families/built-in.js +3 -2
  2. package/lib/commonjs/modules/next/bluetooth/families/built-in.js.map +1 -1
  3. package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/am5.js +32 -0
  4. package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/am5.js.map +1 -0
  5. package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/bind.js +67 -0
  6. package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/bind.js.map +1 -0
  7. package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/block-reader.js +48 -0
  8. package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/block-reader.js.map +1 -0
  9. package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/block.js +57 -0
  10. package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/block.js.map +1 -0
  11. package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/commands.js +105 -0
  12. package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/commands.js.map +1 -0
  13. package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/connection.js +27 -0
  14. package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/connection.js.map +1 -0
  15. package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/device-info.js +39 -0
  16. package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/device-info.js.map +1 -0
  17. package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/frame.js +71 -0
  18. package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/frame.js.map +1 -0
  19. package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/history.js +69 -0
  20. package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/history.js.map +1 -0
  21. package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/ihealth-band.js +17 -0
  22. package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/ihealth-band.js.map +1 -0
  23. package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/live.js +42 -0
  24. package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/live.js.map +1 -0
  25. package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/models.js +18 -0
  26. package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/models.js.map +1 -0
  27. package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/records.js +99 -0
  28. package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/records.js.map +1 -0
  29. package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/replies.js +94 -0
  30. package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/replies.js.map +1 -0
  31. package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/session.js +71 -0
  32. package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/session.js.map +1 -0
  33. package/lib/module/modules/next/bluetooth/families/built-in.js +3 -2
  34. package/lib/module/modules/next/bluetooth/families/built-in.js.map +1 -1
  35. package/lib/module/modules/next/bluetooth/families/ihealth-band/am5.js +30 -0
  36. package/lib/module/modules/next/bluetooth/families/ihealth-band/am5.js.map +1 -0
  37. package/lib/module/modules/next/bluetooth/families/ihealth-band/bind.js +63 -0
  38. package/lib/module/modules/next/bluetooth/families/ihealth-band/bind.js.map +1 -0
  39. package/lib/module/modules/next/bluetooth/families/ihealth-band/block-reader.js +44 -0
  40. package/lib/module/modules/next/bluetooth/families/ihealth-band/block-reader.js.map +1 -0
  41. package/lib/module/modules/next/bluetooth/families/ihealth-band/block.js +52 -0
  42. package/lib/module/modules/next/bluetooth/families/ihealth-band/block.js.map +1 -0
  43. package/lib/module/modules/next/bluetooth/families/ihealth-band/commands.js +92 -0
  44. package/lib/module/modules/next/bluetooth/families/ihealth-band/commands.js.map +1 -0
  45. package/lib/module/modules/next/bluetooth/families/ihealth-band/connection.js +24 -0
  46. package/lib/module/modules/next/bluetooth/families/ihealth-band/connection.js.map +1 -0
  47. package/lib/module/modules/next/bluetooth/families/ihealth-band/device-info.js +33 -0
  48. package/lib/module/modules/next/bluetooth/families/ihealth-band/device-info.js.map +1 -0
  49. package/lib/module/modules/next/bluetooth/families/ihealth-band/frame.js +64 -0
  50. package/lib/module/modules/next/bluetooth/families/ihealth-band/frame.js.map +1 -0
  51. package/lib/module/modules/next/bluetooth/families/ihealth-band/history.js +67 -0
  52. package/lib/module/modules/next/bluetooth/families/ihealth-band/history.js.map +1 -0
  53. package/lib/module/modules/next/bluetooth/families/ihealth-band/ihealth-band.js +9 -0
  54. package/lib/module/modules/next/bluetooth/families/ihealth-band/ihealth-band.js.map +1 -0
  55. package/lib/module/modules/next/bluetooth/families/ihealth-band/live.js +39 -0
  56. package/lib/module/modules/next/bluetooth/families/ihealth-band/live.js.map +1 -0
  57. package/lib/module/modules/next/bluetooth/families/ihealth-band/models.js +16 -0
  58. package/lib/module/modules/next/bluetooth/families/ihealth-band/models.js.map +1 -0
  59. package/lib/module/modules/next/bluetooth/families/ihealth-band/records.js +94 -0
  60. package/lib/module/modules/next/bluetooth/families/ihealth-band/records.js.map +1 -0
  61. package/lib/module/modules/next/bluetooth/families/ihealth-band/replies.js +85 -0
  62. package/lib/module/modules/next/bluetooth/families/ihealth-band/replies.js.map +1 -0
  63. package/lib/module/modules/next/bluetooth/families/ihealth-band/session.js +68 -0
  64. package/lib/module/modules/next/bluetooth/families/ihealth-band/session.js.map +1 -0
  65. package/lib/typescript/commonjs/src/modules/next/bluetooth/families/built-in.d.ts.map +1 -1
  66. package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/am5.d.ts +6 -0
  67. package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/am5.d.ts.map +1 -0
  68. package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/bind.d.ts +6 -0
  69. package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/bind.d.ts.map +1 -0
  70. package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/block-reader.d.ts +6 -0
  71. package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/block-reader.d.ts.map +1 -0
  72. package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/block.d.ts +18 -0
  73. package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/block.d.ts.map +1 -0
  74. package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/commands.d.ts +43 -0
  75. package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/commands.d.ts.map +1 -0
  76. package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/connection.d.ts +15 -0
  77. package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/connection.d.ts.map +1 -0
  78. package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/device-info.d.ts +10 -0
  79. package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/device-info.d.ts.map +1 -0
  80. package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/frame.d.ts +31 -0
  81. package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/frame.d.ts.map +1 -0
  82. package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/history.d.ts +6 -0
  83. package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/history.d.ts.map +1 -0
  84. package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/ihealth-band.d.ts +6 -0
  85. package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/ihealth-band.d.ts.map +1 -0
  86. package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/live.d.ts +6 -0
  87. package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/live.d.ts.map +1 -0
  88. package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/models.d.ts +5 -0
  89. package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/models.d.ts.map +1 -0
  90. package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/records.d.ts +8 -0
  91. package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/records.d.ts.map +1 -0
  92. package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/replies.d.ts +29 -0
  93. package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/replies.d.ts.map +1 -0
  94. package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/session.d.ts +21 -0
  95. package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/session.d.ts.map +1 -0
  96. package/lib/typescript/module/src/modules/next/bluetooth/families/built-in.d.ts.map +1 -1
  97. package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/am5.d.ts +6 -0
  98. package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/am5.d.ts.map +1 -0
  99. package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/bind.d.ts +6 -0
  100. package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/bind.d.ts.map +1 -0
  101. package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/block-reader.d.ts +6 -0
  102. package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/block-reader.d.ts.map +1 -0
  103. package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/block.d.ts +18 -0
  104. package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/block.d.ts.map +1 -0
  105. package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/commands.d.ts +43 -0
  106. package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/commands.d.ts.map +1 -0
  107. package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/connection.d.ts +15 -0
  108. package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/connection.d.ts.map +1 -0
  109. package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/device-info.d.ts +10 -0
  110. package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/device-info.d.ts.map +1 -0
  111. package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/frame.d.ts +31 -0
  112. package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/frame.d.ts.map +1 -0
  113. package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/history.d.ts +6 -0
  114. package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/history.d.ts.map +1 -0
  115. package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/ihealth-band.d.ts +6 -0
  116. package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/ihealth-band.d.ts.map +1 -0
  117. package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/live.d.ts +6 -0
  118. package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/live.d.ts.map +1 -0
  119. package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/models.d.ts +5 -0
  120. package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/models.d.ts.map +1 -0
  121. package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/records.d.ts +8 -0
  122. package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/records.d.ts.map +1 -0
  123. package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/replies.d.ts +29 -0
  124. package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/replies.d.ts.map +1 -0
  125. package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/session.d.ts +21 -0
  126. package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/session.d.ts.map +1 -0
  127. package/package.json +1 -1
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+
3
+ import { DeviceError } from "../../core/errors.js";
4
+ import { authCommand, BIND_KEY, bindCommand } from "./commands.js";
5
+ import { readBasicInfo } from "./device-info.js";
6
+ import { COMMAND_CLASS } from "./frame.js";
7
+ import { authResultOf, bindAnswerOf } from "./replies.js";
8
+ const BIND_ACCEPTED = 0;
9
+ const ALREADY_BOUND = 2;
10
+ const AUTH_ACCEPTED = 0;
11
+ const AUTH_CODE_MAX_DIGITS = 8;
12
+ const DIGITS = /^\d+$/;
13
+
14
+ /** Accepts the answer to the command of `key`, or the band's notice that its wearer turned the pairing down. */
15
+ const isAnswerTo = key => reply => reply.commandClass === COMMAND_CLASS.bind && (reply.key === key || reply.key === BIND_KEY.rejected);
16
+ const failIfTurnedDown = reply => {
17
+ if (reply.key === BIND_KEY.rejected) {
18
+ throw new DeviceError("protocol", "The band's wearer turned the pairing down");
19
+ }
20
+ };
21
+ const digitsOf = (code, length) => {
22
+ if (code === null || code.length !== length || length > AUTH_CODE_MAX_DIGITS || !DIGITS.test(code)) {
23
+ throw new DeviceError("protocol", "The band asks for a pairing code and none was kept for it");
24
+ }
25
+ return Array.from(code, Number);
26
+ };
27
+
28
+ /** Sends the pairing code kept as the device's secret; the band shows it on its screen. */
29
+ const authenticate = async ({
30
+ request
31
+ }, secret, codeLength) => {
32
+ const reply = await request(authCommand(digitsOf(await secret.read(), codeLength)), isAnswerTo(BIND_KEY.auth));
33
+ failIfTurnedDown(reply);
34
+ if (authResultOf(reply) !== AUTH_ACCEPTED) {
35
+ throw new DeviceError("protocol", "The band did not accept the pairing code");
36
+ }
37
+ };
38
+ const bind = async (session, secret) => {
39
+ const reply = await session.bindRequest(bindCommand(), isAnswerTo(BIND_KEY.bind));
40
+ failIfTurnedDown(reply);
41
+ const {
42
+ result,
43
+ codeLength
44
+ } = bindAnswerOf(reply);
45
+ if (result === ALREADY_BOUND) {
46
+ return;
47
+ }
48
+ if (result !== BIND_ACCEPTED) {
49
+ throw new DeviceError("protocol", "The band refused the pairing");
50
+ }
51
+ if (codeLength > 0) {
52
+ await authenticate(session, secret, codeLength);
53
+ }
54
+ };
55
+
56
+ /** Binds the band to this phone unless its basic info says it is bound already. */
57
+ const bindIfUnbound = async (session, secret) => {
58
+ if (!(await readBasicInfo(session)).bound) {
59
+ await bind(session, secret);
60
+ }
61
+ };
62
+ export { bindIfUnbound };
63
+ //# sourceMappingURL=bind.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["DeviceError","authCommand","BIND_KEY","bindCommand","readBasicInfo","COMMAND_CLASS","authResultOf","bindAnswerOf","BIND_ACCEPTED","ALREADY_BOUND","AUTH_ACCEPTED","AUTH_CODE_MAX_DIGITS","DIGITS","isAnswerTo","key","reply","commandClass","bind","rejected","failIfTurnedDown","digitsOf","code","length","test","Array","from","Number","authenticate","request","secret","codeLength","read","auth","session","bindRequest","result","bindIfUnbound","bound"],"sourceRoot":"../../../../../../../src","sources":["modules/next/bluetooth/families/ihealth-band/bind.ts"],"mappings":";;AAAA,SAASA,WAAW,QAAQ,sBAAmB;AAG/C,SAASC,WAAW,EAAEC,QAAQ,EAAEC,WAAW,QAAQ,eAAY;AAC/D,SAASC,aAAa,QAAQ,kBAAe;AAC7C,SAASC,aAAa,QAAe,YAAS;AAC9C,SAASC,YAAY,EAAEC,YAAY,QAAQ,cAAW;AAGtD,MAAMC,aAAa,GAAG,CAAC;AACvB,MAAMC,aAAa,GAAG,CAAC;AACvB,MAAMC,aAAa,GAAG,CAAC;AACvB,MAAMC,oBAAoB,GAAG,CAAC;AAC9B,MAAMC,MAAM,GAAG,OAAO;;AAEtB;AACA,MAAMC,UAAU,GACbC,GAAW,IACXC,KAAY,IACXA,KAAK,CAACC,YAAY,KAAKX,aAAa,CAACY,IAAI,KAAKF,KAAK,CAACD,GAAG,KAAKA,GAAG,IAAIC,KAAK,CAACD,GAAG,KAAKZ,QAAQ,CAACgB,QAAQ,CAAC;AAEvG,MAAMC,gBAAgB,GAAIJ,KAAY,IAAW;EAC/C,IAAIA,KAAK,CAACD,GAAG,KAAKZ,QAAQ,CAACgB,QAAQ,EAAE;IACnC,MAAM,IAAIlB,WAAW,CAAC,UAAU,EAAE,2CAA2C,CAAC;EAChF;AACF,CAAC;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AAM,IAAIR,WAAW,CAAC,UAAU,EAAE,8BAA8B,CAAC;EACnE;EACA,IAAI8B,UAAU,GAAG,CAAC,EAAE;IAClB,MAAMH,YAAY,CAACM,OAAO,EAAEJ,MAAM,EAAEC,UAAU,CAAC;EACjD;AACF,CAAC;;AAED;AACA,MAAMM,aAAa,GAAG,MAAAA,CAAOH,OAAgB,EAAEJ,MAAoB,KAAoB;EACrF,IAAI,CAAC,CAAC,MAAMzB,aAAa,CAAC6B,OAAO,CAAC,EAAEI,KAAK,EAAE;IACzC,MAAMpB,IAAI,CAACgB,OAAO,EAAEJ,MAAM,CAAC;EAC7B;AACF,CAAC;AAED,SAASO,aAAa","ignoreList":[]}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ import { DeviceError } from "../../core/errors.js";
4
+ import { assembleBlock, isFirstHeader } from "./block.js";
5
+ import { blockAckCommand, blockRequestCommand, HEALTH_KEY } from "./commands.js";
6
+ import { COMMAND_CLASS, isEchoOf } from "./frame.js";
7
+ /** A block that goes this long without a packet is given up; it is the band's own guard time for one request. */
8
+ const BLOCK_QUIET_MS = 45_000;
9
+ const isFirstHeaderOf = key => reply => reply.commandClass === COMMAND_CLASS.health && reply.key === key && isFirstHeader(reply);
10
+
11
+ /** The packets of the block of `key`, from the first to the one that ends the block; packets of other keys are left out. */
12
+ const packetsOfBlock = async (packets, key) => {
13
+ const block = [];
14
+ for (;;) {
15
+ const packet = await packets.take(BLOCK_QUIET_MS);
16
+ if (packet === undefined) {
17
+ throw new DeviceError("timeout", "The band stopped sending a block");
18
+ }
19
+ if (packet instanceof DeviceError) {
20
+ throw packet;
21
+ }
22
+ if (packet.key === HEALTH_KEY.blockEnd) {
23
+ return block;
24
+ }
25
+ if (packet.key === key) {
26
+ block.push(packet);
27
+ }
28
+ }
29
+ };
30
+
31
+ /** Asks for one block, reads it to its end and acknowledges it; `null` when it names no day. */
32
+ const readBlock = async ({
33
+ request,
34
+ packets
35
+ }, key) => {
36
+ packets.clear();
37
+ await request(blockRequestCommand(key), isFirstHeaderOf(key));
38
+ const block = assembleBlock(await packetsOfBlock(packets, key));
39
+ const ack = blockAckCommand(key);
40
+ await request(ack, isEchoOf(ack));
41
+ return block;
42
+ };
43
+ export { readBlock };
44
+ //# sourceMappingURL=block-reader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["DeviceError","assembleBlock","isFirstHeader","blockAckCommand","blockRequestCommand","HEALTH_KEY","COMMAND_CLASS","isEchoOf","BLOCK_QUIET_MS","isFirstHeaderOf","key","reply","commandClass","health","packetsOfBlock","packets","block","packet","take","undefined","blockEnd","push","readBlock","request","clear","ack"],"sourceRoot":"../../../../../../../src","sources":["modules/next/bluetooth/families/ihealth-band/block-reader.ts"],"mappings":";;AAAA,SAASA,WAAW,QAAQ,sBAAmB;AAG/C,SAASC,aAAa,EAASC,aAAa,QAAQ,YAAS;AAC7D,SAASC,eAAe,EAAEC,mBAAmB,EAAEC,UAAU,QAAQ,eAAY;AAC7E,SAASC,aAAa,EAASC,QAAQ,QAAQ,YAAS;AAGxD;AACA,MAAMC,cAAc,GAAG,MAAM;AAE7B,MAAMC,eAAe,GAClBC,GAAW,IACXC,KAAY,IACXA,KAAK,CAACC,YAAY,KAAKN,aAAa,CAACO,MAAM,IAAIF,KAAK,CAACD,GAAG,KAAKA,GAAG,IAAIR,aAAa,CAACS,KAAK,CAAC;;AAE5F;AACA,MAAMG,cAAc,GAAG,MAAAA,CAAOC,OAAmC,EAAEL,GAAW,KAAuB;EACnG,MAAMM,KAAc,GAAG,EAAE;EAEzB,SAAS;IACP,MAAMC,MAAM,GAAG,MAAMF,OAAO,CAACG,IAAI,CAACV,cAAc,CAAC;IAEjD,IAAIS,MAAM,KAAKE,SAAS,EAAE;MACxB,MAAM,IAAInB,WAAW,CAAC,SAAS,EAAE,kCAAkC,CAAC;IACtE;IACA,IAAIiB,MAAM,YAAYjB,WAAW,EAAE;MACjC,MAAMiB,MAAM;IACd;IACA,IAAIA,MAAM,CAACP,GAAG,KAAKL,UAAU,CAACe,QAAQ,EAAE;MACtC,OAAOJ,KAAK;IACd;IACA,IAAIC,MAAM,CAACP,GAAG,KAAKA,GAAG,EAAE;MACtBM,KAAK,CAACK,IAAI,CAACJ,MAAM,CAAC;IACpB;EACF;AACF,CAAC;;AAED;AACA,MAAMK,SAAS,GAAG,MAAAA,CAAO;EAAEC,OAAO;EAAER;AAAiB,CAAC,EAAEL,GAAW,KAA4B;EAC7FK,OAAO,CAACS,KAAK,CAAC,CAAC;EACf,MAAMD,OAAO,CAACnB,mBAAmB,CAACM,GAAG,CAAC,EAAED,eAAe,CAACC,GAAG,CAAC,CAAC;EAE7D,MAAMM,KAAK,GAAGf,aAAa,CAAC,MAAMa,cAAc,CAACC,OAAO,EAAEL,GAAG,CAAC,CAAC;EAC/D,MAAMe,GAAG,GAAGtB,eAAe,CAACO,GAAG,CAAC;EAEhC,MAAMa,OAAO,CAACE,GAAG,EAAElB,QAAQ,CAACkB,GAAG,CAAC,CAAC;EAEjC,OAAOT,KAAK;AACd,CAAC;AAED,SAASM,SAAS","ignoreList":[]}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ import { u16le } from "../../codec/bytes.js";
4
+ import { BLOCK_PHASE } from "./commands.js";
5
+ /** The block data the band sends is kept up to this long. */
6
+ const BLOCK_DATA_LIMIT = 0x400;
7
+ const PHASE_AT = 0;
8
+ const DATA_LENGTH_AT = 1;
9
+ const DATA_AT = 2;
10
+ const HEADER_AT = {
11
+ year: 2,
12
+ month: 4,
13
+ day: 5
14
+ };
15
+ const LAST_MONTH = 12;
16
+ const LAST_DAY = 31;
17
+
18
+ /** The calendar day a block's records belong to, in the band's local time. */
19
+
20
+ /** One block: its day, and the item bytes of its data packets in the order they came. */
21
+
22
+ const isFirstHeader = ({
23
+ payload
24
+ }) => payload[PHASE_AT] === BLOCK_PHASE.first;
25
+ const isDataPacket = ({
26
+ payload
27
+ }) => payload[PHASE_AT] !== BLOCK_PHASE.first && payload[PHASE_AT] !== BLOCK_PHASE.second;
28
+ const dayOf = ({
29
+ payload
30
+ }) => {
31
+ const stored = {
32
+ year: u16le(payload, HEADER_AT.year),
33
+ month: payload[HEADER_AT.month] ?? 0,
34
+ day: payload[HEADER_AT.day] ?? 0
35
+ };
36
+ return stored.month >= 1 && stored.month <= LAST_MONTH && stored.day >= 1 && stored.day <= LAST_DAY ? stored : null;
37
+ };
38
+ const itemBytesOf = ({
39
+ payload
40
+ }) => Array.from(payload.subarray(DATA_AT, DATA_AT + (payload[DATA_LENGTH_AT] ?? 0)));
41
+
42
+ /** A block from its packets, which are all of one key and in the order they came; `null` without a first header that names a day. */
43
+ const assembleBlock = packets => {
44
+ const header = packets.find(isFirstHeader);
45
+ const day = header ? dayOf(header) : null;
46
+ return day && {
47
+ day,
48
+ data: Uint8Array.from(packets.filter(isDataPacket).flatMap(itemBytesOf).slice(0, BLOCK_DATA_LIMIT))
49
+ };
50
+ };
51
+ export { assembleBlock, isFirstHeader };
52
+ //# sourceMappingURL=block.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["u16le","BLOCK_PHASE","BLOCK_DATA_LIMIT","PHASE_AT","DATA_LENGTH_AT","DATA_AT","HEADER_AT","year","month","day","LAST_MONTH","LAST_DAY","isFirstHeader","payload","first","isDataPacket","second","dayOf","stored","itemBytesOf","Array","from","subarray","assembleBlock","packets","header","find","data","Uint8Array","filter","flatMap","slice"],"sourceRoot":"../../../../../../../src","sources":["modules/next/bluetooth/families/ihealth-band/block.ts"],"mappings":";;AAAA,SAASA,KAAK,QAAQ,sBAAmB;AAEzC,SAASC,WAAW,QAAQ,eAAY;AAGxC;AACA,MAAMC,gBAAgB,GAAG,KAAK;AAE9B,MAAMC,QAAQ,GAAG,CAAC;AAClB,MAAMC,cAAc,GAAG,CAAC;AACxB,MAAMC,OAAO,GAAG,CAAC;AAEjB,MAAMC,SAAS,GAAG;EAAEC,IAAI,EAAE,CAAC;EAAEC,KAAK,EAAE,CAAC;EAAEC,GAAG,EAAE;A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AC,GAAG,IAAI;EAEzC,OAAOhB,GAAG,IAAI;IAAEA,GAAG;IAAEkB,IAAI,EAAEC,UAAU,CAACP,IAAI,CAACG,OAAO,CAACK,MAAM,CAACd,YAAY,CAAC,CAACe,OAAO,CAACX,WAAW,CAAC,CAACY,KAAK,CAAC,CAAC,EAAE7B,gBAAgB,CAAC;EAAE,CAAC;AAC5H,CAAC;AAED,SAASqB,aAAa,EAAEX,aAAa","ignoreList":[]}
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+
3
+ import { u16leBytes } from "../../codec/bytes.js";
4
+ import { COMMAND_CLASS, command } from "./frame.js";
5
+ const BIND_KEY = {
6
+ bind: 0x01,
7
+ auth: 0x03,
8
+ rejected: 0x04
9
+ };
10
+ const READ_KEY = {
11
+ basicInfo: 0x01,
12
+ functionTable: 0x02,
13
+ liveData: 0xa0
14
+ };
15
+ const SET_TIME_KEY = 0x01;
16
+
17
+ /** Keys of the health class: the sync's own, then the block of each kind of stored day, then the end of a block. */
18
+ const HEALTH_KEY = {
19
+ start: 0x01,
20
+ stop: 0x02,
21
+ sportToday: 0x03,
22
+ sportHistory: 0x05,
23
+ heartRateToday: 0x07,
24
+ heartRateHistory: 0x08,
25
+ blockEnd: 0xee
26
+ };
27
+
28
+ /** The byte after a health key: 1 asks for a block and starts its first header, 2 ends a block and starts its second header. */
29
+ const BLOCK_PHASE = {
30
+ first: 0x01,
31
+ second: 0x02
32
+ };
33
+ const BIND_MARKER = [0xf1, 0x01];
34
+
35
+ /** What the phone says about itself when it binds, as the band's own app does. */
36
+ const BIND_PARAMETERS = {
37
+ version: 1,
38
+ osType: 2,
39
+ osVersion: 2,
40
+ cleanData: 1
41
+ };
42
+
43
+ /** What the phone says about itself when it sends the pairing code, as the band's own app does. */
44
+ const AUTH_PARAMETERS = {
45
+ osType: 1,
46
+ osVersion: 2,
47
+ cleanData: 1
48
+ };
49
+
50
+ /** The pairing code has one byte per digit, zero padded to this many. */
51
+ const AUTH_CODE_BYTES = 8;
52
+ const SYNC_MODE = 0x01;
53
+ const RESERVED = 0x00;
54
+ const FROM_THE_FIRST_ITEM = 0;
55
+ const DAYS_PER_WEEK = 7;
56
+
57
+ /** Monday is 0 and Sunday 6, as the band's own app counts. */
58
+ const weekdayOf = date => (date.getDay() + DAYS_PER_WEEK - 1) % DAYS_PER_WEEK;
59
+
60
+ /** Starts a bind; the band answers, or asks for the pairing code. */
61
+ const bindCommand = () => command(COMMAND_CLASS.bind, BIND_KEY.bind, [...BIND_MARKER, BIND_PARAMETERS.version, BIND_PARAMETERS.osType, BIND_PARAMETERS.osVersion, BIND_PARAMETERS.cleanData]);
62
+
63
+ /** Sends the pairing code the band shows, one byte per digit. */
64
+ const authCommand = digits => command(COMMAND_CLASS.bind, BIND_KEY.auth, [AUTH_PARAMETERS.osType, AUTH_PARAMETERS.osVersion, AUTH_PARAMETERS.cleanData, digits.length, ...Array.from({
65
+ length: AUTH_CODE_BYTES
66
+ }, (_, index) => digits[index] ?? 0)]);
67
+
68
+ /** Sets the band's clock to the local time of `now`. */
69
+ const setTimeCommand = now => command(COMMAND_CLASS.setting, SET_TIME_KEY, [...u16leBytes(now.getFullYear()), now.getMonth() + 1, now.getDate(), now.getHours(), now.getMinutes(), now.getSeconds(), weekdayOf(now)]);
70
+
71
+ /** Asks for the basic info: firmware, battery and whether the band is bound. */
72
+ const basicInfoCommand = () => command(COMMAND_CLASS.read, READ_KEY.basicInfo);
73
+
74
+ /** Asks for the table of features the band has. */
75
+ const functionTableCommand = () => command(COMMAND_CLASS.read, READ_KEY.functionTable);
76
+
77
+ /** Asks for the running counters. */
78
+ const liveDataCommand = () => command(COMMAND_CLASS.read, READ_KEY.liveData);
79
+
80
+ /** Starts a health sync; the band answers with how many days of each kind it holds. */
81
+ const startSyncCommand = () => command(COMMAND_CLASS.health, HEALTH_KEY.start, [SYNC_MODE, RESERVED]);
82
+
83
+ /** Ends a health sync. */
84
+ const stopSyncCommand = () => command(COMMAND_CLASS.health, HEALTH_KEY.stop, [RESERVED]);
85
+
86
+ /** Asks for one block, from its first item. */
87
+ const blockRequestCommand = key => command(COMMAND_CLASS.health, key, [BLOCK_PHASE.first, ...u16leBytes(FROM_THE_FIRST_ITEM)]);
88
+
89
+ /** Tells the band the block of `key` arrived. */
90
+ const blockAckCommand = key => command(COMMAND_CLASS.health, key, [BLOCK_PHASE.second]);
91
+ export { authCommand, basicInfoCommand, BIND_KEY, bindCommand, BLOCK_PHASE, blockAckCommand, blockRequestCommand, functionTableCommand, HEALTH_KEY, liveDataCommand, setTimeCommand, startSyncCommand, stopSyncCommand };
92
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["u16leBytes","COMMAND_CLASS","command","BIND_KEY","bind","auth","rejected","READ_KEY","basicInfo","functionTable","liveData","SET_TIME_KEY","HEALTH_KEY","start","stop","sportToday","sportHistory","heartRateToday","heartRateHistory","blockEnd","BLOCK_PHASE","first","second","BIND_MARKER","BIND_PARAMETERS","version","osType","osVersion","cleanData","AUTH_PARAMETERS","AUTH_CODE_BYTES","SYNC_MODE","RESERVED","FROM_THE_FIRST_ITEM","DAYS_PER_WEEK","weekdayOf","date","getDay","bindCommand","authCommand","digits","length","Array","from","_","index","setTimeCommand","now","setting","getFullYear","getMonth","getDate","getHours","getMinutes","getSeconds","basicInfoCommand","read","functionTableCommand","liveDataCommand","startSyncCommand","health","stopSyncCommand","blockRequestCommand","key","blockAckCommand"],"sourceRoot":"../../../../../../../src","sources":["modules/next/bluetooth/families/ihealth-band/commands.ts"],"mappings":";;AAAA,SAASA,UAAU,QAAQ,sBAAmB;AAE9C,SAASC,aAAa,EAAEC,OAAO,QAAe,YAAS;AAEvD,MAAMC,QAAQ,GAAG;EAAEC,IAAI,EAAE,IAAI;EAAEC,IAAI,EAAE,IAAI;EAAEC,QAAQ,EAAE;AAAK,CAAU;AACpE,MAAMC,QAAQ,GAAG;EAAEC,SAAS,EAAE,IAAI;EAAEC,aAAa,EAAE,IAAI;EAAEC,QAAQ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,QAAQ,CAAC,CAAC;;AAE5G;AACA,MAAM6B,eAAe,GAAGA,CAAA,KAAa3D,OAAO,CAACD,aAAa,CAAC2D,MAAM,EAAEhD,UAAU,CAACE,IAAI,EAAE,CAACkB,QAAQ,CAAC,CAAC;;AAE/F;AACA,MAAM8B,mBAAmB,GAAIC,GAAW,IACtC7D,OAAO,CAACD,aAAa,CAAC2D,MAAM,EAAEG,GAAG,EAAE,CAAC3C,WAAW,CAACC,KAAK,EAAE,GAAGrB,UAAU,CAACiC,mBAAmB,CAAC,CAAC,CAAC;;AAE7F;AACA,MAAM+B,eAAe,GAAID,GAAW,IAAY7D,OAAO,CAACD,aAAa,CAAC2D,MAAM,EAAEG,GAAG,EAAE,CAAC3C,WAAW,CAACE,MAAM,CAAC,CAAC;AAExG,SACEiB,WAAW,EACXgB,gBAAgB,EAChBpD,QAAQ,EACRmC,WAAW,EACXlB,WAAW,EACX4C,eAAe,EACfF,mBAAmB,EACnBL,oBAAoB,EACpB7C,UAAU,EACV8C,eAAe,EACfZ,cAAc,EACda,gBAAgB,EAChBE,eAAe","ignoreList":[]}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ import { bindIfUnbound } from "./bind.js";
4
+ import { openSession } from "./session.js";
5
+
6
+ /** What a protocol keeps of an open link to a band. */
7
+
8
+ /** Opens the session and binds a band that is not yet bound. */
9
+ const openBand = async context => {
10
+ const session = await openSession(context);
11
+ try {
12
+ await bindIfUnbound(session, context.secret);
13
+ } catch (error) {
14
+ session.stop();
15
+ throw error;
16
+ }
17
+ return {
18
+ ...session,
19
+ logger: context.logger,
20
+ now: context.now
21
+ };
22
+ };
23
+ export { openBand };
24
+ //# sourceMappingURL=connection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["bindIfUnbound","openSession","openBand","context","session","secret","error","stop","logger","now"],"sourceRoot":"../../../../../../../src","sources":["modules/next/bluetooth/families/ihealth-band/connection.ts"],"mappings":";;AAGA,SAASA,aAAa,QAAQ,WAAQ;AACtC,SAASC,WAAW,QAAiB,cAAW;;AAEhD;;AAUA;AACA,MAAMC,QAAQ,GAAG,MAAOC,OAAwB,IAA8B;EAC5E,MAAMC,OAAO,GAAG,MAAMH,WAAW,CAACE,OAAO,CAAC;EAE1C,IAAI;IACF,MAAMH,aAAa,CAACI,OAAO,EAAED,OAAO,CAACE,MAAM,CAAC;EAC9C,CAAC,CAAC,OAAOC,KAAK,EAAE;IACdF,OAAO,CAACG,IAAI,CAAC,CAAC;IACd,MAAMD,KAAK;EACb;EAEA,OAAO;IAAE,GAAGF,OAAO;IAAEI,MAAM,EAAEL,OAAO,CAACK,MAAM;IAAEC,GAAG,EAAEN,OAAO,CAACM;EAAI,CAAC;AACjE,CAAC;AAED,SAASP,QAAQ","ignoreList":[]}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ import { basicInfoCommand } from "./commands.js";
4
+ import { isEchoOf } from "./frame.js";
5
+ import { basicInfoOf } from "./replies.js";
6
+ /** Asks the band for its basic info. */
7
+ const readBasicInfo = async ({
8
+ request
9
+ }) => {
10
+ const asked = basicInfoCommand();
11
+ return basicInfoOf(await request(asked, isEchoOf(asked)));
12
+ };
13
+
14
+ /** The firmware number the band reports; it gives no serial, hardware, maker or model. */
15
+ const identify = async session => ({
16
+ serial: null,
17
+ firmware: String((await readBasicInfo(session)).firmware),
18
+ hardware: null,
19
+ manufacturer: null,
20
+ model: null
21
+ });
22
+ const battery = async session => {
23
+ const {
24
+ percent,
25
+ charging
26
+ } = await readBasicInfo(session);
27
+ return {
28
+ percent,
29
+ charging
30
+ };
31
+ };
32
+ export { battery, identify, readBasicInfo };
33
+ //# sourceMappingURL=device-info.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["basicInfoCommand","isEchoOf","basicInfoOf","readBasicInfo","request","asked","identify","session","serial","firmware","String","hardware","manufacturer","model","battery","percent","charging"],"sourceRoot":"../../../../../../../src","sources":["modules/next/bluetooth/families/ihealth-band/device-info.ts"],"mappings":";;AAEA,SAASA,gBAAgB,QAAQ,eAAY;AAC7C,SAASC,QAAQ,QAAQ,YAAS;AAClC,SAAoBC,WAAW,QAAQ,cAAW;AAGlD;AACA,MAAMC,aAAa,GAAG,MAAAA,CAAO;EAAEC;AAAiB,CAAC,KAAyB;EACxE,MAAMC,KAAK,GAAGL,gBAAgB,CAAC,CAAC;EAEhC,OAAOE,WAAW,CAAC,MAAME,OAAO,CAACC,KAAK,EAAEJ,QAAQ,CAACI,KAAK,CAAC,CAAC,CAAC;AAC3D,CAAC;;AAED;AACA,MAAMC,QAAQ,GAAG,MAAOC,OAAgB,KAA2C;EACjFC,MAAM,EAAE,IAAI;EACZC,QAAQ,EAAEC,MAAM,CAAC,CAAC,MAAMP,aAAa,CAACI,OAAO,CAAC,EAAEE,QAAQ,CAAC;EACzDE,QAAQ,EAAE,IAAI;EACdC,YAAY,EAAE,IAAI;EAClBC,KAAK,EAAE;AACT,CAAC,CAAC;AAEF,MAAMC,OAAO,GAAG,MAAOP,OAAgB,IAAmC;EACxE,MAAM;IAAEQ,OAAO;IAAEC;EAAS,CAAC,GAAG,MAAMb,aAAa,CAACI,OAAO,CAAC;EAE1D,OAAO;IAAEQ,OAAO;IAAEC;EAAS,CAAC;AAC9B,CAAC;AAED,SAASF,OAAO,EAAER,QAAQ,EAAEH,aAAa","ignoreList":[]}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ import { fullUuid } from "../../core/advertisement.js";
4
+ import { DeviceError } from "../../core/errors.js";
5
+
6
+ /** The service every frame travels on. */
7
+ const BAND_SERVICE = fullUuid("0AF0");
8
+ const COMMAND_CHARACTERISTIC = fullUuid("0AF6");
9
+ const HEALTH_CHARACTERISTIC = fullUuid("0AF1");
10
+
11
+ /** The characteristics the band notifies on, in the order it wants them enabled. */
12
+ const NOTIFY_CHARACTERISTICS = [fullUuid("0AF7"), fullUuid("0AF2")];
13
+ const MAX_FRAME_BYTES = 20;
14
+ const MAX_INCOMING_BYTES = 100;
15
+ const HEADER_BYTES = 2;
16
+
17
+ /** The first byte of a frame: what kind of exchange it belongs to. */
18
+ const COMMAND_CLASS = {
19
+ read: 0x02,
20
+ setting: 0x03,
21
+ bind: 0x04,
22
+ health: 0x08,
23
+ workout: 0x09
24
+ };
25
+ const OWN_CHARACTERISTIC_CLASSES = [COMMAND_CLASS.health, COMMAND_CLASS.workout];
26
+
27
+ /** One packet: its command class, its key, and the payload after them; payload offsets count from there. */
28
+
29
+ /** A frame to send, from the bytes after its key. */
30
+ const command = (commandClass, key, payload = []) => ({
31
+ commandClass,
32
+ key,
33
+ payload: Uint8Array.from(payload)
34
+ });
35
+
36
+ /** The bytes to write; fails for a frame the band would refuse as too long. */
37
+ const frameBytes = ({
38
+ commandClass,
39
+ key,
40
+ payload
41
+ }) => {
42
+ const bytes = Uint8Array.of(commandClass, key, ...payload);
43
+ if (bytes.length > MAX_FRAME_BYTES) {
44
+ throw new DeviceError("protocol", "A frame is longer than the band takes");
45
+ }
46
+ return bytes;
47
+ };
48
+
49
+ /** The frame a notification carries; `null` when it is too short or too long to be one. */
50
+ const frameOf = bytes => bytes.length < HEADER_BYTES || bytes.length > MAX_INCOMING_BYTES ? null : {
51
+ commandClass: bytes[0] ?? 0,
52
+ key: bytes[1] ?? 0,
53
+ payload: bytes.subarray(HEADER_BYTES)
54
+ };
55
+
56
+ /** Where a frame is written: health and workout data have a characteristic of their own. */
57
+ const characteristicOf = ({
58
+ commandClass
59
+ }) => OWN_CHARACTERISTIC_CLASSES.includes(commandClass) ? HEALTH_CHARACTERISTIC : COMMAND_CHARACTERISTIC;
60
+
61
+ /** Accepts the reply that echoes the class and key of `request`, which is how the band acknowledges it. */
62
+ const isEchoOf = request => reply => reply.commandClass === request.commandClass && reply.key === request.key;
63
+ export { BAND_SERVICE, characteristicOf, COMMAND_CLASS, command, frameBytes, frameOf, isEchoOf, NOTIFY_CHARACTERISTICS };
64
+ //# sourceMappingURL=frame.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["fullUuid","DeviceError","BAND_SERVICE","COMMAND_CHARACTERISTIC","HEALTH_CHARACTERISTIC","NOTIFY_CHARACTERISTICS","MAX_FRAME_BYTES","MAX_INCOMING_BYTES","HEADER_BYTES","COMMAND_CLASS","read","setting","bind","health","workout","OWN_CHARACTERISTIC_CLASSES","command","commandClass","key","payload","Uint8Array","from","frameBytes","bytes","of","length","frameOf","subarray","characteristicOf","includes","isEchoOf","request","reply"],"sourceRoot":"../../../../../../../src","sources":["modules/next/bluetooth/families/ihealth-band/frame.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,6BAA0B;AACnD,SAASC,WAAW,QAAQ,sBAAmB;;AAE/C;AACA,MAAMC,YAAY,GAAGF,QAAQ,CAAC,MAAM,CAAC;AAErC,MAAMG,sBAAsB,GAAGH,QAAQ,CAAC,MAAM,CAAC;AAC/C,MAAMI,qBAAqB,GAAGJ,QAAQ,CAAC,MAAM,CAAC;;AAE9C;AACA,MAAMK,sBAAyC,GAAG,CAACL,QAAQ,CAAC,MAAM,CAAC,EAAEA,QAAQ,CAAC,MAAM,CAAC,CAAC;AAEtF,MAAMM,eAAe,GAAG,EAAE;AAC1B,MAAMC,kBAAkB,GAAG,GAAG;AAC9B,MAAMC,YAAY,GAAG,CAAC;;AAEtB;AACA,MAAMC,aAAa,GAAG;EAAEC,IAAI,EAAE,IAAI;EAAEC,OAAO,EAAE,IAAI;EAAEC,IAAI,EAAE,IAAI;EAAEC,MAAM,EAAE,IAAI;EAAEC,OAAO,EAAE;AAAK,CAAU;AAErG,MAAMC,0BAA6C,GAAG,CAACN,aAAa,CAACI,MAAM,EAAEJ,aAAa,CAACK,OAAO,CAAC;;AAEnG;;AAOA;AACA,MAAME,OAAO,GAAGA,CAACC,YAAoB,EAAEC,GAAW,EAAEC,OAA0B,GAAG,EAAE,MAAa;EAC9FF,YAAY;EACZC,GAAG;EACHC,OAAO,EAAEC,UAAU,CAACC,IAAI,CAACF,OAAO;AAClC,CAAC,CAAC;;AAEF;AACA,MAAMG,UAAU,GAAGA,CAAC;EAAEL,YAAY;EAAEC,GAAG;EAAEC;AAAe,CAAC,KAAiB;EACxE,MAAMI,KAAK,GAAGH,UAAU,CAACI,EAAE,CAACP,YAAY,EAAEC,GAAG,EAAE,GAAGC,OAAO,CAAC;EAE1D,IAAII,KAAK,CAACE,MAAM,GAAGnB,eAAe,EAAE;IAClC,MAAM,IAAIL,WAAW,CAAC,UAAU,EAAE,uCAAuC,CAAC;EAC5E;EAEA,OAAOsB,KAAK;AACd,CAAC;;AAED;AACA,MAAMG,OAAO,GAAIH,KAAiB,IAChCA,KAAK,CAACE,MAAM,GAAGjB,YAAY,IAAIe,KAAK,CAACE,MAAM,GAAGlB,kBAAkB,GAC5D,IAAI,GACJ;EAAEU,YAAY,EAAEM,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;EAAEL,GAAG,EAAEK,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;EAAEJ,OAAO,EAAEI,KAAK,CAACI,QAAQ,CAACnB,YAAY;AAAE,CAAC;;AAEhG;AACA,MAAMoB,gBAAgB,GAAGA,CAAC;EAAEX;AAAoB,CAAC,KAC/CF,0BAA0B,CAACc,QAAQ,CAACZ,YAAY,CAAC,GAAGb,qBAAqB,GAAGD,sBAAsB;;AAEpG;AACA,MAAM2B,QAAQ,GACXC,OAAc,IACdC,KAAY,IACXA,KAAK,CAACf,YAAY,KAAKc,OAAO,CAACd,YAAY,IAAIe,KAAK,CAACd,GAAG,KAAKa,OAAO,CAACb,GAAG;AAE5E,SAAShB,YAAY,EAAE0B,gBAAgB,EAAEnB,aAAa,EAAEO,OAAO,EAAEM,UAAU,EAAEI,OAAO,EAAEI,QAAQ,EAAEzB,sBAAsB","ignoreList":[]}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ import { readBlock } from "./block-reader.js";
4
+ import { functionTableCommand, HEALTH_KEY, startSyncCommand, stopSyncCommand } from "./commands.js";
5
+ import { isEchoOf } from "./frame.js";
6
+ import { heartRateRecords, stepsRecords } from "./records.js";
7
+ import { measuresHeartRate, storedDaysOf } from "./replies.js";
8
+
9
+ /** One kind of stored day: the block for today, the block for each earlier day, and what a block of it holds. */
10
+
11
+ const SPORT = {
12
+ todayKey: HEALTH_KEY.sportToday,
13
+ historyKey: HEALTH_KEY.sportHistory,
14
+ storedDays: ({
15
+ sport
16
+ }) => sport,
17
+ recordsOf: stepsRecords
18
+ };
19
+ const HEART_RATE = {
20
+ todayKey: HEALTH_KEY.heartRateToday,
21
+ historyKey: HEALTH_KEY.heartRateHistory,
22
+ storedDays: ({
23
+ heartRate
24
+ }) => heartRate,
25
+ recordsOf: heartRateRecords
26
+ };
27
+
28
+ /** Today's block, then one history block for each earlier day the band holds. */
29
+ const blockKeysOf = (kind, days) => [kind.todayKey, ...Array(kind.storedDays(days)).fill(kind.historyKey)];
30
+
31
+ /** Sleep and blood pressure are left on the band; heart rate is read only when the band says it measures it. */
32
+ const kindsToRead = async ({
33
+ request
34
+ }) => {
35
+ const asked = functionTableCommand();
36
+ return measuresHeartRate(await request(asked, isEchoOf(asked))) ? [SPORT, HEART_RATE] : [SPORT];
37
+ };
38
+ const startSync = async ({
39
+ request
40
+ }) => {
41
+ const start = startSyncCommand();
42
+ return storedDaysOf(await request(start, isEchoOf(start)));
43
+ };
44
+ const stopSync = async ({
45
+ request,
46
+ logger
47
+ }) => {
48
+ const stop = stopSyncCommand();
49
+ await request(stop, isEchoOf(stop)).catch(() => logger.warn("ihealth-band.stop-sync.failed"));
50
+ };
51
+
52
+ /** The steps of each 15-minute slot and each heart-rate sample the band stores, as the band's blocks come. */
53
+ async function* storedRecords(connection) {
54
+ const kinds = await kindsToRead(connection);
55
+ const days = await startSync(connection);
56
+ for (const kind of kinds) {
57
+ for (const key of blockKeysOf(kind, days)) {
58
+ const block = await readBlock(connection, key);
59
+ if (block !== null) {
60
+ yield* kind.recordsOf(block, connection.now());
61
+ }
62
+ }
63
+ }
64
+ await stopSync(connection);
65
+ }
66
+ export { storedRecords };
67
+ //# sourceMappingURL=history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["readBlock","functionTableCommand","HEALTH_KEY","startSyncCommand","stopSyncCommand","isEchoOf","heartRateRecords","stepsRecords","measuresHeartRate","storedDaysOf","SPORT","todayKey","sportToday","historyKey","sportHistory","storedDays","sport","recordsOf","HEART_RATE","heartRateToday","heartRateHistory","heartRate","blockKeysOf","kind","days","Array","fill","kindsToRead","request","asked","startSync","start","stopSync","logger","stop","catch","warn","storedRecords","connection","kinds","key","block","now"],"sourceRoot":"../../../../../../../src","sources":["modules/next/bluetooth/families/ihealth-band/history.ts"],"mappings":";;AAGA,SAASA,SAAS,QAAQ,mBAAgB;AAC1C,SAASC,oBAAoB,EAAEC,UAAU,EAAEC,gBAAgB,EAAEC,eAAe,QAAQ,eAAY;AAEhG,SAASC,QAAQ,QAAQ,YAAS;AAClC,SAASC,gBAAgB,EAAEC,YAAY,QAAQ,cAAW;AAC1D,SAASC,iBAAiB,EAAcC,YAAY,QAAQ,cAAW;;AAEvE;;AAQA,MAAMC,KAAiB,GAAG;EACxBC,QAAQ,EAAET,UAAU,CAACU,UAAU;EAC/BC,UAAU,EAAEX,UAAU,CAACY,YAAY;EACnCC,UAAU,EAAEA,CAAC;IAAEC;EAAM,CAAC,KAAKA,KAAK;EAChCC,SAAS,EAAEV;AACb,CAAC;AAED,MAAMW,UAAsB,GAAG;EAC7BP,QAAQ,EAAET,UAAU,CAACiB,cAAc;EACnCN,UAAU,EAAEX,UAAU,CAACkB,gBAAgB;EACvCL,UAAU,EAAEA,CAAC;IAAEM;EAAU,CAAC,KAAKA,SAAS;EACxCJ,SAAS,EAAEX;AACb,CAAC;;AAED;AACA,MAAMgB,WAAW,GAAGA,CAACC,IAAgB,EAAEC,IAAgB,KAAe,CACpED,IAAI,CAACZ,QAAQ,EACb,GAAGc,KAAK,CAASF,IAAI,CAACR,UAAU,CAACS,IAAI,CAAC,CAAC,CAACE,IAAI,CAACH,IAAI,CAACV,UAAU,CAAC,CA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AAI,CAACN,SAAS,CAACwB,KAAK,EAAEH,UAAU,CAACI,GAAG,CAAC,CAAC,CAAC;MAChD;IACF;EACF;EAEA,MAAMV,QAAQ,CAACM,UAAU,CAAC;AAC5B;AAEA,SAASD,aAAa","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ import { AM5 } from "./am5.js";
4
+ import { IHEALTH_BAND_MODELS } from "./models.js";
5
+
6
+ /** The protocols of the iHealth fitness bands: the AM5. */
7
+ const IHEALTH_BAND_PROTOCOLS = [AM5];
8
+ export { IHEALTH_BAND_MODELS, IHEALTH_BAND_PROTOCOLS };
9
+ //# sourceMappingURL=ihealth-band.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["AM5","IHEALTH_BAND_MODELS","IHEALTH_BAND_PROTOCOLS"],"sourceRoot":"../../../../../../../src","sources":["modules/next/bluetooth/families/ihealth-band/ihealth-band.ts"],"mappings":";;AAEA,SAASA,GAAG,QAAQ,UAAO;AAC3B,SAASC,mBAAmB,QAAQ,aAAU;;AAE9C;AACA,MAAMC,sBAAiD,GAAG,CAACF,GAAG,CAAC;AAE/D,SAASC,mBAAmB,EAAEC,sBAAsB","ignoreList":[]}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ import { pause, untilAborted } from "../sig/waiting.js";
4
+ import { liveDataCommand } from "./commands.js";
5
+ import { isEchoOf } from "./frame.js";
6
+ import { liveHeartRateOf } from "./replies.js";
7
+
8
+ /** The band gives its counters when asked and sends none by itself, so the phone asks this often. */
9
+ const LIVE_POLL_MS = 1_000;
10
+ const NO_HEART_RATE = 0;
11
+ const heartRateFrame = (heartRate, at) => ({
12
+ values: {
13
+ at,
14
+ values: {
15
+ heart_rate: {
16
+ value: heartRate,
17
+ unit: "/min"
18
+ }
19
+ },
20
+ deviceFlags: []
21
+ }
22
+ });
23
+
24
+ /** Asks for the heart rate once a second until `signal` aborts; a reading of 0 is left out. */
25
+ const pollHeartRate = async ({
26
+ request,
27
+ now
28
+ }, onFrame, signal) => {
29
+ const asked = liveDataCommand();
30
+ while (!signal.aborted) {
31
+ const heartRate = liveHeartRateOf(await request(asked, isEchoOf(asked)));
32
+ if (heartRate !== NO_HEART_RATE) {
33
+ onFrame(heartRateFrame(heartRate, now()));
34
+ }
35
+ await Promise.race([pause(LIVE_POLL_MS), untilAborted(signal)]);
36
+ }
37
+ };
38
+ export { pollHeartRate };
39
+ //# sourceMappingURL=live.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["pause","untilAborted","liveDataCommand","isEchoOf","liveHeartRateOf","LIVE_POLL_MS","NO_HEART_RATE","heartRateFrame","heartRate","at","values","heart_rate","value","unit","deviceFlags","pollHeartRate","request","now","onFrame","signal","asked","aborted","Promise","race"],"sourceRoot":"../../../../../../../src","sources":["modules/next/bluetooth/families/ihealth-band/live.ts"],"mappings":";;AACA,SAASA,KAAK,EAAEC,YAAY,QAAQ,mBAAgB;AAEpD,SAASC,eAAe,QAAQ,eAAY;AAE5C,SAASC,QAAQ,QAAQ,YAAS;AAClC,SAASC,eAAe,QAAQ,cAAW;;AAE3C;AACA,MAAMC,YAAY,GAAG,KAAK;AAE1B,MAAMC,aAAa,GAAG,CAAC;AAEvB,MAAMC,cAAc,GAAGA,CAACC,SAAiB,EAAEC,EAAQ,MAAiB;EAClEC,MAAM,EAAE;IAAED,EAAE;IAAEC,MAAM,EAAE;MAAEC,UAAU,EAAE;QAAEC,KAAK,EAAEJ,SAAS;QAAEK,IAAI,EAAE;MAAO;IAAE,CAAC;IAAEC,WAAW,EAAE;EAAG;AAC5F,CAAC,CAAC;;AAEF;AACA,MAAMC,aAAa,GAAG,MAAAA,CAAO;EAAEC,OAAO;EAAEC;AAAoB,CAAC,EAAEC,OAAmC,EAAEC,MAAmB,KAAoB;EACzI,MAAMC,KAAK,GAAGlB,eAAe,CAAC,CAAC;EAE/B,OAAO,CAACiB,MAAM,CAACE,OAAO,EAAE;IACtB,MAAMb,SAAS,GAAGJ,eAAe,CAAC,MAAMY,OAAO,CAACI,KAAK,EAAEjB,QAAQ,CAACiB,KAAK,CAAC,CAAC,CAAC;IAExE,IAAIZ,SAAS,KAAKF,aAAa,EAAE;MAC/BY,OAAO,CAACX,cAAc,CAACC,SAAS,EAAES,GAAG,CAAC,CAAC,CAAC,CAAC;IAC3C;IACA,MAAMK,OAAO,CAACC,IAAI,CAAC,CAACvB,KAAK,CAACK,YAAY,CAAC,EAAEJ,YAAY,CAACkB,MAAM,CAAC,CAAC,CAAC;EACjE;AACF,CAAC;AAED,SAASJ,aAAa","ignoreList":[]}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ import { modelRows } from "../sig/model-row.js";
4
+ import { AM5 } from "./am5.js";
5
+ import { BAND_SERVICE } from "./frame.js";
6
+
7
+ /** The one band; it has no advertised name, so the service it advertises is what finds it. */
8
+ const IHEALTH_BAND_MODELS = [modelRows(AM5.id, ["activity", "blood_pressure", "heart_rate", "sleep"])("iHealth", "AM5", [], {
9
+ services: [BAND_SERVICE],
10
+ requires: [{
11
+ kind: "service",
12
+ uuid: BAND_SERVICE
13
+ }]
14
+ })];
15
+ export { IHEALTH_BAND_MODELS };
16
+ //# sourceMappingURL=models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["modelRows","AM5","BAND_SERVICE","IHEALTH_BAND_MODELS","id","services","requires","kind","uuid"],"sourceRoot":"../../../../../../../src","sources":["modules/next/bluetooth/families/ihealth-band/models.ts"],"mappings":";;AACA,SAASA,SAAS,QAAQ,qBAAkB;AAE5C,SAASC,GAAG,QAAQ,UAAO;AAC3B,SAASC,YAAY,QAAQ,YAAS;;AAEtC;AACA,MAAMC,mBAA2C,GAAG,CAClDH,SAAS,CAACC,GAAG,CAACG,EAAE,EAAE,CAAC,UAAU,EAAE,gBAAgB,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE,EAAE;EAC7FC,QAAQ,EAAE,CAACH,YAAY,CAAC;EACxBI,QAAQ,EAAE,CAAC;IAAEC,IAAI,EAAE,SAAS;IAAEC,IAAI,EAAEN;EAAa,CAAC;AACpD,CAAC,CAAC,CACH;AAED,SAASC,mBAAmB","ignoreList":[]}