@depz/sensor-sdk 0.1.0
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/README.md +69 -0
- package/dist/dataset.d.ts +93 -0
- package/dist/dataset.d.ts.map +1 -0
- package/dist/dataset.js +253 -0
- package/dist/dataset.js.map +1 -0
- package/dist/device/device.d.ts +185 -0
- package/dist/device/device.d.ts.map +1 -0
- package/dist/device/device.js +421 -0
- package/dist/device/device.js.map +1 -0
- package/dist/device/link.d.ts +62 -0
- package/dist/device/link.d.ts.map +1 -0
- package/dist/device/link.js +130 -0
- package/dist/device/link.js.map +1 -0
- package/dist/discovery.d.ts +109 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +281 -0
- package/dist/discovery.js.map +1 -0
- package/dist/errors.d.ts +39 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +69 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/protocol/bno086.d.ts +36 -0
- package/dist/protocol/bno086.d.ts.map +1 -0
- package/dist/protocol/bno086.js +38 -0
- package/dist/protocol/bno086.js.map +1 -0
- package/dist/protocol/common.d.ts +103 -0
- package/dist/protocol/common.d.ts.map +1 -0
- package/dist/protocol/common.js +121 -0
- package/dist/protocol/common.js.map +1 -0
- package/dist/protocol/crc.d.ts +17 -0
- package/dist/protocol/crc.d.ts.map +1 -0
- package/dist/protocol/crc.js +55 -0
- package/dist/protocol/crc.js.map +1 -0
- package/dist/protocol/framing.d.ts +65 -0
- package/dist/protocol/framing.d.ts.map +1 -0
- package/dist/protocol/framing.js +152 -0
- package/dist/protocol/framing.js.map +1 -0
- package/dist/protocol/fwdepz.d.ts +21 -0
- package/dist/protocol/fwdepz.d.ts.map +1 -0
- package/dist/protocol/fwdepz.js +46 -0
- package/dist/protocol/fwdepz.js.map +1 -0
- package/dist/protocol/identity.d.ts +14 -0
- package/dist/protocol/identity.d.ts.map +1 -0
- package/dist/protocol/identity.js +28 -0
- package/dist/protocol/identity.js.map +1 -0
- package/dist/protocol/sr04.d.ts +38 -0
- package/dist/protocol/sr04.d.ts.map +1 -0
- package/dist/protocol/sr04.js +58 -0
- package/dist/protocol/sr04.js.map +1 -0
- package/dist/protocol/usb-ids.d.ts +60 -0
- package/dist/protocol/usb-ids.d.ts.map +1 -0
- package/dist/protocol/usb-ids.js +79 -0
- package/dist/protocol/usb-ids.js.map +1 -0
- package/dist/protocol/vl53l8.d.ts +59 -0
- package/dist/protocol/vl53l8.d.ts.map +1 -0
- package/dist/protocol/vl53l8.js +116 -0
- package/dist/protocol/vl53l8.js.map +1 -0
- package/dist/sensors/bno086/bno086.d.ts +197 -0
- package/dist/sensors/bno086/bno086.d.ts.map +1 -0
- package/dist/sensors/bno086/bno086.js +543 -0
- package/dist/sensors/bno086/bno086.js.map +1 -0
- package/dist/sensors/bno086/reports.d.ts +289 -0
- package/dist/sensors/bno086/reports.d.ts.map +1 -0
- package/dist/sensors/bno086/reports.js +397 -0
- package/dist/sensors/bno086/reports.js.map +1 -0
- package/dist/sensors/bno086/sh2.d.ts +307 -0
- package/dist/sensors/bno086/sh2.d.ts.map +1 -0
- package/dist/sensors/bno086/sh2.js +480 -0
- package/dist/sensors/bno086/sh2.js.map +1 -0
- package/dist/sensors/bno086/shtp.d.ts +98 -0
- package/dist/sensors/bno086/shtp.d.ts.map +1 -0
- package/dist/sensors/bno086/shtp.js +205 -0
- package/dist/sensors/bno086/shtp.js.map +1 -0
- package/dist/sensors/sr04.d.ts +65 -0
- package/dist/sensors/sr04.d.ts.map +1 -0
- package/dist/sensors/sr04.js +121 -0
- package/dist/sensors/sr04.js.map +1 -0
- package/dist/sensors/vl53l8/assets/ch.d.ts +16 -0
- package/dist/sensors/vl53l8/assets/ch.d.ts.map +1 -0
- package/dist/sensors/vl53l8/assets/ch.js +22 -0
- package/dist/sensors/vl53l8/assets/ch.js.map +1 -0
- package/dist/sensors/vl53l8/assets/cx.d.ts +16 -0
- package/dist/sensors/vl53l8/assets/cx.d.ts.map +1 -0
- package/dist/sensors/vl53l8/assets/cx.js +22 -0
- package/dist/sensors/vl53l8/assets/cx.js.map +1 -0
- package/dist/sensors/vl53l8/assets/decode.d.ts +7 -0
- package/dist/sensors/vl53l8/assets/decode.d.ts.map +1 -0
- package/dist/sensors/vl53l8/assets/decode.js +35 -0
- package/dist/sensors/vl53l8/assets/decode.js.map +1 -0
- package/dist/sensors/vl53l8/assets/index.d.ts +19 -0
- package/dist/sensors/vl53l8/assets/index.d.ts.map +1 -0
- package/dist/sensors/vl53l8/assets/index.js +11 -0
- package/dist/sensors/vl53l8/assets/index.js.map +1 -0
- package/dist/sensors/vl53l8/cnh.d.ts +113 -0
- package/dist/sensors/vl53l8/cnh.d.ts.map +1 -0
- package/dist/sensors/vl53l8/cnh.js +299 -0
- package/dist/sensors/vl53l8/cnh.js.map +1 -0
- package/dist/sensors/vl53l8/uld.d.ts +346 -0
- package/dist/sensors/vl53l8/uld.d.ts.map +1 -0
- package/dist/sensors/vl53l8/uld.js +1388 -0
- package/dist/sensors/vl53l8/uld.js.map +1 -0
- package/dist/sensors/vl53l8/vl53l8.d.ts +182 -0
- package/dist/sensors/vl53l8/vl53l8.d.ts.map +1 -0
- package/dist/sensors/vl53l8/vl53l8.js +411 -0
- package/dist/sensors/vl53l8/vl53l8.js.map +1 -0
- package/dist/transport/loopback.d.ts +18 -0
- package/dist/transport/loopback.d.ts.map +1 -0
- package/dist/transport/loopback.js +53 -0
- package/dist/transport/loopback.js.map +1 -0
- package/dist/transport/node.d.ts +51 -0
- package/dist/transport/node.d.ts.map +1 -0
- package/dist/transport/node.js +123 -0
- package/dist/transport/node.js.map +1 -0
- package/dist/transport/replay.d.ts +68 -0
- package/dist/transport/replay.d.ts.map +1 -0
- package/dist/transport/replay.js +196 -0
- package/dist/transport/replay.js.map +1 -0
- package/dist/transport/types.d.ts +23 -0
- package/dist/transport/types.d.ts.map +1 -0
- package/dist/transport/types.js +7 -0
- package/dist/transport/types.js.map +1 -0
- package/dist/transport/webserial.d.ts +69 -0
- package/dist/transport/webserial.d.ts.map +1 -0
- package/dist/transport/webserial.js +196 -0
- package/dist/transport/webserial.js.map +1 -0
- package/package.json +77 -0
|
@@ -0,0 +1,480 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SH-2 control-channel builders and parsers (contracts/05_SENSOR_BNO086.md §6).
|
|
3
|
+
*
|
|
4
|
+
* Pure request-builders + response-parsers — no I/O, no timing. The device
|
|
5
|
+
* layer owns the SHTP framing, sequence numbers for the SHTP header, and the
|
|
6
|
+
* waiting/correlation. All multi-byte fields little-endian.
|
|
7
|
+
*
|
|
8
|
+
* Mirrors the Python reference `depz_sensor_sdk.bno086.sh2`.
|
|
9
|
+
*/
|
|
10
|
+
import { DepzError } from "../../errors.js";
|
|
11
|
+
/** SH-2 level failure (bad response status, FRS error, ...). */
|
|
12
|
+
export class Sh2Error extends DepzError {
|
|
13
|
+
}
|
|
14
|
+
/** Report IDs on SHTP channel 2 (control). */
|
|
15
|
+
export var ControlReport;
|
|
16
|
+
(function (ControlReport) {
|
|
17
|
+
ControlReport[ControlReport["CommandResponse"] = 241] = "CommandResponse";
|
|
18
|
+
ControlReport[ControlReport["CommandRequest"] = 242] = "CommandRequest";
|
|
19
|
+
ControlReport[ControlReport["FrsReadResponse"] = 243] = "FrsReadResponse";
|
|
20
|
+
ControlReport[ControlReport["FrsReadRequest"] = 244] = "FrsReadRequest";
|
|
21
|
+
ControlReport[ControlReport["FrsWriteResponse"] = 245] = "FrsWriteResponse";
|
|
22
|
+
ControlReport[ControlReport["FrsWriteData"] = 246] = "FrsWriteData";
|
|
23
|
+
ControlReport[ControlReport["FrsWriteRequest"] = 247] = "FrsWriteRequest";
|
|
24
|
+
ControlReport[ControlReport["ProductIdResponse"] = 248] = "ProductIdResponse";
|
|
25
|
+
ControlReport[ControlReport["ProductIdRequest"] = 249] = "ProductIdRequest";
|
|
26
|
+
ControlReport[ControlReport["GetFeatureResponse"] = 252] = "GetFeatureResponse";
|
|
27
|
+
ControlReport[ControlReport["SetFeatureCommand"] = 253] = "SetFeatureCommand";
|
|
28
|
+
ControlReport[ControlReport["GetFeatureRequest"] = 254] = "GetFeatureRequest";
|
|
29
|
+
})(ControlReport || (ControlReport = {}));
|
|
30
|
+
/** `command` field of Command Request/Response (0xF2/0xF1). */
|
|
31
|
+
export var Sh2Command;
|
|
32
|
+
(function (Sh2Command) {
|
|
33
|
+
Sh2Command[Sh2Command["Errors"] = 1] = "Errors";
|
|
34
|
+
Sh2Command[Sh2Command["Counter"] = 2] = "Counter";
|
|
35
|
+
Sh2Command[Sh2Command["Tare"] = 3] = "Tare";
|
|
36
|
+
Sh2Command[Sh2Command["Initialize"] = 4] = "Initialize";
|
|
37
|
+
Sh2Command[Sh2Command["SaveDcd"] = 6] = "SaveDcd";
|
|
38
|
+
Sh2Command[Sh2Command["MeCalibrate"] = 7] = "MeCalibrate";
|
|
39
|
+
Sh2Command[Sh2Command["PeriodicDcdConfig"] = 9] = "PeriodicDcdConfig";
|
|
40
|
+
Sh2Command[Sh2Command["GetOscillatorType"] = 10] = "GetOscillatorType";
|
|
41
|
+
Sh2Command[Sh2Command["ClearDcdAndReset"] = 11] = "ClearDcdAndReset";
|
|
42
|
+
})(Sh2Command || (Sh2Command = {}));
|
|
43
|
+
/** Get-Oscillator-Type (command 0x0A) result (r[0]). */
|
|
44
|
+
export var OscillatorType;
|
|
45
|
+
(function (OscillatorType) {
|
|
46
|
+
OscillatorType[OscillatorType["Internal"] = 0] = "Internal";
|
|
47
|
+
OscillatorType[OscillatorType["ExtCrystal"] = 1] = "ExtCrystal";
|
|
48
|
+
OscillatorType[OscillatorType["ExtClock"] = 2] = "ExtClock";
|
|
49
|
+
})(OscillatorType || (OscillatorType = {}));
|
|
50
|
+
/** `source` field of an error record (SH-2 §6.4.1). */
|
|
51
|
+
export var ErrorSource;
|
|
52
|
+
(function (ErrorSource) {
|
|
53
|
+
ErrorSource[ErrorSource["MotionEngine"] = 1] = "MotionEngine";
|
|
54
|
+
ErrorSource[ErrorSource["MotionHub"] = 2] = "MotionHub";
|
|
55
|
+
ErrorSource[ErrorSource["SensorHub"] = 3] = "SensorHub";
|
|
56
|
+
ErrorSource[ErrorSource["Chip"] = 4] = "Chip";
|
|
57
|
+
/** Sentinel: end of the error queue. */
|
|
58
|
+
ErrorSource[ErrorSource["NoMoreErrors"] = 255] = "NoMoreErrors";
|
|
59
|
+
})(ErrorSource || (ErrorSource = {}));
|
|
60
|
+
/** Counter subcommands (command 0x02, P0). */
|
|
61
|
+
export const COUNTS_GET = 0;
|
|
62
|
+
export const COUNTS_CLEAR = 1;
|
|
63
|
+
/** Counter command 0x02: get event counts for `sensorId`. */
|
|
64
|
+
export function countsGetParams(sensorId) {
|
|
65
|
+
return Uint8Array.of(COUNTS_GET, sensorId & 0xff);
|
|
66
|
+
}
|
|
67
|
+
/** Counter command 0x02: clear event counts for `sensorId`. */
|
|
68
|
+
export function countsClearParams(sensorId) {
|
|
69
|
+
return Uint8Array.of(COUNTS_CLEAR, sensorId & 0xff);
|
|
70
|
+
}
|
|
71
|
+
/** Errors command 0x01: return errors of `severity` or greater (0 = all). */
|
|
72
|
+
export function errorsParams(severity = 0) {
|
|
73
|
+
return Uint8Array.of(severity & 0xff);
|
|
74
|
+
}
|
|
75
|
+
export function errorRecordFromResponse(resp) {
|
|
76
|
+
const r = resp.r;
|
|
77
|
+
return { severity: r[0], seq: r[1], source: r[2], error: r[3], module: r[4], code: r[5] };
|
|
78
|
+
}
|
|
79
|
+
/** Rotation vector used as the tare reference (Tare Now P2). */
|
|
80
|
+
export var TareBasis;
|
|
81
|
+
(function (TareBasis) {
|
|
82
|
+
TareBasis[TareBasis["RotationVector"] = 0] = "RotationVector";
|
|
83
|
+
TareBasis[TareBasis["GameRotationVector"] = 1] = "GameRotationVector";
|
|
84
|
+
TareBasis[TareBasis["GeomagneticRotationVector"] = 2] = "GeomagneticRotationVector";
|
|
85
|
+
TareBasis[TareBasis["GyroIntegratedRv"] = 3] = "GyroIntegratedRv";
|
|
86
|
+
TareBasis[TareBasis["ArvrStabilizedRv"] = 4] = "ArvrStabilizedRv";
|
|
87
|
+
TareBasis[TareBasis["ArvrStabilizedGameRv"] = 5] = "ArvrStabilizedGameRv";
|
|
88
|
+
})(TareBasis || (TareBasis = {}));
|
|
89
|
+
export var TareAxis;
|
|
90
|
+
(function (TareAxis) {
|
|
91
|
+
TareAxis[TareAxis["X"] = 1] = "X";
|
|
92
|
+
TareAxis[TareAxis["Y"] = 2] = "Y";
|
|
93
|
+
TareAxis[TareAxis["Z"] = 4] = "Z";
|
|
94
|
+
TareAxis[TareAxis["All"] = 7] = "All";
|
|
95
|
+
})(TareAxis || (TareAxis = {}));
|
|
96
|
+
function hex2(n) {
|
|
97
|
+
return n.toString(16).toUpperCase().padStart(2, "0");
|
|
98
|
+
}
|
|
99
|
+
function hex4(n) {
|
|
100
|
+
return n.toString(16).toUpperCase().padStart(4, "0");
|
|
101
|
+
}
|
|
102
|
+
function view(p) {
|
|
103
|
+
return new DataView(p.buffer, p.byteOffset, p.byteLength);
|
|
104
|
+
}
|
|
105
|
+
// ── feature control (0xFD / 0xFE / 0xFC) ─────────────────────────────────────
|
|
106
|
+
/**
|
|
107
|
+
* Set Feature Command (0xFD), 17 bytes.
|
|
108
|
+
*
|
|
109
|
+
* `intervalUs` = 0 disables the sensor. `sensitivity` units are
|
|
110
|
+
* sensor-dependent (change sensitivity, u16); `flags` bit meanings per SH-2
|
|
111
|
+
* §6.5.4; `cfgWord` is the sensor-specific configuration u32.
|
|
112
|
+
*/
|
|
113
|
+
export function buildSetFeature(sensorId, intervalUs, batchUs = 0, sensitivity = 0, flags = 0, cfgWord = 0) {
|
|
114
|
+
const out = new Uint8Array(17);
|
|
115
|
+
const v = new DataView(out.buffer);
|
|
116
|
+
v.setUint8(0, ControlReport.SetFeatureCommand);
|
|
117
|
+
v.setUint8(1, sensorId);
|
|
118
|
+
v.setUint8(2, flags & 0xff);
|
|
119
|
+
v.setUint16(3, sensitivity & 0xffff, true);
|
|
120
|
+
v.setUint32(5, intervalUs >>> 0, true);
|
|
121
|
+
v.setUint32(9, batchUs >>> 0, true);
|
|
122
|
+
v.setUint32(13, cfgWord >>> 0, true);
|
|
123
|
+
return out;
|
|
124
|
+
}
|
|
125
|
+
/** Get Feature Request (0xFE), 2 bytes. */
|
|
126
|
+
export function buildGetFeatureRequest(sensorId) {
|
|
127
|
+
return Uint8Array.of(ControlReport.GetFeatureRequest, sensorId);
|
|
128
|
+
}
|
|
129
|
+
export function unpackFeatureResponse(payload) {
|
|
130
|
+
const v = view(payload);
|
|
131
|
+
const rid = v.getUint8(0);
|
|
132
|
+
if (rid !== ControlReport.GetFeatureResponse) {
|
|
133
|
+
throw new Sh2Error(`not a get-feature response: 0x${hex2(rid)}`);
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
sensorId: v.getUint8(1),
|
|
137
|
+
flags: v.getUint8(2),
|
|
138
|
+
sensitivity: v.getUint16(3, true),
|
|
139
|
+
intervalUs: v.getUint32(5, true),
|
|
140
|
+
batchUs: v.getUint32(9, true),
|
|
141
|
+
cfgWord: v.getUint32(13, true),
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
// ── product ID (0xF9 / 0xF8) ─────────────────────────────────────────────────
|
|
145
|
+
export function buildProductIdRequest() {
|
|
146
|
+
return Uint8Array.of(ControlReport.ProductIdRequest, 0x00);
|
|
147
|
+
}
|
|
148
|
+
export function unpackProductId(payload) {
|
|
149
|
+
const v = view(payload);
|
|
150
|
+
const rid = v.getUint8(0);
|
|
151
|
+
if (rid !== ControlReport.ProductIdResponse) {
|
|
152
|
+
throw new Sh2Error(`not a product-id response: 0x${hex2(rid)}`);
|
|
153
|
+
}
|
|
154
|
+
const major = v.getUint8(2);
|
|
155
|
+
const minor = v.getUint8(3);
|
|
156
|
+
const patch = v.getUint16(12, true);
|
|
157
|
+
return {
|
|
158
|
+
resetCause: v.getUint8(1),
|
|
159
|
+
swVersionMajor: major,
|
|
160
|
+
swVersionMinor: minor,
|
|
161
|
+
swPartNumber: v.getUint32(4, true),
|
|
162
|
+
swBuildNumber: v.getUint32(8, true),
|
|
163
|
+
swVersionPatch: patch,
|
|
164
|
+
version: `${major}.${minor}.${patch}`,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
// ── command channel (0xF2 / 0xF1) ────────────────────────────────────────────
|
|
168
|
+
/** Command Request (0xF2), 12 bytes: id, seq, command, P0..P8. */
|
|
169
|
+
export function buildCommandRequest(seq, command, params = new Uint8Array(0)) {
|
|
170
|
+
if (params.length > 9) {
|
|
171
|
+
throw new Error("command request carries at most 9 parameter bytes");
|
|
172
|
+
}
|
|
173
|
+
const out = new Uint8Array(12);
|
|
174
|
+
out[0] = ControlReport.CommandRequest;
|
|
175
|
+
out[1] = seq & 0xff;
|
|
176
|
+
out[2] = command;
|
|
177
|
+
out.set(params, 3);
|
|
178
|
+
return out;
|
|
179
|
+
}
|
|
180
|
+
export function unpackCommandResponse(payload) {
|
|
181
|
+
if (payload[0] !== ControlReport.CommandResponse) {
|
|
182
|
+
throw new Sh2Error(`not a command response: 0x${hex2(payload[0])}`);
|
|
183
|
+
}
|
|
184
|
+
const r = Array.from(payload.subarray(5, 16));
|
|
185
|
+
return {
|
|
186
|
+
seq: payload[1],
|
|
187
|
+
command: payload[2],
|
|
188
|
+
commandSeq: payload[3],
|
|
189
|
+
responseSeq: payload[4],
|
|
190
|
+
r,
|
|
191
|
+
status: r[0],
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
/** Tare subcommand 0 — tare `axes` (bitmap X=1,Y=2,Z=4) using `basis`. */
|
|
195
|
+
export function tareNowParams(axes = TareAxis.All, basis = TareBasis.RotationVector) {
|
|
196
|
+
return Uint8Array.of(0x00, axes, basis);
|
|
197
|
+
}
|
|
198
|
+
/** Tare subcommand 1 — persist current tare into FRS. */
|
|
199
|
+
export function persistTareParams() {
|
|
200
|
+
return Uint8Array.of(0x01);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Tare subcommand 2 — set reorientation quaternion.
|
|
204
|
+
*
|
|
205
|
+
* P1..P8 are four int16 Q14 components (the 8 available parameter bytes only
|
|
206
|
+
* fit Q14 halves; the *FRS* System Orientation record is the one that stores
|
|
207
|
+
* Q30 words). All-zero clears the reorientation.
|
|
208
|
+
*/
|
|
209
|
+
export function setReorientationParams(x, y, z, w) {
|
|
210
|
+
const q14 = [x, y, z, w].map((c) => Math.round(c * (1 << 14)));
|
|
211
|
+
for (const c of q14) {
|
|
212
|
+
if (c < -32768 || c > 32767) {
|
|
213
|
+
throw new Error("quaternion component out of Q14 int16 range");
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
const out = new Uint8Array(9);
|
|
217
|
+
const v = new DataView(out.buffer);
|
|
218
|
+
v.setUint8(0, 0x02);
|
|
219
|
+
q14.forEach((c, i) => v.setInt16(1 + i * 2, c, true));
|
|
220
|
+
return out;
|
|
221
|
+
}
|
|
222
|
+
/** ME Calibration (command 0x07). subcommand 0 = configure, 1 = get. */
|
|
223
|
+
export function meCalibrationParams(accel, gyro, mag, planar = false, subcommand = 0) {
|
|
224
|
+
return Uint8Array.of(Number(accel), Number(gyro), Number(mag), subcommand, Number(planar));
|
|
225
|
+
}
|
|
226
|
+
/** Subcommand: report current ME calibration config. */
|
|
227
|
+
export const ME_CAL_GET = 0x01;
|
|
228
|
+
/**
|
|
229
|
+
* Periodic DCD save config (command 0x09). P0: 0 = enable, 1 = disable.
|
|
230
|
+
* No command response is generated.
|
|
231
|
+
*/
|
|
232
|
+
export function periodicDcdParams(enable) {
|
|
233
|
+
return Uint8Array.of(enable ? 0x00 : 0x01);
|
|
234
|
+
}
|
|
235
|
+
// ── FRS (flash record system) ────────────────────────────────────────────────
|
|
236
|
+
/** FRS record IDs used by this SDK (SH-2 figure 28; metadata records). */
|
|
237
|
+
export var FrsRecordId;
|
|
238
|
+
(function (FrsRecordId) {
|
|
239
|
+
FrsRecordId[FrsRecordId["StaticCalibrationAgm"] = 31097] = "StaticCalibrationAgm";
|
|
240
|
+
FrsRecordId[FrsRecordId["NominalCalibration"] = 19789] = "NominalCalibration";
|
|
241
|
+
FrsRecordId[FrsRecordId["DynamicCalibration"] = 7967] = "DynamicCalibration";
|
|
242
|
+
FrsRecordId[FrsRecordId["MePowerMgmt"] = 54242] = "MePowerMgmt";
|
|
243
|
+
/** Mounting quaternion, 4 × Q30 words. */
|
|
244
|
+
FrsRecordId[FrsRecordId["SystemOrientation"] = 11582] = "SystemOrientation";
|
|
245
|
+
FrsRecordId[FrsRecordId["AccelOrientation"] = 11585] = "AccelOrientation";
|
|
246
|
+
FrsRecordId[FrsRecordId["GyroscopeOrientation"] = 11590] = "GyroscopeOrientation";
|
|
247
|
+
FrsRecordId[FrsRecordId["MagnetometerOrientation"] = 11596] = "MagnetometerOrientation";
|
|
248
|
+
FrsRecordId[FrsRecordId["ArvrStabilizationRv"] = 15917] = "ArvrStabilizationRv";
|
|
249
|
+
FrsRecordId[FrsRecordId["ArvrStabilizationGrv"] = 15918] = "ArvrStabilizationGrv";
|
|
250
|
+
// Feature configuration records (SH-2 §5.1; write to tune detectors).
|
|
251
|
+
FrsRecordId[FrsRecordId["SigMotionDetectConfig"] = 49780] = "SigMotionDetectConfig";
|
|
252
|
+
FrsRecordId[FrsRecordId["ShakeDetectConfig"] = 32125] = "ShakeDetectConfig";
|
|
253
|
+
FrsRecordId[FrsRecordId["StabilityDetectorConfig"] = 60805] = "StabilityDetectorConfig";
|
|
254
|
+
/** Personal-activity-classifier config. */
|
|
255
|
+
FrsRecordId[FrsRecordId["ActivityTrackerConfig"] = 60808] = "ActivityTrackerConfig";
|
|
256
|
+
})(FrsRecordId || (FrsRecordId = {}));
|
|
257
|
+
/** Per-sensor metadata FRS record IDs (subset used by getMetadata()). */
|
|
258
|
+
export const METADATA_RECORDS = {
|
|
259
|
+
0x14: 0xe301, // raw accelerometer
|
|
260
|
+
0x01: 0xe302, // accelerometer
|
|
261
|
+
0x04: 0xe303, // linear acceleration
|
|
262
|
+
0x06: 0xe304, // gravity
|
|
263
|
+
0x15: 0xe305, // raw gyroscope
|
|
264
|
+
0x02: 0xe306, // gyroscope calibrated
|
|
265
|
+
0x07: 0xe307, // gyroscope uncalibrated
|
|
266
|
+
0x16: 0xe308, // raw magnetometer
|
|
267
|
+
0x03: 0xe309, // magnetometer calibrated
|
|
268
|
+
0x0f: 0xe30a, // magnetometer uncalibrated
|
|
269
|
+
0x05: 0xe30b, // rotation vector
|
|
270
|
+
0x08: 0xe30c, // game rotation vector
|
|
271
|
+
0x09: 0xe30d, // geomagnetic rotation vector
|
|
272
|
+
0x10: 0xe313, // tap detector
|
|
273
|
+
0x18: 0xe314, // step detector
|
|
274
|
+
0x11: 0xe315, // step counter
|
|
275
|
+
0x12: 0xe316, // significant motion
|
|
276
|
+
0x13: 0xe317, // stability classifier
|
|
277
|
+
0x19: 0xe318, // shake detector
|
|
278
|
+
0x1e: 0xe31c, // personal activity classifier
|
|
279
|
+
0x28: 0xe322, // ARVR-stabilized RV
|
|
280
|
+
0x29: 0xe323, // ARVR-stabilized game RV
|
|
281
|
+
0x2a: 0xe324, // gyro-integrated RV
|
|
282
|
+
};
|
|
283
|
+
/** FRS Read Response status (low nibble of the len/status byte). */
|
|
284
|
+
export var FrsStatus;
|
|
285
|
+
(function (FrsStatus) {
|
|
286
|
+
FrsStatus[FrsStatus["NoError"] = 0] = "NoError";
|
|
287
|
+
FrsStatus[FrsStatus["UnrecognizedFrsType"] = 1] = "UnrecognizedFrsType";
|
|
288
|
+
FrsStatus[FrsStatus["Busy"] = 2] = "Busy";
|
|
289
|
+
FrsStatus[FrsStatus["ReadCompleted"] = 3] = "ReadCompleted";
|
|
290
|
+
FrsStatus[FrsStatus["OffsetOutOfRange"] = 4] = "OffsetOutOfRange";
|
|
291
|
+
FrsStatus[FrsStatus["RecordEmpty"] = 5] = "RecordEmpty";
|
|
292
|
+
FrsStatus[FrsStatus["BlockCompleted"] = 6] = "BlockCompleted";
|
|
293
|
+
FrsStatus[FrsStatus["BlockAndReadCompleted"] = 7] = "BlockAndReadCompleted";
|
|
294
|
+
FrsStatus[FrsStatus["DeviceError"] = 8] = "DeviceError";
|
|
295
|
+
})(FrsStatus || (FrsStatus = {}));
|
|
296
|
+
export var FrsWriteStatus;
|
|
297
|
+
(function (FrsWriteStatus) {
|
|
298
|
+
FrsWriteStatus[FrsWriteStatus["WordsReceived"] = 0] = "WordsReceived";
|
|
299
|
+
FrsWriteStatus[FrsWriteStatus["UnrecognizedFrsType"] = 1] = "UnrecognizedFrsType";
|
|
300
|
+
FrsWriteStatus[FrsWriteStatus["Busy"] = 2] = "Busy";
|
|
301
|
+
FrsWriteStatus[FrsWriteStatus["WriteCompleted"] = 3] = "WriteCompleted";
|
|
302
|
+
FrsWriteStatus[FrsWriteStatus["WriteModeReady"] = 4] = "WriteModeReady";
|
|
303
|
+
FrsWriteStatus[FrsWriteStatus["WriteFailed"] = 5] = "WriteFailed";
|
|
304
|
+
FrsWriteStatus[FrsWriteStatus["NotInWriteMode"] = 6] = "NotInWriteMode";
|
|
305
|
+
FrsWriteStatus[FrsWriteStatus["InvalidLength"] = 7] = "InvalidLength";
|
|
306
|
+
FrsWriteStatus[FrsWriteStatus["RecordValid"] = 8] = "RecordValid";
|
|
307
|
+
FrsWriteStatus[FrsWriteStatus["RecordInvalid"] = 9] = "RecordInvalid";
|
|
308
|
+
})(FrsWriteStatus || (FrsWriteStatus = {}));
|
|
309
|
+
/** FRS Read Request (0xF4), 8 bytes. blockWords = 0 reads the record. */
|
|
310
|
+
export function buildFrsReadRequest(frsType, offsetWords = 0, blockWords = 0) {
|
|
311
|
+
const out = new Uint8Array(8);
|
|
312
|
+
const v = new DataView(out.buffer);
|
|
313
|
+
v.setUint8(0, ControlReport.FrsReadRequest);
|
|
314
|
+
v.setUint8(1, 0);
|
|
315
|
+
v.setUint16(2, offsetWords, true);
|
|
316
|
+
v.setUint16(4, frsType, true);
|
|
317
|
+
v.setUint16(6, blockWords, true);
|
|
318
|
+
return out;
|
|
319
|
+
}
|
|
320
|
+
export function unpackFrsReadResponse(payload) {
|
|
321
|
+
const v = view(payload);
|
|
322
|
+
const rid = v.getUint8(0);
|
|
323
|
+
if (rid !== ControlReport.FrsReadResponse) {
|
|
324
|
+
throw new Sh2Error(`not an FRS read response: 0x${hex2(rid)}`);
|
|
325
|
+
}
|
|
326
|
+
const lenStatus = v.getUint8(1);
|
|
327
|
+
return {
|
|
328
|
+
status: lenStatus & 0x0f,
|
|
329
|
+
dataLength: lenStatus >> 4,
|
|
330
|
+
offsetWords: v.getUint16(2, true),
|
|
331
|
+
data0: v.getUint32(4, true),
|
|
332
|
+
data1: v.getUint32(8, true),
|
|
333
|
+
frsType: v.getUint16(12, true),
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
/** FRS Write Request (0xF7), 6 bytes. lengthWords = 0 erases the record. */
|
|
337
|
+
export function buildFrsWriteRequest(frsType, lengthWords) {
|
|
338
|
+
const out = new Uint8Array(6);
|
|
339
|
+
const v = new DataView(out.buffer);
|
|
340
|
+
v.setUint8(0, ControlReport.FrsWriteRequest);
|
|
341
|
+
v.setUint8(1, 0);
|
|
342
|
+
v.setUint16(2, lengthWords, true);
|
|
343
|
+
v.setUint16(4, frsType, true);
|
|
344
|
+
return out;
|
|
345
|
+
}
|
|
346
|
+
/** FRS Write Data (0xF6), 12 bytes; 1 or 2 words per packet. */
|
|
347
|
+
export function buildFrsWriteData(offsetWords, words) {
|
|
348
|
+
if (words.length < 1 || words.length > 2) {
|
|
349
|
+
throw new Error("FRS write data carries 1 or 2 words");
|
|
350
|
+
}
|
|
351
|
+
const out = new Uint8Array(12);
|
|
352
|
+
const v = new DataView(out.buffer);
|
|
353
|
+
v.setUint8(0, ControlReport.FrsWriteData);
|
|
354
|
+
v.setUint8(1, 0);
|
|
355
|
+
v.setUint16(2, offsetWords, true);
|
|
356
|
+
v.setUint32(4, words[0] >>> 0, true);
|
|
357
|
+
v.setUint32(8, (words[1] ?? 0) >>> 0, true);
|
|
358
|
+
return out;
|
|
359
|
+
}
|
|
360
|
+
export function unpackFrsWriteResponse(payload) {
|
|
361
|
+
const v = view(payload);
|
|
362
|
+
const rid = v.getUint8(0);
|
|
363
|
+
if (rid !== ControlReport.FrsWriteResponse) {
|
|
364
|
+
throw new Sh2Error(`not an FRS write response: 0x${hex2(rid)}`);
|
|
365
|
+
}
|
|
366
|
+
return { status: v.getUint8(1), offsetWords: v.getUint16(2, true) };
|
|
367
|
+
}
|
|
368
|
+
const FRS_READ_ERROR_STATUSES = new Set([
|
|
369
|
+
FrsStatus.UnrecognizedFrsType,
|
|
370
|
+
FrsStatus.Busy,
|
|
371
|
+
FrsStatus.OffsetOutOfRange,
|
|
372
|
+
FrsStatus.RecordEmpty,
|
|
373
|
+
FrsStatus.DeviceError,
|
|
374
|
+
]);
|
|
375
|
+
/**
|
|
376
|
+
* Multi-packet FRS read state machine (pure — feed parsed responses).
|
|
377
|
+
*
|
|
378
|
+
* Usage: send `request()`, then `feed()` every 0xF3 for this record until it
|
|
379
|
+
* returns true; `words` holds the record. Error statuses throw.
|
|
380
|
+
*/
|
|
381
|
+
export class FrsReadSession {
|
|
382
|
+
frsType;
|
|
383
|
+
words = [];
|
|
384
|
+
done = false;
|
|
385
|
+
constructor(frsType) {
|
|
386
|
+
this.frsType = frsType;
|
|
387
|
+
}
|
|
388
|
+
request() {
|
|
389
|
+
return buildFrsReadRequest(this.frsType);
|
|
390
|
+
}
|
|
391
|
+
feed(resp) {
|
|
392
|
+
if (resp.frsType !== this.frsType) {
|
|
393
|
+
return this.done; // some other record's traffic — not ours
|
|
394
|
+
}
|
|
395
|
+
if (FRS_READ_ERROR_STATUSES.has(resp.status)) {
|
|
396
|
+
throw new Sh2Error(`FRS read 0x${hex4(this.frsType)} failed: ${FrsStatus[resp.status] ?? resp.status}`);
|
|
397
|
+
}
|
|
398
|
+
for (const word of [resp.data0, resp.data1].slice(0, resp.dataLength)) {
|
|
399
|
+
this.words.push(word);
|
|
400
|
+
}
|
|
401
|
+
if (resp.status === FrsStatus.ReadCompleted || resp.status === FrsStatus.BlockAndReadCompleted) {
|
|
402
|
+
this.done = true;
|
|
403
|
+
}
|
|
404
|
+
return this.done;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
const FRS_WRITE_ERROR_STATUSES = new Set([
|
|
408
|
+
FrsWriteStatus.UnrecognizedFrsType,
|
|
409
|
+
FrsWriteStatus.Busy,
|
|
410
|
+
FrsWriteStatus.WriteFailed,
|
|
411
|
+
FrsWriteStatus.NotInWriteMode,
|
|
412
|
+
FrsWriteStatus.InvalidLength,
|
|
413
|
+
FrsWriteStatus.RecordInvalid,
|
|
414
|
+
]);
|
|
415
|
+
/**
|
|
416
|
+
* Multi-packet FRS write state machine (pure).
|
|
417
|
+
*
|
|
418
|
+
* Usage: send `request()`; then for every 0xF5 call `feed()` — it returns
|
|
419
|
+
* the next Write Data payload to send, or null; `done` flips on
|
|
420
|
+
* WriteCompleted. Error statuses throw.
|
|
421
|
+
*/
|
|
422
|
+
export class FrsWriteSession {
|
|
423
|
+
frsType;
|
|
424
|
+
words;
|
|
425
|
+
offset = 0;
|
|
426
|
+
done = false;
|
|
427
|
+
constructor(frsType, words) {
|
|
428
|
+
this.frsType = frsType;
|
|
429
|
+
this.words = words;
|
|
430
|
+
}
|
|
431
|
+
request() {
|
|
432
|
+
return buildFrsWriteRequest(this.frsType, this.words.length);
|
|
433
|
+
}
|
|
434
|
+
nextData() {
|
|
435
|
+
if (this.offset >= this.words.length)
|
|
436
|
+
return null;
|
|
437
|
+
const chunk = this.words.slice(this.offset, this.offset + 2);
|
|
438
|
+
const payload = buildFrsWriteData(this.offset, chunk);
|
|
439
|
+
this.offset += chunk.length;
|
|
440
|
+
return payload;
|
|
441
|
+
}
|
|
442
|
+
feed(resp) {
|
|
443
|
+
if (FRS_WRITE_ERROR_STATUSES.has(resp.status)) {
|
|
444
|
+
throw new Sh2Error(`FRS write 0x${hex4(this.frsType)} failed: ${FrsWriteStatus[resp.status] ?? resp.status}`);
|
|
445
|
+
}
|
|
446
|
+
if (resp.status === FrsWriteStatus.WriteCompleted) {
|
|
447
|
+
this.done = true;
|
|
448
|
+
return null;
|
|
449
|
+
}
|
|
450
|
+
if (resp.status === FrsWriteStatus.WriteModeReady || resp.status === FrsWriteStatus.WordsReceived) {
|
|
451
|
+
return this.nextData();
|
|
452
|
+
}
|
|
453
|
+
return null; // RecordValid and friends: informational
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
export function sensorMetadataFromWords(words) {
|
|
457
|
+
const w = [...words];
|
|
458
|
+
while (w.length < 10)
|
|
459
|
+
w.push(0);
|
|
460
|
+
const revision = w[3] & 0xffff;
|
|
461
|
+
return {
|
|
462
|
+
meVersion: w[0] & 0xff,
|
|
463
|
+
mhVersion: (w[0] >>> 8) & 0xff,
|
|
464
|
+
shVersion: (w[0] >>> 16) & 0xff,
|
|
465
|
+
rangeRaw: w[1],
|
|
466
|
+
resolutionRaw: w[2],
|
|
467
|
+
revision,
|
|
468
|
+
powerMaQ10: (w[3] >>> 16) & 0xffff,
|
|
469
|
+
minPeriodUs: w[4],
|
|
470
|
+
fifoMax: w[5] & 0xffff,
|
|
471
|
+
fifoReserved: (w[5] >>> 16) & 0xffff,
|
|
472
|
+
batchBufferBytes: w[6] & 0xffff,
|
|
473
|
+
qPoint1: w[7] & 0xffff,
|
|
474
|
+
qPoint2: (w[7] >>> 16) & 0xffff,
|
|
475
|
+
qPoint3: revision >= 3 ? (w[8] >>> 16) & 0xffff : 0,
|
|
476
|
+
maxPeriodUs: revision >= 4 ? w[9] : 0,
|
|
477
|
+
rawWords: [...words],
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
//# sourceMappingURL=sh2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sh2.js","sourceR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QAChC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAE;QACf,aAAa,EAAE,CAAC,CAAC,CAAC,CAAE;QACpB,QAAQ;QACR,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAE,KAAK,EAAE,CAAC,GAAG,MAAM;QACnC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAE;QAClB,OAAO,EAAE,CAAC,CAAC,CAAC,CAAE,GAAG,MAAM;QACvB,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC,CAAE,KAAK,EAAE,CAAC,GAAG,MAAM;QACrC,gBAAgB,EAAE,CAAC,CAAC,CAAC,CAAE,GAAG,MAAM;QAChC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAE,GAAG,MAAM;QACvB,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAE,KAAK,EAAE,CAAC,GAAG,MAAM;QAChC,OAAO,EAAE,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACpD,WAAW,EAAE,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,CAAC;QACtC,QAAQ,EAAE,CAAC,GAAG,KAAK,CAAC;KACrB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SHTP framing layer for the BNO086 (contracts/05_SENSOR_BNO086.md §3).
|
|
3
|
+
*
|
|
4
|
+
* Pure codec — no I/O. A frame is a 4-byte header plus a cargo fragment:
|
|
5
|
+
*
|
|
6
|
+
* length u16 LE — bits 14:0 cargo length *including* the 4-byte header;
|
|
7
|
+
* bit 15 set marks a continuation fragment
|
|
8
|
+
* channel u8 — see ShtpChannel
|
|
9
|
+
* seq u8 — per-channel, per-direction free-running counter
|
|
10
|
+
*
|
|
11
|
+
* For a cargo that spans several bridge frames, the first fragment's length
|
|
12
|
+
* field carries the TOTAL cargo length (header included) even though the
|
|
13
|
+
* frame itself holds fewer bytes; each continuation fragment carries the
|
|
14
|
+
* remaining length (its own header included) with bit 15 set. The receiver
|
|
15
|
+
* trusts the first fragment's total and the actual frame sizes; continuation
|
|
16
|
+
* length fields are informative only.
|
|
17
|
+
*
|
|
18
|
+
* Mirrors the Python reference `depz_sensor_sdk.bno086.shtp`.
|
|
19
|
+
*/
|
|
20
|
+
export declare enum ShtpChannel {
|
|
21
|
+
/** SHTP command channel (advertisements). */
|
|
22
|
+
Command = 0,
|
|
23
|
+
/** Device executable: reset/on/sleep; RX 0x01 = reset done. */
|
|
24
|
+
Executable = 1,
|
|
25
|
+
/** SH-2 control: feature/FRS/command reports. */
|
|
26
|
+
Control = 2,
|
|
27
|
+
/** Non-wake input reports (0xFB timebase + sensors). */
|
|
28
|
+
InputNormal = 3,
|
|
29
|
+
/** Wake input reports (same cargo format as channel 3). */
|
|
30
|
+
InputWake = 4,
|
|
31
|
+
/** Gyro-integrated rotation vector, dense format. */
|
|
32
|
+
GyroRv = 5
|
|
33
|
+
}
|
|
34
|
+
export declare const SHTP_HEADER_SIZE = 4;
|
|
35
|
+
export declare const LENGTH_MASK = 32767;
|
|
36
|
+
export declare const CONTINUATION_BIT = 32768;
|
|
37
|
+
export declare const NUM_CHANNELS = 6;
|
|
38
|
+
/** Host->sensor frames must fit one MCU transmit slot (ERRATA E2: 2 x 64 B). */
|
|
39
|
+
export declare const MAX_TX_FRAME = 64;
|
|
40
|
+
export interface ShtpHeader {
|
|
41
|
+
/** Bits 14:0 — cargo length incl. this 4-byte header. */
|
|
42
|
+
length: number;
|
|
43
|
+
channel: number;
|
|
44
|
+
seq: number;
|
|
45
|
+
continuation: boolean;
|
|
46
|
+
}
|
|
47
|
+
export declare function packShtpHeader(hdr: ShtpHeader): Uint8Array;
|
|
48
|
+
export declare function unpackShtpHeader(data: Uint8Array): ShtpHeader;
|
|
49
|
+
/** One reassembled cargo: `payload` excludes all SHTP headers. */
|
|
50
|
+
export interface ShtpCargo {
|
|
51
|
+
channel: number;
|
|
52
|
+
/** seq of the first fragment. */
|
|
53
|
+
seq: number;
|
|
54
|
+
payload: Uint8Array;
|
|
55
|
+
}
|
|
56
|
+
/** Single-fragment frame: length = header + payload. */
|
|
57
|
+
export declare function buildFrame(channel: number, payload: Uint8Array, seq: number): Uint8Array;
|
|
58
|
+
/**
|
|
59
|
+
* Split a cargo into wire frames of at most `maxFrame` bytes.
|
|
60
|
+
*
|
|
61
|
+
* First fragment advertises the TOTAL cargo length; continuations carry the
|
|
62
|
+
* remaining length with the continuation bit set. seq increments per frame.
|
|
63
|
+
*/
|
|
64
|
+
export declare function fragmentCargo(channel: number, payload: Uint8Array, seqStart: number, maxFrame?: number): Uint8Array[];
|
|
65
|
+
/**
|
|
66
|
+
* Per-channel TX sequence counters + RX cargo reassembly.
|
|
67
|
+
*
|
|
68
|
+
* Feed every inbound frame (the RPT_DATA payload after cmd/timestamp) to
|
|
69
|
+
* `feed()`; it returns a completed ShtpCargo or null. Build outbound frames
|
|
70
|
+
* with `nextFrame()` which consumes the channel's TX seq. The device layer
|
|
71
|
+
* serializes access.
|
|
72
|
+
*/
|
|
73
|
+
export declare class ShtpLayer {
|
|
74
|
+
/** Incomplete cargos thrown away. */
|
|
75
|
+
discarded: number;
|
|
76
|
+
private txSeqs;
|
|
77
|
+
private rx;
|
|
78
|
+
/**
|
|
79
|
+
* Build a single-fragment frame, consuming the channel's TX seq.
|
|
80
|
+
*
|
|
81
|
+
* Host-side cargos always fit one MCU slot (control payloads are <= 21
|
|
82
|
+
* bytes); larger payloads are a caller bug.
|
|
83
|
+
*/
|
|
84
|
+
nextFrame(channel: number, payload: Uint8Array): Uint8Array;
|
|
85
|
+
txSeq(channel: number): number;
|
|
86
|
+
/**
|
|
87
|
+
* Consume one inbound frame; return the cargo when complete.
|
|
88
|
+
*
|
|
89
|
+
* Rules (contract 05 §3): a non-continuation fragment starts a new cargo
|
|
90
|
+
* (discarding any partial one on that channel); a continuation without a
|
|
91
|
+
* cargo in progress is dropped; the cargo completes when the accumulated
|
|
92
|
+
* bytes reach the first fragment's advertised total.
|
|
93
|
+
*/
|
|
94
|
+
feed(frame: Uint8Array): ShtpCargo | null;
|
|
95
|
+
/** Forget all TX seq counters and partial cargos (sensor reset). */
|
|
96
|
+
reset(): void;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=shtp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shtp.d.ts","sourceRoot":"","sources":["../../../src/sensors/bno086/shtp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,oBAAY,WAAW;IACrB,6CAA6C;IAC7C,OAAO,IAAI;IACX,+DAA+D;IAC/D,UAAU,IAAI;IACd,iDAAiD;IACjD,OAAO,IAAI;IACX,wDAAwD;IACxD,WAAW,IAAI;IACf,2DAA2D;IAC3D,SAAS,IAAI;IACb,qDAAqD;IACrD,MAAM,IAAI;CACX;AAED,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAClC,eAAO,MAAM,WAAW,QAAS,CAAC;AAClC,eAAO,MAAM,gBAAgB,QAAS,CAAC;AACvC,eAAO,MAAM,YAAY,IAAI,CAAC;AAE9B,gFAAgF;AAChF,eAAO,MAAM,YAAY,KAAK,CAAC;AAE/B,MAAM,WAAW,UAAU;IACzB,yDAAyD;IACzD,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,OAAO,CAAC;CACvB;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU,CAQ1D;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAS7D;AAED,kEAAkE;AAClE,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,iCAAiC;IACjC,GAAG,E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