@ovok/native 1.17.0-dev.2293 → 1.17.0-dev.2297
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/finicare/crc.js → codec/crc8-maxim.js} +1 -1
- package/lib/commonjs/modules/next/bluetooth/codec/crc8-maxim.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/core/device-snapshot.js +4 -2
- package/lib/commonjs/modules/next/bluetooth/core/device-snapshot.js.map +1 -1
- package/lib/commonjs/modules/next/bluetooth/core/device-state.js +2 -0
- package/lib/commonjs/modules/next/bluetooth/core/device-state.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/core/device.js +3 -0
- package/lib/commonjs/modules/next/bluetooth/core/device.js.map +1 -1
- package/lib/commonjs/modules/next/bluetooth/core/live-session.js +7 -1
- package/lib/commonjs/modules/next/bluetooth/core/live-session.js.map +1 -1
- 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/famidoc-hearing-aid/famidoc-hearing-aid.js +17 -0
- package/lib/commonjs/modules/next/bluetooth/families/famidoc-hearing-aid/famidoc-hearing-aid.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/families/famidoc-hearing-aid/frame.js +116 -0
- package/lib/commonjs/modules/next/bluetooth/families/famidoc-hearing-aid/frame.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/families/famidoc-hearing-aid/models.js +14 -0
- package/lib/commonjs/modules/next/bluetooth/families/famidoc-hearing-aid/models.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/families/famidoc-hearing-aid/protocol.js +34 -0
- package/lib/commonjs/modules/next/bluetooth/families/famidoc-hearing-aid/protocol.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/families/famidoc-hearing-aid/replies.js +86 -0
- package/lib/commonjs/modules/next/bluetooth/families/famidoc-hearing-aid/replies.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/families/famidoc-hearing-aid/session.js +112 -0
- package/lib/commonjs/modules/next/bluetooth/families/famidoc-hearing-aid/session.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/families/famidoc-hearing-aid/settings.js +121 -0
- package/lib/commonjs/modules/next/bluetooth/families/famidoc-hearing-aid/settings.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/families/famidoc-hearing-aid/status.js +153 -0
- package/lib/commonjs/modules/next/bluetooth/families/famidoc-hearing-aid/status.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/families/famidoc-hearing-aid/values.js +44 -0
- package/lib/commonjs/modules/next/bluetooth/families/famidoc-hearing-aid/values.js.map +1 -0
- package/lib/commonjs/modules/next/bluetooth/families/finicare/frame.js +3 -3
- package/lib/commonjs/modules/next/bluetooth/families/finicare/frame.js.map +1 -1
- package/lib/commonjs/modules/next/bluetooth/shared.js.map +1 -1
- package/lib/module/modules/next/bluetooth/{families/finicare/crc.js → codec/crc8-maxim.js} +1 -1
- package/lib/module/modules/next/bluetooth/codec/crc8-maxim.js.map +1 -0
- package/lib/module/modules/next/bluetooth/core/device-snapshot.js +4 -2
- package/lib/module/modules/next/bluetooth/core/device-snapshot.js.map +1 -1
- package/lib/module/modules/next/bluetooth/core/device-state.js +2 -0
- package/lib/module/modules/next/bluetooth/core/device-state.js.map +1 -0
- package/lib/module/modules/next/bluetooth/core/device.js +3 -0
- package/lib/module/modules/next/bluetooth/core/device.js.map +1 -1
- package/lib/module/modules/next/bluetooth/core/live-session.js +7 -1
- package/lib/module/modules/next/bluetooth/core/live-session.js.map +1 -1
- 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/famidoc-hearing-aid/famidoc-hearing-aid.js +9 -0
- package/lib/module/modules/next/bluetooth/families/famidoc-hearing-aid/famidoc-hearing-aid.js.map +1 -0
- package/lib/module/modules/next/bluetooth/families/famidoc-hearing-aid/frame.js +110 -0
- package/lib/module/modules/next/bluetooth/families/famidoc-hearing-aid/frame.js.map +1 -0
- package/lib/module/modules/next/bluetooth/families/famidoc-hearing-aid/models.js +12 -0
- package/lib/module/modules/next/bluetooth/families/famidoc-hearing-aid/models.js.map +1 -0
- package/lib/module/modules/next/bluetooth/families/famidoc-hearing-aid/protocol.js +32 -0
- package/lib/module/modules/next/bluetooth/families/famidoc-hearing-aid/protocol.js.map +1 -0
- package/lib/module/modules/next/bluetooth/families/famidoc-hearing-aid/replies.js +78 -0
- package/lib/module/modules/next/bluetooth/families/famidoc-hearing-aid/replies.js.map +1 -0
- package/lib/module/modules/next/bluetooth/families/famidoc-hearing-aid/session.js +109 -0
- package/lib/module/modules/next/bluetooth/families/famidoc-hearing-aid/session.js.map +1 -0
- package/lib/module/modules/next/bluetooth/families/famidoc-hearing-aid/settings.js +116 -0
- package/lib/module/modules/next/bluetooth/families/famidoc-hearing-aid/settings.js.map +1 -0
- package/lib/module/modules/next/bluetooth/families/famidoc-hearing-aid/status.js +148 -0
- package/lib/module/modules/next/bluetooth/families/famidoc-hearing-aid/status.js.map +1 -0
- package/lib/module/modules/next/bluetooth/families/famidoc-hearing-aid/values.js +34 -0
- package/lib/module/modules/next/bluetooth/families/famidoc-hearing-aid/values.js.map +1 -0
- package/lib/module/modules/next/bluetooth/families/finicare/frame.js +1 -1
- package/lib/module/modules/next/bluetooth/families/finicare/frame.js.map +1 -1
- package/lib/module/modules/next/bluetooth/shared.js.map +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/{families/finicare/crc.d.ts → codec/crc8-maxim.d.ts} +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/codec/crc8-maxim.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/core/device-snapshot.d.ts +4 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/core/device-snapshot.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/core/device-state.d.ts +108 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/core/device-state.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/core/device.d.ts +3 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/core/device.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/core/live-session.d.ts +2 -2
- package/lib/typescript/commonjs/src/modules/next/bluetooth/core/live-session.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/core/protocol.d.ts +3 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/core/protocol.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/core/reading.d.ts +3 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/core/reading.d.ts.map +1 -1
- 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/famidoc-hearing-aid/famidoc-hearing-aid.d.ts +6 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/famidoc-hearing-aid/famidoc-hearing-aid.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/famidoc-hearing-aid/frame.d.ts +63 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/famidoc-hearing-aid/frame.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/famidoc-hearing-aid/models.d.ts +5 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/famidoc-hearing-aid/models.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/famidoc-hearing-aid/protocol.d.ts +6 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/famidoc-hearing-aid/protocol.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/famidoc-hearing-aid/replies.d.ts +23 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/famidoc-hearing-aid/replies.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/famidoc-hearing-aid/session.d.ts +31 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/famidoc-hearing-aid/session.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/famidoc-hearing-aid/settings.d.ts +14 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/famidoc-hearing-aid/settings.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/famidoc-hearing-aid/status.d.ts +14 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/famidoc-hearing-aid/status.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/famidoc-hearing-aid/values.d.ts +18 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/famidoc-hearing-aid/values.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/finicare/frame.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/shared.d.ts +1 -0
- package/lib/typescript/commonjs/src/modules/next/bluetooth/shared.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/{families/finicare/crc.d.ts → codec/crc8-maxim.d.ts} +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/codec/crc8-maxim.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/core/device-snapshot.d.ts +4 -1
- package/lib/typescript/module/src/modules/next/bluetooth/core/device-snapshot.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/core/device-state.d.ts +108 -0
- package/lib/typescript/module/src/modules/next/bluetooth/core/device-state.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/core/device.d.ts +3 -0
- package/lib/typescript/module/src/modules/next/bluetooth/core/device.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/core/live-session.d.ts +2 -2
- package/lib/typescript/module/src/modules/next/bluetooth/core/live-session.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/core/protocol.d.ts +3 -0
- package/lib/typescript/module/src/modules/next/bluetooth/core/protocol.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/core/reading.d.ts +3 -0
- package/lib/typescript/module/src/modules/next/bluetooth/core/reading.d.ts.map +1 -1
- 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/famidoc-hearing-aid/famidoc-hearing-aid.d.ts +6 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/famidoc-hearing-aid/famidoc-hearing-aid.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/famidoc-hearing-aid/frame.d.ts +63 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/famidoc-hearing-aid/frame.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/famidoc-hearing-aid/models.d.ts +5 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/famidoc-hearing-aid/models.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/famidoc-hearing-aid/protocol.d.ts +6 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/famidoc-hearing-aid/protocol.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/famidoc-hearing-aid/replies.d.ts +23 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/famidoc-hearing-aid/replies.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/famidoc-hearing-aid/session.d.ts +31 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/famidoc-hearing-aid/session.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/famidoc-hearing-aid/settings.d.ts +14 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/famidoc-hearing-aid/settings.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/famidoc-hearing-aid/status.d.ts +14 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/famidoc-hearing-aid/status.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/famidoc-hearing-aid/values.d.ts +18 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/famidoc-hearing-aid/values.d.ts.map +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/families/finicare/frame.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/shared.d.ts +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/shared.d.ts.map +1 -1
- package/package.json +1 -1
- package/lib/commonjs/modules/next/bluetooth/families/finicare/crc.js.map +0 -1
- package/lib/module/modules/next/bluetooth/families/finicare/crc.js.map +0 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/finicare/crc.d.ts.map +0 -1
- package/lib/typescript/module/src/modules/next/bluetooth/families/finicare/crc.d.ts.map +0 -1
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.openSession = exports.AID_SERVICE = void 0;
|
|
7
|
+
var _advertisement = require("../../core/advertisement.js");
|
|
8
|
+
var _errors = require("../../core/errors.js");
|
|
9
|
+
var _exchange = require("../../core/exchange.js");
|
|
10
|
+
var _frameLink = require("../frame-tools/frame-link.js");
|
|
11
|
+
var _frame = require("./frame.js");
|
|
12
|
+
var _replies = require("./replies.js");
|
|
13
|
+
/** The service the phone talks to the aid through; the OTA and audio services are left alone. */
|
|
14
|
+
const AID_SERVICE = exports.AID_SERVICE = (0, _advertisement.fullUuid)("FF00");
|
|
15
|
+
const WRITE = (0, _advertisement.fullUuid)("FF01");
|
|
16
|
+
const NOTIFY = (0, _advertisement.fullUuid)("FF02");
|
|
17
|
+
|
|
18
|
+
/** The aid answered every read within a second on hardware. */
|
|
19
|
+
const REPLY_TIMING = {
|
|
20
|
+
replyTimeoutMs: 3_000,
|
|
21
|
+
attempts: 2
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/** One open link: which ears are linked, and how to read from one. */
|
|
25
|
+
|
|
26
|
+
/** The reply's first data bit is set when the aid refused a change. */
|
|
27
|
+
const REFUSED = 0x01;
|
|
28
|
+
|
|
29
|
+
/** Lets listeners in and out, and calls each one with what happened. */
|
|
30
|
+
const listeners = () => {
|
|
31
|
+
const all = new Set();
|
|
32
|
+
return {
|
|
33
|
+
add: listener => {
|
|
34
|
+
all.add(listener);
|
|
35
|
+
return () => {
|
|
36
|
+
all.delete(listener);
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
call: value => all.forEach(listener => listener(value))
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/** Counts from 1 to 63 and round again, so a reply names the request it answers. */
|
|
44
|
+
const counter = () => {
|
|
45
|
+
let count = 0;
|
|
46
|
+
return () => {
|
|
47
|
+
count = count % _frame.COUNT_MASK + 1;
|
|
48
|
+
return count;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/** Listens to the aid, then asks which ears are linked. */
|
|
53
|
+
const openSession = async ({
|
|
54
|
+
link,
|
|
55
|
+
logger
|
|
56
|
+
}) => {
|
|
57
|
+
const exchange = new _exchange.Exchange(REPLY_TIMING);
|
|
58
|
+
const nextCount = counter();
|
|
59
|
+
const reports = listeners();
|
|
60
|
+
const changes = listeners();
|
|
61
|
+
const request = async (ear, command, data = []) => {
|
|
62
|
+
const count = nextCount();
|
|
63
|
+
const answers = reply => reply.ear === ear && reply.count === count && reply.command === command;
|
|
64
|
+
const frame = (0, _frame.encodeRequest)(ear, count, command, data);
|
|
65
|
+
const {
|
|
66
|
+
data: replyData
|
|
67
|
+
} = await exchange.request(() => (0, _frameLink.writeFrame)(link, AID_SERVICE, WRITE, frame), answers);
|
|
68
|
+
return replyData;
|
|
69
|
+
};
|
|
70
|
+
const read = (ear, command) => request(ear, command);
|
|
71
|
+
const write = async (command, data) => {
|
|
72
|
+
const reply = await request(_frame.EAR.main, command, data);
|
|
73
|
+
if (((reply[0] ?? REFUSED) & REFUSED) !== 0) {
|
|
74
|
+
throw new _errors.DeviceError("protocol", "The hearing aid refused the change");
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
const stop = await (0, _frameLink.listenToFrames)(link, [{
|
|
78
|
+
service: AID_SERVICE,
|
|
79
|
+
characteristic: NOTIFY,
|
|
80
|
+
framing: _frame.AID_FRAMING
|
|
81
|
+
}], {
|
|
82
|
+
onFrame: bytes => {
|
|
83
|
+
const frame = (0, _frame.decodeFrame)(bytes);
|
|
84
|
+
if ((0, _frame.isReply)(frame)) {
|
|
85
|
+
exchange.receive(frame);
|
|
86
|
+
} else {
|
|
87
|
+
logger.debug("famidoc-hearing-aid.report.received", {
|
|
88
|
+
command: frame.command
|
|
89
|
+
});
|
|
90
|
+
reports.call(frame);
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
onDisconnect: () => exchange.fail(new _errors.DeviceError("disconnected", "The hearing aid dropped the link"))
|
|
94
|
+
});
|
|
95
|
+
try {
|
|
96
|
+
return {
|
|
97
|
+
ears: (0, _replies.earsOf)(await read(_frame.EAR.main, _frame.COMMAND.connection)),
|
|
98
|
+
read,
|
|
99
|
+
write,
|
|
100
|
+
onReport: reports.add,
|
|
101
|
+
onChanged: changes.add,
|
|
102
|
+
changed: changes.call,
|
|
103
|
+
logger,
|
|
104
|
+
stop
|
|
105
|
+
};
|
|
106
|
+
} catch (error) {
|
|
107
|
+
stop();
|
|
108
|
+
throw error;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
exports.openSession = openSession;
|
|
112
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_advertisement","require","_errors","_exchange","_frameLink","_frame","_replies","AID_SERVICE","exports","fullUuid","WRITE","NOTIFY","REPLY_TIMING","replyTimeoutMs","attempts","REFUSED","listeners","all","Set","add","listener","delete","call","value","forEach","counter","count","COUNT_MASK","openSession","link","logger","exchange","Exchange","nextCount","reports","changes","request","ear","command","data","answers","reply","frame","encodeRequest","replyData","writeFrame","read","write","EAR","main","DeviceError","stop","listenToFrames","service","characteristic","framing","AID_FRAMING","onFrame","bytes","decodeFrame","isReply","receive","debug","onDisconnect","fail","ears","earsOf","COMMAND","connection","onReport","onChanged","changed","error"],"sourceRoot":"../../../../../../../src","sources":["modules/next/bluetooth/families/famidoc-hearing-aid/session.ts"],"mappings":";;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAGA,IAAAG,UAAA,GAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AAEA;AACA,MAAMM,WAAW,GAAAC,OAAA,CAAAD,WAAA,GAAG,IAAAE,uBAAQ,EAAC,MAAM,CAAC;AACpC,MAAMC,KAAK,GAAG,IAAAD,uBAAQ,EAAC,MAAM,CAAC;AAC9B,MAAME,MAAM,GAAG,IAAAF,uBAAQ,EAAC,MAAM,CAAC;;AAE/B;AACA,MAAMG,YAA4B,GAAG;EAAEC,cAAc,EAAE,KAAK;EAAEC,QAAQ,EAAE;AAAE,CAAC;;AAE3E;;AA4BA;AACA,MAAMC,OAAO,GAAG,IAAI;;AAEpB;AACA,MAAMC,SAAS,GAAGA,CAAA,KAAS;EACzB,MAAMC,GAAG,GAAG,IAAIC,GAAG,CAAqB,CAAC;EAEzC,OAAO;IACLC,GAAG,EAAGC,QAA4B,IAAK;MACrCH,GAAG,CAACE,GAAG,CAACC,QAAQ,CAAC;MAEjB,OAAO,MAAM;QACXH,GAAG,CAACI,MAAM,CAACD,QAAQ,CAAC;MACtB,CAAC;IACH,CAAC;IACDE,IAAI,EAAGC,KAAQ,IAAKN,GAAG,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AACf,GAAG;MACrBmD,SAAS,EAAEnC,OAAO,CAAChB,GAAG;MACtBoD,OAAO,EAAEpC,OAAO,CAACb,IAAI;MACrBQ,MAAM;MACNqB;IACF,CAAC;EACH,CAAC,CAAC,OAAOqB,KAAK,EAAE;IACdrB,IAAI,CAAC,CAAC;IACN,MAAMqB,KAAK;EACb;AACF,CAAC;AAAChE,OAAA,CAAAoB,WAAA,GAAAA,WAAA","ignoreList":[]}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.withChange = exports.requestOf = exports.applyChange = void 0;
|
|
7
|
+
var _frame = require("./frame.js");
|
|
8
|
+
var _values = require("./values.js");
|
|
9
|
+
/** The command a change is sent with and its data. */
|
|
10
|
+
|
|
11
|
+
const BIT_ON = 1;
|
|
12
|
+
const BIT_OFF = 0;
|
|
13
|
+
|
|
14
|
+
/** What the phone sends for each change. */
|
|
15
|
+
const REQUESTS = {
|
|
16
|
+
volume: ({
|
|
17
|
+
level
|
|
18
|
+
}) => ({
|
|
19
|
+
command: _frame.SETTING.volume,
|
|
20
|
+
data: [(0, _values.clampedVolume)(level)]
|
|
21
|
+
}),
|
|
22
|
+
mode: ({
|
|
23
|
+
mode
|
|
24
|
+
}) => ({
|
|
25
|
+
command: _frame.SETTING.mode,
|
|
26
|
+
data: [_values.MODES.indexOf(mode)]
|
|
27
|
+
}),
|
|
28
|
+
"noise-reduction": ({
|
|
29
|
+
on,
|
|
30
|
+
scene
|
|
31
|
+
}) => ({
|
|
32
|
+
command: _frame.SETTING.noiseReduction,
|
|
33
|
+
data: [(0, _values.noiseByte)(on, scene)]
|
|
34
|
+
}),
|
|
35
|
+
microphone: ({
|
|
36
|
+
direction
|
|
37
|
+
}) => ({
|
|
38
|
+
command: _frame.SETTING.microphone,
|
|
39
|
+
data: [direction === "front" ? BIT_ON : BIT_OFF]
|
|
40
|
+
}),
|
|
41
|
+
"in-ear-detection": ({
|
|
42
|
+
on
|
|
43
|
+
}) => ({
|
|
44
|
+
command: _frame.SETTING.inEarDetection,
|
|
45
|
+
data: [on ? BIT_ON : BIT_OFF]
|
|
46
|
+
}),
|
|
47
|
+
"prompt-language": ({
|
|
48
|
+
language
|
|
49
|
+
}) => ({
|
|
50
|
+
command: _frame.SETTING.promptLanguage,
|
|
51
|
+
data: [_values.LANGUAGES.indexOf(language)]
|
|
52
|
+
}),
|
|
53
|
+
"factory-reset": () => ({
|
|
54
|
+
command: _frame.SETTING.factoryReset,
|
|
55
|
+
data: []
|
|
56
|
+
})
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/** How each change the aid took moves the status; a factory reset is read again instead. */
|
|
60
|
+
const UPDATES = {
|
|
61
|
+
volume: (state, {
|
|
62
|
+
level
|
|
63
|
+
}) => ({
|
|
64
|
+
...state,
|
|
65
|
+
volume: {
|
|
66
|
+
level: (0, _values.clampedVolume)(level),
|
|
67
|
+
max: _values.MAX_VOLUME
|
|
68
|
+
}
|
|
69
|
+
}),
|
|
70
|
+
mode: (state, {
|
|
71
|
+
mode
|
|
72
|
+
}) => ({
|
|
73
|
+
...state,
|
|
74
|
+
mode
|
|
75
|
+
}),
|
|
76
|
+
"noise-reduction": (state, {
|
|
77
|
+
on,
|
|
78
|
+
scene
|
|
79
|
+
}) => ({
|
|
80
|
+
...state,
|
|
81
|
+
noiseReduction: on,
|
|
82
|
+
noiseScene: scene
|
|
83
|
+
}),
|
|
84
|
+
microphone: (state, {
|
|
85
|
+
direction
|
|
86
|
+
}) => ({
|
|
87
|
+
...state,
|
|
88
|
+
microphone: direction
|
|
89
|
+
}),
|
|
90
|
+
"in-ear-detection": (state, {
|
|
91
|
+
on
|
|
92
|
+
}) => ({
|
|
93
|
+
...state,
|
|
94
|
+
inEarDetection: on
|
|
95
|
+
}),
|
|
96
|
+
"prompt-language": (state, {
|
|
97
|
+
language
|
|
98
|
+
}) => ({
|
|
99
|
+
...state,
|
|
100
|
+
promptLanguage: language
|
|
101
|
+
}),
|
|
102
|
+
"factory-reset": state => state
|
|
103
|
+
};
|
|
104
|
+
const requestOf = change => REQUESTS[change.kind](change);
|
|
105
|
+
|
|
106
|
+
/** The status after a change the aid took. */
|
|
107
|
+
exports.requestOf = requestOf;
|
|
108
|
+
const withChange = (state, change) => UPDATES[change.kind](state, change);
|
|
109
|
+
|
|
110
|
+
/** Sends one change to the aid, then tells the live status once the aid took it. */
|
|
111
|
+
exports.withChange = withChange;
|
|
112
|
+
const applyChange = async (connection, change) => {
|
|
113
|
+
const {
|
|
114
|
+
command,
|
|
115
|
+
data
|
|
116
|
+
} = requestOf(change);
|
|
117
|
+
await connection.write(command, data);
|
|
118
|
+
connection.changed(change);
|
|
119
|
+
};
|
|
120
|
+
exports.applyChange = applyChange;
|
|
121
|
+
//# sourceMappingURL=settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_frame","require","_values","BIT_ON","BIT_OFF","REQUESTS","volume","level","command","SETTING","data","clampedVolume","mode","MODES","indexOf","noise-reduction","on","scene","noiseReduction","noiseByte","microphone","direction","in-ear-detection","inEarDetection","prompt-language","language","promptLanguage","LANGUAGES","factory-reset","factoryReset","UPDATES","state","max","MAX_VOLUME","noiseScene","requestOf","change","kind","exports","withChange","applyChange","connection","write","changed"],"sourceRoot":"../../../../../../../src","sources":["modules/next/bluetooth/families/famidoc-hearing-aid/settings.ts"],"mappings":";;;;;;AAEA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAKA;;AAGA,MAAME,MAAM,GAAG,CAAC;AAChB,MAAMC,OAAO,GAAG,CAAC;;AAEjB;AACA,MAAMC,QAAkE,GAAG;EACzEC,MAAM,EAAEA,CAAC;IAAEC;EAAM,CAAC,MAAM;IAAEC,OAAO,EAAEC,cAAO,CAACH,MAAM;IAAEI,IAAI,EAAE,CAAC,IAAAC,qBAAa,E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AAU,CAACC,KAAK,CAAClC,OAAO,EAAEE,IAAI,CAAC;EACrC+B,UAAU,CAACE,OAAO,CAACP,MAAM,CAAC;AAC5B,CAAC;AAACE,OAAA,CAAAE,WAAA,GAAAA,WAAA","ignoreList":[]}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.withReport = exports.streamStatus = exports.readStatus = exports.BATTERY_REFRESH_MS = void 0;
|
|
7
|
+
var _waiting = require("../sig/waiting.js");
|
|
8
|
+
var _frame = require("./frame.js");
|
|
9
|
+
var _replies = require("./replies.js");
|
|
10
|
+
var _settings = require("./settings.js");
|
|
11
|
+
var _values = require("./values.js");
|
|
12
|
+
/** A battery drains slowly and the aid reports only a low one by itself, so it is read again this often. */
|
|
13
|
+
const BATTERY_REFRESH_MS = exports.BATTERY_REFRESH_MS = 60_000;
|
|
14
|
+
const SIDE = {
|
|
15
|
+
[_frame.EAR.left]: "left",
|
|
16
|
+
[_frame.EAR.right]: "right"
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/** A linked ear is always the left or the right one; only reads to the pair go to the main ear. */
|
|
20
|
+
const sideOf = ear => ear === _frame.EAR.left ? "left" : "right";
|
|
21
|
+
const readBattery = async ({
|
|
22
|
+
read
|
|
23
|
+
}, ear) => {
|
|
24
|
+
const {
|
|
25
|
+
percent,
|
|
26
|
+
charging
|
|
27
|
+
} = (0, _replies.batteryOf)(await read(ear, _frame.COMMAND.battery));
|
|
28
|
+
return {
|
|
29
|
+
battery: percent,
|
|
30
|
+
charging
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
const readEar = async (connection, ear) => ({
|
|
34
|
+
...(await readBattery(connection, ear)),
|
|
35
|
+
inEar: (0, _values.flagOf)(await connection.read(ear, _frame.COMMAND.inEar)),
|
|
36
|
+
inCase: (0, _values.flagOf)(await connection.read(ear, _frame.COMMAND.inCase))
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
/** The prompt language is the one read not yet answered on hardware, so a silent aid leaves it unknown. */
|
|
40
|
+
const readLanguage = connection => connection.read(_frame.EAR.main, _frame.COMMAND.promptLanguage).then(_values.languageOf, () => null);
|
|
41
|
+
|
|
42
|
+
/** Reads what the status shows: per ear its battery, in-ear and in-case; for the pair its settings. */
|
|
43
|
+
const readStatus = async connection => {
|
|
44
|
+
const ears = {};
|
|
45
|
+
for (const ear of (0, _replies.linkedEars)(connection.ears)) {
|
|
46
|
+
ears[sideOf(ear)] = await readEar(connection, ear);
|
|
47
|
+
}
|
|
48
|
+
const noise = await connection.read(_frame.EAR.main, _frame.COMMAND.noiseReduction);
|
|
49
|
+
return {
|
|
50
|
+
kind: "hearing-aid",
|
|
51
|
+
mainEar: sideOf(connection.ears.main),
|
|
52
|
+
ears,
|
|
53
|
+
volume: (0, _values.volumeOf)(await connection.read(_frame.EAR.main, _frame.COMMAND.volume)),
|
|
54
|
+
mode: (0, _values.modeOf)(await connection.read(_frame.EAR.main, _frame.COMMAND.mode)),
|
|
55
|
+
noiseReduction: (0, _values.flagOf)(noise),
|
|
56
|
+
noiseScene: (0, _values.sceneOf)(noise),
|
|
57
|
+
microphone: null,
|
|
58
|
+
inEarDetection: (0, _values.flagOf)(await connection.read(_frame.EAR.main, _frame.COMMAND.inEarDetection)),
|
|
59
|
+
promptLanguage: await readLanguage(connection)
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
exports.readStatus = readStatus;
|
|
63
|
+
const withEar = (state, side, change) => {
|
|
64
|
+
const current = side ? state.ears[side] : undefined;
|
|
65
|
+
return side && current ? {
|
|
66
|
+
...state,
|
|
67
|
+
ears: {
|
|
68
|
+
...state.ears,
|
|
69
|
+
[side]: {
|
|
70
|
+
...current,
|
|
71
|
+
...change
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
} : state;
|
|
75
|
+
};
|
|
76
|
+
/** How each report the status shows changes it. */
|
|
77
|
+
const REPORT_UPDATES = {
|
|
78
|
+
[_frame.REPORT.volume]: (state, {
|
|
79
|
+
data
|
|
80
|
+
}) => ({
|
|
81
|
+
...state,
|
|
82
|
+
volume: (0, _values.volumeOf)(data)
|
|
83
|
+
}),
|
|
84
|
+
[_frame.REPORT.noiseReduction]: (state, {
|
|
85
|
+
data
|
|
86
|
+
}) => ({
|
|
87
|
+
...state,
|
|
88
|
+
noiseReduction: (0, _values.flagOf)(data),
|
|
89
|
+
noiseScene: (0, _values.sceneOf)(data)
|
|
90
|
+
}),
|
|
91
|
+
[_frame.REPORT.mode]: (state, {
|
|
92
|
+
data
|
|
93
|
+
}) => ({
|
|
94
|
+
...state,
|
|
95
|
+
mode: (0, _values.modeOf)(data)
|
|
96
|
+
}),
|
|
97
|
+
[_frame.REPORT.inEar]: (state, {
|
|
98
|
+
ear,
|
|
99
|
+
data
|
|
100
|
+
}) => withEar(state, SIDE[ear], {
|
|
101
|
+
inEar: (0, _values.flagOf)(data)
|
|
102
|
+
}),
|
|
103
|
+
[_frame.REPORT.inCase]: (state, {
|
|
104
|
+
ear,
|
|
105
|
+
data
|
|
106
|
+
}) => withEar(state, SIDE[ear], {
|
|
107
|
+
inCase: (0, _values.flagOf)(data)
|
|
108
|
+
})
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/** The state after one report the aid sent by itself; a report the status does not show leaves it as it was. */
|
|
112
|
+
const withReport = (state, report) => REPORT_UPDATES[report.command]?.(state, report) ?? state;
|
|
113
|
+
exports.withReport = withReport;
|
|
114
|
+
const readBatteries = async connection => {
|
|
115
|
+
const batteries = {};
|
|
116
|
+
for (const ear of (0, _replies.linkedEars)(connection.ears)) {
|
|
117
|
+
batteries[sideOf(ear)] = await readBattery(connection, ear);
|
|
118
|
+
}
|
|
119
|
+
return batteries;
|
|
120
|
+
};
|
|
121
|
+
const withBatteries = (state, batteries) => Object.entries(batteries).reduce((next, [side, battery]) => withEar(next, side, battery), state);
|
|
122
|
+
|
|
123
|
+
/** Streams the pair's status until `signal` aborts: all of it once, then every change and its batteries every minute. */
|
|
124
|
+
const streamStatus = async (connection, onFrame, signal) => {
|
|
125
|
+
let state = await readStatus(connection);
|
|
126
|
+
const publish = next => {
|
|
127
|
+
state = next;
|
|
128
|
+
onFrame({
|
|
129
|
+
state
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
publish(state);
|
|
133
|
+
const stopReports = connection.onReport(report => publish(withReport(state, report)));
|
|
134
|
+
const stopChanges = connection.onChanged(change => {
|
|
135
|
+
if (change.kind !== "factory-reset") {
|
|
136
|
+
publish((0, _settings.withChange)(state, change));
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
readStatus(connection).then(publish).catch(() => connection.logger.warn("famidoc-hearing-aid.status.reread-failed"));
|
|
140
|
+
});
|
|
141
|
+
const refresh = setInterval(() => {
|
|
142
|
+
readBatteries(connection).then(batteries => publish(withBatteries(state, batteries))).catch(() => connection.logger.warn("famidoc-hearing-aid.battery.refresh-failed"));
|
|
143
|
+
}, BATTERY_REFRESH_MS);
|
|
144
|
+
try {
|
|
145
|
+
await (0, _waiting.untilAborted)(signal);
|
|
146
|
+
} finally {
|
|
147
|
+
stopReports();
|
|
148
|
+
stopChanges();
|
|
149
|
+
clearInterval(refresh);
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
exports.streamStatus = streamStatus;
|
|
153
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_waiting","require","_frame","_replies","_settings","_values","BATTERY_REFRESH_MS","exports","SIDE","EAR","left","right","sideOf","ear","readBattery","read","percent","charging","batteryOf","COMMAND","battery","readEar","connection","inEar","flagOf","inCase","readLanguage","main","promptLanguage","then","languageOf","readStatus","ears","linkedEars","noise","noiseReduction","kind","mainEar","volume","volumeOf","mode","modeOf","noiseScene","sceneOf","microphone","inEarDetection","withEar","state","side","change","current","undefined","REPORT_UPDATES","REPORT","data","withReport","report","command","readBatteries","batteries","withBatteries","Object","entries","reduce","next","streamStatus","onFrame","signal","publish","stopReports","onReport","stopChanges","onChanged","withChange","catch","logger","warn","refresh","setInterval","untilAborted","clearInterval"],"sourceRoot":"../../../../../../../src","sources":["modules/next/bluetooth/families/famidoc-hearing-aid/status.ts"],"mappings":";;;;;;AAEA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAEA;AACA,MAAMK,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG,MAAM;AAEjC,MAAME,IAAuC,GAAG;EAAE,CAACC,UAAG,CAACC,IAAI,GAAG,MAAM;EAAE,CAACD,UAAG,CAACE,KAAK,GAAG;AAAQ,CAAC;;AAE5F;AACA,MAAMC,MAAM,GAAIC,GAAQ,IAAeA,GAAG,KAAKJ,UAAG,CAACC,IAAI,GAAG,MAAM,GAAG,OAAQ;AAI3E,MAAMI,WAAW,GAAG,MAAAA,CAAO;EAAEC;AAA2B,CAAC,EAAEF,GAAQ,KAAsD;EACvH,MAAM;IAAEG,OAAO;IAAEC;EAAS,CAAC,GAAG,IAAAC,kBAAS,EAAC,MAAMH,IAAI,CAACF,GAAG,EAAEM,cAAO,CAACC,OAAO,CAAC,CAAC;EAEzE,OAAO;IAAEA,OAAO,EAAEJ,OAAO;IAAEC;EAAS,CAAC;AACvC,CAAC;AAED,MAAMI,OAAO,GAAG,MAAAA,CAAOC,UAAgC,EAAET,GAAQ,MAAyB;EACxF,IAAI,MAAMC,WAAW,CAACQ,UAAU,EAAET,GAAG,CAAC,CAAC;EACvCU,KAAK,EAAE,IAAAC,cAAM,EAAC,MAAMF,UAAU,CAACP,IAAI,CAACF,GAAG,EAAEM,cAAO,CAACI,KAAK,CAAC,CAAC;EACxDE,MAAM,EAAE,IAAAD,cAAM,EAAC,MA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+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.volumeOf = exports.sceneOf = exports.noiseByte = exports.modeOf = exports.languageOf = exports.flagOf = exports.clampedVolume = exports.MODES = exports.MAX_VOLUME = exports.LANGUAGES = void 0;
|
|
7
|
+
const FLAG = 0x01;
|
|
8
|
+
const VOLUME_MASK = 0x1f;
|
|
9
|
+
const TWO_BITS = 0x03;
|
|
10
|
+
const SCENE_SHIFT = 1;
|
|
11
|
+
|
|
12
|
+
/** The protocol document gives the volume as 0 to 16. */
|
|
13
|
+
const MAX_VOLUME = exports.MAX_VOLUME = 16;
|
|
14
|
+
|
|
15
|
+
/** The mode bits in order; the last value is reserved. */
|
|
16
|
+
const MODES = exports.MODES = ["mixed", "hearing-aid", "earphone", null];
|
|
17
|
+
|
|
18
|
+
/** The noise scene bits in order. */
|
|
19
|
+
const SCENES = ["general", "outdoor", "meeting", "cinema"];
|
|
20
|
+
|
|
21
|
+
/** The prompt language bit in order. */
|
|
22
|
+
const LANGUAGES = exports.LANGUAGES = ["chinese", "english"];
|
|
23
|
+
const flagOf = data => ((data[0] ?? 0) & FLAG) !== 0;
|
|
24
|
+
exports.flagOf = flagOf;
|
|
25
|
+
const volumeOf = data => ({
|
|
26
|
+
level: Math.min((data[0] ?? 0) & VOLUME_MASK, MAX_VOLUME),
|
|
27
|
+
max: MAX_VOLUME
|
|
28
|
+
});
|
|
29
|
+
exports.volumeOf = volumeOf;
|
|
30
|
+
const modeOf = data => MODES[(data[0] ?? 0) & TWO_BITS] ?? null;
|
|
31
|
+
|
|
32
|
+
/** The noise reduction byte holds the scene in bits 2–1 and whether it is on in bit 0. */
|
|
33
|
+
exports.modeOf = modeOf;
|
|
34
|
+
const sceneOf = data => SCENES[(data[0] ?? 0) >> SCENE_SHIFT & TWO_BITS] ?? null;
|
|
35
|
+
exports.sceneOf = sceneOf;
|
|
36
|
+
const noiseByte = (on, scene) => SCENES.indexOf(scene) << SCENE_SHIFT | (on ? FLAG : 0);
|
|
37
|
+
exports.noiseByte = noiseByte;
|
|
38
|
+
const languageOf = data => LANGUAGES[(data[0] ?? 0) & FLAG] ?? null;
|
|
39
|
+
|
|
40
|
+
/** A volume within the steps the aid takes. */
|
|
41
|
+
exports.languageOf = languageOf;
|
|
42
|
+
const clampedVolume = level => Math.min(Math.max(Math.round(level), 0), MAX_VOLUME);
|
|
43
|
+
exports.clampedVolume = clampedVolume;
|
|
44
|
+
//# sourceMappingURL=values.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["FLAG","VOLUME_MASK","TWO_BITS","SCENE_SHIFT","MAX_VOLUME","exports","MODES","SCENES","LANGUAGES","flagOf","data","volumeOf","level","Math","min","max","modeOf","sceneOf","noiseByte","on","scene","indexOf","languageOf","clampedVolume","round"],"sourceRoot":"../../../../../../../src","sources":["modules/next/bluetooth/families/famidoc-hearing-aid/values.ts"],"mappings":";;;;;;AAEA,MAAMA,IAAI,GAAG,IAAI;AACjB,MAAMC,WAAW,GAAG,IAAI;AACxB,MAAMC,QAAQ,GAAG,IAAI;AACrB,MAAMC,WAAW,GAAG,CAAC;;AAErB;AACA,MAAMC,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAG,EAAE;;AAErB;AACA,MAAME,KAAyC,GAAAD,OAAA,CAAAC,KAAA,GAAG,CAAC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,IAAI,CAAC;;AAE5F;AACA,MAAMC,MAA6B,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC;;AAEjF;AACA,MAAMC,SAAoC,GAAAH,OAAA,CAAAG,SAAA,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC;AAEnE,MAAMC,MAAM,GAAIC,IAAgB,IAAc,CAAC,CAACA,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAIV,IAAI,MAAM,CAAC;AAACK,OAAA,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object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.statusOf = exports.encodeFrame = exports.dataOf = exports.STATUS = exports.MONITOR_FRAMING = exports.MEASUREMENT_MARKER = exports.COMMAND = void 0;
|
|
7
|
+
var _crc8Maxim = require("../../codec/crc8-maxim.js");
|
|
7
8
|
var _frameStream = require("../frame-tools/frame-stream.js");
|
|
8
9
|
var _numbers = require("../frame-tools/numbers.js");
|
|
9
|
-
var _crc = require("./crc.js");
|
|
10
10
|
const PHONE_HEADER = [0xbe, 0xb0];
|
|
11
11
|
const MONITOR_HEADER = [0xd0, 0xc2];
|
|
12
12
|
const LENGTH_AT = 2;
|
|
@@ -37,10 +37,10 @@ const MEASUREMENT_MARKER = exports.MEASUREMENT_MARKER = 0xcc;
|
|
|
37
37
|
/** A phone frame: `be b0`, the length of command and payload, the command, the payload and the CRC-8/MAXIM of all of it. */
|
|
38
38
|
const encodeFrame = (command, payload = []) => {
|
|
39
39
|
const body = [...PHONE_HEADER, payload.length + COMMAND_BYTES, command, ...payload];
|
|
40
|
-
return Uint8Array.from([...body, (0,
|
|
40
|
+
return Uint8Array.from([...body, (0, _crc8Maxim.crc8Maxim)(body)]);
|
|
41
41
|
};
|
|
42
42
|
exports.encodeFrame = encodeFrame;
|
|
43
|
-
const isIntact = frame => (0,
|
|
43
|
+
const isIntact = frame => (0, _crc8Maxim.crc8Maxim)(frame.subarray(0, frame.length - CHECKSUM_BYTES)) === frame[frame.length - CHECKSUM_BYTES];
|
|
44
44
|
|
|
45
45
|
/** Cuts the monitor's notifications into frames that start with `d0 c2` and hold their checksum. */
|
|
46
46
|
const MONITOR_FRAMING = exports.MONITOR_FRAMING = (0, _frameStream.framingOf)({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_crc8Maxim","require","_frameStream","_numbers","PHONE_HEADER","MONITOR_HEADER","LENGTH_AT","DATA_AT","CHECKSUM_BYTES","COMMAND_BYTES","STATUS_BYTES","FRAME_OVERHEAD","COMMAND","exports","handshake","setTime","turnOff","STATUS","ok","busy","MEASUREMENT_MARKER","encodeFrame","command","payload","body","length","Uint8Array","from","crc8Maxim","isIntact","frame","subarray","MONITOR_FRAMING","framingOf","header","lengthOf","held","undefined","accepts","dataOf","statusOf","data","u16be"],"sourceRoot":"../../../../../../../src","sources":["modules/next/bluetooth/families/finicare/frame.ts"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAGA,MAAMG,YAAY,GAAG,CAAC,IAAI,EAAE,IAAI,CAAU;AAC1C,MAAMC,cAAc,GAAG,CAAC,IAAI,EAAE,IAAI,CAAU;AAC5C,MAAMC,SAAS,GAAG,CAAC;AACnB,MAAMC,OAAO,GAAG,CAAC;AACjB,MAAMC,cAAc,GAAG,CAAC;AACxB,MAAMC,aAAa,GAAG,CAAC;AACvB,MAAMC,YAAY,GAAG,CAAC;;AAEtB;AACA,MAAMC,cAAc,GAAGJ,OAAO,GAAGC,cAAc;;AAE/C;AACA,MAAMI,OAAO,GAAAC,OAAA,CAAAD,OAAA,GAAG;EAAEE,SAAS,EAAE,IAAI;EAAEC,OAAO,EAAE,IAAI;EAAEC,OAAO,EAAE;AAAK,CAAU;;AAE1E;AACA,MAAMC,MAAM,GAAAJ,OAAA,CAAAI,MAAA,GAAG;EAAEC,EAAE,EAAE,MAAM;EAAEC,IAAI,EAAE;AAAO,CAAU;;AAEpD;AACA,MAAMC,kBAAkB,GAAAP,OAAA,CAAAO,kBAAA,GAAG,IAAI;;AAE/B;AACA,MAAMC,WAAW,GAAGA,CAACC,OAAe,EAAEC,OAA0B,GAAG,EAAE,KAAiB;EACpF,MAAMC,IAAI,GAAG,CAAC,GAAGpB,YAAY,EAAEmB,OAAO,CAACE,MAAM,GAAGhB,aAAa,EAAEa,OAAO,EAAE,GAAGC,OAAO,CAAC;EAEnF,OAAOG,UAAU,CAACC,IAAI,CAAC,CAAC,GAAGH,IAAI,EAAE,IAAAI,oBAAS,EAACJ,IAAI,CAAC,CAAC,CAAC;AACpD,CAAC;AAACX,OAAA,CAAAQ,WAAA,GAAAA,WAAA;AAEF,MAAMQ,QAAQ,GAAIC,KAAiB,IAAc,IAAAF,oBAAS,EAACE,KAAK,CAACC,QAAQ,CAAC,CAAC,EAAED,KAAK,CAACL,MAAM,GAAGjB,cAAc,CAAC,CAAC,KAAKsB,KAAK,CAACA,KAAK,CAACL,MAAM,GAAGjB,cAAc,CAAC;;AAErJ;AACA,MAAMwB,eAAwB,GAAAnB,OAAA,CAAAmB,eAAA,GAAG,IAAAC,sBAAS,EAAC;EACzCC,MAAM,EAAE7B,cAAc;EACtB8B,QAAQ,EAAGC,IAAI,IAAMA,IAAI,CAACX,MAAM,GAAGnB,SAAS,GAAG,CAAC8B,IAAI,CAAC9B,SAAS,CAAC,IAAI,CAAC,IAAIK,cAAc,GAAG0B,SAAU;EACnGC,OAAO,EAAET;AACX,CAAC,CAAC;;AAEF;AACA,MAAMU,MAAM,GAAIT,KAAiB,IAAiBA,KAAK,CAACC,QAAQ,CAACxB,OAAO,EAAEuB,KAAK,CAACL,MAAM,GAAGjB,cAAc,CAAC;;AAExG;AAAAK,OAAA,CAAA0B,MAAA,GAAAA,MAAA;AACA,MAAMC,QAAQ,GAAIC,IAAgB,IAA0BA,IAAI,CAAChB,MAAM,KAAKf,YAAY,GAAG,IAAAgC,cAAK,EAACD,IAAI,EAAE,CAAC,CAAC,GAAGJ,SAAU;AAACxB,OAAA,CAAA2B,QAAA,GAAAA,QAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_ovokOutboxWatch","require","_ovokReadingSink","_storagePairedDevices","_bluetooth","_catalog","_device","_discovery","_errors","_builtIn","_context","_hooks","_useDevice","_useDiscovery","_react"],"sourceRoot":"../../../../../src","sources":["modules/next/bluetooth/shared.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,qBAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAEA,IAAAI,QAAA,GAAAJ,OAAA;AAEA,IAAAK,OAAA,GAAAL,OAAA;
|
|
1
|
+
{"version":3,"names":["_ovokOutboxWatch","require","_ovokReadingSink","_storagePairedDevices","_bluetooth","_catalog","_device","_discovery","_errors","_builtIn","_context","_hooks","_useDevice","_useDiscovery","_react"],"sourceRoot":"../../../../../src","sources":["modules/next/bluetooth/shared.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,qBAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAEA,IAAAI,QAAA,GAAAJ,OAAA;AAEA,IAAAK,OAAA,GAAAL,OAAA;AAsBA,IAAAM,UAAA,GAAAN,OAAA;AAEA,IAAAO,OAAA,GAAAP,OAAA;AA0BA,IAAAQ,QAAA,GAAAR,OAAA;AACA,IAAAS,QAAA,GAAAT,OAAA;AAEA,IAAAU,MAAA,GAAAV,OAAA;AACA,IAAAW,UAAA,GAAAX,OAAA;AAEA,IAAAY,aAAA,GAAAZ,OAAA;AACA,IAAAa,MAAA,GAAAb,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["REFLECTED_POLYNOMIAL","BITS_PER_BYTE","crc8Maxim","bytes","Array","from","reduce","crc","byte","value","bit"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/codec/crc8-maxim.ts"],"mappings":";;AAAA,MAAMA,oBAAoB,GAAG,IAAI;AACjC,MAAMC,aAAa,GAAG,CAAC;;AAEvB;AACA,MAAMC,SAAS,GAAIC,KAAwB,IACzCC,KAAK,CAACC,IAAI,CAACF,KAAK,CAAC,CAACG,MAAM,CAAC,CAACC,GAAG,EAAEC,IAAI,KAAK;EACtC,IAAIC,KAAK,GAAGF,GAAG,GAAGC,IAAI;EAEtB,KAAK,IAAIE,GAAG,GAAG,CAAC,EAAEA,GAAG,GAAGT,aAAa,EAAES,GAAG,IAAI,CAAC,EAAE;IAC/CD,KAAK,GAAGA,KAAK,GAAG,CAAC,GAAIA,KAAK,IAAI,CAAC,GAAIT,oBAAoB,GAAGS,KAAK,IAAI,CAAC;EACtE;EAEA,OAAOA,KAAK;AACd,CAAC,EAAE,CAAC,CAAC;AAEP,SAASP,SAAS","ignoreList":[]}
|
|
@@ -16,7 +16,8 @@ const ACTION_MEMBERS = {
|
|
|
16
16
|
records: [["records"]],
|
|
17
17
|
fetch: [["fetch"]],
|
|
18
18
|
live: [["live"]],
|
|
19
|
-
setClock: [["setClock"]]
|
|
19
|
+
setClock: [["setClock"]],
|
|
20
|
+
change: [["change"]]
|
|
20
21
|
};
|
|
21
22
|
|
|
22
23
|
/** The actions a protocol can run, from the members it has. */
|
|
@@ -54,7 +55,8 @@ const initialSnapshot = (record, model, protocol) => ({
|
|
|
54
55
|
rssi: null,
|
|
55
56
|
lastError: null,
|
|
56
57
|
unacknowledged: 0,
|
|
57
|
-
deviceStatus: null
|
|
58
|
+
deviceStatus: null,
|
|
59
|
+
deviceState: null
|
|
58
60
|
});
|
|
59
61
|
|
|
60
62
|
/** The display events one live frame becomes: its numbers, then its samples. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ACTION_MEMBERS","sync","records","fetch","live","setClock","actionsOf","protocol","Object","keys","filter","action","some","members","every","member","undefined","storedFields","record","model","name","lastConnectedAt","lastSyncedAt","lastSyncOutcome","lastReadingAt","battery","identity","autoSync","keepInBackground","initialSnapshot","address","id","vendor","pairedAt","connection","activity","measuringSince","progress","actions","lastSeenAt","rssi","lastError","unacknowledged","deviceStatus","liveEventsOf","values","waveform","kind"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/core/device-snapshot.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"names":["ACTION_MEMBERS","sync","records","fetch","live","setClock","change","actionsOf","protocol","Object","keys","filter","action","some","members","every","member","undefined","storedFields","record","model","name","lastConnectedAt","lastSyncedAt","lastSyncOutcome","lastReadingAt","battery","identity","autoSync","keepInBackground","initialSnapshot","address","id","vendor","pairedAt","connection","activity","measuringSince","progress","actions","lastSeenAt","rssi","lastError","unacknowledged","deviceStatus","deviceState","liveEventsOf","values","waveform","kind"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/core/device-snapshot.ts"],"mappings":";;AAOA;;AAGA;;AAGA;;AAuGA;;AA+CA;;AAUA;AACA,MAAMA,cAAoF,GAAG;EAC3FC,IAAI,EAAE,CAAC,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;EACzCC,OAAO,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC;EACtBC,KAAK,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;EAClBC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;EAChBC,QAAQ,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC;EACxBC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC;AACrB,CAAC;;AAED;AACA,MAAMC,SAAS,GAAIC,QAAwB,IACxCC,MAAM,CAACC,IAAI,CAACV,cAAc,CAAC,CAAoBW,MAAM,CAAEC,MAAM,IAC5DZ,cAAc,CAACY,MAAM,CAAC,CAACC,IAAI,CAAEC,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AAc,EAAE,CAAC;EACjBC,YAAY,EAAE,IAAI;EAClBC,WAAW,EAAE;AACf,CAAC,CAAC;;AAEF;AACA,MAAMC,YAAY,GAAGA,CAAC;EAAEC,MAAM;EAAEC;AAAoB,CAAC,KAAoB,CACvE,IAAID,MAAM,GAAG,CAAC;EAAEE,IAAI,EAAE,MAAe;EAAEF;AAAO,CAAC,CAAC,GAAG,EAAE,CAAC,EACtD,IAAIC,QAAQ,GAAG,CAAC;EAAEC,IAAI,EAAE,UAAmB;EAAED;AAAS,CAAC,CAAC,GAAG,EAAE,CAAC,CAC/D;AAED,SAASzC,SAAS,EAAEuB,eAAe,EAAEgB,YAAY,EAAE5B,YAAY","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/core/device-state.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -73,6 +73,9 @@ class Device {
|
|
|
73
73
|
/** Sets the device's clock to now. */
|
|
74
74
|
setClock = () => this.run("setClock", connection => this.deps.protocol.setClock?.(connection, this.deps.now()) ?? Promise.reject(unsupported("clock")));
|
|
75
75
|
|
|
76
|
+
/** Changes one of the device's settings, such as a hearing aid's volume. */
|
|
77
|
+
change = change => this.run("change", connection => this.deps.protocol.change?.(connection, change) ?? Promise.reject(unsupported("settings")));
|
|
78
|
+
|
|
76
79
|
/** Starts `live` and `waveform` events, which the device also records and saves while it measures with `record` on. */
|
|
77
80
|
startLive = () => this.run("live", async connection => this.live.start((onFrame, signal) => this.deps.protocol.live?.(connection, onFrame, signal) ?? Promise.resolve()));
|
|
78
81
|
|