@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.
- package/lib/commonjs/modules/next/bluetooth/families/built-in.js +3 -2
- package/lib/commonjs/modules/next/bluetooth/families/built-in.js.map +1 -1
- package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/am5.js +32 -0
- package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/am5.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/bind.js +67 -0
- package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/bind.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/block-reader.js +48 -0
- package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/block-reader.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/block.js +57 -0
- package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/block.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/commands.js +105 -0
- package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/commands.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/connection.js +27 -0
- package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/connection.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/device-info.js +39 -0
- package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/device-info.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/frame.js +71 -0
- package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/frame.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/history.js +69 -0
- package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/history.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/ihealth-band.js +17 -0
- package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/ihealth-band.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/live.js +42 -0
- package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/live.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/models.js +18 -0
- package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/models.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/records.js +99 -0
- package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/records.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/replies.js +94 -0
- package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/replies.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/session.js +71 -0
- package/lib/commonjs/modules/next/bluetooth/families/ihealth-band/session.js.map +1 -0
- package/lib/module/modules/next/bluetooth/families/built-in.js +3 -2
- package/lib/module/modules/next/bluetooth/families/built-in.js.map +1 -1
- package/lib/module/modules/next/bluetooth/families/ihealth-band/am5.js +30 -0
- package/lib/module/modules/next/bluetooth/families/ihealth-band/am5.js.map +1 -0
- package/lib/module/modules/next/bluetooth/families/ihealth-band/bind.js +63 -0
- package/lib/module/modules/next/bluetooth/families/ihealth-band/bind.js.map +1 -0
- package/lib/module/modules/next/bluetooth/families/ihealth-band/block-reader.js +44 -0
- package/lib/module/modules/next/bluetooth/families/ihealth-band/block-reader.js.map +1 -0
- package/lib/module/modules/next/bluetooth/families/ihealth-band/block.js +52 -0
- package/lib/module/modules/next/bluetooth/families/ihealth-band/block.js.map +1 -0
- package/lib/module/modules/next/bluetooth/families/ihealth-band/commands.js +92 -0
- package/lib/module/modules/next/bluetooth/families/ihealth-band/commands.js.map +1 -0
- package/lib/module/modules/next/bluetooth/families/ihealth-band/connection.js +24 -0
- package/lib/module/modules/next/bluetooth/families/ihealth-band/connection.js.map +1 -0
- package/lib/module/modules/next/bluetooth/families/ihealth-band/device-info.js +33 -0
- package/lib/module/modules/next/bluetooth/families/ihealth-band/device-info.js.map +1 -0
- package/lib/module/modules/next/bluetooth/families/ihealth-band/frame.js +64 -0
- package/lib/module/modules/next/bluetooth/families/ihealth-band/frame.js.map +1 -0
- package/lib/module/modules/next/bluetooth/families/ihealth-band/history.js +67 -0
- package/lib/module/modules/next/bluetooth/families/ihealth-band/history.js.map +1 -0
- package/lib/module/modules/next/bluetooth/families/ihealth-band/ihealth-band.js +9 -0
- package/lib/module/modules/next/bluetooth/families/ihealth-band/ihealth-band.js.map +1 -0
- package/lib/module/modules/next/bluetooth/families/ihealth-band/live.js +39 -0
- package/lib/module/modules/next/bluetooth/families/ihealth-band/live.js.map +1 -0
- package/lib/module/modules/next/bluetooth/families/ihealth-band/models.js +16 -0
- package/lib/module/modules/next/bluetooth/families/ihealth-band/models.js.map +1 -0
- package/lib/module/modules/next/bluetooth/families/ihealth-band/records.js +94 -0
- package/lib/module/modules/next/bluetooth/families/ihealth-band/records.js.map +1 -0
- package/lib/module/modules/next/bluetooth/families/ihealth-band/replies.js +85 -0
- package/lib/module/modules/next/bluetooth/families/ihealth-band/replies.js.map +1 -0
- package/lib/module/modules/next/bluetooth/families/ihealth-band/session.js +68 -0
- package/lib/module/modules/next/bluetooth/families/ihealth-band/session.js.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/built-in.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/am5.d.ts +6 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/am5.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/bind.d.ts +6 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/bind.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/block-reader.d.ts +6 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/block-reader.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/block.d.ts +18 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/block.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/commands.d.ts +43 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/commands.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/connection.d.ts +15 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/connection.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/device-info.d.ts +10 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/device-info.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/frame.d.ts +31 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/frame.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/history.d.ts +6 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/history.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/ihealth-band.d.ts +6 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/ihealth-band.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/live.d.ts +6 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/live.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/models.d.ts +5 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/models.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/records.d.ts +8 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/records.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/replies.d.ts +29 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/replies.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/session.d.ts +21 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/session.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/built-in.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/am5.d.ts +6 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/am5.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/bind.d.ts +6 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/bind.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/block-reader.d.ts +6 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/block-reader.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/block.d.ts +18 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/block.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/commands.d.ts +43 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/commands.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/connection.d.ts +15 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/connection.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/device-info.d.ts +10 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/device-info.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/frame.d.ts +31 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/frame.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/history.d.ts +6 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/history.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/ihealth-band.d.ts +6 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/ihealth-band.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/live.d.ts +6 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/live.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/models.d.ts +5 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/models.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/records.d.ts +8 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/records.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/replies.d.ts +29 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/replies.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/session.d.ts +21 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/ihealth-band/session.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { u16le } from "../../codec/bytes.js";
|
|
4
|
+
const MS_PER_MINUTE = 60_000;
|
|
5
|
+
|
|
6
|
+
/** Every stored sport item covers this many minutes, from local midnight of its day. */
|
|
7
|
+
const SLOT_MINUTES = 15;
|
|
8
|
+
const SPORT_ITEM_BYTES = 5;
|
|
9
|
+
const STEPS_SHIFT = 2;
|
|
10
|
+
const STEPS_MASK = 0xfff;
|
|
11
|
+
const STEPS_UNIT = "{steps}";
|
|
12
|
+
const HEART_RATE_ITEM_BYTES = 2;
|
|
13
|
+
const NO_SAMPLE_OFFSET = 255;
|
|
14
|
+
const HEART_RATE_UNIT = "/min";
|
|
15
|
+
const midnightOf = ({
|
|
16
|
+
year,
|
|
17
|
+
month,
|
|
18
|
+
day
|
|
19
|
+
}) => new Date(year, month - 1, day);
|
|
20
|
+
|
|
21
|
+
/** The same sample read again, however the phone's zone has changed, gets the same id: it names the day by its parts. */
|
|
22
|
+
const idOf = (kind, {
|
|
23
|
+
year,
|
|
24
|
+
month,
|
|
25
|
+
day
|
|
26
|
+
}, minutes, value) => [kind, year, month, day, minutes, value].join("-");
|
|
27
|
+
|
|
28
|
+
/** The steps of the item at `at`: bits 2 to 13 of its 40-bit little-endian value. */
|
|
29
|
+
const stepsAt = (data, at) => u16le(data, at) >> STEPS_SHIFT & STEPS_MASK;
|
|
30
|
+
const stepsRecord = (day, slot, steps, takenAt) => ({
|
|
31
|
+
id: idOf("steps", day, slot * SLOT_MINUTES, steps),
|
|
32
|
+
reading: {
|
|
33
|
+
type: "activity",
|
|
34
|
+
takenAt,
|
|
35
|
+
values: {
|
|
36
|
+
steps: {
|
|
37
|
+
value: steps,
|
|
38
|
+
unit: STEPS_UNIT
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
deviceFlags: []
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
/** The steps of each 15-minute slot of the day that has ended by `now` and holds steps; a slot still counting would come back under another id. */
|
|
46
|
+
const stepsRecords = ({
|
|
47
|
+
day,
|
|
48
|
+
data
|
|
49
|
+
}, now) => {
|
|
50
|
+
const midnight = midnightOf(day).getTime();
|
|
51
|
+
const slots = Array.from({
|
|
52
|
+
length: Math.floor(data.length / SPORT_ITEM_BYTES)
|
|
53
|
+
}, (_, slot) => slot);
|
|
54
|
+
return slots.flatMap(slot => {
|
|
55
|
+
const steps = stepsAt(data, slot * SPORT_ITEM_BYTES);
|
|
56
|
+
const takenAt = new Date(midnight + slot * SLOT_MINUTES * MS_PER_MINUTE);
|
|
57
|
+
const endedAt = takenAt.getTime() + SLOT_MINUTES * MS_PER_MINUTE;
|
|
58
|
+
return steps === 0 || endedAt > now.getTime() ? [] : [stepsRecord(day, slot, steps, takenAt)];
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
const heartRateRecord = (day, minutes, rate) => ({
|
|
62
|
+
id: idOf("heart-rate", day, minutes, rate),
|
|
63
|
+
reading: {
|
|
64
|
+
type: "heart_rate",
|
|
65
|
+
takenAt: new Date(day.year, day.month - 1, day.day, 0, minutes),
|
|
66
|
+
values: {
|
|
67
|
+
heart_rate: {
|
|
68
|
+
value: rate,
|
|
69
|
+
unit: HEART_RATE_UNIT
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
deviceFlags: []
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
/** The samples of a heart-rate day: each item gives the minutes since the one before, which add up from local midnight. */
|
|
77
|
+
const heartRateRecords = ({
|
|
78
|
+
day,
|
|
79
|
+
data
|
|
80
|
+
}) => {
|
|
81
|
+
const records = [];
|
|
82
|
+
let minutes = 0;
|
|
83
|
+
for (let at = 0; at + HEART_RATE_ITEM_BYTES <= data.length; at += HEART_RATE_ITEM_BYTES) {
|
|
84
|
+
const offset = data[at] ?? 0;
|
|
85
|
+
const rate = data[at + 1] ?? 0;
|
|
86
|
+
minutes += offset;
|
|
87
|
+
if (offset !== NO_SAMPLE_OFFSET && rate !== 0) {
|
|
88
|
+
records.push(heartRateRecord(day, minutes, rate));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return records;
|
|
92
|
+
};
|
|
93
|
+
export { heartRateRecords, stepsRecords };
|
|
94
|
+
//# sourceMappingURL=records.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["u16le","MS_PER_MINUTE","SLOT_MINUTES","SPORT_ITEM_BYTES","STEPS_SHIFT","STEPS_MASK","STEPS_UNIT","HEART_RATE_ITEM_BYTES","NO_SAMPLE_OFFSET","HEART_RATE_UNIT","midnightOf","year","month","day","Date","idOf","kind","minutes","value","join","stepsAt","data","at","stepsRecord","slot","steps","takenAt","id","reading","type","values","unit","deviceFlags","stepsRecords","now","midnight","getTime","slots","Array","from","length","Math","floor","_","flatMap","endedAt","heartRateRecord","rate","heart_rate","heartRateRecords","records","offset","push"],"sourceRoot":"../../../../../../../src","sources":["modules/next/bluetooth/families/ihealth-band/records.ts"],"mappings":"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","ignoreList":[]}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { DeviceError } from "../../core/errors.js";
|
|
4
|
+
/** The most days of one kind the band reports; a larger count is read as this. */
|
|
5
|
+
const MAX_STORED_DAYS = 40;
|
|
6
|
+
const FULL_CHARGE_PERCENT = 100;
|
|
7
|
+
const BOUND = 1;
|
|
8
|
+
const HEART_RATE_FLAG = 0x20;
|
|
9
|
+
const BIND_AT = {
|
|
10
|
+
result: 0,
|
|
11
|
+
codeLength: 1
|
|
12
|
+
};
|
|
13
|
+
const BASIC_INFO_AT = {
|
|
14
|
+
firmware: 2,
|
|
15
|
+
chargeState: 4,
|
|
16
|
+
percent: 5,
|
|
17
|
+
bound: 6
|
|
18
|
+
};
|
|
19
|
+
const STORED_DAYS_AT = {
|
|
20
|
+
sport: 2,
|
|
21
|
+
heartRate: 4
|
|
22
|
+
};
|
|
23
|
+
const FUNCTION_FLAGS_AT = 0;
|
|
24
|
+
const LIVE_HEART_RATE_AT = 16;
|
|
25
|
+
|
|
26
|
+
/** The states the band reports for its charge; only some say whether it is charging. */
|
|
27
|
+
const CHARGE_STATE = {
|
|
28
|
+
normal: 0,
|
|
29
|
+
charging: 1,
|
|
30
|
+
low: 3
|
|
31
|
+
};
|
|
32
|
+
const CHARGING_BY_STATE = {
|
|
33
|
+
[CHARGE_STATE.normal]: false,
|
|
34
|
+
[CHARGE_STATE.charging]: true,
|
|
35
|
+
[CHARGE_STATE.low]: false
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** The basic info reply: the firmware number, the charge, and whether the band is bound to a phone. */
|
|
39
|
+
|
|
40
|
+
/** How many days of each kind the sync reads; the band holds more kinds, which this does not read. */
|
|
41
|
+
|
|
42
|
+
const payloadOf = ({
|
|
43
|
+
payload
|
|
44
|
+
}, atLeastBytes) => {
|
|
45
|
+
if (payload.length < atLeastBytes) {
|
|
46
|
+
throw new DeviceError("protocol", "The band sent a reply that is too short");
|
|
47
|
+
}
|
|
48
|
+
return payload;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/** The bind reply: its result code, and how many digits of pairing code the band wants, none when 0. */
|
|
52
|
+
const bindAnswerOf = reply => {
|
|
53
|
+
const payload = payloadOf(reply, BIND_AT.codeLength + 1);
|
|
54
|
+
return {
|
|
55
|
+
result: payload[BIND_AT.result] ?? 0,
|
|
56
|
+
codeLength: payload[BIND_AT.codeLength] ?? 0
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/** The result code of the reply to the pairing code. */
|
|
61
|
+
const authResultOf = reply => payloadOf(reply, 1)[0] ?? 0;
|
|
62
|
+
const basicInfoOf = reply => {
|
|
63
|
+
const payload = payloadOf(reply, BASIC_INFO_AT.bound + 1);
|
|
64
|
+
return {
|
|
65
|
+
firmware: payload[BASIC_INFO_AT.firmware] ?? 0,
|
|
66
|
+
percent: Math.min(payload[BASIC_INFO_AT.percent] ?? 0, FULL_CHARGE_PERCENT),
|
|
67
|
+
charging: CHARGING_BY_STATE[payload[BASIC_INFO_AT.chargeState] ?? 0] ?? null,
|
|
68
|
+
bound: payload[BASIC_INFO_AT.bound] === BOUND
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/** Whether the band says it measures heart rate; without it the band has no heart-rate blocks. */
|
|
73
|
+
const measuresHeartRate = reply => ((payloadOf(reply, 1)[FUNCTION_FLAGS_AT] ?? 0) & HEART_RATE_FLAG) !== 0;
|
|
74
|
+
const storedDaysOf = reply => {
|
|
75
|
+
const payload = payloadOf(reply, STORED_DAYS_AT.heartRate + 1);
|
|
76
|
+
return {
|
|
77
|
+
sport: Math.min(payload[STORED_DAYS_AT.sport] ?? 0, MAX_STORED_DAYS),
|
|
78
|
+
heartRate: Math.min(payload[STORED_DAYS_AT.heartRate] ?? 0, MAX_STORED_DAYS)
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/** The heart rate of a live data reply, in beats per minute. */
|
|
83
|
+
const liveHeartRateOf = reply => payloadOf(reply, LIVE_HEART_RATE_AT + 1)[LIVE_HEART_RATE_AT] ?? 0;
|
|
84
|
+
export { authResultOf, basicInfoOf, bindAnswerOf, liveHeartRateOf, measuresHeartRate, storedDaysOf };
|
|
85
|
+
//# sourceMappingURL=replies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["DeviceError","MAX_STORED_DAYS","FULL_CHARGE_PERCENT","BOUND","HEART_RATE_FLAG","BIND_AT","result","codeLength","BASIC_INFO_AT","firmware","chargeState","percent","bound","STORED_DAYS_AT","sport","heartRate","FUNCTION_FLAGS_AT","LIVE_HEART_RATE_AT","CHARGE_STATE","normal","charging","low","CHARGING_BY_STATE","payloadOf","payload","atLeastBytes","length","bindAnswerOf","reply","authResultOf","basicInfoOf","Math","min","measuresHeartRate","storedDaysOf","liveHeartRateOf"],"sourceRoot":"../../../../../../../src","sources":["modules/next/bluetooth/families/ihealth-band/replies.ts"],"mappings":"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","ignoreList":[]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { DeviceError } from "../../core/errors.js";
|
|
4
|
+
import { Exchange } from "../../core/exchange.js";
|
|
5
|
+
import { Inbox } from "../sig/waiting.js";
|
|
6
|
+
import { BAND_SERVICE, characteristicOf, COMMAND_CLASS, frameBytes, frameOf, NOTIFY_CHARACTERISTICS } from "./frame.js";
|
|
7
|
+
|
|
8
|
+
/** A queued packet is sent again after 3 s without its echo, up to 3 more times. */
|
|
9
|
+
const REQUEST_TIMING = {
|
|
10
|
+
replyTimeoutMs: 3_000,
|
|
11
|
+
attempts: 4
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/** A bind is sent again after 5 s without a reply, up to 5 times in all. */
|
|
15
|
+
const BIND_TIMING = {
|
|
16
|
+
replyTimeoutMs: 5_000,
|
|
17
|
+
attempts: 5
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/** One open link: requests that wait for the band's reply, and the health packets the band sends on its own. */
|
|
21
|
+
|
|
22
|
+
/** Enables both notify characteristics, and routes what the band sends to whoever waits for it. */
|
|
23
|
+
const openSession = async ({
|
|
24
|
+
link
|
|
25
|
+
}) => {
|
|
26
|
+
const queued = new Exchange(REQUEST_TIMING);
|
|
27
|
+
const binding = new Exchange(BIND_TIMING);
|
|
28
|
+
const packets = new Inbox();
|
|
29
|
+
const unsubscribes = [];
|
|
30
|
+
const send = frame => link.write(BAND_SERVICE, characteristicOf(frame), frameBytes(frame));
|
|
31
|
+
const receive = bytes => {
|
|
32
|
+
const frame = frameOf(bytes);
|
|
33
|
+
if (frame === null) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
queued.receive(frame);
|
|
37
|
+
binding.receive(frame);
|
|
38
|
+
if (frame.commandClass === COMMAND_CLASS.health) {
|
|
39
|
+
packets.push(frame);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const stopWatching = link.onDisconnect(() => {
|
|
43
|
+
const dropped = new DeviceError("disconnected", "The band dropped the link");
|
|
44
|
+
queued.fail(dropped);
|
|
45
|
+
binding.fail(dropped);
|
|
46
|
+
packets.push(dropped);
|
|
47
|
+
});
|
|
48
|
+
const stop = () => {
|
|
49
|
+
unsubscribes.forEach(unsubscribe => unsubscribe());
|
|
50
|
+
stopWatching();
|
|
51
|
+
};
|
|
52
|
+
try {
|
|
53
|
+
for (const characteristic of NOTIFY_CHARACTERISTICS) {
|
|
54
|
+
unsubscribes.push(await link.subscribe(BAND_SERVICE, characteristic, receive));
|
|
55
|
+
}
|
|
56
|
+
} catch (error) {
|
|
57
|
+
stop();
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
request: (frame, accepts) => queued.request(() => send(frame), accepts),
|
|
62
|
+
bindRequest: (frame, accepts) => binding.request(() => send(frame), accepts),
|
|
63
|
+
packets,
|
|
64
|
+
stop
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
export { openSession };
|
|
68
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["DeviceError","Exchange","Inbox","BAND_SERVICE","characteristicOf","COMMAND_CLASS","frameBytes","frameOf","NOTIFY_CHARACTERISTICS","REQUEST_TIMING","replyTimeoutMs","attempts","BIND_TIMING","openSession","link","queued","binding","packets","unsubscribes","send","frame","write","receive","bytes","commandClass","health","push","stopWatching","onDisconnect","dropped","fail","stop","forEach","unsubscribe","characteristic","subscribe","error","request","accepts","bindRequest"],"sourceRoot":"../../../../../../../src","sources":["modules/next/bluetooth/families/ihealth-band/session.ts"],"mappings":";;AAAA,SAASA,WAAW,QAAQ,sBAAmB;AAC/C,SAASC,QAAQ,QAAwB,wBAAqB;AAE9D,SAASC,KAAK,QAAQ,mBAAgB;AAEtC,SAASC,YAAY,EAAEC,gBAAgB,EAAEC,aAAa,EAASC,UAAU,EAAEC,OAAO,EAAEC,sBAAsB,QAAQ,YAAS;;AAE3H;AACA,MAAMC,cAA8B,GAAG;EAAEC,cAAc,EAAE,KAAK;EAAEC,QAAQ,EAAE;AAAE,CAAC;;AAE7E;AACA,MAAMC,WAA2B,GAAG;EAAEF,cAAc,EAAE,KAAK;EAAEC,QAAQ,EAAE;AAAE,CAAC;;AAI1E;;AAgBA;AACA,MAAME,WAAW,GAAG,MAAAA,CAAO;EAAEC;AAAsB,CAAC,KAAuB;EACzE,MAAMC,MAAM,GAAG,IAAId,QAAQ,CAAQQ,cAAc,CAAC;EAClD,MAAMO,OAAO,GAAG,IAAIf,QAAQ,CAAQW,WAAW,CAAC;EAChD,MAAMK,OAAO,GAAG,IAAIf,KAAK,CAAsB,CAAC;EAChD,MAAMgB,YAA4B,GAAG,EAAE;EAEvC,MAAMC,IAAI,GAAIC,KAAY,IAAKN,IAAI,CAACO,KAAK,CAAClB,YAAY,EAAEC,gBAAgB,CAACgB,KAAK,CAAC,EAAEd,UAAU,CAACc,KAAK,CAAC,CAAC;EAEnG,MAAME,OAAO,GAAIC,KAAiB,IAAK;IACrC,MAAMH,KAAK,GAAGb,OAAO,CAACgB,KAAK,CAAC;IAE5B,IAAIH,KAAK,KAAK,IAAI,EAAE;MAClB;IACF;IACAL,MAAM,CAACO,OAAO,CAACF,KAAK,CAAC;IACrBJ,OAAO,CAACM,OAAO,CAACF,KAAK,CAAC;IACtB,IAAIA,KAAK,CAACI,YAAY,KAAKnB,aAAa,CAACoB,MAAM,EAAE;MAC/CR,OAAO,CAACS,IAAI,CAACN,KAAK,CAAC;IACrB;EACF,CAAC;EAED,MAAMO,YAAY,GAAGb,IAAI,CAACc,YAAY,CAAC,MAAM;IAC3C,MAAMC,OAAO,GAAG,IAAI7B,WAAW,CAAC,cAAc,EAAE,2BAA2B,CAAC;IAE5Ee,MAAM,CAACe,IAAI,CAACD,OAAO,CAAC;IACpBb,OAAO,CAACc,IAAI,CAACD,OAAO,CAAC;IACrBZ,OAAO,CAACS,IAAI,CAACG,OAAO,CAAC;EACvB,CAAC,CAAC;EAEF,MAAME,IAAI,GAAGA,CAAA,KAAM;IACjBb,YAAY,CAACc,OAAO,CAAEC,WAAW,IAAKA,WAAW,CAAC,CAAC,CAAC;IACpDN,YAAY,CAAC,CAAC;EAChB,CAAC;EAED,IAAI;IACF,KAAK,MAAMO,cAAc,IAAI1B,sBAAsB,EAAE;MACnDU,YAAY,CAACQ,IAAI,CAAC,MAAMZ,IAAI,CAACqB,SAAS,CAAChC,YAAY,EAAE+B,cAAc,EAAEZ,OAAO,CAAC,CAAC;IAChF;EACF,CAAC,CAAC,OAAOc,KAAK,EAAE;IACdL,IAAI,CAAC,CAAC;IACN,MAAMK,KAAK;EACb;EAEA,OAAO;IACLC,OAAO,EAAEA,CAACjB,KAAK,EAAEkB,OAAO,KAAKvB,MAAM,CAACsB,OAAO,CAAC,MAAMlB,IAAI,CAACC,KAAK,CAAC,EAAEkB,OAAO,CAAC;IACvEC,WAAW,EAAEA,CAACnB,KAAK,EAAEkB,OAAO,KAAKtB,OAAO,CAACqB,OAAO,CAAC,MAAMlB,IAAI,CAACC,KAAK,CAAC,EAAEkB,OAAO,CAAC;IAC5ErB,OAAO;IACPc;EACF,CAAC;AACH,CAAC;AAED,SAASlB,WAAW","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"built-in.d.ts","sourceRoot":"","sources":["../../../../../../../../src/modules/next/bluetooth/families/built-in.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"built-in.d.ts","sourceRoot":"","sources":["../../../../../../../../src/modules/next/bluetooth/families/built-in.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAoFlD,6FAA6F;AAC7F,QAAA,MAAM,eAAe,EAAE,SAAS,WAAW,EAiFzC,CAAC;AAEH,6CAA6C;AAC7C,QAAA,MAAM,kBAAkB,EAAE,SAAS,cAAc,EAiFhD,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DeviceProtocol } from "../../core/protocol";
|
|
2
|
+
import { BandConnection } from "./connection";
|
|
3
|
+
/** The AM5 band: identity, battery, a clock, its heart rate live, and the steps and heart rates it stores as history. */
|
|
4
|
+
declare const AM5: DeviceProtocol<BandConnection>;
|
|
5
|
+
export { AM5 };
|
|
6
|
+
//# sourceMappingURL=am5.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"am5.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/next/bluetooth/families/ihealth-band/am5.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,EAAY,cAAc,EAAE,MAAM,cAAc,CAAC;AAMxD,yHAAyH;AACzH,QAAA,MAAM,GAAG,EAAE,cAAc,CAAC,cAAc,CAcvC,CAAC;AAEF,OAAO,EAAE,GAAG,EAAE,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DeviceSecret } from "../../core/protocol";
|
|
2
|
+
import { Session } from "./session";
|
|
3
|
+
/** Binds the band to this phone unless its basic info says it is bound already. */
|
|
4
|
+
declare const bindIfUnbound: (session: Session, secret: DeviceSecret) => Promise<void>;
|
|
5
|
+
export { bindIfUnbound };
|
|
6
|
+
//# sourceMappingURL=bind.d.ts.map
|
package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/bind.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bind.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/next/bluetooth/families/ihealth-band/bind.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAMnD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAwDpC,mFAAmF;AACnF,QAAA,MAAM,aAAa,GAAU,SAAS,OAAO,EAAE,QAAQ,YAAY,KAAG,OAAO,CAAC,IAAI,CAIjF,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/block-reader.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Block } from "./block";
|
|
2
|
+
import { Session } from "./session";
|
|
3
|
+
/** Asks for one block, reads it to its end and acknowledges it; `null` when it names no day. */
|
|
4
|
+
declare const readBlock: ({ request, packets }: Session, key: number) => Promise<Block | null>;
|
|
5
|
+
export { readBlock };
|
|
6
|
+
//# sourceMappingURL=block-reader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block-reader.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/next/bluetooth/families/ihealth-band/block-reader.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiB,KAAK,EAAiB,MAAM,SAAS,CAAC;AAG9D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAgCpC,gGAAgG;AAChG,QAAA,MAAM,SAAS,GAAU,sBAAsB,OAAO,EAAE,KAAK,MAAM,KAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAUzF,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Frame } from "./frame";
|
|
2
|
+
/** The calendar day a block's records belong to, in the band's local time. */
|
|
3
|
+
type StoredDay = {
|
|
4
|
+
year: number;
|
|
5
|
+
month: number;
|
|
6
|
+
day: number;
|
|
7
|
+
};
|
|
8
|
+
/** One block: its day, and the item bytes of its data packets in the order they came. */
|
|
9
|
+
type Block = {
|
|
10
|
+
day: StoredDay;
|
|
11
|
+
data: Uint8Array;
|
|
12
|
+
};
|
|
13
|
+
declare const isFirstHeader: ({ payload }: Frame) => boolean;
|
|
14
|
+
/** 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. */
|
|
15
|
+
declare const assembleBlock: (packets: readonly Frame[]) => Block | null;
|
|
16
|
+
export { assembleBlock, isFirstHeader };
|
|
17
|
+
export type { Block, StoredDay };
|
|
18
|
+
//# sourceMappingURL=block.d.ts.map
|
package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/block.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/next/bluetooth/families/ihealth-band/block.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAahC,8EAA8E;AAC9E,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,yFAAyF;AACzF,KAAK,KAAK,GAAG;IACX,GAAG,EAAE,SAAS,CAAC;IACf,IAAI,EAAE,UAAU,CAAC;CAClB,CAAC;AAEF,QAAA,MAAM,aAAa,GAAI,aAAa,KAAK,KAAG,OAAkD,CAAC;AAa/F,qIAAqI;AACrI,QAAA,MAAM,aAAa,GAAI,SAAS,SAAS,KAAK,EAAE,KAAG,KAAK,GAAG,IAK1D,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC;AACxC,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC"}
|
package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/commands.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Frame } from "./frame";
|
|
2
|
+
declare const BIND_KEY: {
|
|
3
|
+
readonly bind: 1;
|
|
4
|
+
readonly auth: 3;
|
|
5
|
+
readonly rejected: 4;
|
|
6
|
+
};
|
|
7
|
+
/** Keys of the health class: the sync's own, then the block of each kind of stored day, then the end of a block. */
|
|
8
|
+
declare const HEALTH_KEY: {
|
|
9
|
+
readonly start: 1;
|
|
10
|
+
readonly stop: 2;
|
|
11
|
+
readonly sportToday: 3;
|
|
12
|
+
readonly sportHistory: 5;
|
|
13
|
+
readonly heartRateToday: 7;
|
|
14
|
+
readonly heartRateHistory: 8;
|
|
15
|
+
readonly blockEnd: 238;
|
|
16
|
+
};
|
|
17
|
+
/** 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. */
|
|
18
|
+
declare const BLOCK_PHASE: {
|
|
19
|
+
readonly first: 1;
|
|
20
|
+
readonly second: 2;
|
|
21
|
+
};
|
|
22
|
+
/** Starts a bind; the band answers, or asks for the pairing code. */
|
|
23
|
+
declare const bindCommand: () => Frame;
|
|
24
|
+
/** Sends the pairing code the band shows, one byte per digit. */
|
|
25
|
+
declare const authCommand: (digits: readonly number[]) => Frame;
|
|
26
|
+
/** Sets the band's clock to the local time of `now`. */
|
|
27
|
+
declare const setTimeCommand: (now: Date) => Frame;
|
|
28
|
+
/** Asks for the basic info: firmware, battery and whether the band is bound. */
|
|
29
|
+
declare const basicInfoCommand: () => Frame;
|
|
30
|
+
/** Asks for the table of features the band has. */
|
|
31
|
+
declare const functionTableCommand: () => Frame;
|
|
32
|
+
/** Asks for the running counters. */
|
|
33
|
+
declare const liveDataCommand: () => Frame;
|
|
34
|
+
/** Starts a health sync; the band answers with how many days of each kind it holds. */
|
|
35
|
+
declare const startSyncCommand: () => Frame;
|
|
36
|
+
/** Ends a health sync. */
|
|
37
|
+
declare const stopSyncCommand: () => Frame;
|
|
38
|
+
/** Asks for one block, from its first item. */
|
|
39
|
+
declare const blockRequestCommand: (key: number) => Frame;
|
|
40
|
+
/** Tells the band the block of `key` arrived. */
|
|
41
|
+
declare const blockAckCommand: (key: number) => Frame;
|
|
42
|
+
export { authCommand, basicInfoCommand, BIND_KEY, bindCommand, BLOCK_PHASE, blockAckCommand, blockRequestCommand, functionTableCommand, HEALTH_KEY, liveDataCommand, setTimeCommand, startSyncCommand, stopSyncCommand, };
|
|
43
|
+
//# sourceMappingURL=commands.d.ts.map
|
package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/commands.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/next/bluetooth/families/ihealth-band/commands.ts"],"names":[],"mappings":"AAEA,OAAO,EAA0B,KAAK,EAAE,MAAM,SAAS,CAAC;AAExD,QAAA,MAAM,QAAQ;;;;CAAsD,CAAC;AAIrE,oHAAoH;AACpH,QAAA,MAAM,UAAU;;;;;;;;CAQN,CAAC;AAEX,gIAAgI;AAChI,QAAA,MAAM,WAAW;;;CAAyC,CAAC;AAqB3D,qEAAqE;AACrE,QAAA,MAAM,WAAW,QAAO,KAOpB,CAAC;AAEL,iEAAiE;AACjE,QAAA,MAAM,WAAW,GAAI,QAAQ,SAAS,MAAM,EAAE,KAAG,KAO7C,CAAC;AAEL,wDAAwD;AACxD,QAAA,MAAM,cAAc,GAAI,KAAK,IAAI,KAAG,KAShC,CAAC;AAEL,gFAAgF;AAChF,QAAA,MAAM,gBAAgB,QAAO,KAAwD,CAAC;AAEtF,mDAAmD;AACnD,QAAA,MAAM,oBAAoB,QAAO,KAA4D,CAAC;AAE9F,qCAAqC;AACrC,QAAA,MAAM,eAAe,QAAO,KAAuD,CAAC;AAEpF,uFAAuF;AACvF,QAAA,MAAM,gBAAgB,QAAO,KAA+E,CAAC;AAE7G,0BAA0B;AAC1B,QAAA,MAAM,eAAe,QAAO,KAAmE,CAAC;AAEhG,+CAA+C;AAC/C,QAAA,MAAM,mBAAmB,GAAI,KAAK,MAAM,KAAG,KACkD,CAAC;AAE9F,iDAAiD;AACjD,QAAA,MAAM,eAAe,GAAI,KAAK,MAAM,KAAG,KAAiE,CAAC;AAEzG,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,QAAQ,EACR,WAAW,EACX,WAAW,EACX,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,UAAU,EACV,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,eAAe,GAChB,CAAC"}
|
package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/connection.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Logger } from "../../core/ports";
|
|
2
|
+
import { ProtocolContext } from "../../core/protocol";
|
|
3
|
+
import { Session } from "./session";
|
|
4
|
+
/** What a protocol keeps of an open link to a band. */
|
|
5
|
+
type BandConnection = Session & {
|
|
6
|
+
/** For structured events. */
|
|
7
|
+
logger: Logger;
|
|
8
|
+
/** The phone's clock, which says how far into today a stored day has got. */
|
|
9
|
+
now: () => Date;
|
|
10
|
+
};
|
|
11
|
+
/** Opens the session and binds a band that is not yet bound. */
|
|
12
|
+
declare const openBand: (context: ProtocolContext) => Promise<BandConnection>;
|
|
13
|
+
export { openBand };
|
|
14
|
+
export type { BandConnection };
|
|
15
|
+
//# sourceMappingURL=connection.d.ts.map
|
package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/connection.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/next/bluetooth/families/ihealth-band/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD,OAAO,EAAe,OAAO,EAAE,MAAM,WAAW,CAAC;AAEjD,uDAAuD;AACvD,KAAK,cAAc,GAAG,OAAO,GAAG;IAE9B,6BAA6B;IAC7B,MAAM,EAAE,MAAM,CAAC;IAEf,6EAA6E;IAC7E,GAAG,EAAE,MAAM,IAAI,CAAC;CACjB,CAAC;AAEF,gEAAgE;AAChE,QAAA,MAAM,QAAQ,GAAU,SAAS,eAAe,KAAG,OAAO,CAAC,cAAc,CAWxE,CAAC;AAEF,OAAO,EAAE,QAAQ,EAAE,CAAC;AACpB,YAAY,EAAE,cAAc,EAAE,CAAC"}
|
package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/device-info.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Battery, DeviceIdentity } from "../../core/paired-device";
|
|
2
|
+
import { BasicInfo } from "./replies";
|
|
3
|
+
import { Session } from "./session";
|
|
4
|
+
/** Asks the band for its basic info. */
|
|
5
|
+
declare const readBasicInfo: ({ request }: Session) => Promise<BasicInfo>;
|
|
6
|
+
/** The firmware number the band reports; it gives no serial, hardware, maker or model. */
|
|
7
|
+
declare const identify: (session: Session) => Promise<Omit<DeviceIdentity, "at">>;
|
|
8
|
+
declare const battery: (session: Session) => Promise<Omit<Battery, "at">>;
|
|
9
|
+
export { battery, identify, readBasicInfo };
|
|
10
|
+
//# sourceMappingURL=device-info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device-info.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/next/bluetooth/families/ihealth-band/device-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAInE,OAAO,EAAE,SAAS,EAAe,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,wCAAwC;AACxC,QAAA,MAAM,aAAa,GAAU,aAAa,OAAO,KAAG,OAAO,CAAC,SAAS,CAIpE,CAAC;AAEF,0FAA0F;AAC1F,QAAA,MAAM,QAAQ,GAAU,SAAS,OAAO,KAAG,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,CAM3E,CAAC;AAEH,QAAA,MAAM,OAAO,GAAU,SAAS,OAAO,KAAG,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAIpE,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** The service every frame travels on. */
|
|
2
|
+
declare const BAND_SERVICE: string;
|
|
3
|
+
/** The characteristics the band notifies on, in the order it wants them enabled. */
|
|
4
|
+
declare const NOTIFY_CHARACTERISTICS: readonly string[];
|
|
5
|
+
/** The first byte of a frame: what kind of exchange it belongs to. */
|
|
6
|
+
declare const COMMAND_CLASS: {
|
|
7
|
+
readonly read: 2;
|
|
8
|
+
readonly setting: 3;
|
|
9
|
+
readonly bind: 4;
|
|
10
|
+
readonly health: 8;
|
|
11
|
+
readonly workout: 9;
|
|
12
|
+
};
|
|
13
|
+
/** One packet: its command class, its key, and the payload after them; payload offsets count from there. */
|
|
14
|
+
type Frame = {
|
|
15
|
+
commandClass: number;
|
|
16
|
+
key: number;
|
|
17
|
+
payload: Uint8Array;
|
|
18
|
+
};
|
|
19
|
+
/** A frame to send, from the bytes after its key. */
|
|
20
|
+
declare const command: (commandClass: number, key: number, payload?: readonly number[]) => Frame;
|
|
21
|
+
/** The bytes to write; fails for a frame the band would refuse as too long. */
|
|
22
|
+
declare const frameBytes: ({ commandClass, key, payload }: Frame) => Uint8Array;
|
|
23
|
+
/** The frame a notification carries; `null` when it is too short or too long to be one. */
|
|
24
|
+
declare const frameOf: (bytes: Uint8Array) => Frame | null;
|
|
25
|
+
/** Where a frame is written: health and workout data have a characteristic of their own. */
|
|
26
|
+
declare const characteristicOf: ({ commandClass }: Frame) => string;
|
|
27
|
+
/** Accepts the reply that echoes the class and key of `request`, which is how the band acknowledges it. */
|
|
28
|
+
declare const isEchoOf: (request: Frame) => (reply: Frame) => boolean;
|
|
29
|
+
export { BAND_SERVICE, characteristicOf, COMMAND_CLASS, command, frameBytes, frameOf, isEchoOf, NOTIFY_CHARACTERISTICS };
|
|
30
|
+
export type { Frame };
|
|
31
|
+
//# sourceMappingURL=frame.d.ts.map
|
package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/frame.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frame.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/next/bluetooth/families/ihealth-band/frame.ts"],"names":[],"mappings":"AAGA,0CAA0C;AAC1C,QAAA,MAAM,YAAY,QAAmB,CAAC;AAKtC,oFAAoF;AACpF,QAAA,MAAM,sBAAsB,EAAE,SAAS,MAAM,EAAyC,CAAC;AAMvF,sEAAsE;AACtE,QAAA,MAAM,aAAa;;;;;;CAAkF,CAAC;AAItG,4GAA4G;AAC5G,KAAK,KAAK,GAAG;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,UAAU,CAAC;CACrB,CAAC;AAEF,qDAAqD;AACrD,QAAA,MAAM,OAAO,GAAI,cAAc,MAAM,EAAE,KAAK,MAAM,EAAE,UAAS,SAAS,MAAM,EAAO,KAAG,KAIpF,CAAC;AAEH,+EAA+E;AAC/E,QAAA,MAAM,UAAU,GAAI,gCAAgC,KAAK,KAAG,UAQ3D,CAAC;AAEF,2FAA2F;AAC3F,QAAA,MAAM,OAAO,GAAI,OAAO,UAAU,KAAG,KAAK,GAAG,IAGmD,CAAC;AAEjG,4FAA4F;AAC5F,QAAA,MAAM,gBAAgB,GAAI,kBAAkB,KAAK,KAAG,MACgD,CAAC;AAErG,2GAA2G;AAC3G,QAAA,MAAM,QAAQ,GACX,SAAS,KAAK,MACd,OAAO,KAAK,KAAG,OAC0D,CAAC;AAE7E,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,sBAAsB,EAAE,CAAC;AACzH,YAAY,EAAE,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { HistoryRecord } from "../../core/protocol";
|
|
2
|
+
import { BandConnection } from "./connection";
|
|
3
|
+
/** The steps of each 15-minute slot and each heart-rate sample the band stores, as the band's blocks come. */
|
|
4
|
+
declare function storedRecords(connection: BandConnection): AsyncGenerator<HistoryRecord>;
|
|
5
|
+
export { storedRecords };
|
|
6
|
+
//# sourceMappingURL=history.d.ts.map
|
package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/history.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/next/bluetooth/families/ihealth-band/history.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAKpD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAoD9C,8GAA8G;AAC9G,iBAAgB,aAAa,CAAC,UAAU,EAAE,cAAc,GAAG,cAAc,CAAC,aAAa,CAAC,CAevF;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/ihealth-band.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DeviceProtocol } from "../../core/protocol";
|
|
2
|
+
import { IHEALTH_BAND_MODELS } from "./models";
|
|
3
|
+
/** The protocols of the iHealth fitness bands: the AM5. */
|
|
4
|
+
declare const IHEALTH_BAND_PROTOCOLS: readonly DeviceProtocol[];
|
|
5
|
+
export { IHEALTH_BAND_MODELS, IHEALTH_BAND_PROTOCOLS };
|
|
6
|
+
//# sourceMappingURL=ihealth-band.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ihealth-band.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/next/bluetooth/families/ihealth-band/ihealth-band.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C,2DAA2D;AAC3D,QAAA,MAAM,sBAAsB,EAAE,SAAS,cAAc,EAAU,CAAC;AAEhE,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { LiveFrame } from "../../core/reading";
|
|
2
|
+
import { BandConnection } from "./connection";
|
|
3
|
+
/** Asks for the heart rate once a second until `signal` aborts; a reading of 0 is left out. */
|
|
4
|
+
declare const pollHeartRate: ({ request, now }: BandConnection, onFrame: (frame: LiveFrame) => void, signal: AbortSignal) => Promise<void>;
|
|
5
|
+
export { pollHeartRate };
|
|
6
|
+
//# sourceMappingURL=live.d.ts.map
|
package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/live.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/next/bluetooth/families/ihealth-band/live.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI/C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAa9C,+FAA+F;AAC/F,QAAA,MAAM,aAAa,GAAU,kBAAkB,cAAc,EAAE,SAAS,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,EAAE,QAAQ,WAAW,KAAG,OAAO,CAAC,IAAI,CAWrI,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DeviceModel } from "../../core/catalog";
|
|
2
|
+
/** The one band; it has no advertised name, so the service it advertises is what finds it. */
|
|
3
|
+
declare const IHEALTH_BAND_MODELS: readonly DeviceModel[];
|
|
4
|
+
export { IHEALTH_BAND_MODELS };
|
|
5
|
+
//# sourceMappingURL=models.d.ts.map
|
package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/models.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/next/bluetooth/families/ihealth-band/models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAMjD,8FAA8F;AAC9F,QAAA,MAAM,mBAAmB,EAAE,SAAS,WAAW,EAK9C,CAAC;AAEF,OAAO,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { HistoryRecord } from "../../core/protocol";
|
|
2
|
+
import { Block } from "./block";
|
|
3
|
+
/** The steps of each 15-minute slot of the day that has ended by `now` and holds steps; a slot still counting would come back under another id. */
|
|
4
|
+
declare const stepsRecords: ({ day, data }: Block, now: Date) => HistoryRecord[];
|
|
5
|
+
/** The samples of a heart-rate day: each item gives the minutes since the one before, which add up from local midnight. */
|
|
6
|
+
declare const heartRateRecords: ({ day, data }: Block) => HistoryRecord[];
|
|
7
|
+
export { heartRateRecords, stepsRecords };
|
|
8
|
+
//# sourceMappingURL=records.d.ts.map
|
package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/records.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/next/bluetooth/families/ihealth-band/records.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,KAAK,EAAa,MAAM,SAAS,CAAC;AA8B3C,mJAAmJ;AACnJ,QAAA,MAAM,YAAY,GAAI,eAAe,KAAK,EAAE,KAAK,IAAI,KAAG,aAAa,EAWpE,CAAC;AAYF,2HAA2H;AAC3H,QAAA,MAAM,gBAAgB,GAAI,eAAe,KAAK,KAAG,aAAa,EAe7D,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Frame } from "./frame";
|
|
2
|
+
/** The basic info reply: the firmware number, the charge, and whether the band is bound to a phone. */
|
|
3
|
+
type BasicInfo = {
|
|
4
|
+
firmware: number;
|
|
5
|
+
percent: number;
|
|
6
|
+
charging: boolean | null;
|
|
7
|
+
bound: boolean;
|
|
8
|
+
};
|
|
9
|
+
/** How many days of each kind the sync reads; the band holds more kinds, which this does not read. */
|
|
10
|
+
type StoredDays = {
|
|
11
|
+
sport: number;
|
|
12
|
+
heartRate: number;
|
|
13
|
+
};
|
|
14
|
+
/** The bind reply: its result code, and how many digits of pairing code the band wants, none when 0. */
|
|
15
|
+
declare const bindAnswerOf: (reply: Frame) => {
|
|
16
|
+
result: number;
|
|
17
|
+
codeLength: number;
|
|
18
|
+
};
|
|
19
|
+
/** The result code of the reply to the pairing code. */
|
|
20
|
+
declare const authResultOf: (reply: Frame) => number;
|
|
21
|
+
declare const basicInfoOf: (reply: Frame) => BasicInfo;
|
|
22
|
+
/** Whether the band says it measures heart rate; without it the band has no heart-rate blocks. */
|
|
23
|
+
declare const measuresHeartRate: (reply: Frame) => boolean;
|
|
24
|
+
declare const storedDaysOf: (reply: Frame) => StoredDays;
|
|
25
|
+
/** The heart rate of a live data reply, in beats per minute. */
|
|
26
|
+
declare const liveHeartRateOf: (reply: Frame) => number;
|
|
27
|
+
export { authResultOf, basicInfoOf, bindAnswerOf, liveHeartRateOf, measuresHeartRate, storedDaysOf };
|
|
28
|
+
export type { BasicInfo, StoredDays };
|
|
29
|
+
//# sourceMappingURL=replies.d.ts.map
|
package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/replies.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replies.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/next/bluetooth/families/ihealth-band/replies.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAwBhC,uGAAuG;AACvG,KAAK,SAAS,GAAG;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAC;IACzB,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,sGAAsG;AACtG,KAAK,UAAU,GAAG;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAUF,wGAAwG;AACxG,QAAA,MAAM,YAAY,GAAI,OAAO,KAAK,KAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAIxE,CAAC;AAEF,wDAAwD;AACxD,QAAA,MAAM,YAAY,GAAI,OAAO,KAAK,KAAG,MAAqC,CAAC;AAE3E,QAAA,MAAM,WAAW,GAAI,OAAO,KAAK,KAAG,SASnC,CAAC;AAEF,kGAAkG;AAClG,QAAA,MAAM,iBAAiB,GAAI,OAAO,KAAK,KAAG,OAAkF,CAAC;AAE7H,QAAA,MAAM,YAAY,GAAI,OAAO,KAAK,KAAG,UAOpC,CAAC;AAEF,gEAAgE;AAChE,QAAA,MAAM,eAAe,GAAI,OAAO,KAAK,KAAG,MAA2E,CAAC;AAEpH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,YAAY,EAAE,CAAC;AACrG,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DeviceError } from "../../core/errors";
|
|
2
|
+
import { ProtocolContext } from "../../core/protocol";
|
|
3
|
+
import { Inbox } from "../sig/waiting";
|
|
4
|
+
import { Frame } from "./frame";
|
|
5
|
+
type Accepts = (reply: Frame) => boolean;
|
|
6
|
+
/** One open link: requests that wait for the band's reply, and the health packets the band sends on its own. */
|
|
7
|
+
type Session = {
|
|
8
|
+
/** Sends a frame and resolves with the reply `accepts`, resending when the band is silent. */
|
|
9
|
+
request: (frame: Frame, accepts: Accepts) => Promise<Frame>;
|
|
10
|
+
/** Like `request`, with the longer wait the band gets to answer a bind. */
|
|
11
|
+
bindRequest: (frame: Frame, accepts: Accepts) => Promise<Frame>;
|
|
12
|
+
/** Every health packet, or the error that ended the link, in the order they came. */
|
|
13
|
+
packets: Inbox<Frame | DeviceError>;
|
|
14
|
+
/** Stops listening. */
|
|
15
|
+
stop: () => void;
|
|
16
|
+
};
|
|
17
|
+
/** Enables both notify characteristics, and routes what the band sends to whoever waits for it. */
|
|
18
|
+
declare const openSession: ({ link }: ProtocolContext) => Promise<Session>;
|
|
19
|
+
export { openSession };
|
|
20
|
+
export type { Session };
|
|
21
|
+
//# sourceMappingURL=session.d.ts.map
|
package/lib/typescript/commonjs/src/modules/next/bluetooth/families/ihealth-band/session.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/next/bluetooth/families/ihealth-band/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEvC,OAAO,EAAiD,KAAK,EAA+C,MAAM,SAAS,CAAC;AAQ5H,KAAK,OAAO,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC;AAEzC,gHAAgH;AAChH,KAAK,OAAO,GAAG;IAEb,8FAA8F;IAC9F,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,KAAK,CAAC,CAAC;IAE5D,2EAA2E;IAC3E,WAAW,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,KAAK,CAAC,CAAC;IAEhE,qFAAqF;IACrF,OAAO,EAAE,KAAK,CAAC,KAAK,GAAG,WAAW,CAAC,CAAC;IAEpC,uBAAuB;IACvB,IAAI,EAAE,MAAM,IAAI,CAAC;CAClB,CAAC;AAEF,mGAAmG;AACnG,QAAA,MAAM,WAAW,GAAU,UAAU,eAAe,KAAG,OAAO,CAAC,OAAO,CAiDrE,CAAC;AAEF,OAAO,EAAE,WAAW,EAAE,CAAC;AACvB,YAAY,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"built-in.d.ts","sourceRoot":"","sources":["../../../../../../../../src/modules/next/bluetooth/families/built-in.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"built-in.d.ts","sourceRoot":"","sources":["../../../../../../../../src/modules/next/bluetooth/families/built-in.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAoFlD,6FAA6F;AAC7F,QAAA,MAAM,eAAe,EAAE,SAAS,WAAW,EAiFzC,CAAC;AAEH,6CAA6C;AAC7C,QAAA,MAAM,kBAAkB,EAAE,SAAS,cAAc,EAiFhD,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DeviceProtocol } from "../../core/protocol";
|
|
2
|
+
import { BandConnection } from "./connection";
|
|
3
|
+
/** The AM5 band: identity, battery, a clock, its heart rate live, and the steps and heart rates it stores as history. */
|
|
4
|
+
declare const AM5: DeviceProtocol<BandConnection>;
|
|
5
|
+
export { AM5 };
|
|
6
|
+
//# sourceMappingURL=am5.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"am5.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/next/bluetooth/families/ihealth-band/am5.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,EAAY,cAAc,EAAE,MAAM,cAAc,CAAC;AAMxD,yHAAyH;AACzH,QAAA,MAAM,GAAG,EAAE,cAAc,CAAC,cAAc,CAcvC,CAAC;AAEF,OAAO,EAAE,GAAG,EAAE,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DeviceSecret } from "../../core/protocol";
|
|
2
|
+
import { Session } from "./session";
|
|
3
|
+
/** Binds the band to this phone unless its basic info says it is bound already. */
|
|
4
|
+
declare const bindIfUnbound: (session: Session, secret: DeviceSecret) => Promise<void>;
|
|
5
|
+
export { bindIfUnbound };
|
|
6
|
+
//# sourceMappingURL=bind.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bind.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/modules/next/bluetooth/families/ihealth-band/bind.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAMnD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAwDpC,mFAAmF;AACnF,QAAA,MAAM,aAAa,GAAU,SAAS,OAAO,EAAE,QAAQ,YAAY,KAAG,OAAO,CAAC,IAAI,CAIjF,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC"}
|