@matter/nodejs-shell 0.17.0-alpha.0-20260507-059f7763b → 0.17.0-alpha.0-20260508-29ff5ae9e
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/package.json +9 -9
- package/src/MatterNode.ts +13 -12
- package/src/shell/cmd_cert.ts +34 -0
- package/src/shell/cmd_commission.ts +24 -1
- package/src/shell/cmd_config.ts +140 -0
- package/src/shell/cmd_nodes.ts +1 -3
- package/dist/esm/MatterNode.js +0 -189
- package/dist/esm/MatterNode.js.map +0 -6
- package/dist/esm/app.js +0 -167
- package/dist/esm/app.js.map +0 -6
- package/dist/esm/package.json +0 -3
- package/dist/esm/shell/Shell.js +0 -201
- package/dist/esm/shell/Shell.js.map +0 -6
- package/dist/esm/shell/cmd_cert.js +0 -134
- package/dist/esm/shell/cmd_cert.js.map +0 -6
- package/dist/esm/shell/cmd_cluster-attributes.js +0 -295
- package/dist/esm/shell/cmd_cluster-attributes.js.map +0 -6
- package/dist/esm/shell/cmd_cluster-commands.js +0 -137
- package/dist/esm/shell/cmd_cluster-commands.js.map +0 -6
- package/dist/esm/shell/cmd_cluster-events.js +0 -77
- package/dist/esm/shell/cmd_cluster-events.js.map +0 -6
- package/dist/esm/shell/cmd_commission.js +0 -269
- package/dist/esm/shell/cmd_commission.js.map +0 -6
- package/dist/esm/shell/cmd_config.js +0 -462
- package/dist/esm/shell/cmd_config.js.map +0 -6
- package/dist/esm/shell/cmd_dcl.js +0 -178
- package/dist/esm/shell/cmd_dcl.js.map +0 -6
- package/dist/esm/shell/cmd_discover.js +0 -115
- package/dist/esm/shell/cmd_discover.js.map +0 -6
- package/dist/esm/shell/cmd_identify.js +0 -46
- package/dist/esm/shell/cmd_identify.js.map +0 -6
- package/dist/esm/shell/cmd_nodes.js +0 -688
- package/dist/esm/shell/cmd_nodes.js.map +0 -6
- package/dist/esm/shell/cmd_ota.js +0 -493
- package/dist/esm/shell/cmd_ota.js.map +0 -6
- package/dist/esm/shell/cmd_session.js +0 -23
- package/dist/esm/shell/cmd_session.js.map +0 -6
- package/dist/esm/shell/cmd_subscribe.js +0 -39
- package/dist/esm/shell/cmd_subscribe.js.map +0 -6
- package/dist/esm/shell/cmd_tlv.js +0 -167
- package/dist/esm/shell/cmd_tlv.js.map +0 -6
- package/dist/esm/shell/cmd_vendor.js +0 -135
- package/dist/esm/shell/cmd_vendor.js.map +0 -6
- package/dist/esm/util/CommandlineParser.js +0 -87
- package/dist/esm/util/CommandlineParser.js.map +0 -6
- package/dist/esm/util/Json.js +0 -45
- package/dist/esm/util/Json.js.map +0 -6
- package/dist/esm/web_plumbing.js +0 -140
- package/dist/esm/web_plumbing.js.map +0 -6
|
@@ -1,295 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2022-2026 Matter.js Authors
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import { Diagnostic } from "@matter/general";
|
|
7
|
-
import { Matter } from "@matter/model";
|
|
8
|
-
import { AttributeId, ClusterId, EndpointNumber, ValidationError } from "@matter/types";
|
|
9
|
-
import { SupportedAttributeClient } from "@project-chip/matter.js/cluster";
|
|
10
|
-
import { convertJsonDataWithModel } from "../util/Json.js";
|
|
11
|
-
function generateAllAttributeHandlersForCluster(yargs, theNode) {
|
|
12
|
-
Matter.clusters.forEach((cluster) => {
|
|
13
|
-
yargs = generateClusterAttributeHandlers(yargs, cluster, theNode);
|
|
14
|
-
});
|
|
15
|
-
yargs = yargs.command(
|
|
16
|
-
"by-id <cluster-id> read <attribute-id> <node-id> <endpoint-id>",
|
|
17
|
-
`Read attributes by id`,
|
|
18
|
-
(yargs2) => yargs2.positional("cluster-id", {
|
|
19
|
-
describe: "cluster id to read from",
|
|
20
|
-
type: "number",
|
|
21
|
-
demandOption: true
|
|
22
|
-
}).positional("attribute-id", {
|
|
23
|
-
describe: "attribute id to read, use * to read all attributes of the given cluster",
|
|
24
|
-
type: "string",
|
|
25
|
-
demandOption: true
|
|
26
|
-
}).positional("node-id", {
|
|
27
|
-
describe: "node id to read",
|
|
28
|
-
type: "string",
|
|
29
|
-
demandOption: true
|
|
30
|
-
}).positional("endpoint-id", {
|
|
31
|
-
describe: "endpoint id to read",
|
|
32
|
-
type: "number",
|
|
33
|
-
demandOption: true
|
|
34
|
-
}),
|
|
35
|
-
async (argv) => {
|
|
36
|
-
const { nodeId, endpointId, clusterId, attributeId: rawAttributeId } = argv;
|
|
37
|
-
const attributeId = rawAttributeId === "*" ? void 0 : parseInt(rawAttributeId);
|
|
38
|
-
const node = (await theNode.connectAndGetNodes(nodeId))[0];
|
|
39
|
-
try {
|
|
40
|
-
const interactionClient = await node.getInteractionClient();
|
|
41
|
-
const result = await interactionClient.getMultipleAttributes({
|
|
42
|
-
attributes: [
|
|
43
|
-
{
|
|
44
|
-
endpointId: EndpointNumber(endpointId),
|
|
45
|
-
clusterId: ClusterId(clusterId),
|
|
46
|
-
attributeId: attributeId !== void 0 ? AttributeId(attributeId) : void 0
|
|
47
|
-
}
|
|
48
|
-
]
|
|
49
|
-
});
|
|
50
|
-
console.log(
|
|
51
|
-
`Attribute values for cluster ${node.nodeId.toString()}/${endpointId}/${clusterId}/${attributeId}:`
|
|
52
|
-
);
|
|
53
|
-
for (const {
|
|
54
|
-
path: { attributeId: attributeId2, attributeName },
|
|
55
|
-
value
|
|
56
|
-
} of result) {
|
|
57
|
-
console.log(
|
|
58
|
-
` ${Diagnostic.hex(attributeId2)}${attributeName !== void 0 ? ` (${attributeName})` : ""}: ${Diagnostic.json(value)}`
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
} catch (error) {
|
|
62
|
-
console.log(
|
|
63
|
-
`ERROR: Could not get attribute ${node.nodeId.toString()}/${endpointId}/${clusterId}/${attributeId}: ${error}`
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
);
|
|
68
|
-
return yargs;
|
|
69
|
-
}
|
|
70
|
-
function generateClusterAttributeHandlers(yargs, cluster, theNode) {
|
|
71
|
-
const clusterId = cluster.id;
|
|
72
|
-
if (clusterId === void 0) {
|
|
73
|
-
return yargs;
|
|
74
|
-
}
|
|
75
|
-
yargs = yargs.command(
|
|
76
|
-
[cluster.name.toLowerCase(), `0x${clusterId.toString(16)}`],
|
|
77
|
-
`Read/Write ${cluster.name} attributes`,
|
|
78
|
-
(yargs2) => {
|
|
79
|
-
yargs2 = yargs2.command(
|
|
80
|
-
"read",
|
|
81
|
-
`Reads attributes of ${cluster.name}`,
|
|
82
|
-
(yargs3) => {
|
|
83
|
-
yargs3 = yargs3.command(
|
|
84
|
-
["* <node-id> <endpoint-id>", "all"],
|
|
85
|
-
`Read all attributes of ${cluster.name}`,
|
|
86
|
-
(yargs4) => {
|
|
87
|
-
return yargs4.positional("node-id", {
|
|
88
|
-
describe: "node id to read",
|
|
89
|
-
type: "string",
|
|
90
|
-
demandOption: true
|
|
91
|
-
}).positional("endpoint-id", {
|
|
92
|
-
describe: "endpoint id to read",
|
|
93
|
-
type: "number",
|
|
94
|
-
demandOption: true
|
|
95
|
-
}).options({
|
|
96
|
-
remote: {
|
|
97
|
-
describe: "request value always remote. Also ignores information about attribute existence on device",
|
|
98
|
-
default: false,
|
|
99
|
-
type: "boolean"
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
},
|
|
103
|
-
async (argv) => {
|
|
104
|
-
const clusterId2 = cluster.id;
|
|
105
|
-
const { nodeId, endpointId, remote } = argv;
|
|
106
|
-
const requestRemote = remote ? true : void 0;
|
|
107
|
-
const node = (await theNode.connectAndGetNodes(nodeId))[0];
|
|
108
|
-
const clusterClient = node.getDeviceById(endpointId)?.getClusterClientById(ClusterId(clusterId2));
|
|
109
|
-
if (clusterClient === void 0) {
|
|
110
|
-
console.log(
|
|
111
|
-
`ERROR: Cluster ${node.nodeId.toString()}/${endpointId}/${clusterId2} not found.`
|
|
112
|
-
);
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
console.log(
|
|
116
|
-
`Attribute values for cluster ${cluster.name} (${node.nodeId.toString()}/${endpointId}/${clusterId2}):`
|
|
117
|
-
);
|
|
118
|
-
for (const attribute of cluster.attributes) {
|
|
119
|
-
const attributeName = attribute.propertyName;
|
|
120
|
-
const attributeClient = clusterClient.attributes[attributeName];
|
|
121
|
-
if (!remote && !(attributeClient instanceof SupportedAttributeClient)) {
|
|
122
|
-
continue;
|
|
123
|
-
}
|
|
124
|
-
console.log(
|
|
125
|
-
` ${attributeName} (${attribute.id}): ${Diagnostic.json(await attributeClient.get(requestRemote))}`
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
);
|
|
130
|
-
cluster.attributes.forEach((attribute) => {
|
|
131
|
-
yargs3 = generateAttributeReadHandler(yargs3, clusterId, cluster.name, attribute, theNode);
|
|
132
|
-
});
|
|
133
|
-
return yargs3;
|
|
134
|
-
},
|
|
135
|
-
async (argv) => {
|
|
136
|
-
argv.unhandled = true;
|
|
137
|
-
}
|
|
138
|
-
);
|
|
139
|
-
if (cluster.attributes.some((attribute) => attribute.writable)) {
|
|
140
|
-
yargs2 = yargs2.command(
|
|
141
|
-
"write",
|
|
142
|
-
`Writes attributes of ${cluster.name}`,
|
|
143
|
-
(yargs3) => {
|
|
144
|
-
cluster.attributes.forEach((attribute) => {
|
|
145
|
-
if (!attribute.writable) {
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
yargs3 = generateAttributeWriteHandler(yargs3, clusterId, cluster.name, attribute, theNode);
|
|
149
|
-
});
|
|
150
|
-
return yargs3;
|
|
151
|
-
},
|
|
152
|
-
async (argv) => {
|
|
153
|
-
argv.unhandled = true;
|
|
154
|
-
}
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
return yargs2;
|
|
158
|
-
},
|
|
159
|
-
async (argv) => {
|
|
160
|
-
argv.unhandled = true;
|
|
161
|
-
}
|
|
162
|
-
);
|
|
163
|
-
return yargs;
|
|
164
|
-
}
|
|
165
|
-
function generateAttributeReadHandler(yargs, clusterId, clusterName, attribute, theNode) {
|
|
166
|
-
const attributeName = attribute.propertyName;
|
|
167
|
-
return yargs.command(
|
|
168
|
-
[`${attribute.name.toLowerCase()} <node-id> <endpoint-id>`, `0x${attribute.id.toString(16)}`],
|
|
169
|
-
`Read ${clusterName}.${attribute.name} attribute`,
|
|
170
|
-
(yargs2) => yargs2.positional("node-id", {
|
|
171
|
-
describe: "node id to read",
|
|
172
|
-
type: "string",
|
|
173
|
-
demandOption: true
|
|
174
|
-
}).positional("endpoint-id", {
|
|
175
|
-
describe: "endpoint id to read",
|
|
176
|
-
type: "number",
|
|
177
|
-
demandOption: true
|
|
178
|
-
}).options({
|
|
179
|
-
remote: {
|
|
180
|
-
describe: "request value always remote. Also ignores information about attribute existence on device",
|
|
181
|
-
default: false,
|
|
182
|
-
type: "boolean"
|
|
183
|
-
}
|
|
184
|
-
}),
|
|
185
|
-
async (argv) => {
|
|
186
|
-
const { nodeId, endpointId, remote } = argv;
|
|
187
|
-
const requestRemote = remote ? true : void 0;
|
|
188
|
-
const node = (await theNode.connectAndGetNodes(nodeId))[0];
|
|
189
|
-
const clusterClient = node.getDeviceById(endpointId)?.getClusterClientById(ClusterId(clusterId));
|
|
190
|
-
if (clusterClient === void 0) {
|
|
191
|
-
console.log(`ERROR: Cluster ${node.nodeId.toString()}/${endpointId}/${clusterId} not found.`);
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
const attributeClient = clusterClient.attributes[attributeName];
|
|
195
|
-
if (!remote && !(attributeClient instanceof SupportedAttributeClient)) {
|
|
196
|
-
console.log(
|
|
197
|
-
`ERROR: Attribute ${node.nodeId.toString()}/${endpointId}/${clusterId}/${attribute.id} not supported by the device.`
|
|
198
|
-
);
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
try {
|
|
202
|
-
console.log(
|
|
203
|
-
`Attribute value for ${attributeName} ${node.nodeId.toString()}/${endpointId}/${clusterId}/${attribute.id}: ${Diagnostic.json(await attributeClient.get(requestRemote))}`
|
|
204
|
-
);
|
|
205
|
-
} catch (error) {
|
|
206
|
-
console.log(`ERROR: Could not get attribute ${attribute.name}: ${error}`);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
);
|
|
210
|
-
}
|
|
211
|
-
function generateAttributeWriteHandler(yargs, clusterId, clusterName, attribute, theNode) {
|
|
212
|
-
const attributeName = attribute.propertyName;
|
|
213
|
-
const typeHint = `${attribute.type}${attribute.definingModel === void 0 ? "" : " as JSON string"}`;
|
|
214
|
-
return yargs.command(
|
|
215
|
-
[`${attribute.name.toLowerCase()} <value> <nodeId> <endpointId>`, `0x${attribute.id.toString(16)}`],
|
|
216
|
-
`Write ${clusterName}.${attribute.name} attribute`,
|
|
217
|
-
(yargs2) => yargs2.positional("value", {
|
|
218
|
-
describe: `value to write (${typeHint})`,
|
|
219
|
-
type: "string",
|
|
220
|
-
demandOption: true
|
|
221
|
-
}).positional("node-id", {
|
|
222
|
-
describe: "node id to write t.",
|
|
223
|
-
type: "string",
|
|
224
|
-
demandOption: true
|
|
225
|
-
}).positional("endpoint-id", {
|
|
226
|
-
describe: "endpoint id to write to",
|
|
227
|
-
type: "number",
|
|
228
|
-
demandOption: true
|
|
229
|
-
}).options({
|
|
230
|
-
force: {
|
|
231
|
-
describe: "ignore verification if attribute exists on device",
|
|
232
|
-
default: false,
|
|
233
|
-
type: "boolean"
|
|
234
|
-
}
|
|
235
|
-
}),
|
|
236
|
-
async (argv) => {
|
|
237
|
-
const { nodeId, endpointId, value, force } = argv;
|
|
238
|
-
let parsedValue;
|
|
239
|
-
try {
|
|
240
|
-
parsedValue = JSON.parse(value);
|
|
241
|
-
} catch (error) {
|
|
242
|
-
try {
|
|
243
|
-
parsedValue = JSON.parse(`"${value}"`);
|
|
244
|
-
} catch (innerError) {
|
|
245
|
-
console.log(`ERROR: Could not parse value ${value} as JSON.`);
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
const node = (await theNode.connectAndGetNodes(nodeId))[0];
|
|
250
|
-
const clusterClient = node.getDeviceById(endpointId)?.getClusterClientById(ClusterId(clusterId));
|
|
251
|
-
if (clusterClient === void 0) {
|
|
252
|
-
console.log(`ERROR: Cluster ${node.nodeId.toString()}/${endpointId}/${clusterId} not found.`);
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
const attributeClient = clusterClient.attributes[attributeName];
|
|
256
|
-
if (!force && !(attributeClient instanceof SupportedAttributeClient)) {
|
|
257
|
-
console.log(
|
|
258
|
-
`ERROR: Attribute ${node.nodeId.toString()}/${endpointId}/${clusterId}/${attribute.id} not supported by the device.`
|
|
259
|
-
);
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
try {
|
|
263
|
-
parsedValue = convertJsonDataWithModel(attribute, parsedValue);
|
|
264
|
-
await attributeClient.set(parsedValue);
|
|
265
|
-
console.log(
|
|
266
|
-
`Attribute ${attributeName} ${node.nodeId.toString()}/${endpointId}/${clusterId}/${attribute.id} set to ${Diagnostic.json(value)}`
|
|
267
|
-
);
|
|
268
|
-
} catch (error) {
|
|
269
|
-
if (error instanceof ValidationError) {
|
|
270
|
-
console.log(
|
|
271
|
-
`ERROR: Could not validate data for attribute ${attribute.name} to ${Diagnostic.json(parsedValue)}: ${error}${error.fieldName !== void 0 ? ` in field ${error.fieldName}` : ""}`
|
|
272
|
-
);
|
|
273
|
-
} else {
|
|
274
|
-
console.log(
|
|
275
|
-
`ERROR: Could not set attribute ${attribute.name} to ${Diagnostic.json(parsedValue)}: ${error}`
|
|
276
|
-
);
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
);
|
|
281
|
-
}
|
|
282
|
-
function cmdAttributes(theNode) {
|
|
283
|
-
return {
|
|
284
|
-
command: ["attributes", "a"],
|
|
285
|
-
describe: "Read and Write attributes",
|
|
286
|
-
builder: (yargs) => generateAllAttributeHandlersForCluster(yargs, theNode),
|
|
287
|
-
handler: async (argv) => {
|
|
288
|
-
argv.unhandled = true;
|
|
289
|
-
}
|
|
290
|
-
};
|
|
291
|
-
}
|
|
292
|
-
export {
|
|
293
|
-
cmdAttributes as default
|
|
294
|
-
};
|
|
295
|
-
//# sourceMappingURL=cmd_cluster-attributes.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/shell/cmd_cluster-attributes.ts"],
|
|
4
|
-
"mappings": "AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,SAAS,kBAAkB;AAC3B,SAAuC,cAAc;AACrD,SAAS,aAAa,WAAW,gBAAgB,uBAAuB;AACxE,SAAS,gCAAgC;AAGzC,SAAS,gCAAgC;AAEzC,SAAS,uCAAuC,OAAa,SAAqB;AAC9E,SAAO,SAAS,QAAQ,aAAW;AAC/B,YAAQ,iCAAiC,OAAO,SAAS,OAAO;AAAA,EACpE,CAAC;AAED,UAAQ,MAAM;AAAA,IACV;AAAA,IACA;AAAA,IACA,CAAAA,WACIA,OACK,WAAW,cAAc;AAAA,MACtB,UAAU;AAAA,MACV,MAAM;AAAA,MACN,cAAc;AAAA,IAClB,CAAC,EACA,WAAW,gBAAgB;AAAA,MACxB,UAAU;AAAA,MACV,MAAM;AAAA,MACN,cAAc;AAAA,IAClB,CAAC,EACA,WAAW,WAAW;AAAA,MACnB,UAAU;AAAA,MACV,MAAM;AAAA,MACN,cAAc;AAAA,IAClB,CAAC,EACA,WAAW,eAAe;AAAA,MACvB,UAAU;AAAA,MACV,MAAM;AAAA,MACN,cAAc;AAAA,IAClB,CAAC;AAAA,IACT,OAAM,SAAQ;AACV,YAAM,EAAE,QAAQ,YAAY,WAAW,aAAa,eAAe,IAAI;AACvE,YAAM,cAAc,mBAAmB,MAAM,SAAY,SAAS,cAAc;AAChF,YAAM,QAAQ,MAAM,QAAQ,mBAAmB,MAAM,GAAG,CAAC;AAEzD,UAAI;AACA,cAAM,o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W;AAE7D,cAAM,gBAAgB,IAAI,WAAW;AACrC,gBAAQ;AAAA,UACJ,aAAa,aAAa,IAAI,KAAK,OAAO,SAAS,CAAC,IAAI,UAAU,IAAI,SAAS,IAAI,UAAU,EAAE,WAAW,WAAW,KAAK,KAAK,CAAC;AAAA,QACpI;AAAA,MACJ,SAAS,OAAO;AACZ,YAAI,iBAAiB,iBAAiB;AAClC,kBAAQ;AAAA,YACJ,gDAAgD,UAAU,IAAI,OAAO,WAAW,KAAK,WAAW,CAAC,KAAK,KAAK,GAAG,MAAM,cAAc,SAAY,aAAa,MAAM,SAAS,KAAK,EAAE;AAAA,UACrL;AAAA,QACJ,OAAO;AACH,kBAAQ;AAAA,YACJ,kCAAkC,UAAU,IAAI,OAAO,WAAW,KAAK,WAAW,CAAC,KAAK,KAAK;AAAA,UACjG;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AACJ;AAEe,SAAR,cAA+B,SAAqB;AACvD,SAAO;AAAA,IACH,SAAS,CAAC,cAAc,GAAG;AAAA,IAC3B,UAAU;AAAA,IACV,SAAS,CAAC,UAAgB,uCAAuC,OAAO,OAAO;AAAA,IAC/E,SAAS,OAAO,SAAc;AAC1B,WAAK,YAAY;AAAA,IACrB;AAAA,EACJ;AACJ;",
|
|
5
|
-
"names": ["yargs", "attributeId", "clusterId"]
|
|
6
|
-
}
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2022-2026 Matter.js Authors
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import { Diagnostic } from "@matter/general";
|
|
7
|
-
import { Matter } from "@matter/model";
|
|
8
|
-
import { ClusterId, ValidationError } from "@matter/types";
|
|
9
|
-
import { convertJsonDataWithModel } from "../util/Json.js";
|
|
10
|
-
function generateAllCommandHandlersForCluster(yargs, theNode) {
|
|
11
|
-
Matter.clusters.forEach((cluster) => {
|
|
12
|
-
yargs = generateClusterCommandHandlers(yargs, cluster, theNode);
|
|
13
|
-
});
|
|
14
|
-
return yargs;
|
|
15
|
-
}
|
|
16
|
-
function generateClusterCommandHandlers(yargs, cluster, theNode) {
|
|
17
|
-
const clusterId = cluster.id;
|
|
18
|
-
if (clusterId === void 0) {
|
|
19
|
-
return yargs;
|
|
20
|
-
}
|
|
21
|
-
yargs = yargs.command(
|
|
22
|
-
[cluster.name.toLowerCase(), `0x${clusterId.toString(16)}`],
|
|
23
|
-
`Invoke ${cluster.name} commands`,
|
|
24
|
-
(yargs2) => {
|
|
25
|
-
cluster.commands.forEach((command) => {
|
|
26
|
-
yargs2 = generateCommandHandler(yargs2, clusterId, cluster.name, command, theNode);
|
|
27
|
-
});
|
|
28
|
-
return yargs2;
|
|
29
|
-
},
|
|
30
|
-
async (argv) => {
|
|
31
|
-
argv.unhandled = true;
|
|
32
|
-
}
|
|
33
|
-
);
|
|
34
|
-
return yargs;
|
|
35
|
-
}
|
|
36
|
-
function generateCommandHandler(yargs, clusterId, clusterName, command, theNode) {
|
|
37
|
-
if (command.definingModel !== void 0) {
|
|
38
|
-
return yargs.command(
|
|
39
|
-
[`${command.name.toLowerCase()} <value> <nodeId> <endpointId>`, `0x${command.id.toString(16)}`],
|
|
40
|
-
`Invoke ${clusterName}.${command.name} command`,
|
|
41
|
-
(yargs2) => yargs2.positional("value", {
|
|
42
|
-
describe: "value to write as JSON value",
|
|
43
|
-
type: "string",
|
|
44
|
-
demandOption: true
|
|
45
|
-
}).positional("node-id", {
|
|
46
|
-
describe: "node id to write t.",
|
|
47
|
-
type: "string",
|
|
48
|
-
demandOption: true
|
|
49
|
-
}).positional("endpoint-id", {
|
|
50
|
-
describe: "endpoint id to write to",
|
|
51
|
-
type: "number",
|
|
52
|
-
demandOption: true
|
|
53
|
-
}),
|
|
54
|
-
async (argv) => {
|
|
55
|
-
const { nodeId, endpointId, value } = argv;
|
|
56
|
-
let parsedValue;
|
|
57
|
-
try {
|
|
58
|
-
parsedValue = JSON.parse(value);
|
|
59
|
-
} catch (error) {
|
|
60
|
-
try {
|
|
61
|
-
parsedValue = JSON.parse(`"${value}"`);
|
|
62
|
-
} catch (innerError) {
|
|
63
|
-
console.log(`ERROR: Could not parse value ${value} as JSON.`);
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
await executeCommand(theNode, nodeId, endpointId, clusterId, command, parsedValue);
|
|
68
|
-
}
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
return yargs.command(
|
|
72
|
-
[`${command.name.toLowerCase()} <nodeId> <endpointId>`, `0x${command.id.toString(16)}`],
|
|
73
|
-
`Invoke ${clusterName}.${command.name} command`,
|
|
74
|
-
(yargs2) => yargs2.positional("node-id", {
|
|
75
|
-
describe: "node id to write t.",
|
|
76
|
-
type: "string",
|
|
77
|
-
demandOption: true
|
|
78
|
-
}).positional("endpoint-id", {
|
|
79
|
-
describe: "endpoint id to write to",
|
|
80
|
-
type: "number",
|
|
81
|
-
demandOption: true
|
|
82
|
-
}),
|
|
83
|
-
async (argv) => {
|
|
84
|
-
const { nodeId, endpointId } = argv;
|
|
85
|
-
await executeCommand(theNode, nodeId, endpointId, clusterId, command);
|
|
86
|
-
}
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
async function executeCommand(theNode, nodeId, endpointId, clusterId, command, requestData) {
|
|
90
|
-
const commandName = command.propertyName;
|
|
91
|
-
const node = (await theNode.connectAndGetNodes(nodeId))[0];
|
|
92
|
-
const clusterClient = node.getDeviceById(endpointId)?.getClusterClientById(ClusterId(clusterId));
|
|
93
|
-
if (clusterClient === void 0) {
|
|
94
|
-
console.log(`ERROR: Cluster ${node.nodeId.toString()}/${endpointId}/${clusterId} not found.`);
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
if (clusterClient.commands[commandName] === void 0) {
|
|
98
|
-
console.log(`ERROR: Command ${node.nodeId.toString()}/${endpointId}/${clusterId}/${command.id} not supported.`);
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
try {
|
|
102
|
-
if (requestData !== void 0) {
|
|
103
|
-
requestData = convertJsonDataWithModel(command, requestData);
|
|
104
|
-
}
|
|
105
|
-
const result = await clusterClient.commands[commandName](requestData);
|
|
106
|
-
console.log(
|
|
107
|
-
`Command ${command.name} ${node.nodeId.toString()}/${endpointId}/${clusterId}/${command.id} invoked ${requestData ? `with ${Diagnostic.json(requestData)}` : ""}`
|
|
108
|
-
);
|
|
109
|
-
if (result !== void 0) {
|
|
110
|
-
console.log(`Result: ${Diagnostic.json(result)}`);
|
|
111
|
-
}
|
|
112
|
-
} catch (error) {
|
|
113
|
-
if (error instanceof ValidationError) {
|
|
114
|
-
console.log(
|
|
115
|
-
`ERROR: Could not validate data for command ${command.name} with ${Diagnostic.json(requestData)}: ${error}${error.fieldName !== void 0 ? ` in field ${error.fieldName}` : ""}`
|
|
116
|
-
);
|
|
117
|
-
} else {
|
|
118
|
-
console.log(
|
|
119
|
-
`ERROR: Could not invoke command ${command.name} ${requestData ? `with ${Diagnostic.json(requestData)}` : ""}: ${error}`
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
function cmdCommands(theNode) {
|
|
125
|
-
return {
|
|
126
|
-
command: ["commands", "c"],
|
|
127
|
-
describe: "Invoke commands",
|
|
128
|
-
builder: (yargs) => generateAllCommandHandlersForCluster(yargs, theNode),
|
|
129
|
-
handler: async (argv) => {
|
|
130
|
-
argv.unhandled = true;
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
export {
|
|
135
|
-
cmdCommands as default
|
|
136
|
-
};
|
|
137
|
-
//# sourceMappingURL=cmd_cluster-commands.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/shell/cmd_cluster-commands.ts"],
|
|
4
|
-
"mappings": "AAAA;AAAA;AAAA;AAAA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}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2022-2026 Matter.js Authors
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import { Diagnostic } from "@matter/general";
|
|
7
|
-
import { Matter } from "@matter/model";
|
|
8
|
-
import { ClusterId } from "@matter/types";
|
|
9
|
-
function generateAllEventHandlersForCluster(yargs, theNode) {
|
|
10
|
-
Matter.clusters.forEach((cluster) => {
|
|
11
|
-
yargs = generateClusterEventHandlers(yargs, cluster, theNode);
|
|
12
|
-
});
|
|
13
|
-
return yargs;
|
|
14
|
-
}
|
|
15
|
-
function generateClusterEventHandlers(yargs, cluster, theNode) {
|
|
16
|
-
const clusterId = cluster.id;
|
|
17
|
-
if (clusterId === void 0) {
|
|
18
|
-
return yargs;
|
|
19
|
-
}
|
|
20
|
-
yargs = yargs.command(
|
|
21
|
-
[cluster.name.toLowerCase(), `0x${clusterId.toString(16)}`],
|
|
22
|
-
`Read ${cluster.name} events`,
|
|
23
|
-
(yargs2) => {
|
|
24
|
-
cluster.events.forEach((event) => {
|
|
25
|
-
yargs2 = generateEventHandler(yargs2, clusterId, cluster.name, event, theNode);
|
|
26
|
-
});
|
|
27
|
-
return yargs2;
|
|
28
|
-
},
|
|
29
|
-
async (argv) => {
|
|
30
|
-
argv.unhandled = true;
|
|
31
|
-
}
|
|
32
|
-
);
|
|
33
|
-
return yargs;
|
|
34
|
-
}
|
|
35
|
-
function generateEventHandler(yargs, clusterId, clusterName, event, theNode) {
|
|
36
|
-
const eventName = event.propertyName;
|
|
37
|
-
return yargs.command(
|
|
38
|
-
[`${event.name.toLowerCase()} <node-id> <endpoint-id>`, `0x${event.id.toString(16)}`],
|
|
39
|
-
`Read ${clusterName}.${event.name} event`,
|
|
40
|
-
(yargs2) => yargs2.positional("node-id", {
|
|
41
|
-
describe: "node id to read",
|
|
42
|
-
type: "string",
|
|
43
|
-
demandOption: true
|
|
44
|
-
}).positional("endpoint-id", {
|
|
45
|
-
describe: "endpoint id to read",
|
|
46
|
-
type: "number",
|
|
47
|
-
demandOption: true
|
|
48
|
-
}),
|
|
49
|
-
async (argv) => {
|
|
50
|
-
const { nodeId, endpointId } = argv;
|
|
51
|
-
const node = (await theNode.connectAndGetNodes(nodeId))[0];
|
|
52
|
-
const clusterClient = node.getDeviceById(endpointId)?.getClusterClientById(ClusterId(clusterId));
|
|
53
|
-
if (clusterClient === void 0) {
|
|
54
|
-
console.log(`ERROR: Cluster ${node.nodeId.toString()}/${endpointId}/${clusterId} not found.`);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const eventClient = clusterClient.events[eventName];
|
|
58
|
-
console.log(
|
|
59
|
-
`Event value for ${eventName} ${node.nodeId.toString()}/${endpointId}/${clusterId}/${event.id}: ${Diagnostic.json(await eventClient.get())}`
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
function cmdEvents(theNode) {
|
|
65
|
-
return {
|
|
66
|
-
command: ["events", "e"],
|
|
67
|
-
describe: "Read events",
|
|
68
|
-
builder: (yargs) => generateAllEventHandlersForCluster(yargs, theNode),
|
|
69
|
-
handler: async (argv) => {
|
|
70
|
-
argv.unhandled = true;
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
export {
|
|
75
|
-
cmdEvents as default
|
|
76
|
-
};
|
|
77
|
-
//# sourceMappingURL=cmd_cluster-events.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/shell/cmd_cluster-events.ts"],
|
|
4
|
-
"mappings": "AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,SAAS,kBAAkB;AAC3B,SAAmC,cAAc;AACjD,SAAS,iBAAiB;AAI1B,SAAS,mCAAmC,OAAa,SAAqB;AAC1E,SAAO,SAAS,QAAQ,aAAW;AAC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