@ovok/native 1.17.0-dev.2295 → 1.17.0-dev.2299
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/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/famidoc-hearing-aid/frame.js +33 -6
- package/lib/commonjs/modules/next/bluetooth/families/famidoc-hearing-aid/frame.js.map +1 -1
- package/lib/commonjs/modules/next/bluetooth/families/famidoc-hearing-aid/protocol.js +5 -1
- package/lib/commonjs/modules/next/bluetooth/families/famidoc-hearing-aid/protocol.js.map +1 -1
- package/lib/commonjs/modules/next/bluetooth/families/famidoc-hearing-aid/replies.js +5 -23
- package/lib/commonjs/modules/next/bluetooth/families/famidoc-hearing-aid/replies.js.map +1 -1
- package/lib/commonjs/modules/next/bluetooth/families/famidoc-hearing-aid/session.js +37 -4
- package/lib/commonjs/modules/next/bluetooth/families/famidoc-hearing-aid/session.js.map +1 -1
- 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/shared.js.map +1 -1
- 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/famidoc-hearing-aid/frame.js +32 -5
- package/lib/module/modules/next/bluetooth/families/famidoc-hearing-aid/frame.js.map +1 -1
- package/lib/module/modules/next/bluetooth/families/famidoc-hearing-aid/protocol.js +5 -1
- package/lib/module/modules/next/bluetooth/families/famidoc-hearing-aid/protocol.js.map +1 -1
- package/lib/module/modules/next/bluetooth/families/famidoc-hearing-aid/replies.js +5 -23
- package/lib/module/modules/next/bluetooth/families/famidoc-hearing-aid/replies.js.map +1 -1
- package/lib/module/modules/next/bluetooth/families/famidoc-hearing-aid/session.js +38 -5
- package/lib/module/modules/next/bluetooth/families/famidoc-hearing-aid/session.js.map +1 -1
- 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/shared.js.map +1 -1
- 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/famidoc-hearing-aid/frame.d.ts +28 -3
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/famidoc-hearing-aid/frame.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/famidoc-hearing-aid/protocol.d.ts +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/famidoc-hearing-aid/protocol.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/famidoc-hearing-aid/replies.d.ts +4 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/famidoc-hearing-aid/replies.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/famidoc-hearing-aid/session.d.ts +13 -1
- package/lib/typescript/commonjs/src/modules/next/bluetooth/families/famidoc-hearing-aid/session.d.ts.map +1 -1
- 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/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/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/famidoc-hearing-aid/frame.d.ts +28 -3
- package/lib/typescript/module/src/modules/next/bluetooth/families/famidoc-hearing-aid/frame.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/families/famidoc-hearing-aid/protocol.d.ts +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/families/famidoc-hearing-aid/protocol.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/families/famidoc-hearing-aid/replies.d.ts +4 -1
- package/lib/typescript/module/src/modules/next/bluetooth/families/famidoc-hearing-aid/replies.d.ts.map +1 -1
- package/lib/typescript/module/src/modules/next/bluetooth/families/famidoc-hearing-aid/session.d.ts +13 -1
- package/lib/typescript/module/src/modules/next/bluetooth/families/famidoc-hearing-aid/session.d.ts.map +1 -1
- 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/shared.d.ts +1 -0
- package/lib/typescript/module/src/modules/next/bluetooth/shared.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -4,7 +4,7 @@ import { fullUuid } from "../../core/advertisement.js";
|
|
|
4
4
|
import { DeviceError } from "../../core/errors.js";
|
|
5
5
|
import { Exchange } from "../../core/exchange.js";
|
|
6
6
|
import { listenToFrames, writeFrame } from "../frame-tools/frame-link.js";
|
|
7
|
-
import { AID_FRAMING, COMMAND, COUNT_MASK, decodeFrame, EAR,
|
|
7
|
+
import { AID_FRAMING, COMMAND, COUNT_MASK, decodeFrame, EAR, encodeRequest, isReply } from "./frame.js";
|
|
8
8
|
import { earsOf } from "./replies.js";
|
|
9
9
|
|
|
10
10
|
/** The service the phone talks to the aid through; the OTA and audio services are left alone. */
|
|
@@ -20,6 +20,23 @@ const REPLY_TIMING = {
|
|
|
20
20
|
|
|
21
21
|
/** One open link: which ears are linked, and how to read from one. */
|
|
22
22
|
|
|
23
|
+
/** The reply's first data bit is set when the aid refused a change. */
|
|
24
|
+
const REFUSED = 0x01;
|
|
25
|
+
|
|
26
|
+
/** Lets listeners in and out, and calls each one with what happened. */
|
|
27
|
+
const listeners = () => {
|
|
28
|
+
const all = new Set();
|
|
29
|
+
return {
|
|
30
|
+
add: listener => {
|
|
31
|
+
all.add(listener);
|
|
32
|
+
return () => {
|
|
33
|
+
all.delete(listener);
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
call: value => all.forEach(listener => listener(value))
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
23
40
|
/** Counts from 1 to 63 and round again, so a reply names the request it answers. */
|
|
24
41
|
const counter = () => {
|
|
25
42
|
let count = 0;
|
|
@@ -36,13 +53,23 @@ const openSession = async ({
|
|
|
36
53
|
}) => {
|
|
37
54
|
const exchange = new Exchange(REPLY_TIMING);
|
|
38
55
|
const nextCount = counter();
|
|
39
|
-
const
|
|
56
|
+
const reports = listeners();
|
|
57
|
+
const changes = listeners();
|
|
58
|
+
const request = async (ear, command, data = []) => {
|
|
40
59
|
const count = nextCount();
|
|
41
60
|
const answers = reply => reply.ear === ear && reply.count === count && reply.command === command;
|
|
61
|
+
const frame = encodeRequest(ear, count, command, data);
|
|
42
62
|
const {
|
|
43
|
-
data
|
|
44
|
-
} = await exchange.request(() => writeFrame(link, AID_SERVICE, WRITE,
|
|
45
|
-
return
|
|
63
|
+
data: replyData
|
|
64
|
+
} = await exchange.request(() => writeFrame(link, AID_SERVICE, WRITE, frame), answers);
|
|
65
|
+
return replyData;
|
|
66
|
+
};
|
|
67
|
+
const read = (ear, command) => request(ear, command);
|
|
68
|
+
const write = async (command, data) => {
|
|
69
|
+
const reply = await request(EAR.main, command, data);
|
|
70
|
+
if (((reply[0] ?? REFUSED) & REFUSED) !== 0) {
|
|
71
|
+
throw new DeviceError("protocol", "The hearing aid refused the change");
|
|
72
|
+
}
|
|
46
73
|
};
|
|
47
74
|
const stop = await listenToFrames(link, [{
|
|
48
75
|
service: AID_SERVICE,
|
|
@@ -57,6 +84,7 @@ const openSession = async ({
|
|
|
57
84
|
logger.debug("famidoc-hearing-aid.report.received", {
|
|
58
85
|
command: frame.command
|
|
59
86
|
});
|
|
87
|
+
reports.call(frame);
|
|
60
88
|
}
|
|
61
89
|
},
|
|
62
90
|
onDisconnect: () => exchange.fail(new DeviceError("disconnected", "The hearing aid dropped the link"))
|
|
@@ -65,6 +93,11 @@ const openSession = async ({
|
|
|
65
93
|
return {
|
|
66
94
|
ears: earsOf(await read(EAR.main, COMMAND.connection)),
|
|
67
95
|
read,
|
|
96
|
+
write,
|
|
97
|
+
onReport: reports.add,
|
|
98
|
+
onChanged: changes.add,
|
|
99
|
+
changed: changes.call,
|
|
100
|
+
logger,
|
|
68
101
|
stop
|
|
69
102
|
};
|
|
70
103
|
} catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["fullUuid","DeviceError","Exchange","listenToFrames","writeFrame","AID_FRAMING","COMMAND","COUNT_MASK","decodeFrame","EAR","
|
|
1
|
+
{"version":3,"names":["fullUuid","DeviceError","Exchange","listenToFrames","writeFrame","AID_FRAMING","COMMAND","COUNT_MASK","decodeFrame","EAR","encodeRequest","isReply","earsOf","AID_SERVICE","WRITE","NOTIFY","REPLY_TIMING","replyTimeoutMs","attempts","REFUSED","listeners","all","Set","add","listener","delete","call","value","forEach","counter","count","openSession","link","logger","exchange","nextCount","reports","changes","request","ear","command","data","answers","reply","frame","replyData","read","write","main","stop","service","characteristic","framing","onFrame","bytes","receive","debug","onDisconnect","fail","ears","connection","onReport","onChanged","changed","error"],"sourceRoot":"../../../../../../../src","sources":["modules/next/bluetooth/families/famidoc-hearing-aid/session.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,6BAA0B;AAEnD,SAASC,WAAW,QAAQ,sBAAmB;AAC/C,SAASC,QAAQ,QAAwB,wBAAqB;AAG9D,SAASC,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AAO,EAAErC,WAAW;IAAEsC,cAAc,EAAEpC,MAAM;IAAEqC,OAAO,EAAE/C;EAAY,CAAC,CAAC,EAAE;IAChHgD,OAAO,EAAGC,KAAK,IAAK;MAClB,MAAMV,KAAK,GAAGpC,WAAW,CAAC8C,KAAK,CAAC;MAEhC,IAAI3C,OAAO,CAACiC,KAAK,CAAC,EAAE;QAClBV,QAAQ,CAACqB,OAAO,CAACX,KAAK,CAAC;MACzB,CAAC,MAAM;QACLX,MAAM,CAACuB,KAAK,CAAC,qCAAqC,EAAE;UAAEhB,OAAO,EAAEI,KAAK,CAACJ;QAAQ,CAAC,CAAC;QAC/EJ,OAAO,CAACV,IAAI,CAACkB,KAAK,CAAC;MACrB;IACF,CAAC;IACDa,YAAY,EAAEA,CAAA,KAAMvB,QAAQ,CAACwB,IAAI,CAAC,IAAIzD,WAAW,CAAC,cAAc,EAAE,kCAAkC,CAAC;EACvG,CAAC,CAAC;EAEF,IAAI;IACF,OAAO;MACL0D,IAAI,EAAE/C,MAAM,CAAC,MAAMkC,IAAI,CAACrC,GAAG,CAACuC,IAAI,EAAE1C,OAAO,CAACsD,UAAU,CAAC,CAAC;MACtDd,IAAI;MACJC,KAAK;MACLc,QAAQ,EAAEzB,OAAO,CAACb,GAAG;MACrBuC,SAAS,EAAEzB,OAAO,CAACd,GAAG;MACtBwC,OAAO,EAAE1B,OAAO,CAACX,IAAI;MACrBO,MAAM;MACNgB;IACF,CAAC;EACH,CAAC,CAAC,OAAOe,KAAK,EAAE;IACdf,IAAI,CAAC,CAAC;IACN,MAAMe,KAAK;EACb;AACF,CAAC;AAED,SAASnD,WAAW,EAAEkB,WAAW","ignoreList":[]}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { SETTING } from "./frame.js";
|
|
4
|
+
import { clampedVolume, LANGUAGES, MAX_VOLUME, MODES, noiseByte } from "./values.js";
|
|
5
|
+
|
|
6
|
+
/** The command a change is sent with and its data. */
|
|
7
|
+
|
|
8
|
+
const BIT_ON = 1;
|
|
9
|
+
const BIT_OFF = 0;
|
|
10
|
+
|
|
11
|
+
/** What the phone sends for each change. */
|
|
12
|
+
const REQUESTS = {
|
|
13
|
+
volume: ({
|
|
14
|
+
level
|
|
15
|
+
}) => ({
|
|
16
|
+
command: SETTING.volume,
|
|
17
|
+
data: [clampedVolume(level)]
|
|
18
|
+
}),
|
|
19
|
+
mode: ({
|
|
20
|
+
mode
|
|
21
|
+
}) => ({
|
|
22
|
+
command: SETTING.mode,
|
|
23
|
+
data: [MODES.indexOf(mode)]
|
|
24
|
+
}),
|
|
25
|
+
"noise-reduction": ({
|
|
26
|
+
on,
|
|
27
|
+
scene
|
|
28
|
+
}) => ({
|
|
29
|
+
command: SETTING.noiseReduction,
|
|
30
|
+
data: [noiseByte(on, scene)]
|
|
31
|
+
}),
|
|
32
|
+
microphone: ({
|
|
33
|
+
direction
|
|
34
|
+
}) => ({
|
|
35
|
+
command: SETTING.microphone,
|
|
36
|
+
data: [direction === "front" ? BIT_ON : BIT_OFF]
|
|
37
|
+
}),
|
|
38
|
+
"in-ear-detection": ({
|
|
39
|
+
on
|
|
40
|
+
}) => ({
|
|
41
|
+
command: SETTING.inEarDetection,
|
|
42
|
+
data: [on ? BIT_ON : BIT_OFF]
|
|
43
|
+
}),
|
|
44
|
+
"prompt-language": ({
|
|
45
|
+
language
|
|
46
|
+
}) => ({
|
|
47
|
+
command: SETTING.promptLanguage,
|
|
48
|
+
data: [LANGUAGES.indexOf(language)]
|
|
49
|
+
}),
|
|
50
|
+
"factory-reset": () => ({
|
|
51
|
+
command: SETTING.factoryReset,
|
|
52
|
+
data: []
|
|
53
|
+
})
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/** How each change the aid took moves the status; a factory reset is read again instead. */
|
|
57
|
+
const UPDATES = {
|
|
58
|
+
volume: (state, {
|
|
59
|
+
level
|
|
60
|
+
}) => ({
|
|
61
|
+
...state,
|
|
62
|
+
volume: {
|
|
63
|
+
level: clampedVolume(level),
|
|
64
|
+
max: MAX_VOLUME
|
|
65
|
+
}
|
|
66
|
+
}),
|
|
67
|
+
mode: (state, {
|
|
68
|
+
mode
|
|
69
|
+
}) => ({
|
|
70
|
+
...state,
|
|
71
|
+
mode
|
|
72
|
+
}),
|
|
73
|
+
"noise-reduction": (state, {
|
|
74
|
+
on,
|
|
75
|
+
scene
|
|
76
|
+
}) => ({
|
|
77
|
+
...state,
|
|
78
|
+
noiseReduction: on,
|
|
79
|
+
noiseScene: scene
|
|
80
|
+
}),
|
|
81
|
+
microphone: (state, {
|
|
82
|
+
direction
|
|
83
|
+
}) => ({
|
|
84
|
+
...state,
|
|
85
|
+
microphone: direction
|
|
86
|
+
}),
|
|
87
|
+
"in-ear-detection": (state, {
|
|
88
|
+
on
|
|
89
|
+
}) => ({
|
|
90
|
+
...state,
|
|
91
|
+
inEarDetection: on
|
|
92
|
+
}),
|
|
93
|
+
"prompt-language": (state, {
|
|
94
|
+
language
|
|
95
|
+
}) => ({
|
|
96
|
+
...state,
|
|
97
|
+
promptLanguage: language
|
|
98
|
+
}),
|
|
99
|
+
"factory-reset": state => state
|
|
100
|
+
};
|
|
101
|
+
const requestOf = change => REQUESTS[change.kind](change);
|
|
102
|
+
|
|
103
|
+
/** The status after a change the aid took. */
|
|
104
|
+
const withChange = (state, change) => UPDATES[change.kind](state, change);
|
|
105
|
+
|
|
106
|
+
/** Sends one change to the aid, then tells the live status once the aid took it. */
|
|
107
|
+
const applyChange = async (connection, change) => {
|
|
108
|
+
const {
|
|
109
|
+
command,
|
|
110
|
+
data
|
|
111
|
+
} = requestOf(change);
|
|
112
|
+
await connection.write(command, data);
|
|
113
|
+
connection.changed(change);
|
|
114
|
+
};
|
|
115
|
+
export { applyChange, requestOf, withChange };
|
|
116
|
+
//# sourceMappingURL=settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["SETTING","clampedVolume","LANGUAGES","MAX_VOLUME","MODES","noiseByte","BIT_ON","BIT_OFF","REQUESTS","volume","level","command","data","mode","indexOf","noise-reduction","on","scene","noiseReduction","microphone","direction","in-ear-detection","inEarDetection","prompt-language","language","promptLanguage","factory-reset","factoryReset","UPDATES","state","max","noiseScene","requestOf","change","kind","withChange","applyChange","connection","write","changed"],"sourceRoot":"../../../../../../../src","sources":["modules/next/bluetooth/families/famidoc-hearing-aid/settings.ts"],"mappings":";;AAEA,SAASA,OAAO,QAAQ,YAAS;AAEjC,SAASC,aAAa,EAAEC,SAAS,EAAEC,UAAU,EAAEC,KAAK,EAAEC,SAAS,QAAQ,aAAU;;AAKjF;;AAGA,MAAMC,MAAM,GAAG,CAAC;AAChB,MAAMC,OAAO,GAAG,CAAC;;AAEjB;AACA,MAAMC,QAAkE,GAAG;EACzEC,MAAM,EAAEA,CAAC;IAAEC;EAAM,CAAC,MAAM;IAAEC,OAAO,EAAEX,OAAO,CAACS,MAAM;IAAEG,IAAI,EAAE,CAACX,aAAa,CAACS,KAAK,CAAC;EAAE,CAAC,CAAC;EAClFG,IAAI,EAAEA,CAAC;IAAEA;EAAK,CAAC,MAAM;IAAEF,OAAO,EAAEX,OAAO,CAACa,IAAI;IAAED,IAAI,EAAE,CAACR,KAAK,CAACU,OAAO,CAACD,IAAI,CAAC;EAAE,CAAC,CAAC;EAC5E,iBAAiB,EAAEE,CAAC;IAAEC,EAAE;IAAEC;EAAM,CAAC,MAAM;IAAEN,OAAO,EAAEX,OAAO,CAACkB,cAAc;IAAEN,IAAI,EAAE,CAACP,SAAS,CAACW,EAAE,EAAEC,KAAK,CAAC;EAAE,CAAC,CAAC;EACzGE,UAAU,EAAEA,CAAC;IAAEC;EAAU,CAAC,MAAM;IAAET,OAAO,EAAEX,OAAO,CAACmB,UAAU;IAAEP,IAAI,EAAE,CAACQ,SAAS,KAAK,OAAO,GAAGd,MAAM,GAAGC,OAAO;EAAE,CAAC,CAAC;EAClH,kBAAkB,EAAEc,CAAC;IAAEL;EAAG,CAAC,MAAM;IAA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K,KAAK;IAAEJ,cAAc,EAAED;EAAS,CAAC,CAAC;EACpF,eAAe,EAAGK,KAAK,IAAKA;AAC9B,CAAC;AAED,MAAMG,SAAS,GAAIC,MAAwB,IACxCzB,QAAQ,CAACyB,MAAM,CAACC,IAAI,CAAC,CAAkDD,MAAM,CAAC;;AAEjF;AACA,MAAME,UAAU,GAAGA,CAACN,KAAsB,EAAEI,MAAwB,KACjEL,OAAO,CAACK,MAAM,CAACC,IAAI,CAAC,CAA2EL,KAAK,EAAEI,MAAM,CAAC;;AAEhH;AACA,MAAMG,WAAW,GAAG,MAAAA,CAAOC,UAAgC,EAAEJ,MAAwB,KAAoB;EACvG,MAAM;IAAEtB,OAAO;IAAEC;EAAK,CAAC,GAAGoB,SAAS,CAACC,MAAM,CAAC;EAE3C,MAAMI,UAAU,CAACC,KAAK,CAAC3B,OAAO,EAAEC,IAAI,CAAC;EACrCyB,UAAU,CAACE,OAAO,CAACN,MAAM,CAAC;AAC5B,CAAC;AAED,SAASG,WAAW,EAAEJ,SAAS,EAAEG,UAAU","ignoreList":[]}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { untilAborted } from "../sig/waiting.js";
|
|
4
|
+
import { COMMAND, EAR, REPORT } from "./frame.js";
|
|
5
|
+
import { batteryOf, linkedEars } from "./replies.js";
|
|
6
|
+
import { withChange } from "./settings.js";
|
|
7
|
+
import { flagOf, languageOf, modeOf, sceneOf, volumeOf } from "./values.js";
|
|
8
|
+
|
|
9
|
+
/** A battery drains slowly and the aid reports only a low one by itself, so it is read again this often. */
|
|
10
|
+
const BATTERY_REFRESH_MS = 60_000;
|
|
11
|
+
const SIDE = {
|
|
12
|
+
[EAR.left]: "left",
|
|
13
|
+
[EAR.right]: "right"
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/** A linked ear is always the left or the right one; only reads to the pair go to the main ear. */
|
|
17
|
+
const sideOf = ear => ear === EAR.left ? "left" : "right";
|
|
18
|
+
const readBattery = async ({
|
|
19
|
+
read
|
|
20
|
+
}, ear) => {
|
|
21
|
+
const {
|
|
22
|
+
percent,
|
|
23
|
+
charging
|
|
24
|
+
} = batteryOf(await read(ear, COMMAND.battery));
|
|
25
|
+
return {
|
|
26
|
+
battery: percent,
|
|
27
|
+
charging
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
const readEar = async (connection, ear) => ({
|
|
31
|
+
...(await readBattery(connection, ear)),
|
|
32
|
+
inEar: flagOf(await connection.read(ear, COMMAND.inEar)),
|
|
33
|
+
inCase: flagOf(await connection.read(ear, COMMAND.inCase))
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
/** The prompt language is the one read not yet answered on hardware, so a silent aid leaves it unknown. */
|
|
37
|
+
const readLanguage = connection => connection.read(EAR.main, COMMAND.promptLanguage).then(languageOf, () => null);
|
|
38
|
+
|
|
39
|
+
/** Reads what the status shows: per ear its battery, in-ear and in-case; for the pair its settings. */
|
|
40
|
+
const readStatus = async connection => {
|
|
41
|
+
const ears = {};
|
|
42
|
+
for (const ear of linkedEars(connection.ears)) {
|
|
43
|
+
ears[sideOf(ear)] = await readEar(connection, ear);
|
|
44
|
+
}
|
|
45
|
+
const noise = await connection.read(EAR.main, COMMAND.noiseReduction);
|
|
46
|
+
return {
|
|
47
|
+
kind: "hearing-aid",
|
|
48
|
+
mainEar: sideOf(connection.ears.main),
|
|
49
|
+
ears,
|
|
50
|
+
volume: volumeOf(await connection.read(EAR.main, COMMAND.volume)),
|
|
51
|
+
mode: modeOf(await connection.read(EAR.main, COMMAND.mode)),
|
|
52
|
+
noiseReduction: flagOf(noise),
|
|
53
|
+
noiseScene: sceneOf(noise),
|
|
54
|
+
microphone: null,
|
|
55
|
+
inEarDetection: flagOf(await connection.read(EAR.main, COMMAND.inEarDetection)),
|
|
56
|
+
promptLanguage: await readLanguage(connection)
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
const withEar = (state, side, change) => {
|
|
60
|
+
const current = side ? state.ears[side] : undefined;
|
|
61
|
+
return side && current ? {
|
|
62
|
+
...state,
|
|
63
|
+
ears: {
|
|
64
|
+
...state.ears,
|
|
65
|
+
[side]: {
|
|
66
|
+
...current,
|
|
67
|
+
...change
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
} : state;
|
|
71
|
+
};
|
|
72
|
+
/** How each report the status shows changes it. */
|
|
73
|
+
const REPORT_UPDATES = {
|
|
74
|
+
[REPORT.volume]: (state, {
|
|
75
|
+
data
|
|
76
|
+
}) => ({
|
|
77
|
+
...state,
|
|
78
|
+
volume: volumeOf(data)
|
|
79
|
+
}),
|
|
80
|
+
[REPORT.noiseReduction]: (state, {
|
|
81
|
+
data
|
|
82
|
+
}) => ({
|
|
83
|
+
...state,
|
|
84
|
+
noiseReduction: flagOf(data),
|
|
85
|
+
noiseScene: sceneOf(data)
|
|
86
|
+
}),
|
|
87
|
+
[REPORT.mode]: (state, {
|
|
88
|
+
data
|
|
89
|
+
}) => ({
|
|
90
|
+
...state,
|
|
91
|
+
mode: modeOf(data)
|
|
92
|
+
}),
|
|
93
|
+
[REPORT.inEar]: (state, {
|
|
94
|
+
ear,
|
|
95
|
+
data
|
|
96
|
+
}) => withEar(state, SIDE[ear], {
|
|
97
|
+
inEar: flagOf(data)
|
|
98
|
+
}),
|
|
99
|
+
[REPORT.inCase]: (state, {
|
|
100
|
+
ear,
|
|
101
|
+
data
|
|
102
|
+
}) => withEar(state, SIDE[ear], {
|
|
103
|
+
inCase: flagOf(data)
|
|
104
|
+
})
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/** The state after one report the aid sent by itself; a report the status does not show leaves it as it was. */
|
|
108
|
+
const withReport = (state, report) => REPORT_UPDATES[report.command]?.(state, report) ?? state;
|
|
109
|
+
const readBatteries = async connection => {
|
|
110
|
+
const batteries = {};
|
|
111
|
+
for (const ear of linkedEars(connection.ears)) {
|
|
112
|
+
batteries[sideOf(ear)] = await readBattery(connection, ear);
|
|
113
|
+
}
|
|
114
|
+
return batteries;
|
|
115
|
+
};
|
|
116
|
+
const withBatteries = (state, batteries) => Object.entries(batteries).reduce((next, [side, battery]) => withEar(next, side, battery), state);
|
|
117
|
+
|
|
118
|
+
/** Streams the pair's status until `signal` aborts: all of it once, then every change and its batteries every minute. */
|
|
119
|
+
const streamStatus = async (connection, onFrame, signal) => {
|
|
120
|
+
let state = await readStatus(connection);
|
|
121
|
+
const publish = next => {
|
|
122
|
+
state = next;
|
|
123
|
+
onFrame({
|
|
124
|
+
state
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
publish(state);
|
|
128
|
+
const stopReports = connection.onReport(report => publish(withReport(state, report)));
|
|
129
|
+
const stopChanges = connection.onChanged(change => {
|
|
130
|
+
if (change.kind !== "factory-reset") {
|
|
131
|
+
publish(withChange(state, change));
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
readStatus(connection).then(publish).catch(() => connection.logger.warn("famidoc-hearing-aid.status.reread-failed"));
|
|
135
|
+
});
|
|
136
|
+
const refresh = setInterval(() => {
|
|
137
|
+
readBatteries(connection).then(batteries => publish(withBatteries(state, batteries))).catch(() => connection.logger.warn("famidoc-hearing-aid.battery.refresh-failed"));
|
|
138
|
+
}, BATTERY_REFRESH_MS);
|
|
139
|
+
try {
|
|
140
|
+
await untilAborted(signal);
|
|
141
|
+
} finally {
|
|
142
|
+
stopReports();
|
|
143
|
+
stopChanges();
|
|
144
|
+
clearInterval(refresh);
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
export { BATTERY_REFRESH_MS, readStatus, streamStatus, withReport };
|
|
148
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["untilAborted","COMMAND","EAR","REPORT","batteryOf","linkedEars","withChange","flagOf","languageOf","modeOf","sceneOf","volumeOf","BATTERY_REFRESH_MS","SIDE","left","right","sideOf","ear","readBattery","read","percent","charging","battery","readEar","connection","inEar","inCase","readLanguage","main","promptLanguage","then","readStatus","ears","noise","noiseReduction","kind","mainEar","volume","mode","noiseScene","microphone","inEarDetection","withEar","state","side","change","current","undefined","REPORT_UPDATES","data","withReport","report","command","readBatteries","batteries","withBatteries","Object","entries","reduce","next","streamStatus","onFrame","signal","publish","stopReports","onReport","stopChanges","onChanged","catch","logger","warn","refresh","setInterval","clearInterval"],"sourceRoot":"../../../../../../../src","sources":["modules/next/bluetooth/families/famidoc-hearing-aid/status.ts"],"mappings":";;AAEA,SAASA,YAAY,QAAQ,mBAAgB;AAE7C,SAASC,OAAO,EAAEC,GAAG,EAAwBC,MAAM,QAAQ,YAAS;AACpE,SAASC,SAAS,EAAEC,UAAU,QAAQ,cAAW;AAEjD,SAASC,UAAU,QAAQ,eAAY;AACvC,SAASC,MAAM,EAAEC,UAAU,EAAEC,MAAM,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,aAAU;;AAExE;AACA,MAAMC,kBAAkB,GAAG,MAAM;AAEjC,MAAMC,IAAuC,GAAG;EAAE,CAACX,GAAG,CAACY,IAAI,GAAG,MAAM;EAAE,CAACZ,GAAG,CAACa,KAAK,GAAG;AAAQ,CAAC;;AAE5F;AACA,MAAMC,MAAM,GAAIC,GAAQ,IAAeA,GAAG,KAAKf,GAAG,CAACY,IAAI,GAAG,MAAM,GAAG,OAAQ;AAI3E,MAAMI,WAAW,GAAG,MAAAA,CAAO;EAAEC;AAA2B,CAAC,EAAEF,GAAQ,KAAsD;EACvH,MAAM;IAAEG,OAAO;IAAEC;EAAS,CAAC,GAAGjB,SAAS,CAAC,MAAMe,IAAI,CAACF,GAAG,EAAEhB,OAAO,CAACqB,OAAO,CAAC,CAAC;EAEzE,OAAO;IAAEA,OAAO,EAAEF,OAAO;IAAEC;EAAS,CAAC;AACvC,CAAC;AAED,MAAME,OAAO,GAAG,MAAAA,CAAOC,UAAgC,EAAEP,GAAQ,MAAyB;EACxF,IAAI,MAAMC,WAAW,CAACM,UAAU,EAAEP,GAAG,CAAC,CAAC;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,EAAEV,UAAU","ignoreList":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const FLAG = 0x01;
|
|
4
|
+
const VOLUME_MASK = 0x1f;
|
|
5
|
+
const TWO_BITS = 0x03;
|
|
6
|
+
const SCENE_SHIFT = 1;
|
|
7
|
+
|
|
8
|
+
/** The protocol document gives the volume as 0 to 16. */
|
|
9
|
+
const MAX_VOLUME = 16;
|
|
10
|
+
|
|
11
|
+
/** The mode bits in order; the last value is reserved. */
|
|
12
|
+
const MODES = ["mixed", "hearing-aid", "earphone", null];
|
|
13
|
+
|
|
14
|
+
/** The noise scene bits in order. */
|
|
15
|
+
const SCENES = ["general", "outdoor", "meeting", "cinema"];
|
|
16
|
+
|
|
17
|
+
/** The prompt language bit in order. */
|
|
18
|
+
const LANGUAGES = ["chinese", "english"];
|
|
19
|
+
const flagOf = data => ((data[0] ?? 0) & FLAG) !== 0;
|
|
20
|
+
const volumeOf = data => ({
|
|
21
|
+
level: Math.min((data[0] ?? 0) & VOLUME_MASK, MAX_VOLUME),
|
|
22
|
+
max: MAX_VOLUME
|
|
23
|
+
});
|
|
24
|
+
const modeOf = data => MODES[(data[0] ?? 0) & TWO_BITS] ?? null;
|
|
25
|
+
|
|
26
|
+
/** The noise reduction byte holds the scene in bits 2–1 and whether it is on in bit 0. */
|
|
27
|
+
const sceneOf = data => SCENES[(data[0] ?? 0) >> SCENE_SHIFT & TWO_BITS] ?? null;
|
|
28
|
+
const noiseByte = (on, scene) => SCENES.indexOf(scene) << SCENE_SHIFT | (on ? FLAG : 0);
|
|
29
|
+
const languageOf = data => LANGUAGES[(data[0] ?? 0) & FLAG] ?? null;
|
|
30
|
+
|
|
31
|
+
/** A volume within the steps the aid takes. */
|
|
32
|
+
const clampedVolume = level => Math.min(Math.max(Math.round(level), 0), MAX_VOLUME);
|
|
33
|
+
export { clampedVolume, flagOf, LANGUAGES, languageOf, MAX_VOLUME, modeOf, MODES, noiseByte, sceneOf, volumeOf };
|
|
34
|
+
//# sourceMappingURL=values.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["FLAG","VOLUME_MASK","TWO_BITS","SCENE_SHIFT","MAX_VOLUME","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,GAAG,EAAE;;AAErB;AACA,MAAMC,KAAyC,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,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC;AAEnE,MAAMC,MAAM,GAAIC,IAAgB,IAAc,CAAC,CAACA,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAIT,IAAI,MAAM,CAAC;AAE3E,MAAMU,QAAQ,GAAID,IAAgB,KAAiC;EACjEE,KAAK,EAAEC,IAAI,CAACC,GAAG,CAAC,CAACJ,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAIR,WAAW,EAAEG,UAAU,CAAC;EACzDU,GAAG,EAAEV;AACP,CAAC,CAAC;AAEF,MAAMW,MAAM,GAAIN,IAAgB,IAA4BJ,KAAK,CAAC,CAACI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAIP,QAAQ,CAAC,IAAI,IAAI;;AAEpG;AACA,MAAMc,OAAO,GAAIP,IAAgB,IAAwBH,MAAM,CAAE,CAACG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAKN,WAAW,GAAID,QAAQ,CAAC,IAAI,IAAI;AAEnH,MAAMe,SAAS,GAAGA,CAACC,EAAW,EAAEC,KAAiB,KAAcb,MAAM,CAACc,OAAO,CAACD,KAAK,CAAC,IAAIhB,WAAW,IAAKe,EAAE,GAAGlB,IAAI,GAAG,CAAC,CAAC;AAEtH,MAAMqB,UAAU,GAAIZ,IAAgB,IAA4BF,SAAS,CAAC,CAACE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAIT,IAAI,CAAC,IAAI,IAAI;;AAExG;AACA,MAAMsB,aAAa,GAAIX,KAAa,IAAaC,IAAI,CAACC,GAAG,CAACD,IAAI,CAACE,GAAG,CAACF,IAAI,CAACW,KAAK,CAACZ,KAAK,CAAC,EAAE,CAAC,CAAC,EAAEP,UAAU,CAAC;AAErG,SAASkB,aAAa,EAAEd,MAAM,EAAED,SAAS,EAAEc,UAAU,EAAEjB,UAAU,EAAEW,MAAM,EAAEV,KAAK,EAAEY,SAAS,EAAED,OAAO,EAAEN,QAAQ","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ovokOutboxWatch","ovokReadingSink","storagePairedDevices","Bluetooth","Catalog","Device","Discovery","DeviceError","BUILT_IN_MODELS","BUILT_IN_PROTOCOLS","BluetoothProvider","useBluetooth","useBluetoothAdapter","useCatalog","usePairedDevices","useReadings","useDevice","useLiveValues","useWaveform","useDiscovery","useOutbox"],"sourceRoot":"../../../../../src","sources":["modules/next/bluetooth/shared.ts"],"mappings":";;AAAA,SAASA,eAAe,QAAQ,iCAA8B;AAC9D,SAASC,eAAe,QAAQ,iCAA8B;AAC9D,SAASC,oBAAoB,QAAQ,sCAAmC;AACxE,SAASC,SAAS,QAAQ,qBAAkB;AAE5C,SAASC,OAAO,QAAQ,mBAAgB;AAExC,SAASC,MAAM,QAAQ,kBAAe;
|
|
1
|
+
{"version":3,"names":["ovokOutboxWatch","ovokReadingSink","storagePairedDevices","Bluetooth","Catalog","Device","Discovery","DeviceError","BUILT_IN_MODELS","BUILT_IN_PROTOCOLS","BluetoothProvider","useBluetooth","useBluetoothAdapter","useCatalog","usePairedDevices","useReadings","useDevice","useLiveValues","useWaveform","useDiscovery","useOutbox"],"sourceRoot":"../../../../../src","sources":["modules/next/bluetooth/shared.ts"],"mappings":";;AAAA,SAASA,eAAe,QAAQ,iCAA8B;AAC9D,SAASC,eAAe,QAAQ,iCAA8B;AAC9D,SAASC,oBAAoB,QAAQ,sCAAmC;AACxE,SAASC,SAAS,QAAQ,qBAAkB;AAE5C,SAASC,OAAO,QAAQ,mBAAgB;AAExC,SAASC,MAAM,QAAQ,kBAAe;AAsBtC,SAASC,SAAS,QAAQ,qBAAkB;AAE5C,SAASC,WAAW,QAAQ,kBAAe;AA0B3C,SAASC,eAAe,EAAEC,kBAAkB,QAAQ,wBAAqB;AACzE,SAASC,iBAAiB,EAAEC,YAAY,QAAQ,oBAAiB;AAEjE,SAASC,mBAAmB,EAAEC,UAAU,EAAEC,gBAAgB,EAAEC,WAAW,QAAQ,kBAAe;AAC9F,SAASC,SAAS,EAAEC,aAAa,EAAEC,WAAW,QAAQ,uBAAoB;AAE1E,SAASC,YAAY,QAAQ,0BAAuB;AACpD,SAASC,SAAS,QAAQ,uBAAuB","ignoreList":[]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { DeviceModel } from "./catalog";
|
|
2
|
+
import { DeviceState } from "./device-state";
|
|
2
3
|
import { DeviceError } from "./errors";
|
|
3
4
|
import { Battery, DeviceIdentity, PairedDevice } from "./paired-device";
|
|
4
5
|
import { DeviceProtocol } from "./protocol";
|
|
5
6
|
import { LiveFrame, LiveValues, Reading, Waveform } from "./reading";
|
|
6
7
|
/** A button a device may offer. */
|
|
7
|
-
type DeviceAction = "sync" | "records" | "fetch" | "live" | "setClock";
|
|
8
|
+
type DeviceAction = "sync" | "records" | "fetch" | "live" | "setClock" | "change";
|
|
8
9
|
/** Where the link stands; `pairing` is a new device's first connect. */
|
|
9
10
|
type ConnectionState = "disconnected" | "connecting" | "pairing" | "connected" | "disconnecting";
|
|
10
11
|
/** Everything a UI shows about one paired device; the same keys for every model. */
|
|
@@ -74,6 +75,8 @@ type DeviceSnapshot = {
|
|
|
74
75
|
/** When the device reported it. */
|
|
75
76
|
at: Date;
|
|
76
77
|
} | null;
|
|
78
|
+
/** What the device reports about itself while its stream runs, `null` otherwise. */
|
|
79
|
+
deviceState: DeviceState | null;
|
|
77
80
|
};
|
|
78
81
|
/** What a device handle reports: its new snapshot, and readings to save or show. */
|
|
79
82
|
type DeviceEvent = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device-snapshot.d.ts","sourceRoot":"","sources":["../../../../../../../../src/modules/next/bluetooth/core/device-snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErE,mCAAmC;AACnC,KAAK,YAAY,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"device-snapshot.d.ts","sourceRoot":"","sources":["../../../../../../../../src/modules/next/bluetooth/core/device-snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,cAAc,EA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D,OAAO,EAAE,OAAO,CAAC;CAClB,GACD;IAEE,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAC;IAEb,4CAA4C;IAC5C,MAAM,EAAE,UAAU,CAAC;CACpB,GACD;IAEE,uDAAuD;IACvD,IAAI,EAAE,UAAU,CAAC;IAEjB,8DAA8D;IAC9D,QAAQ,EAAE,QAAQ,CAAC;CACpB,CAAC;AAEN,oCAAoC;AACpC,KAAK,WAAW,GAAG;IAEjB,yDAAyD;IACzD,QAAQ,EAAE,MAAM,CAAC;IAEjB,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAYF,+DAA+D;AAC/D,QAAA,MAAM,SAAS,GAAI,UAAU,cAAc,KAAG,YAAY,EAE8C,CAAC;AAEzG,4DAA4D;AAC5D,QAAA,MAAM,YAAY,GAAI,QAAQ,YAAY,EAAE,OAAO,WAAW;;;;;;;;;;;CAW5D,CAAC;AAEH,QAAA,MAAM,eAAe,GAAI,QAAQ,YAAY,EAAE,OAAO,WAAW,EAAE,UAAU,cAAc,KAAG,cAiB5F,CAAC;AAEH,gFAAgF;AAChF,QAAA,MAAM,YAAY,GAAI,sBAAsB,SAAS,KAAG,WAAW,EAGlE,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC;AAClE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/** One ear of a pair. */
|
|
2
|
+
type EarSide = "left" | "right";
|
|
3
|
+
/** One ear of a hearing aid pair as it last reported itself; a field is `null` until the ear answers. */
|
|
4
|
+
type EarState = {
|
|
5
|
+
/** Charge level from 0 to 100. */
|
|
6
|
+
battery: number | null;
|
|
7
|
+
/** Whether it is charging. */
|
|
8
|
+
charging: boolean | null;
|
|
9
|
+
/** Whether its sensor says it sits in the ear. */
|
|
10
|
+
inEar: boolean | null;
|
|
11
|
+
/** Whether it sits in its charging case. */
|
|
12
|
+
inCase: boolean | null;
|
|
13
|
+
};
|
|
14
|
+
/** A volume step and the highest step the device has. */
|
|
15
|
+
type VolumeStep = {
|
|
16
|
+
/** The step it is set to. */
|
|
17
|
+
level: number;
|
|
18
|
+
/** The highest step. */
|
|
19
|
+
max: number;
|
|
20
|
+
};
|
|
21
|
+
/** How a hearing aid plays sound: amplifying what it hears, playing Bluetooth audio, or both. */
|
|
22
|
+
type HearingAidMode = "mixed" | "hearing-aid" | "earphone";
|
|
23
|
+
/** The surroundings a hearing aid's noise reduction is tuned for. */
|
|
24
|
+
type NoiseScene = "general" | "outdoor" | "meeting" | "cinema";
|
|
25
|
+
/** Where a hearing aid listens: all around with one microphone, or ahead with two. */
|
|
26
|
+
type MicrophoneDirection = "all-around" | "front";
|
|
27
|
+
/** The language of a hearing aid's voice prompts. */
|
|
28
|
+
type PromptLanguage = "chinese" | "english";
|
|
29
|
+
/** A hearing aid pair as it reports itself while linked, every value as the aid sent it. */
|
|
30
|
+
type HearingAidState = {
|
|
31
|
+
/** The kind of device the state comes from. */
|
|
32
|
+
kind: "hearing-aid";
|
|
33
|
+
/** The ear that speaks for the pair. */
|
|
34
|
+
mainEar: EarSide;
|
|
35
|
+
/** The linked ears. */
|
|
36
|
+
ears: Partial<Record<EarSide, EarState>>;
|
|
37
|
+
/** The volume step and the highest step, `null` until read. */
|
|
38
|
+
volume: VolumeStep | null;
|
|
39
|
+
/** How it plays sound, `null` until read or for a value the aid reserves. */
|
|
40
|
+
mode: HearingAidMode | null;
|
|
41
|
+
/** Whether noise reduction is on, `null` until read. */
|
|
42
|
+
noiseReduction: boolean | null;
|
|
43
|
+
/** The surroundings noise reduction is tuned for, `null` until read. */
|
|
44
|
+
noiseScene: NoiseScene | null;
|
|
45
|
+
/** Where it listens, `null` until changed, since the aid cannot be asked. */
|
|
46
|
+
microphone: MicrophoneDirection | null;
|
|
47
|
+
/** Whether it pauses when taken out of the ear, `null` until read. */
|
|
48
|
+
inEarDetection: boolean | null;
|
|
49
|
+
/** The language of its voice prompts, `null` until read. */
|
|
50
|
+
promptLanguage: PromptLanguage | null;
|
|
51
|
+
};
|
|
52
|
+
/** A new volume for a hearing aid. */
|
|
53
|
+
type VolumeChange = {
|
|
54
|
+
/** Which setting changes. */
|
|
55
|
+
kind: "volume";
|
|
56
|
+
/** The step to set; one past the aid's range is kept within it. */
|
|
57
|
+
level: number;
|
|
58
|
+
};
|
|
59
|
+
/** A new way for a hearing aid to play sound. */
|
|
60
|
+
type ModeChange = {
|
|
61
|
+
/** Which setting changes. */
|
|
62
|
+
kind: "mode";
|
|
63
|
+
/** The mode to set. */
|
|
64
|
+
mode: HearingAidMode;
|
|
65
|
+
};
|
|
66
|
+
/** Noise reduction turned on or off, tuned for a scene. */
|
|
67
|
+
type NoiseReductionChange = {
|
|
68
|
+
/** Which setting changes. */
|
|
69
|
+
kind: "noise-reduction";
|
|
70
|
+
/** Whether noise reduction is on. */
|
|
71
|
+
on: boolean;
|
|
72
|
+
/** The surroundings it is tuned for. */
|
|
73
|
+
scene: NoiseScene;
|
|
74
|
+
};
|
|
75
|
+
/** Where a hearing aid listens. */
|
|
76
|
+
type MicrophoneChange = {
|
|
77
|
+
/** Which setting changes. */
|
|
78
|
+
kind: "microphone";
|
|
79
|
+
/** The direction to set. */
|
|
80
|
+
direction: MicrophoneDirection;
|
|
81
|
+
};
|
|
82
|
+
/** Whether a hearing aid pauses when taken out of the ear. */
|
|
83
|
+
type InEarDetectionChange = {
|
|
84
|
+
/** Which setting changes. */
|
|
85
|
+
kind: "in-ear-detection";
|
|
86
|
+
/** Whether in-ear detection is on. */
|
|
87
|
+
on: boolean;
|
|
88
|
+
};
|
|
89
|
+
/** The language of a hearing aid's voice prompts. */
|
|
90
|
+
type PromptLanguageChange = {
|
|
91
|
+
/** Which setting changes. */
|
|
92
|
+
kind: "prompt-language";
|
|
93
|
+
/** The language to set. */
|
|
94
|
+
language: PromptLanguage;
|
|
95
|
+
};
|
|
96
|
+
/** The maker's defaults restored on a hearing aid: volume 9, noise reduction on, mixed mode, Chinese prompts. */
|
|
97
|
+
type FactoryReset = {
|
|
98
|
+
/** Which setting changes. */
|
|
99
|
+
kind: "factory-reset";
|
|
100
|
+
};
|
|
101
|
+
/** One setting to change on a hearing aid. */
|
|
102
|
+
type HearingAidChange = VolumeChange | ModeChange | NoiseReductionChange | MicrophoneChange | InEarDetectionChange | PromptLanguageChange | FactoryReset;
|
|
103
|
+
/** One setting to change on a device, one shape per kind of device. */
|
|
104
|
+
type DeviceChange = HearingAidChange;
|
|
105
|
+
/** What a device reports about itself beyond its battery and identity, one shape per kind of device. */
|
|
106
|
+
type DeviceState = HearingAidState;
|
|
107
|
+
export type { DeviceChange, DeviceState, EarSide, EarState, FactoryReset, HearingAidChange, HearingAidMode, HearingAidState, InEarDetectionChange, MicrophoneChange, MicrophoneDirection, ModeChange, NoiseReductionChange, NoiseScene, PromptLanguage, PromptLanguageChange, VolumeChange, VolumeStep, };
|
|
108
|
+
//# sourceMappingURL=device-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device-state.d.ts","sourceRoot":"","sources":["../../../../../../../../src/modules/next/bluetooth/core/device-state.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,KAAK,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;AAEhC,yGAAyG;AACzG,KAAK,QAAQ,GAAG;IAEd,kCAAkC;IAClC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAEvB,8BAA8B;IAC9B,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAC;IAEzB,kDAAkD;IAClD,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAEtB,4CAA4C;IAC5C,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;CACxB,CAAC;AAEF,yDAAyD;AACzD,KAAK,UAAU,GAAG;IAEhB,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAC;IAE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,EACpB,YAAY,EACZ,UAAU,GACX,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Advertisement } from "./advertisement";
|
|
2
2
|
import { DeviceDeps } from "./device-deps";
|
|
3
3
|
import { DeviceEvent, DeviceSnapshot, SyncSummary } from "./device-snapshot";
|
|
4
|
+
import { DeviceChange } from "./device-state";
|
|
4
5
|
import { DeviceSettings, PairedDevice } from "./paired-device";
|
|
5
6
|
import { RecordInfo } from "./protocol";
|
|
6
7
|
/** One paired device: it owns the link, queues every action on it, and reconnects when a press needs it. */
|
|
@@ -32,6 +33,8 @@ declare class Device {
|
|
|
32
33
|
fetch: (recordId: string) => Promise<void>;
|
|
33
34
|
/** Sets the device's clock to now. */
|
|
34
35
|
setClock: () => Promise<void>;
|
|
36
|
+
/** Changes one of the device's settings, such as a hearing aid's volume. */
|
|
37
|
+
change: (change: DeviceChange) => Promise<void>;
|
|
35
38
|
/** Starts `live` and `waveform` events, which the device also records and saves while it measures with `record` on. */
|
|
36
39
|
startLive: () => Promise<void>;
|
|
37
40
|
/** Stops the stream and waits until the device has stopped sending. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../../../../../../../../src/modules/next/bluetooth/core/device.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAgB,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,
|
|
1
|
+
{"version":3,"file":"device.d.ts","sourceRoot":"","sources":["../../../../../../../../src/modules/next/bluetooth/core/device.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAgB,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAiC,WAAW,EAAE,cAAc,EAAiC,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC3I,OAAO,EAAE,YAAY,EAAE,MAAM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,OAAO,CAAC,IAAI,CAAC,CAC4E;IAEjI,uHAAuH;IAChH,SAAS,QAAO,OAAO,CAAC,IAAI,CAAC,CACwH;IAE5J,uEAAuE;IAChE,QAAQ,QAAO,OAAO,CAAC,IAAI,CAAC,CAAqB;IAExD,uFAAuF;IAChF,WAAW,GAAU,UAAU,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC,CAK1D;IAEF,wFAAwF;IACjF,OAAO,GAAI,UAAU,MAAM,KAAG,IAAI,CAGvC;IAEF,qHAAqH;IAC9G,SAAS,GAAI,UAAU,OAAO,CAAC,cAAc,CAAC,KAAG,OAAO,CAAC,IAAI,CAAC,CAAgC;IAErG,kEAAkE;IAC3D,UAAU,QAAa,OAAO,CAAC,IAAI,CAAC,CAIzC;IAEF,6GAA6G;IACtG,IAAI,QAAO,OAAO,CAAC,IAAI,CAAC,CAA+H;IAE9J,qHAAqH;IAC9G,IAAI,CAAC,EAAE,EAAE,aAAa,GAAG,IAAI;IAapC,OAAO,CAAC,GAAG;YAYG,OAAO;YAmBP,OAAO;YAaP,SAAS;YAaT,WAAW;IAazB,8DAA8D;IAC9D,OAAO,CAAC,KAAK,CAA2F;YAE1F,WAAW;YAIX,OAAO;IAiBrB,wHAAwH;IACxH,OAAO,CAAC,kBAAkB;IAM1B,iGAAiG;IACjG,OAAO,CAAC,WAAW;YAIL,YAAY;IAM1B,OAAO,CAAC,KAAK;CAId;AAED,OAAO,EAAE,MAAM,EAAE,CAAC;AAClB,YAAY,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -5,8 +5,8 @@ declare const STORED_AFTER_MS = 3000;
|
|
|
5
5
|
/** Streams the device's frames to `onFrame` until `signal` aborts. */
|
|
6
6
|
type Live = (onFrame: (frame: LiveFrame) => void, signal: AbortSignal) => Promise<void>;
|
|
7
7
|
type LiveSessionCallbacks = {
|
|
8
|
-
/** The stream started or ended, failed,
|
|
9
|
-
changed: (change: Partial<Pick<DeviceSnapshot, "live" | "lastError" | "measuringSince">>) => void;
|
|
8
|
+
/** The stream started or ended, failed, the device started or stopped measuring, or reported its state. */
|
|
9
|
+
changed: (change: Partial<Pick<DeviceSnapshot, "live" | "lastError" | "measuringSince" | "deviceState">>) => void;
|
|
10
10
|
/** The live numbers and samples of one frame. */
|
|
11
11
|
emit: (event: DeviceEvent) => void;
|
|
12
12
|
/** A measurement ended while the stream still ran, long enough ago for the device to have stored it. */
|