@wms-js/lib 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/LICENSE +21 -0
- package/README.md +16 -0
- package/dist/command/ack-match.d.ts +5 -0
- package/dist/command/ack-match.js +9 -0
- package/dist/command/ack-match.js.map +1 -0
- package/dist/command/session.d.ts +23 -0
- package/dist/command/session.js +98 -0
- package/dist/command/session.js.map +1 -0
- package/dist/command/types.d.ts +14 -0
- package/dist/command/types.js +2 -0
- package/dist/command/types.js.map +1 -0
- package/dist/commands/name.d.ts +25 -0
- package/dist/commands/name.js +209 -0
- package/dist/commands/name.js.map +1 -0
- package/dist/controller.d.ts +26 -0
- package/dist/controller.js +108 -0
- package/dist/controller.js.map +1 -0
- package/dist/frame/errors.d.ts +4 -0
- package/dist/frame/errors.js +9 -0
- package/dist/frame/errors.js.map +1 -0
- package/dist/frame/parser.d.ts +13 -0
- package/dist/frame/parser.js +69 -0
- package/dist/frame/parser.js.map +1 -0
- package/dist/frame/serializer.d.ts +1 -0
- package/dist/frame/serializer.js +5 -0
- package/dist/frame/serializer.js.map +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/logging/logger.d.ts +15 -0
- package/dist/logging/logger.js +60 -0
- package/dist/logging/logger.js.map +1 -0
- package/dist/network/events.d.ts +6 -0
- package/dist/network/events.js +24 -0
- package/dist/network/events.js.map +1 -0
- package/dist/network/manager.d.ts +36 -0
- package/dist/network/manager.js +281 -0
- package/dist/network/manager.js.map +1 -0
- package/dist/network/types.d.ts +35 -0
- package/dist/network/types.js +2 -0
- package/dist/network/types.js.map +1 -0
- package/dist/parsers/device-scan-response.d.ts +10 -0
- package/dist/parsers/device-scan-response.js +24 -0
- package/dist/parsers/device-scan-response.js.map +1 -0
- package/dist/parsers/device-scan.d.ts +6 -0
- package/dist/parsers/device-scan.js +14 -0
- package/dist/parsers/device-scan.js.map +1 -0
- package/dist/parsers/device-status.d.ts +14 -0
- package/dist/parsers/device-status.js +23 -0
- package/dist/parsers/device-status.js.map +1 -0
- package/dist/parsers/move-response.d.ts +8 -0
- package/dist/parsers/move-response.js +16 -0
- package/dist/parsers/move-response.js.map +1 -0
- package/dist/parsers/network-join.d.ts +8 -0
- package/dist/parsers/network-join.js +29 -0
- package/dist/parsers/network-join.js.map +1 -0
- package/dist/parsers/network-params.d.ts +7 -0
- package/dist/parsers/network-params.js +19 -0
- package/dist/parsers/network-params.js.map +1 -0
- package/dist/parsers/wave-request.d.ts +5 -0
- package/dist/parsers/wave-request.js +13 -0
- package/dist/parsers/wave-request.js.map +1 -0
- package/dist/parsers/wave-response.d.ts +6 -0
- package/dist/parsers/wave-response.js +14 -0
- package/dist/parsers/wave-response.js.map +1 -0
- package/dist/parsers/weather-station.d.ts +9 -0
- package/dist/parsers/weather-station.js +30 -0
- package/dist/parsers/weather-station.js.map +1 -0
- package/dist/routing/broadcast-router.d.ts +9 -0
- package/dist/routing/broadcast-router.js +40 -0
- package/dist/routing/broadcast-router.js.map +1 -0
- package/dist/serial/driver.d.ts +8 -0
- package/dist/serial/driver.js +2 -0
- package/dist/serial/driver.js.map +1 -0
- package/dist/testing/mock-serial.d.ts +22 -0
- package/dist/testing/mock-serial.js +62 -0
- package/dist/testing/mock-serial.js.map +1 -0
- package/package.json +29 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { MalformedFrameError } from "./errors.js";
|
|
2
|
+
const decoder = new TextDecoder("utf-8", { fatal: false });
|
|
3
|
+
export class FrameParser {
|
|
4
|
+
buffer = "";
|
|
5
|
+
malformedHandler = null;
|
|
6
|
+
malformedTimer = null;
|
|
7
|
+
partialTimeoutMs;
|
|
8
|
+
constructor(partialTimeoutMs = 1000) {
|
|
9
|
+
this.partialTimeoutMs = partialTimeoutMs;
|
|
10
|
+
}
|
|
11
|
+
onMalformedFrame(handler) {
|
|
12
|
+
this.malformedHandler = handler;
|
|
13
|
+
return () => {
|
|
14
|
+
this.malformedHandler = null;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
feed(data) {
|
|
18
|
+
const text = decoder.decode(data, { stream: true });
|
|
19
|
+
this.buffer += text;
|
|
20
|
+
const frames = [];
|
|
21
|
+
let startIdx = 0;
|
|
22
|
+
while (startIdx < this.buffer.length) {
|
|
23
|
+
const openIdx = this.buffer.indexOf("{", startIdx);
|
|
24
|
+
if (openIdx === -1) {
|
|
25
|
+
this.buffer = "";
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
const closeIdx = this.buffer.indexOf("}", openIdx + 1);
|
|
29
|
+
if (closeIdx === -1) {
|
|
30
|
+
const partial = this.buffer.slice(openIdx);
|
|
31
|
+
this.buffer = partial;
|
|
32
|
+
this.startMalformedTimer(partial);
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
this.clearMalformedTimer();
|
|
36
|
+
const content = this.buffer.slice(openIdx + 1, closeIdx);
|
|
37
|
+
frames.push(content);
|
|
38
|
+
const nextStart = closeIdx + 1;
|
|
39
|
+
if (nextStart >= this.buffer.length) {
|
|
40
|
+
this.buffer = "";
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
startIdx = nextStart;
|
|
44
|
+
}
|
|
45
|
+
return frames;
|
|
46
|
+
}
|
|
47
|
+
reset() {
|
|
48
|
+
this.clearMalformedTimer();
|
|
49
|
+
this.buffer = "";
|
|
50
|
+
}
|
|
51
|
+
startMalformedTimer(partial) {
|
|
52
|
+
this.clearMalformedTimer();
|
|
53
|
+
this.malformedTimer = setTimeout(() => {
|
|
54
|
+
const error = new MalformedFrameError(partial);
|
|
55
|
+
if (this.malformedHandler) {
|
|
56
|
+
this.malformedHandler(error);
|
|
57
|
+
}
|
|
58
|
+
this.buffer = this.buffer.replace(partial, "");
|
|
59
|
+
this.malformedTimer = null;
|
|
60
|
+
}, this.partialTimeoutMs);
|
|
61
|
+
}
|
|
62
|
+
clearMalformedTimer() {
|
|
63
|
+
if (this.malformedTimer !== null) {
|
|
64
|
+
clearTimeout(this.malformedTimer);
|
|
65
|
+
this.malformedTimer = null;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../src/frame/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEjD,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;AAE1D,MAAM,OAAO,WAAW;IACd,MAAM,GAAG,EAAE,CAAA;IACX,gBAAgB,GAAkD,IAAI,CAAA;IACtE,cAAc,GAAyC,IAAI,CAAA;IAClD,gBAAgB,CAAQ;IAEzC,YAAY,gBAAgB,GAAG,IAAI;QACjC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAA;IAC1C,CAAC;IAED,gBAAgB,CAAC,OAA6C;QAC5D,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAA;QAC/B,OAAO,GAAG,EAAE;YACV,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAA;QAC9B,CAAC,CAAA;IACH,CAAC;IAED,IAAI,CAAC,IAAgB;QACnB,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;QACnD,IAAI,CAAC,MAAM,IAAI,IAAI,CAAA;QAEnB,MAAM,MAAM,GAAa,EAAE,CAAA;QAC3B,IAAI,QAAQ,GAAG,CAAC,CAAA;QAEhB,OAAO,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YACrC,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;YAClD,IAAI,OAAO,KAAK,CA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IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAA;YAC9B,CAAC;YACD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;YAC9C,IAAI,CAAC,cAAc,GAAG,IAAI,CAAA;QAC5B,CAAC,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAA;IAC3B,CAAC;IAEO,mBAAmB;QACzB,IAAI,IAAI,CAAC,cAAc,KAAK,IAAI,EAAE,CAAC;YACjC,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;YACjC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAA;QAC5B,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function serializeFrame(content: string): Uint8Array;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../../src/frame/serializer.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAA;AAEjC,MAAM,UAAU,cAAc,CAAC,OAAe;IAC5C,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,OAAO,GAAG,CAAC,CAAA;AACvC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export { FrameParser } from "./frame/parser.js";
|
|
2
|
+
export { serializeFrame } from "./frame/serializer.js";
|
|
3
|
+
export { MalformedFrameError } from "./frame/errors.js";
|
|
4
|
+
export { CommandSession } from "./command/session.js";
|
|
5
|
+
export { ackMatch } from "./command/ack-match.js";
|
|
6
|
+
export { RadioController } from "./controller.js";
|
|
7
|
+
export { Commands } from "./commands/name.js";
|
|
8
|
+
export { type SerialDriver } from "./serial/driver.js";
|
|
9
|
+
export { type SendResult, type SessionOptions } from "./command/types.js";
|
|
10
|
+
export { MockSerialDriver } from "./testing/mock-serial.js";
|
|
11
|
+
export { weatherStationMatcher } from "./parsers/weather-station.js";
|
|
12
|
+
export type { WeatherStationMessage } from "./parsers/weather-station.js";
|
|
13
|
+
export { networkParamsMatcher } from "./parsers/network-params.js";
|
|
14
|
+
export type { NetworkParamsMessage } from "./parsers/network-params.js";
|
|
15
|
+
export { deviceScanMatcher } from "./parsers/device-scan.js";
|
|
16
|
+
export type { DeviceScanQuery } from "./parsers/device-scan.js";
|
|
17
|
+
export { deviceScanResponseMatcher, getDeviceTypeName } from "./parsers/device-scan-response.js";
|
|
18
|
+
export type { DeviceScanResponse } from "./parsers/device-scan-response.js";
|
|
19
|
+
export { deviceStatusMatcher } from "./parsers/device-status.js";
|
|
20
|
+
export type { DeviceStatus, DeviceDirection } from "./parsers/device-status.js";
|
|
21
|
+
export { waveRequestMatcher } from "./parsers/wave-request.js";
|
|
22
|
+
export type { WaveRequest } from "./parsers/wave-request.js";
|
|
23
|
+
export { waveResponseMatcher } from "./parsers/wave-response.js";
|
|
24
|
+
export type { WaveResponse } from "./parsers/wave-response.js";
|
|
25
|
+
export { moveResponseMatcher } from "./parsers/move-response.js";
|
|
26
|
+
export type { MoveResponse } from "./parsers/move-response.js";
|
|
27
|
+
export { networkJoinMatcher } from "./parsers/network-join.js";
|
|
28
|
+
export type { NetworkJoinMessage } from "./parsers/network-join.js";
|
|
29
|
+
export { BroadcastRouter } from "./routing/broadcast-router.js";
|
|
30
|
+
export { NetworkManager } from "./network/manager.js";
|
|
31
|
+
export { TypedEventEmitter } from "./network/events.js";
|
|
32
|
+
export type { ConnectionState, KnownDevice, NetworkEventMap } from "./network/types.js";
|
|
33
|
+
export { LogLevel, setLogLevel, getLogLevel, info, debug, warn, error, log } from "./logging/logger.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export { FrameParser } from "./frame/parser.js";
|
|
2
|
+
export { serializeFrame } from "./frame/serializer.js";
|
|
3
|
+
export { MalformedFrameError } from "./frame/errors.js";
|
|
4
|
+
export { CommandSession } from "./command/session.js";
|
|
5
|
+
export { ackMatch } from "./command/ack-match.js";
|
|
6
|
+
export { RadioController } from "./controller.js";
|
|
7
|
+
export { Commands } from "./commands/name.js";
|
|
8
|
+
export { MockSerialDriver } from "./testing/mock-serial.js";
|
|
9
|
+
export { weatherStationMatcher } from "./parsers/weather-station.js";
|
|
10
|
+
export { networkParamsMatcher } from "./parsers/network-params.js";
|
|
11
|
+
export { deviceScanMatcher } from "./parsers/device-scan.js";
|
|
12
|
+
export { deviceScanResponseMatcher, getDeviceTypeName } from "./parsers/device-scan-response.js";
|
|
13
|
+
export { deviceStatusMatcher } from "./parsers/device-status.js";
|
|
14
|
+
export { waveRequestMatcher } from "./parsers/wave-request.js";
|
|
15
|
+
export { waveResponseMatcher } from "./parsers/wave-response.js";
|
|
16
|
+
export { moveResponseMatcher } from "./parsers/move-response.js";
|
|
17
|
+
export { networkJoinMatcher } from "./parsers/network-join.js";
|
|
18
|
+
export { BroadcastRouter } from "./routing/broadcast-router.js";
|
|
19
|
+
export { NetworkManager } from "./network/manager.js";
|
|
20
|
+
export { TypedEventEmitter } from "./network/events.js";
|
|
21
|
+
export { LogLevel, setLogLevel, getLogLevel, info, debug, warn, error, log } from "./logging/logger.js";
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAG7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AAEpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAElE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAE5D,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAA;AAEhG,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAEhE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAE9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAEhE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAEhE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAE9D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAEvD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const LogLevel: {
|
|
2
|
+
readonly DEBUG: 0;
|
|
3
|
+
readonly INFO: 1;
|
|
4
|
+
readonly WARN: 2;
|
|
5
|
+
readonly ERROR: 3;
|
|
6
|
+
readonly SILENT: 4;
|
|
7
|
+
};
|
|
8
|
+
export type LogLevel = (typeof LogLevel)[keyof typeof LogLevel];
|
|
9
|
+
export declare function setLogLevel(level: LogLevel): void;
|
|
10
|
+
export declare function getLogLevel(): LogLevel;
|
|
11
|
+
export declare function log(level: LogLevel, tag: string, message: string, ...rest: unknown[]): void;
|
|
12
|
+
export declare function debug(tag: string, message: string, ...rest: unknown[]): void;
|
|
13
|
+
export declare function info(tag: string, message: string, ...rest: unknown[]): void;
|
|
14
|
+
export declare function warn(tag: string, message: string, ...rest: unknown[]): void;
|
|
15
|
+
export declare function error(tag: string, message: string, ...rest: unknown[]): void;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export const LogLevel = {
|
|
2
|
+
DEBUG: 0,
|
|
3
|
+
INFO: 1,
|
|
4
|
+
WARN: 2,
|
|
5
|
+
ERROR: 3,
|
|
6
|
+
SILENT: 4,
|
|
7
|
+
};
|
|
8
|
+
const levelNames = {
|
|
9
|
+
debug: LogLevel.DEBUG,
|
|
10
|
+
info: LogLevel.INFO,
|
|
11
|
+
warn: LogLevel.WARN,
|
|
12
|
+
error: LogLevel.ERROR,
|
|
13
|
+
silent: LogLevel.SILENT,
|
|
14
|
+
};
|
|
15
|
+
function parseLevel() {
|
|
16
|
+
if (typeof process !== "undefined" && process.env?.WMS_LOG_LEVEL) {
|
|
17
|
+
const n = levelNames[process.env.WMS_LOG_LEVEL.toLowerCase()];
|
|
18
|
+
if (n !== undefined)
|
|
19
|
+
return n;
|
|
20
|
+
}
|
|
21
|
+
return LogLevel.INFO;
|
|
22
|
+
}
|
|
23
|
+
let currentLevel = parseLevel();
|
|
24
|
+
export function setLogLevel(level) {
|
|
25
|
+
currentLevel = level;
|
|
26
|
+
}
|
|
27
|
+
export function getLogLevel() {
|
|
28
|
+
return currentLevel;
|
|
29
|
+
}
|
|
30
|
+
const label = (level) => {
|
|
31
|
+
switch (level) {
|
|
32
|
+
case LogLevel.DEBUG: return "DBG";
|
|
33
|
+
case LogLevel.INFO: return "INF";
|
|
34
|
+
case LogLevel.WARN: return "WRN";
|
|
35
|
+
case LogLevel.ERROR: return "ERR";
|
|
36
|
+
default: return "???";
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const timestamp = () => new Date().toISOString();
|
|
40
|
+
export function log(level, tag, message, ...rest) {
|
|
41
|
+
if (level < currentLevel)
|
|
42
|
+
return;
|
|
43
|
+
const fn = level >= LogLevel.ERROR ? console.error
|
|
44
|
+
: level >= LogLevel.WARN ? console.warn
|
|
45
|
+
: console.log;
|
|
46
|
+
fn(`[${timestamp()}] [${label(level)}] [${tag}] ${message}`, ...rest);
|
|
47
|
+
}
|
|
48
|
+
export function debug(tag, message, ...rest) {
|
|
49
|
+
log(LogLevel.DEBUG, tag, message, ...rest);
|
|
50
|
+
}
|
|
51
|
+
export function info(tag, message, ...rest) {
|
|
52
|
+
log(LogLevel.INFO, tag, message, ...rest);
|
|
53
|
+
}
|
|
54
|
+
export function warn(tag, message, ...rest) {
|
|
55
|
+
log(LogLevel.WARN, tag, message, ...rest);
|
|
56
|
+
}
|
|
57
|
+
export function error(tag, message, ...rest) {
|
|
58
|
+
log(LogLevel.ERROR, tag, message, ...rest);
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/logging/logger.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;IACR,MAAM,EAAE,CAAC;CACD,CAAA;AAIV,MAAM,UAAU,GAA6B;IAC3C,KAAK,EAAE,QAAQ,CAAC,KAAK;IACrB,IAAI,EAAE,QAAQ,CAAC,IAAI;IACnB,IAAI,EAAE,QAAQ,CAAC,IAAI;IACnB,KAAK,EAAE,QAAQ,CAAC,KAAK;IACrB,MAAM,EAAE,QAAQ,CAAC,MAAM;CACxB,CAAA;AAED,SAAS,UAAU;IACjB,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,aAAa,EAAE,CAAC;QACjE,MAAM,CAAC,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC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OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAA;AACvE,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,GAAW,EAAE,OAAe,EAAE,GAAG,IAAe;IACpE,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,CAAA;AAC5C,CAAC;AAED,MAAM,UAAU,IAAI,CAAC,GAAW,EAAE,OAAe,EAAE,GAAG,IAAe;IACnE,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,CAAA;AAC3C,CAAC;AAED,MAAM,UAAU,IAAI,CAAC,GAAW,EAAE,OAAe,EAAE,GAAG,IAAe;IACnE,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,CAAA;AAC3C,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,GAAW,EAAE,OAAe,EAAE,GAAG,IAAe;IACpE,GAAG,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,CAAA;AAC5C,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export class TypedEventEmitter {
|
|
2
|
+
listeners = new Map();
|
|
3
|
+
on(type, fn) {
|
|
4
|
+
let set = this.listeners.get(type);
|
|
5
|
+
if (!set) {
|
|
6
|
+
set = new Set();
|
|
7
|
+
this.listeners.set(type, set);
|
|
8
|
+
}
|
|
9
|
+
set.add(fn);
|
|
10
|
+
return () => {
|
|
11
|
+
set.delete(fn);
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
emit(type, event) {
|
|
15
|
+
this.listeners.get(type)?.forEach((fn) => {
|
|
16
|
+
;
|
|
17
|
+
fn(event);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
removeAllListeners() {
|
|
21
|
+
this.listeners.clear();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/network/events.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,iBAAiB;IACpB,SAAS,GAAG,IAAI,GAAG,EAAiD,CAAA;IAE5E,EAAE,CAA2B,IAAO,EAAE,EAAgC;QACpE,IAAI,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAClC,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,GAAG,GAAG,IAAI,GAAG,EAAE,CAAA;YACf,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;QAC/B,CAAC;QACD,GAAG,CAAC,GAAG,CAAC,EAA8B,CAAC,CAAA;QACvC,OAAO,GAAG,EAAE;YACV,GAAI,CAAC,MAAM,CAAC,EAA8B,CAAC,CAAA;QAC7C,CAAC,CAAA;IACH,CAAC;IAED,IAAI,CAA2B,IAAO,EAAE,KAAkB;QACxD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE;YACvC,CAAC;YAAC,EAAmC,CAAC,KAAK,CAAC,CAAA;QAC9C,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,kBAAkB;QAChB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAA;IACxB,CAAC;CACF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type SerialDriver } from "../serial/driver.js";
|
|
2
|
+
import type { ConnectionState, KnownDevice, NetworkEventMap } from "./types.js";
|
|
3
|
+
export declare class NetworkManager {
|
|
4
|
+
private driver;
|
|
5
|
+
private parser;
|
|
6
|
+
private emitter;
|
|
7
|
+
private writeQueue;
|
|
8
|
+
private _state;
|
|
9
|
+
private devices;
|
|
10
|
+
private stickName;
|
|
11
|
+
private movingTimer;
|
|
12
|
+
private lastPositions;
|
|
13
|
+
constructor(driver: SerialDriver);
|
|
14
|
+
get state(): ConnectionState;
|
|
15
|
+
get knownDevices(): KnownDevice[];
|
|
16
|
+
on<K extends keyof NetworkEventMap>(type: K, fn: (event: NetworkEventMap[K]) => void): () => void;
|
|
17
|
+
open(path: string, params: {
|
|
18
|
+
channel: number;
|
|
19
|
+
panId: string;
|
|
20
|
+
key?: string;
|
|
21
|
+
}): Promise<void>;
|
|
22
|
+
close(): Promise<void>;
|
|
23
|
+
scanNetwork(panId: string): void;
|
|
24
|
+
queryStatus(serialNumber: string): void;
|
|
25
|
+
waveDevice(serialNumber: string): void;
|
|
26
|
+
moveToPosition(serialNumber: string, position: number, inclination?: number): void;
|
|
27
|
+
stopDevice(serialNumber: string): void;
|
|
28
|
+
private startMovingPoll;
|
|
29
|
+
private stopMovingPoll;
|
|
30
|
+
private sendCommand;
|
|
31
|
+
private onSerialData;
|
|
32
|
+
private processFrame;
|
|
33
|
+
private hasStatusChanged;
|
|
34
|
+
private emitError;
|
|
35
|
+
private onClose;
|
|
36
|
+
}
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { FrameParser } from "../frame/parser.js";
|
|
2
|
+
import { serializeFrame } from "../frame/serializer.js";
|
|
3
|
+
import { ackMatch } from "../command/ack-match.js";
|
|
4
|
+
import { weatherStationMatcher } from "../parsers/weather-station.js";
|
|
5
|
+
import { deviceScanResponseMatcher } from "../parsers/device-scan-response.js";
|
|
6
|
+
import { deviceStatusMatcher } from "../parsers/device-status.js";
|
|
7
|
+
import { waveResponseMatcher } from "../parsers/wave-response.js";
|
|
8
|
+
import { waveRequestMatcher } from "../parsers/wave-request.js";
|
|
9
|
+
import { moveResponseMatcher } from "../parsers/move-response.js";
|
|
10
|
+
import { TypedEventEmitter } from "./events.js";
|
|
11
|
+
import { info, debug } from "../logging/logger.js";
|
|
12
|
+
export class NetworkManager {
|
|
13
|
+
driver;
|
|
14
|
+
parser = new FrameParser();
|
|
15
|
+
emitter = new TypedEventEmitter();
|
|
16
|
+
writeQueue = Promise.resolve();
|
|
17
|
+
_state = "disconnected";
|
|
18
|
+
devices = new Map();
|
|
19
|
+
stickName = "";
|
|
20
|
+
movingTimer = null;
|
|
21
|
+
lastPositions = new Map();
|
|
22
|
+
constructor(driver) {
|
|
23
|
+
this.driver = driver;
|
|
24
|
+
}
|
|
25
|
+
get state() {
|
|
26
|
+
return this._state;
|
|
27
|
+
}
|
|
28
|
+
get knownDevices() {
|
|
29
|
+
return [...this.devices.values()];
|
|
30
|
+
}
|
|
31
|
+
on(type, fn) {
|
|
32
|
+
return this.emitter.on(type, fn);
|
|
33
|
+
}
|
|
34
|
+
async open(path, params) {
|
|
35
|
+
this._state = "connecting";
|
|
36
|
+
await this.driver.open(path);
|
|
37
|
+
const setupParser = new FrameParser();
|
|
38
|
+
const send = (cmd) => this.driver.write(serializeFrame(cmd));
|
|
39
|
+
const sendAndWait = (cmd, matcher, timeoutMs = 1000) => {
|
|
40
|
+
return new Promise((resolve, reject) => {
|
|
41
|
+
let timer = null;
|
|
42
|
+
const cleanup = () => {
|
|
43
|
+
if (timer !== null)
|
|
44
|
+
clearTimeout(timer);
|
|
45
|
+
unsub();
|
|
46
|
+
};
|
|
47
|
+
const unsub = this.driver.onData((data) => {
|
|
48
|
+
const frames = setupParser.feed(data);
|
|
49
|
+
for (const frame of frames) {
|
|
50
|
+
if (frame === "f") {
|
|
51
|
+
cleanup();
|
|
52
|
+
reject(new Error(`Command rejected: ${cmd}`));
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const result = matcher(frame);
|
|
56
|
+
if (result !== null) {
|
|
57
|
+
cleanup();
|
|
58
|
+
resolve(result);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
send(cmd);
|
|
64
|
+
timer = setTimeout(() => {
|
|
65
|
+
cleanup();
|
|
66
|
+
reject(new Error(`Timeout waiting for response to: ${cmd}`));
|
|
67
|
+
}, timeoutMs);
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
try {
|
|
71
|
+
const name = await sendAndWait("G", ackMatch.prefix("g"));
|
|
72
|
+
this.stickName = name.trim();
|
|
73
|
+
const modeChar = "%";
|
|
74
|
+
const panId = params.panId.toUpperCase();
|
|
75
|
+
await sendAndWait(`M ${modeChar} ${params.channel} ${panId}`, ackMatch.exact("a"));
|
|
76
|
+
if (params.key) {
|
|
77
|
+
await sendAndWait(`K 401 ${params.key.toUpperCase()}`, ackMatch.exact("a"));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
await this.driver.close().catch(() => { });
|
|
82
|
+
this._state = "disconnected";
|
|
83
|
+
throw err;
|
|
84
|
+
}
|
|
85
|
+
this.parser.reset();
|
|
86
|
+
const unsubData = this.driver.onData((data) => this.onSerialData(data));
|
|
87
|
+
const unsubError = this.driver.onError((error) => this.emitError(error));
|
|
88
|
+
const unsubClose = this.driver.onClose(() => this.onClose());
|
|
89
|
+
this._state = "configured";
|
|
90
|
+
this.emitter.emit("connected", { stickName: this.stickName });
|
|
91
|
+
this.emitter.emit("configured", {});
|
|
92
|
+
}
|
|
93
|
+
async close() {
|
|
94
|
+
this.parser.reset();
|
|
95
|
+
if (this.movingTimer) {
|
|
96
|
+
clearInterval(this.movingTimer);
|
|
97
|
+
this.movingTimer = null;
|
|
98
|
+
}
|
|
99
|
+
await this.driver.close().catch(() => { });
|
|
100
|
+
this._state = "disconnected";
|
|
101
|
+
this.devices.clear();
|
|
102
|
+
this.lastPositions.clear();
|
|
103
|
+
this.emitter.emit("disconnected", {});
|
|
104
|
+
}
|
|
105
|
+
scanNetwork(panId) {
|
|
106
|
+
this.sendCommand(`R04FFFFFF7020${panId.toUpperCase()}02`);
|
|
107
|
+
}
|
|
108
|
+
queryStatus(serialNumber) {
|
|
109
|
+
this.sendCommand(`R06${serialNumber.toUpperCase()}801001000005`);
|
|
110
|
+
}
|
|
111
|
+
waveDevice(serialNumber) {
|
|
112
|
+
this.sendCommand(`R06${serialNumber.toUpperCase()}7050`);
|
|
113
|
+
}
|
|
114
|
+
moveToPosition(serialNumber, position, inclination = 0) {
|
|
115
|
+
const upper = serialNumber.toUpperCase();
|
|
116
|
+
const pp = Math.round(position * 2).toString(16).toUpperCase().padStart(2, "0");
|
|
117
|
+
const ww = Math.round(inclination + 127).toString(16).toUpperCase().padStart(2, "0");
|
|
118
|
+
this.sendCommand(`R06${upper}707003${pp}${ww}FFFF`);
|
|
119
|
+
const device = this.devices.get(upper);
|
|
120
|
+
if (device) {
|
|
121
|
+
const prev = device.status;
|
|
122
|
+
device.status = {
|
|
123
|
+
serialNumber: upper,
|
|
124
|
+
deviceType: device.deviceType,
|
|
125
|
+
deviceTypeName: device.deviceTypeName,
|
|
126
|
+
position: prev?.position ?? 0,
|
|
127
|
+
inclination: prev?.inclination ?? 0,
|
|
128
|
+
valance1: prev?.valance1 ?? 0,
|
|
129
|
+
valance2: prev?.valance2 ?? 0,
|
|
130
|
+
moving: true,
|
|
131
|
+
direction: prev !== undefined && position < prev.position ? "opening" : "closing",
|
|
132
|
+
raw: "",
|
|
133
|
+
};
|
|
134
|
+
this.devices.set(upper, device);
|
|
135
|
+
this.emitter.emit("deviceStatus", { serial: upper, status: device.status });
|
|
136
|
+
info("MOVE", `${upper} moving=true direction=${device.status.direction} (from moveToPosition)`);
|
|
137
|
+
}
|
|
138
|
+
this.startMovingPoll();
|
|
139
|
+
this.queryStatus(upper);
|
|
140
|
+
}
|
|
141
|
+
stopDevice(serialNumber) {
|
|
142
|
+
const upper = serialNumber.toUpperCase();
|
|
143
|
+
this.sendCommand(`R06${upper}707001`);
|
|
144
|
+
// Always reflect stop immediately — even if we don't think it's moving
|
|
145
|
+
const device = this.devices.get(upper);
|
|
146
|
+
if (device?.status) {
|
|
147
|
+
device.status = { ...device.status, moving: false, direction: "stopped" };
|
|
148
|
+
this.devices.set(upper, device);
|
|
149
|
+
this.emitter.emit("deviceStatus", { serial: upper, status: device.status });
|
|
150
|
+
this.stopMovingPoll();
|
|
151
|
+
info("STOP", `${upper} moving=false (from stopDevice)`);
|
|
152
|
+
}
|
|
153
|
+
this.queryStatus(upper);
|
|
154
|
+
}
|
|
155
|
+
startMovingPoll() {
|
|
156
|
+
if (this.movingTimer)
|
|
157
|
+
return;
|
|
158
|
+
this.movingTimer = setInterval(() => {
|
|
159
|
+
for (const [serial, device] of this.devices) {
|
|
160
|
+
if (device.status?.moving) {
|
|
161
|
+
this.queryStatus(serial);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}, 2000);
|
|
165
|
+
}
|
|
166
|
+
stopMovingPoll() {
|
|
167
|
+
const hasMoving = [...this.devices.values()].some((d) => d.status?.moving);
|
|
168
|
+
if (!hasMoving && this.movingTimer) {
|
|
169
|
+
clearInterval(this.movingTimer);
|
|
170
|
+
this.movingTimer = null;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
sendCommand(frame) {
|
|
174
|
+
this.writeQueue = this.writeQueue
|
|
175
|
+
.then(() => this.driver.write(serializeFrame(frame)))
|
|
176
|
+
.catch(() => { });
|
|
177
|
+
}
|
|
178
|
+
onSerialData(data) {
|
|
179
|
+
const frames = this.parser.feed(data);
|
|
180
|
+
for (const frame of frames) {
|
|
181
|
+
this.processFrame(frame);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
processFrame(frame) {
|
|
185
|
+
const ws = weatherStationMatcher(frame);
|
|
186
|
+
if (ws) {
|
|
187
|
+
this.emitter.emit("weatherStation", {
|
|
188
|
+
serial: ws.serialNumber,
|
|
189
|
+
windSpeed: ws.windSpeed,
|
|
190
|
+
});
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
const ds = deviceScanResponseMatcher(frame);
|
|
194
|
+
if (ds) {
|
|
195
|
+
if (!this.devices.has(ds.serialNumber)) {
|
|
196
|
+
this.devices.set(ds.serialNumber, {
|
|
197
|
+
serialNumber: ds.serialNumber,
|
|
198
|
+
deviceType: ds.deviceType,
|
|
199
|
+
deviceTypeName: ds.deviceTypeName,
|
|
200
|
+
});
|
|
201
|
+
this.emitter.emit("deviceDiscovered", { device: ds });
|
|
202
|
+
}
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
const st = deviceStatusMatcher(frame);
|
|
206
|
+
if (st) {
|
|
207
|
+
// Once stopped, ignore 8011 reports that say "moving" — only
|
|
208
|
+
// moveToPosition() or a 7071 with valid pp can re-enter moving.
|
|
209
|
+
const prev = this.devices.get(st.serialNumber)?.status;
|
|
210
|
+
const wouldOverride = !!(prev && !prev.moving && st.moving);
|
|
211
|
+
// Derive direction from position change (only when moving=true)
|
|
212
|
+
const lastPos = this.lastPositions.get(st.serialNumber);
|
|
213
|
+
if (st.moving && lastPos !== undefined && Number.isFinite(st.position) && !isNaN(st.position)) {
|
|
214
|
+
if (st.position < lastPos) {
|
|
215
|
+
st.direction = "opening";
|
|
216
|
+
}
|
|
217
|
+
else if (st.position > lastPos) {
|
|
218
|
+
st.direction = "closing";
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
st.direction = "stopped";
|
|
223
|
+
}
|
|
224
|
+
if (wouldOverride) {
|
|
225
|
+
debug("8011", `${st.serialNumber} override prev=${prev.moving} raw=${st.moving} → false`);
|
|
226
|
+
st.moving = false;
|
|
227
|
+
}
|
|
228
|
+
if (Number.isFinite(st.position) && !isNaN(st.position)) {
|
|
229
|
+
this.lastPositions.set(st.serialNumber, st.position);
|
|
230
|
+
}
|
|
231
|
+
if (!prev || this.hasStatusChanged(prev, st)) {
|
|
232
|
+
const device = this.devices.get(st.serialNumber) ?? {
|
|
233
|
+
serialNumber: st.serialNumber,
|
|
234
|
+
deviceType: st.deviceType,
|
|
235
|
+
deviceTypeName: st.deviceTypeName,
|
|
236
|
+
};
|
|
237
|
+
device.status = st;
|
|
238
|
+
this.devices.set(st.serialNumber, device);
|
|
239
|
+
this.emitter.emit("deviceStatus", { serial: st.serialNumber, status: st });
|
|
240
|
+
}
|
|
241
|
+
if (st.moving) {
|
|
242
|
+
this.startMovingPoll();
|
|
243
|
+
}
|
|
244
|
+
this.stopMovingPoll();
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
const mv = moveResponseMatcher(frame);
|
|
248
|
+
if (mv) {
|
|
249
|
+
debug("7071", `${frame} serial=${mv.serialNumber} cmd=${mv.subCommand} pp=${mv.previousPosition}% ww=${mv.previousInclination}°`);
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
const wr = waveResponseMatcher(frame);
|
|
253
|
+
if (wr) {
|
|
254
|
+
this.emitter.emit("waveResult", {
|
|
255
|
+
serial: wr.serialNumber,
|
|
256
|
+
code: wr.code,
|
|
257
|
+
});
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
const wq = waveRequestMatcher(frame);
|
|
261
|
+
if (wq) {
|
|
262
|
+
this.emitter.emit("waveResult", { serial: wq.serialNumber });
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
hasStatusChanged(a, b) {
|
|
267
|
+
return (a.position !== b.position ||
|
|
268
|
+
a.inclination !== b.inclination ||
|
|
269
|
+
a.moving !== b.moving ||
|
|
270
|
+
a.direction !== b.direction ||
|
|
271
|
+
a.valance1 !== b.valance1 ||
|
|
272
|
+
a.valance2 !== b.valance2);
|
|
273
|
+
}
|
|
274
|
+
emitError(error) {
|
|
275
|
+
this.emitter.emit("error", { error });
|
|
276
|
+
}
|
|
277
|
+
onClose() {
|
|
278
|
+
this.close();
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
//# sourceMappingURL=manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manager.js","sourceRoot":"","sources":["../../src/network/manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAw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AC,CAAA;YAC5D,OAAM;QACR,CAAC;IACH,CAAC;IAEO,gBAAgB,CAAC,CAAe,EAAE,CAAe;QACvD,OAAO,CACL,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,QAAQ;YACzB,CAAC,CAAC,WAAW,KAAK,CAAC,CAAC,WAAW;YAC/B,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;YACrB,CAAC,CAAC,SAAS,KAAK,CAAC,CAAC,SAAS;YAC3B,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,QAAQ;YACzB,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,QAAQ,CAC1B,CAAA;IACH,CAAC;IAEO,SAAS,CAAC,KAAY;QAC5B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;IACvC,CAAC;IAEO,OAAO;QACb,IAAI,CAAC,KAAK,EAAE,CAAA;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { DeviceScanResponse } from "../parsers/device-scan-response.js";
|
|
2
|
+
import type { DeviceStatus } from "../parsers/device-status.js";
|
|
3
|
+
export type ConnectionState = "disconnected" | "connecting" | "configured";
|
|
4
|
+
export interface KnownDevice {
|
|
5
|
+
serialNumber: string;
|
|
6
|
+
deviceType: string;
|
|
7
|
+
deviceTypeName: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
status?: DeviceStatus;
|
|
10
|
+
}
|
|
11
|
+
export interface NetworkEventMap {
|
|
12
|
+
connected: {
|
|
13
|
+
stickName: string;
|
|
14
|
+
};
|
|
15
|
+
disconnected: {};
|
|
16
|
+
configured: {};
|
|
17
|
+
error: {
|
|
18
|
+
error: Error;
|
|
19
|
+
};
|
|
20
|
+
weatherStation: {
|
|
21
|
+
serial: string;
|
|
22
|
+
windSpeed: number;
|
|
23
|
+
};
|
|
24
|
+
deviceDiscovered: {
|
|
25
|
+
device: DeviceScanResponse;
|
|
26
|
+
};
|
|
27
|
+
deviceStatus: {
|
|
28
|
+
serial: string;
|
|
29
|
+
status: DeviceStatus;
|
|
30
|
+
};
|
|
31
|
+
waveResult: {
|
|
32
|
+
serial: string;
|
|
33
|
+
code?: string;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/network/types.ts"],"names":[],"mappings":""}
|