@matter-server/ws-controller 0.6.2-alpha.0-20260426-e2eae3d → 0.6.2
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/dist/esm/controller/ControllerCommandHandler.d.ts +1 -6
- package/dist/esm/controller/ControllerCommandHandler.d.ts.map +1 -1
- package/dist/esm/controller/ControllerCommandHandler.js +89 -225
- package/dist/esm/controller/ControllerCommandHandler.js.map +2 -2
- package/dist/esm/controller/Nodes.d.ts +1 -19
- package/dist/esm/controller/Nodes.d.ts.map +1 -1
- package/dist/esm/controller/Nodes.js +0 -31
- package/dist/esm/controller/Nodes.js.map +1 -1
- package/dist/esm/types/CommandHandler.d.ts +1 -117
- package/dist/esm/types/CommandHandler.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/controller/ControllerCommandHandler.ts +100 -248
- package/src/controller/Nodes.ts +1 -48
- package/src/types/CommandHandler.ts +1 -122
package/src/controller/Nodes.ts
CHANGED
|
@@ -5,20 +5,16 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { NodeId } from "@matter/main";
|
|
8
|
-
import { ClusterClientObj } from "@matter/main/protocol";
|
|
9
|
-
import { ClusterId, ClusterType, EndpointNumber } from "@matter/main/types";
|
|
10
|
-
import { InteractionClient } from "@project-chip/matter.js/cluster";
|
|
11
8
|
import { NodeStates, PairedNode } from "@project-chip/matter.js/device";
|
|
12
9
|
import { ServerError } from "../types/WebSocketMessageTypes.js";
|
|
13
10
|
import { AttributeDataCache } from "./AttributeDataCache.js";
|
|
14
11
|
|
|
15
12
|
/**
|
|
16
|
-
* Manages node storage and
|
|
13
|
+
* Manages node storage and tracks per-node availability.
|
|
17
14
|
*
|
|
18
15
|
* This class handles:
|
|
19
16
|
* - Storage of PairedNode instances
|
|
20
17
|
* - Node retrieval and existence checking
|
|
21
|
-
* - Access to interaction clients and cluster clients
|
|
22
18
|
* - Attribute data caching
|
|
23
19
|
* - Connection state tracking for availability debouncing
|
|
24
20
|
*/
|
|
@@ -156,47 +152,4 @@ export class Nodes {
|
|
|
156
152
|
isAvailable(nodeId: NodeId): boolean {
|
|
157
153
|
return this.#lastAvailability.get(nodeId) ?? false;
|
|
158
154
|
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Get the interaction client for a node.
|
|
162
|
-
*/
|
|
163
|
-
interactionClientFor(nodeId: NodeId): InteractionClient {
|
|
164
|
-
return this.get(nodeId).getInteractionClient();
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Get a cluster client by cluster ID for a specific endpoint on a node.
|
|
169
|
-
* @throws Error if endpoint or cluster not found
|
|
170
|
-
* TODO: Migrate to new node API
|
|
171
|
-
*/
|
|
172
|
-
clusterClientByIdFor(nodeId: NodeId, endpointId: EndpointNumber, clusterId: ClusterId): ClusterClientObj<any> {
|
|
173
|
-
const node = this.get(nodeId);
|
|
174
|
-
|
|
175
|
-
const endpoint = endpointId === 0 ? node.getRootEndpoint() : node.getDeviceById(endpointId);
|
|
176
|
-
|
|
177
|
-
if (endpoint === undefined) {
|
|
178
|
-
throw ServerError.invalidArguments(`Endpoint ${endpointId} on node ${nodeId} not found`);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
const client = endpoint.getClusterClientById(clusterId);
|
|
182
|
-
|
|
183
|
-
if (client === undefined) {
|
|
184
|
-
throw ServerError.invalidArguments(
|
|
185
|
-
`Cluster ${clusterId} on endpoint ${endpointId} on node ${nodeId} not found`,
|
|
186
|
-
);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return client;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Get a typed cluster client for a specific endpoint on a node.
|
|
194
|
-
*/
|
|
195
|
-
clusterClientFor<const T extends ClusterType>(
|
|
196
|
-
nodeId: NodeId,
|
|
197
|
-
endpointId: EndpointNumber,
|
|
198
|
-
cluster: T,
|
|
199
|
-
): ClusterClientObj<T["Typing"]> {
|
|
200
|
-
return this.clusterClientByIdFor(nodeId, endpointId, cluster.id!) as ClusterClientObj<T["Typing"]>;
|
|
201
|
-
}
|
|
202
155
|
}
|
|
@@ -3,28 +3,11 @@
|
|
|
3
3
|
* Copyright 2025-2026 Open Home Foundation
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { AttributeId, ClusterId,
|
|
6
|
+
import { AttributeId, ClusterId, Duration, NodeId } from "@matter/main";
|
|
7
7
|
import { CommissionableDeviceIdentifiers } from "@matter/main/protocol";
|
|
8
8
|
import { EndpointNumber, Status } from "@matter/main/types";
|
|
9
9
|
import { ControllerCommissioningFlowOptions } from "@matter/protocol";
|
|
10
10
|
|
|
11
|
-
export type ReadAttributeRequest = {
|
|
12
|
-
nodeId: NodeId;
|
|
13
|
-
/** Endpoint ID or undefined for wildcard */
|
|
14
|
-
endpointId?: EndpointNumber;
|
|
15
|
-
/** Cluster ID or undefined for wildcard */
|
|
16
|
-
clusterId?: ClusterId;
|
|
17
|
-
/** Attribute ID or undefined for wildcard */
|
|
18
|
-
attributeId?: AttributeId;
|
|
19
|
-
fabricFiltered?: boolean;
|
|
20
|
-
};
|
|
21
|
-
export type AttributeResponseData = {
|
|
22
|
-
clusterId: number;
|
|
23
|
-
attributeId: number;
|
|
24
|
-
endpointId: number;
|
|
25
|
-
dataVersion: number;
|
|
26
|
-
value: unknown;
|
|
27
|
-
};
|
|
28
11
|
export type AttributeResponseStatus = {
|
|
29
12
|
clusterId: number;
|
|
30
13
|
attributeId: number;
|
|
@@ -32,33 +15,6 @@ export type AttributeResponseStatus = {
|
|
|
32
15
|
status?: Status;
|
|
33
16
|
clusterStatus?: number;
|
|
34
17
|
};
|
|
35
|
-
export type ReadAttributeResponse = { values: AttributeResponseData[]; status?: AttributeResponseStatus[] };
|
|
36
|
-
|
|
37
|
-
export type ReadByIdRequest = {
|
|
38
|
-
nodeId: NodeId;
|
|
39
|
-
endpointId: EndpointNumber;
|
|
40
|
-
clusterId: ClusterId;
|
|
41
|
-
attributeId: AttributeId;
|
|
42
|
-
fabricFiltered?: boolean;
|
|
43
|
-
};
|
|
44
|
-
export type AttributeErrorResponseData = {
|
|
45
|
-
clusterId: number;
|
|
46
|
-
attributeId: number;
|
|
47
|
-
endpointId: number;
|
|
48
|
-
error: string;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export type ReadByIdResponse = AttributeErrorResponseData;
|
|
52
|
-
|
|
53
|
-
export type SubscribeAttributeRequest = ReadAttributeRequest & {
|
|
54
|
-
minInterval: number;
|
|
55
|
-
maxInterval: number;
|
|
56
|
-
changeListener: (data: AttributeResponseData) => void;
|
|
57
|
-
};
|
|
58
|
-
export type SubscribeAttributeResponse = {
|
|
59
|
-
values: AttributeResponseData[];
|
|
60
|
-
updated: Observable<[void]>;
|
|
61
|
-
};
|
|
62
18
|
|
|
63
19
|
export type WriteAttributeRequest = {
|
|
64
20
|
nodeId: NodeId;
|
|
@@ -68,47 +24,6 @@ export type WriteAttributeRequest = {
|
|
|
68
24
|
value: unknown;
|
|
69
25
|
};
|
|
70
26
|
|
|
71
|
-
export type WriteAttributeByIdRequest = {
|
|
72
|
-
nodeId: NodeId;
|
|
73
|
-
endpointId: EndpointNumber;
|
|
74
|
-
clusterId: ClusterId;
|
|
75
|
-
attributeId: AttributeId;
|
|
76
|
-
value: unknown;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export type ReadEventRequest = {
|
|
80
|
-
nodeId: NodeId;
|
|
81
|
-
endpointId: EndpointNumber;
|
|
82
|
-
clusterId: ClusterId;
|
|
83
|
-
eventId: EventId;
|
|
84
|
-
eventMin?: EventNumber;
|
|
85
|
-
};
|
|
86
|
-
export type EventResponseData = {
|
|
87
|
-
clusterId: number;
|
|
88
|
-
eventId: number;
|
|
89
|
-
endpointId: number;
|
|
90
|
-
eventNumber: number | bigint;
|
|
91
|
-
value: unknown;
|
|
92
|
-
};
|
|
93
|
-
export type EventResponseStatus = {
|
|
94
|
-
clusterId: number;
|
|
95
|
-
eventId: number;
|
|
96
|
-
endpointId: number;
|
|
97
|
-
status?: Status;
|
|
98
|
-
clusterStatus?: number;
|
|
99
|
-
};
|
|
100
|
-
export type ReadEventResponse = { values: EventResponseData[]; status?: EventResponseStatus[] };
|
|
101
|
-
|
|
102
|
-
export type SubscribeEventRequest = ReadEventRequest & {
|
|
103
|
-
minInterval: number;
|
|
104
|
-
maxInterval: number;
|
|
105
|
-
changeListener: (data: EventResponseData) => void;
|
|
106
|
-
};
|
|
107
|
-
export type SubscribeEventResponse = {
|
|
108
|
-
values: EventResponseData[];
|
|
109
|
-
updated: Observable<[void]>;
|
|
110
|
-
};
|
|
111
|
-
|
|
112
27
|
export type InvokeRequest = {
|
|
113
28
|
nodeId: NodeId;
|
|
114
29
|
endpointId: EndpointNumber;
|
|
@@ -118,26 +33,6 @@ export type InvokeRequest = {
|
|
|
118
33
|
timedInteractionTimeoutMs?: Duration;
|
|
119
34
|
interactionTimeoutMs?: Duration;
|
|
120
35
|
};
|
|
121
|
-
export type InvokeResponse = {
|
|
122
|
-
clusterId: number;
|
|
123
|
-
commandId?: number;
|
|
124
|
-
endpointId: number;
|
|
125
|
-
value?: unknown;
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
export type InvokeByIdRequest = {
|
|
129
|
-
nodeId: NodeId;
|
|
130
|
-
endpointId: EndpointNumber;
|
|
131
|
-
clusterId: ClusterId;
|
|
132
|
-
commandId: CommandId;
|
|
133
|
-
data: unknown;
|
|
134
|
-
timedInteractionTimeoutMs?: number;
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
export type DelayRequest = {
|
|
138
|
-
nodeId?: NodeId;
|
|
139
|
-
expireExistingSession?: boolean;
|
|
140
|
-
};
|
|
141
36
|
|
|
142
37
|
export type CommissioningRequest = {
|
|
143
38
|
nodeId?: NodeId;
|
|
@@ -185,22 +80,6 @@ export type DiscoveryResponse = {
|
|
|
185
80
|
mrpSessionActiveInterval?: number;
|
|
186
81
|
}[];
|
|
187
82
|
|
|
188
|
-
export type RootCertificateResponse = {
|
|
189
|
-
RCAC: Uint8Array;
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
export type IssueNocChainRequest = {
|
|
193
|
-
elements: Uint8Array;
|
|
194
|
-
nodeId: NodeId;
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
export type IssueNocChainResponse = {
|
|
198
|
-
ICAC?: Uint8Array;
|
|
199
|
-
IPK: Uint8Array;
|
|
200
|
-
NOC: Uint8Array;
|
|
201
|
-
RCAC: Uint8Array;
|
|
202
|
-
};
|
|
203
|
-
|
|
204
83
|
export type OpenCommissioningWindowRequest = {
|
|
205
84
|
nodeId: NodeId;
|
|
206
85
|
timeout?: number;
|