Skip to content

Commit e7c5470

Browse files
authored
refactor: zniffer exports, add to /safe entrypoint (#6830)
1 parent d127c77 commit e7c5470

File tree

7 files changed

+48
-57
lines changed

7 files changed

+48
-57
lines changed

packages/core/src/capabilities/Protocols.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ export enum MPDUHeaderType {
128128
Singlecast = 0x1,
129129
Multicast = 0x2,
130130
Acknowledgement = 0x3,
131+
Explorer = 0x5,
131132
Routed = 0x8,
132133
}
133134

packages/zwave-js/src/Zniffer.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export { BeamingInfo, MPDUHeaderType } from "@zwave-js/core/safe";
12
export type { MPDU } from "./lib/zniffer/MPDU";
23
export type {
34
BeamFrame,
@@ -6,12 +7,11 @@ export type {
67
LongRangeFrame,
78
ZWaveFrame,
89
} from "./lib/zniffer/MPDU";
10+
export { LongRangeMPDU, ZWaveMPDU, parseMPDU } from "./lib/zniffer/MPDU";
11+
export type { ZnifferOptions } from "./lib/zniffer/Zniffer";
12+
export { Zniffer } from "./lib/zniffer/Zniffer";
913
export {
14+
ExplorerFrameCommand,
1015
LongRangeFrameType,
11-
LongRangeMPDU,
1216
ZWaveFrameType,
13-
ZWaveMPDU,
14-
parseMPDU,
15-
} from "./lib/zniffer/MPDU";
16-
export type { ZnifferOptions } from "./lib/zniffer/Zniffer";
17-
export { Zniffer } from "./lib/zniffer/Zniffer";
17+
} from "./lib/zniffer/_Types";

packages/zwave-js/src/Zniffer_safe.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export { BeamingInfo, MPDUHeaderType } from "@zwave-js/core/safe";
2+
export type { ZnifferOptions } from "./lib/zniffer/Zniffer";
3+
export {
4+
ExplorerFrameCommand,
5+
LongRangeFrameType,
6+
ZWaveFrameType,
7+
} from "./lib/zniffer/_Types";

packages/zwave-js/src/index_safe.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ export * from "./Error";
66
export * from "./Node_safe";
77
export * from "./Utils_safe";
88
export * from "./Values";
9+
export * from "./Zniffer_safe";

packages/zwave-js/src/lib/zniffer/MPDU.ts

Lines changed: 7 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { type CommandClass } from "@zwave-js/cc";
22
import {
3+
type BeamingInfo,
4+
MPDUHeaderType,
35
type MessageOrCCLogEntry,
46
type MessageRecord,
57
Protocols,
@@ -26,16 +28,11 @@ import {
2628
} from "@zwave-js/shared";
2729
import { padStart } from "alcalzone-shared/strings";
2830
import { parseRSSI } from "../serialapi/transport/SendDataShared";
29-
30-
// FIXME: Parsing breaks on this chunk:
31-
// 21003021030bdcb605840141020b03005e2101000021003421030adcb6058403
32-
// 03020a011d2101000002002a21030ec5b9bc284641010e019f01be32d42101000002002a21030e
33-
// c5b9bc284641010e019f01be32d42101000021002921030dc5b9bc284651010d019f01be2d2101
34-
// 000002002a210311c5b9bc2846910111010010439f01beb6a32101000002002a
35-
// 210311c5b9bc2846810111010010439f01be2235
36-
37-
// FIXME: Beam Stop frame is followed by 0x00, which gets discarded - why?
38-
// 210500003000e6210100 00
31+
import {
32+
ExplorerFrameCommand,
33+
LongRangeFrameType,
34+
ZWaveFrameType,
35+
} from "./_Types";
3936

4037
function getChannelConfiguration(region: ZnifferRegion): "1/2" | "3" | "4" {
4138
switch (region) {
@@ -95,27 +92,6 @@ export interface MPDUOptions {
9592
frameInfo: ZnifferFrameInfo;
9693
}
9794

98-
export enum MPDUHeaderType {
99-
Singlecast = 0x1,
100-
Multicast = 0x2,
101-
Acknowledgement = 0x3,
102-
Explorer = 0x5,
103-
Routed = 0x8,
104-
}
105-
106-
export enum BeamingInfo {
107-
None = 0b00,
108-
ShortContinuous = 0b01,
109-
LongContinuous = 0b10,
110-
Fragmented = 0b100,
111-
}
112-
113-
export enum ExplorerFrameCommand {
114-
Normal = 0x00,
115-
InclusionRequest = 0x01,
116-
SearchResult = 0x02,
117-
}
118-
11995
export interface MPDU {
12096
frameInfo: ZnifferFrameInfo;
12197
homeId: number;
@@ -934,18 +910,6 @@ export class BeamStop {
934910
}
935911
}
936912

937-
export enum ZWaveFrameType {
938-
Singlecast,
939-
Multicast,
940-
AckDirect,
941-
ExplorerNormal,
942-
ExplorerSearchResult,
943-
ExplorerInclusionRequest,
944-
BeamStart,
945-
BeamStop,
946-
}
947-
948-
/** An application-oriented representation of a Z-Wave frame that was captured by the Zniffer */
949913
export type ZWaveFrame =
950914
// Common fields for all Z-Wave frames
951915
& {
@@ -1042,13 +1006,6 @@ export type ZWaveFrame =
10421006
)
10431007
);
10441008

1045-
export enum LongRangeFrameType {
1046-
Singlecast,
1047-
Ack,
1048-
BeamStart,
1049-
BeamStop,
1050-
}
1051-
10521009
export type LongRangeFrame =
10531010
// Common fields for all Long Range frames
10541011
& {

packages/zwave-js/src/lib/zniffer/Zniffer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
import {
99
CommandClasses,
1010
type LogConfig,
11+
MPDUHeaderType,
1112
type RSSI,
1213
SPANState,
1314
SecurityClass,
@@ -61,7 +62,6 @@ import { ZnifferCCParsingContext } from "./CCParsingContext";
6162
import {
6263
type CorruptedFrame,
6364
type Frame,
64-
MPDUHeaderType,
6565
beamToFrame,
6666
mpduToFrame,
6767
parseBeamFrame,
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
export enum ExplorerFrameCommand {
2+
Normal = 0x00,
3+
InclusionRequest = 0x01,
4+
SearchResult = 0x02,
5+
}
6+
7+
export enum ZWaveFrameType {
8+
Singlecast,
9+
Multicast,
10+
AckDirect,
11+
ExplorerNormal,
12+
ExplorerSearchResult,
13+
ExplorerInclusionRequest,
14+
BeamStart,
15+
BeamStop,
16+
}
17+
18+
/** An application-oriented representation of a Z-Wave frame that was captured by the Zniffer */
19+
20+
export enum LongRangeFrameType {
21+
Singlecast,
22+
Ack,
23+
BeamStart,
24+
BeamStop,
25+
}

0 commit comments

Comments
 (0)