@matter/nodejs-shell 0.16.0-alpha.0-20251112-dba1973d5 → 0.16.0-alpha.0-20251125-16883ca92
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 +210 -5
- package/dist/cjs/MatterNode.js +18 -0
- package/dist/cjs/MatterNode.js.map +1 -1
- package/dist/cjs/shell/Shell.js +8 -0
- package/dist/cjs/shell/Shell.js.map +2 -2
- package/dist/cjs/shell/cmd_cert.js +154 -0
- package/dist/cjs/shell/cmd_cert.js.map +6 -0
- package/dist/cjs/shell/cmd_config.js +62 -1
- package/dist/cjs/shell/cmd_config.js.map +1 -1
- package/dist/cjs/shell/cmd_dcl.js +198 -0
- package/dist/cjs/shell/cmd_dcl.js.map +6 -0
- package/dist/cjs/shell/cmd_nodes.js +160 -0
- package/dist/cjs/shell/cmd_nodes.js.map +1 -1
- package/dist/cjs/shell/cmd_ota.js +449 -0
- package/dist/cjs/shell/cmd_ota.js.map +6 -0
- package/dist/cjs/shell/cmd_vendor.js +118 -0
- package/dist/cjs/shell/cmd_vendor.js.map +6 -0
- package/package.json +10 -10
- package/src/MatterNode.ts +30 -1
- package/src/shell/Shell.ts +8 -0
- package/src/shell/cmd_cert.ts +156 -0
- package/src/shell/cmd_config.ts +80 -1
- package/src/shell/cmd_dcl.ts +221 -0
- package/src/shell/cmd_nodes.ts +192 -1
- package/src/shell/cmd_ota.ts +550 -0
- package/src/shell/cmd_vendor.ts +108 -0
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var cmd_ota_exports = {};
|
|
20
|
+
__export(cmd_ota_exports, {
|
|
21
|
+
default: () => commands
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(cmd_ota_exports);
|
|
24
|
+
var import_general = require("#general");
|
|
25
|
+
var import_protocol = require("#protocol");
|
|
26
|
+
var import_node_fs = require("node:fs");
|
|
27
|
+
var import_node_path = require("node:path");
|
|
28
|
+
var import_node_stream = require("node:stream");
|
|
29
|
+
/**
|
|
30
|
+
* @license
|
|
31
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
32
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
33
|
+
*/
|
|
34
|
+
function parseHexId(value, type) {
|
|
35
|
+
const hexStr = value.replace(/^0x/i, "");
|
|
36
|
+
const parsed = parseInt(hexStr, 16);
|
|
37
|
+
if (isNaN(parsed)) {
|
|
38
|
+
console.error(`Error: Invalid ${type} ID "${value}"`);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
return parsed;
|
|
42
|
+
}
|
|
43
|
+
function createWritableStream(writeStream) {
|
|
44
|
+
return new WritableStream({
|
|
45
|
+
write(chunk) {
|
|
46
|
+
return new Promise((resolve, reject) => {
|
|
47
|
+
writeStream.write(chunk, (error) => {
|
|
48
|
+
if (error) reject(error);
|
|
49
|
+
else resolve();
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
close() {
|
|
54
|
+
return new Promise((resolve, reject) => {
|
|
55
|
+
writeStream.end((error) => {
|
|
56
|
+
if (error) reject(error);
|
|
57
|
+
else resolve();
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function commands(theNode) {
|
|
64
|
+
return {
|
|
65
|
+
command: "ota",
|
|
66
|
+
describe: "OTA update operations",
|
|
67
|
+
builder: (yargs) => yargs.command(
|
|
68
|
+
"info <file>",
|
|
69
|
+
"Display OTA image information from a file or storage key",
|
|
70
|
+
(yargs2) => {
|
|
71
|
+
return yargs2.positional("file", {
|
|
72
|
+
describe: "File path (with file:// prefix for absolute paths) or storage key (without prefix)",
|
|
73
|
+
type: "string",
|
|
74
|
+
demandOption: true
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
async (argv) => {
|
|
78
|
+
const { file } = argv;
|
|
79
|
+
const fileArg = file;
|
|
80
|
+
let updateInfo;
|
|
81
|
+
if (fileArg.startsWith("file://")) {
|
|
82
|
+
const filePath = fileArg.slice(7);
|
|
83
|
+
const nodeStream = (0, import_node_fs.createReadStream)(filePath);
|
|
84
|
+
const webStream = import_node_stream.Readable.toWeb(nodeStream);
|
|
85
|
+
updateInfo = await theNode.otaService.updateInfoFromStream(webStream, fileArg);
|
|
86
|
+
} else {
|
|
87
|
+
const fileDesignator = await theNode.otaService.fileDesignatorForUpdate(fileArg);
|
|
88
|
+
const blob = await fileDesignator.openBlob();
|
|
89
|
+
const reader = blob.stream().getReader();
|
|
90
|
+
const header = await import_protocol.OtaImageReader.header(reader);
|
|
91
|
+
updateInfo = {
|
|
92
|
+
vid: header.vendorId,
|
|
93
|
+
pid: header.productId,
|
|
94
|
+
softwareVersion: header.softwareVersion,
|
|
95
|
+
softwareVersionString: header.softwareVersionString,
|
|
96
|
+
payloadSize: header.payloadSize,
|
|
97
|
+
imageDigestType: header.imageDigestType,
|
|
98
|
+
imageDigest: header.imageDigest,
|
|
99
|
+
minApplicableSoftwareVersion: header.minApplicableSoftwareVersion,
|
|
100
|
+
maxApplicableSoftwareVersion: header.maxApplicableSoftwareVersion,
|
|
101
|
+
releaseNotesUrl: header.releaseNotesUrl,
|
|
102
|
+
storageKey: fileArg
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
console.log(import_general.Diagnostic.json(updateInfo));
|
|
106
|
+
}
|
|
107
|
+
).command(
|
|
108
|
+
"extract <file>",
|
|
109
|
+
"Extract and validate payload from an OTA image file",
|
|
110
|
+
(yargs2) => {
|
|
111
|
+
return yargs2.positional("file", {
|
|
112
|
+
describe: "Absolute path to the OTA image file",
|
|
113
|
+
type: "string",
|
|
114
|
+
demandOption: true
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
async (argv) => {
|
|
118
|
+
const { file } = argv;
|
|
119
|
+
const crypto = import_general.Environment.default.get(import_general.Crypto);
|
|
120
|
+
const dir = (0, import_node_path.dirname)(file);
|
|
121
|
+
const ext = (0, import_node_path.extname)(file);
|
|
122
|
+
const base = (0, import_node_path.basename)(file, ext);
|
|
123
|
+
const outputFile = (0, import_node_path.join)(dir, `${base}-payload${ext}`);
|
|
124
|
+
console.log(`Reading OTA image from: ${file}`);
|
|
125
|
+
console.log(`Extracting payload to: ${outputFile}`);
|
|
126
|
+
const response = await fetch(`file://${file}`, { method: "GET" });
|
|
127
|
+
if (!response.ok) {
|
|
128
|
+
throw new Error(`Failed to read OTA file: ${response.status} ${response.statusText}`);
|
|
129
|
+
}
|
|
130
|
+
if (!response.body) {
|
|
131
|
+
throw new Error("No response body received");
|
|
132
|
+
}
|
|
133
|
+
const writeStream = (0, import_node_fs.createWriteStream)(outputFile);
|
|
134
|
+
const writableStream = createWritableStream(writeStream);
|
|
135
|
+
const payloadWriter = writableStream.getWriter();
|
|
136
|
+
const reader = response.body.getReader();
|
|
137
|
+
const header = await import_protocol.OtaImageReader.extractPayload(reader, payloadWriter, crypto);
|
|
138
|
+
console.log(`
|
|
139
|
+
Payload extracted successfully!`);
|
|
140
|
+
console.log(`Vendor ID: ${import_general.Diagnostic.hex(header.vendorId, 4)}`);
|
|
141
|
+
console.log(`Product ID: 0x${import_general.Diagnostic.hex(header.productId, 4)}`);
|
|
142
|
+
console.log(`Software Version: ${header.softwareVersion}`);
|
|
143
|
+
console.log(`Software Version String: ${header.softwareVersionString}`);
|
|
144
|
+
console.log(`Payload Size: ${header.payloadSize} bytes`);
|
|
145
|
+
console.log(`Output file: ${outputFile}`);
|
|
146
|
+
}
|
|
147
|
+
).command(
|
|
148
|
+
"verify <file>",
|
|
149
|
+
"Verify an OTA image file (validates header and payload checksums)",
|
|
150
|
+
(yargs2) => {
|
|
151
|
+
return yargs2.positional("file", {
|
|
152
|
+
describe: "Path to the OTA image file (with file:// prefix) or storage key",
|
|
153
|
+
type: "string",
|
|
154
|
+
demandOption: true
|
|
155
|
+
});
|
|
156
|
+
},
|
|
157
|
+
async (argv) => {
|
|
158
|
+
const { file } = argv;
|
|
159
|
+
const fileArg = file;
|
|
160
|
+
const crypto = import_general.Environment.default.get(import_general.Crypto);
|
|
161
|
+
console.log(`Verifying OTA image: ${fileArg}
|
|
162
|
+
`);
|
|
163
|
+
let header;
|
|
164
|
+
let source;
|
|
165
|
+
if (fileArg.startsWith("file://")) {
|
|
166
|
+
const filePath = fileArg.slice(7);
|
|
167
|
+
source = filePath;
|
|
168
|
+
const nodeStream = (0, import_node_fs.createReadStream)(filePath);
|
|
169
|
+
const webStream = import_node_stream.Readable.toWeb(nodeStream);
|
|
170
|
+
const reader = webStream.getReader();
|
|
171
|
+
header = await import_protocol.OtaImageReader.file(reader, crypto);
|
|
172
|
+
} else {
|
|
173
|
+
source = `storage:${fileArg}`;
|
|
174
|
+
const fileDesignator = await theNode.otaService.fileDesignatorForUpdate(fileArg);
|
|
175
|
+
const blob = await fileDesignator.openBlob();
|
|
176
|
+
const reader = blob.stream().getReader();
|
|
177
|
+
header = await import_protocol.OtaImageReader.file(reader, crypto);
|
|
178
|
+
}
|
|
179
|
+
console.log(`\u2713 OTA image is valid!
|
|
180
|
+
`);
|
|
181
|
+
console.log(`File: ${source}`);
|
|
182
|
+
console.log(`Vendor ID: ${import_general.Diagnostic.hex(header.vendorId, 4)}`);
|
|
183
|
+
console.log(`Product ID: ${import_general.Diagnostic.hex(header.productId, 4)}`);
|
|
184
|
+
console.log(`Software Version: ${header.softwareVersion}`);
|
|
185
|
+
console.log(`Software Version String: ${header.softwareVersionString}`);
|
|
186
|
+
console.log(`Payload Size: ${header.payloadSize} bytes`);
|
|
187
|
+
console.log(`Digest Algorithm: ${header.imageDigestType}`);
|
|
188
|
+
console.log(`Digest: ${header.imageDigest}`);
|
|
189
|
+
if (header.minApplicableSoftwareVersion !== void 0) {
|
|
190
|
+
console.log(`Min Applicable Version: ${header.minApplicableSoftwareVersion}`);
|
|
191
|
+
}
|
|
192
|
+
if (header.maxApplicableSoftwareVersion !== void 0) {
|
|
193
|
+
console.log(`Max Applicable Version: ${header.maxApplicableSoftwareVersion}`);
|
|
194
|
+
}
|
|
195
|
+
if (header.releaseNotesUrl) {
|
|
196
|
+
console.log(`Release Notes: ${header.releaseNotesUrl}`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
).command(
|
|
200
|
+
"list",
|
|
201
|
+
"List downloaded OTA images in storage",
|
|
202
|
+
(yargs2) => {
|
|
203
|
+
return yargs2.option("vid", {
|
|
204
|
+
alias: "vendor-id",
|
|
205
|
+
describe: "Filter by vendor ID (hex, e.g., 0xFFF1 or FFF1)",
|
|
206
|
+
type: "string"
|
|
207
|
+
}).option("pid", {
|
|
208
|
+
alias: "product-id",
|
|
209
|
+
describe: "Filter by product ID (hex, e.g., 0x8000 or 8000) - requires --vid",
|
|
210
|
+
type: "string"
|
|
211
|
+
}).option("mode", {
|
|
212
|
+
describe: "Filter by mode (prod or test)",
|
|
213
|
+
type: "string",
|
|
214
|
+
choices: ["prod", "test"]
|
|
215
|
+
});
|
|
216
|
+
},
|
|
217
|
+
async (argv) => {
|
|
218
|
+
const { vid, pid, mode } = argv;
|
|
219
|
+
if (pid && !vid) {
|
|
220
|
+
console.error("Error: --pid requires --vid to be specified");
|
|
221
|
+
process.exit(1);
|
|
222
|
+
}
|
|
223
|
+
const vendorId = vid ? parseHexId(vid, "vendor") : void 0;
|
|
224
|
+
const productId = pid ? parseHexId(pid, "product") : void 0;
|
|
225
|
+
const isProduction = mode ? mode === "prod" : void 0;
|
|
226
|
+
const updates = await theNode.otaService.find({
|
|
227
|
+
vendorId,
|
|
228
|
+
productId,
|
|
229
|
+
isProduction
|
|
230
|
+
});
|
|
231
|
+
if (updates.length === 0) {
|
|
232
|
+
console.log("No OTA images found in storage matching the criteria.");
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
console.log(
|
|
236
|
+
`Found ${updates.length} OTA image${updates.length === 1 ? "" : "s"} in storage:
|
|
237
|
+
`
|
|
238
|
+
);
|
|
239
|
+
console.log(
|
|
240
|
+
"Filename".padEnd(35) + "VID".padEnd(8) + "PID".padEnd(8) + "Version".padEnd(12) + "Mode".padEnd(8) + "Size"
|
|
241
|
+
);
|
|
242
|
+
console.log("-".repeat(100));
|
|
243
|
+
for (const update of updates) {
|
|
244
|
+
const vidHex = `0x${update.vendorId.toString(16).toUpperCase()}`;
|
|
245
|
+
const pidHex = `0x${update.productId.toString(16).toUpperCase()}`;
|
|
246
|
+
const sizeKB = (update.size / 1024).toFixed(2);
|
|
247
|
+
console.log(
|
|
248
|
+
update.filename.padEnd(35) + vidHex.padEnd(8) + pidHex.padEnd(8) + `${update.softwareVersion}`.padEnd(12) + update.mode.padEnd(8) + `${sizeKB} KB`
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
).command(
|
|
253
|
+
"add <file>",
|
|
254
|
+
"Add an OTA image file to storage",
|
|
255
|
+
(yargs2) => {
|
|
256
|
+
return yargs2.positional("file", {
|
|
257
|
+
describe: "Absolute path to the OTA image file",
|
|
258
|
+
type: "string",
|
|
259
|
+
demandOption: true
|
|
260
|
+
}).option("mode", {
|
|
261
|
+
describe: "Mode for the OTA file (prod or test)",
|
|
262
|
+
type: "string",
|
|
263
|
+
choices: ["prod", "test"],
|
|
264
|
+
default: "prod"
|
|
265
|
+
});
|
|
266
|
+
},
|
|
267
|
+
async (argv) => {
|
|
268
|
+
const { file, mode } = argv;
|
|
269
|
+
let filePath = file;
|
|
270
|
+
const isProduction = mode === "prod";
|
|
271
|
+
if (filePath.startsWith("file://")) {
|
|
272
|
+
filePath = filePath.slice(7);
|
|
273
|
+
} else if (!filePath.startsWith("/")) {
|
|
274
|
+
console.error("Error: File path must be absolute or start with file://");
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
console.log(`Reading OTA image from: ${filePath}`);
|
|
278
|
+
let localFile = false;
|
|
279
|
+
let updateInfo;
|
|
280
|
+
if (filePath.toLowerCase().startsWith("https://")) {
|
|
281
|
+
updateInfo = await theNode.otaService.createUpdateInfoFromFile(filePath);
|
|
282
|
+
} else {
|
|
283
|
+
const nodeStream = (0, import_node_fs.createReadStream)(filePath);
|
|
284
|
+
const webStream = import_node_stream.Readable.toWeb(nodeStream);
|
|
285
|
+
const fileUrl = `file://${filePath}`;
|
|
286
|
+
localFile = true;
|
|
287
|
+
updateInfo = await theNode.otaService.updateInfoFromStream(webStream, fileUrl);
|
|
288
|
+
}
|
|
289
|
+
console.log(`Validated OTA image:`);
|
|
290
|
+
console.log(` Vendor ID: 0x${updateInfo.vid.toString(16).toUpperCase()}`);
|
|
291
|
+
console.log(` Product ID: 0x${updateInfo.pid.toString(16).toUpperCase()}`);
|
|
292
|
+
console.log(` Software Version: ${updateInfo.softwareVersion}`);
|
|
293
|
+
console.log(` Software Version String: ${updateInfo.softwareVersionString}`);
|
|
294
|
+
console.log(` Mode: ${isProduction ? "production" : "test"}`);
|
|
295
|
+
let fd;
|
|
296
|
+
if (localFile) {
|
|
297
|
+
const nodeStream = (0, import_node_fs.createReadStream)(filePath);
|
|
298
|
+
const webStream = import_node_stream.Readable.toWeb(nodeStream);
|
|
299
|
+
fd = await theNode.otaService.store(webStream, updateInfo, isProduction);
|
|
300
|
+
} else {
|
|
301
|
+
fd = await theNode.otaService.downloadUpdate(updateInfo, isProduction);
|
|
302
|
+
}
|
|
303
|
+
console.log(`
|
|
304
|
+
OTA image added to storage successfully: ${fd.text}`);
|
|
305
|
+
}
|
|
306
|
+
).command(
|
|
307
|
+
"delete [keyname]",
|
|
308
|
+
"Delete OTA image(s) from storage",
|
|
309
|
+
(yargs2) => {
|
|
310
|
+
return yargs2.positional("keyname", {
|
|
311
|
+
describe: "Storage key name to delete",
|
|
312
|
+
type: "string"
|
|
313
|
+
}).option("vid", {
|
|
314
|
+
alias: "vendor-id",
|
|
315
|
+
describe: "Delete by vendor ID (hex, e.g., 0xFFF1 or FFF1)",
|
|
316
|
+
type: "string",
|
|
317
|
+
conflicts: "keyname"
|
|
318
|
+
}).option("pid", {
|
|
319
|
+
alias: "product-id",
|
|
320
|
+
describe: "Delete by product ID (hex, e.g., 0x8000 or 8000) - requires --vid",
|
|
321
|
+
type: "string",
|
|
322
|
+
requires: "vid"
|
|
323
|
+
}).option("mode", {
|
|
324
|
+
describe: "Mode (prod or test) - requires --vid",
|
|
325
|
+
type: "string",
|
|
326
|
+
choices: ["prod", "test"],
|
|
327
|
+
default: "prod",
|
|
328
|
+
requires: "vid"
|
|
329
|
+
}).check((argv) => {
|
|
330
|
+
if (!argv.keyname && !argv.vid) {
|
|
331
|
+
throw new Error("Either keyname or --vid must be provided");
|
|
332
|
+
}
|
|
333
|
+
if (argv.pid && !argv.vid) {
|
|
334
|
+
throw new Error("--pid requires --vid to be specified");
|
|
335
|
+
}
|
|
336
|
+
return true;
|
|
337
|
+
});
|
|
338
|
+
},
|
|
339
|
+
async (argv) => {
|
|
340
|
+
const { keyname, vid, pid, mode } = argv;
|
|
341
|
+
if (keyname) {
|
|
342
|
+
await theNode.otaService.delete({
|
|
343
|
+
filename: keyname
|
|
344
|
+
});
|
|
345
|
+
console.log(`Deleted OTA image: ${keyname}`);
|
|
346
|
+
} else {
|
|
347
|
+
const vendorId = parseHexId(vid, "vendor");
|
|
348
|
+
const productId = pid ? parseHexId(pid, "product") : void 0;
|
|
349
|
+
const isProduction = mode === "prod";
|
|
350
|
+
const deletedCount = await theNode.otaService.delete({
|
|
351
|
+
vendorId,
|
|
352
|
+
productId,
|
|
353
|
+
isProduction
|
|
354
|
+
});
|
|
355
|
+
if (productId !== void 0) {
|
|
356
|
+
console.log(
|
|
357
|
+
`Deleted OTA image for VID: 0x${vendorId.toString(16).toUpperCase()}, PID: 0x${productId.toString(16).toUpperCase()}, mode: ${mode}`
|
|
358
|
+
);
|
|
359
|
+
} else {
|
|
360
|
+
console.log(
|
|
361
|
+
`Deleted ${deletedCount} OTA image(s) for VID: 0x${vendorId.toString(16).toUpperCase()}, mode: ${mode}`
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
).command(
|
|
367
|
+
"copy <source> <target>",
|
|
368
|
+
"Copy OTA image from storage to filesystem",
|
|
369
|
+
(yargs2) => {
|
|
370
|
+
return yargs2.positional("source", {
|
|
371
|
+
describe: "Storage key name OR vendor ID (if using --pid and --mode)",
|
|
372
|
+
type: "string",
|
|
373
|
+
demandOption: true
|
|
374
|
+
}).positional("target", {
|
|
375
|
+
describe: "Target filesystem path (file or directory)",
|
|
376
|
+
type: "string",
|
|
377
|
+
demandOption: true
|
|
378
|
+
}).option("pid", {
|
|
379
|
+
alias: "product-id",
|
|
380
|
+
describe: "Product ID when source is vendor ID (hex, e.g., 0x8000 or 8000)",
|
|
381
|
+
type: "string"
|
|
382
|
+
}).option("mode", {
|
|
383
|
+
describe: "Mode when using vendor/product ID (prod or test)",
|
|
384
|
+
type: "string",
|
|
385
|
+
choices: ["prod", "test"]
|
|
386
|
+
}).check((argv) => {
|
|
387
|
+
if ((argv.pid || argv.mode) && !(argv.pid && argv.mode)) {
|
|
388
|
+
throw new Error("Both --pid and --mode must be provided together");
|
|
389
|
+
}
|
|
390
|
+
return true;
|
|
391
|
+
});
|
|
392
|
+
},
|
|
393
|
+
async (argv) => {
|
|
394
|
+
const { source, target, pid, mode } = argv;
|
|
395
|
+
const sourceArg = source;
|
|
396
|
+
const targetArg = target;
|
|
397
|
+
let keyname;
|
|
398
|
+
if (pid && mode) {
|
|
399
|
+
const vendorId = parseHexId(sourceArg, "vendor");
|
|
400
|
+
const productId = parseHexId(pid, "product");
|
|
401
|
+
const modeStr = mode;
|
|
402
|
+
keyname = `${vendorId.toString(16)}-${productId.toString(16)}-${modeStr}`;
|
|
403
|
+
} else {
|
|
404
|
+
keyname = sourceArg;
|
|
405
|
+
}
|
|
406
|
+
const fileDesignator = await theNode.otaService.fileDesignatorForUpdate(keyname);
|
|
407
|
+
let targetPath = targetArg;
|
|
408
|
+
try {
|
|
409
|
+
const stats = (0, import_node_fs.statSync)(targetArg);
|
|
410
|
+
if (stats.isDirectory()) {
|
|
411
|
+
targetPath = (0, import_node_path.join)(targetArg, keyname);
|
|
412
|
+
}
|
|
413
|
+
} catch {
|
|
414
|
+
const parentDir = (0, import_node_path.dirname)(targetArg);
|
|
415
|
+
try {
|
|
416
|
+
const parentStats = (0, import_node_fs.statSync)(parentDir);
|
|
417
|
+
if (parentStats.isDirectory()) {
|
|
418
|
+
targetPath = targetArg;
|
|
419
|
+
} else {
|
|
420
|
+
console.error(`Error: Parent path is not a directory: ${parentDir}`);
|
|
421
|
+
process.exit(1);
|
|
422
|
+
}
|
|
423
|
+
} catch {
|
|
424
|
+
console.error(`Error: Parent directory does not exist: ${parentDir}`);
|
|
425
|
+
process.exit(1);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
console.log(`Copying OTA image from storage: ${keyname}`);
|
|
429
|
+
console.log(`Target path: ${targetPath}`);
|
|
430
|
+
const blob = await fileDesignator.openBlob();
|
|
431
|
+
const reader = blob.stream().getReader();
|
|
432
|
+
const writeStream = (0, import_node_fs.createWriteStream)(targetPath);
|
|
433
|
+
const writableStream = createWritableStream(writeStream);
|
|
434
|
+
const writer = writableStream.getWriter();
|
|
435
|
+
while (true) {
|
|
436
|
+
const { value, done } = await reader.read();
|
|
437
|
+
if (done) break;
|
|
438
|
+
await writer.write(value);
|
|
439
|
+
}
|
|
440
|
+
await writer.close();
|
|
441
|
+
console.log(`OTA image copied successfully to: ${targetPath}`);
|
|
442
|
+
}
|
|
443
|
+
),
|
|
444
|
+
handler: async (argv) => {
|
|
445
|
+
argv.unhandled = true;
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
//# sourceMappingURL=cmd_ota.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/shell/cmd_ota.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,qBAAgD;AAChD,sBAAwD;AACxD,qBAA2E;AAC3E,uBAAiD;AACjD,yBAAyB;AAVzB;AAAA;AAAA;AAAA;AAAA;AAkBA,SAAS,WAAW,OAAe,MAAoC;AACnE,QAAM,SAAS,MAAM,QAAQ,QAAQ,EAAE;AACvC,QAAM,SAAS,SAAS,QAAQ,EAAE;AAClC,MAAI,MAAM,MAAM,GAAG;AACf,YAAQ,MAAM,kBAAkB,IAAI,QAAQ,KAAK,GAAG;AACpD,YAAQ,KAAK,CAAC;AAAA,EAClB;AACA,SAAO;AACX;AAEA,SAAS,qBAAqB,aAA0B;AACpD,SAAO,IAAI,eAAe;AAAA,IACtB,MAAM,OAAO;AACT,aAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACpC,oBAAY,MAAM,OAAO,CAAC,UAAoC;AAC1D,cAAI,MAAO,QAAO,KAAK;AAAA,cAClB,SAAQ;AAAA,QACjB,CAAC;AAAA,MACL,CAAC;AAAA,IACL;AAAA,IACA,QAAQ;AACJ,aAAO,IAAI,Q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ineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var cmd_vendor_exports = {};
|
|
20
|
+
__export(cmd_vendor_exports, {
|
|
21
|
+
default: () => commands
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(cmd_vendor_exports);
|
|
24
|
+
var import_general = require("#general");
|
|
25
|
+
/**
|
|
26
|
+
* @license
|
|
27
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
28
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
29
|
+
*/
|
|
30
|
+
function commands(theNode) {
|
|
31
|
+
return {
|
|
32
|
+
command: "vendor",
|
|
33
|
+
describe: "Vendor information management operations",
|
|
34
|
+
builder: (yargs) => yargs.command(
|
|
35
|
+
["*", "list"],
|
|
36
|
+
"List all stored vendor information",
|
|
37
|
+
() => {
|
|
38
|
+
},
|
|
39
|
+
async () => {
|
|
40
|
+
await theNode.start();
|
|
41
|
+
const vendors = [...theNode.vendorInfoService.vendors.values()];
|
|
42
|
+
if (vendors.length === 0) {
|
|
43
|
+
console.log("No vendor information found in storage.");
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
console.log(`
|
|
47
|
+
Found ${vendors.length} vendor(s):
|
|
48
|
+
`);
|
|
49
|
+
vendors.sort((a, b) => a.vendorId - b.vendorId);
|
|
50
|
+
vendors.forEach((vendor) => {
|
|
51
|
+
console.log(
|
|
52
|
+
`Vendor ID: ${vendor.vendorId} (0x${vendor.vendorId.toString(16).toUpperCase().padStart(4, "0")})`
|
|
53
|
+
);
|
|
54
|
+
console.log(` Name: ${vendor.vendorName}`);
|
|
55
|
+
console.log(` Legal Name: ${vendor.companyLegalName}`);
|
|
56
|
+
console.log(` Preferred Name: ${vendor.companyPreferredName}`);
|
|
57
|
+
console.log(` Landing Page: ${vendor.vendorLandingPageUrl}`);
|
|
58
|
+
console.log("");
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
).command(
|
|
62
|
+
"get <vendor-id>",
|
|
63
|
+
"Display detailed information about a vendor",
|
|
64
|
+
(yargs2) => {
|
|
65
|
+
return yargs2.positional("vendor-id", {
|
|
66
|
+
describe: "Vendor ID (hex format like 0xFFF1 or decimal)",
|
|
67
|
+
type: "string",
|
|
68
|
+
demandOption: true
|
|
69
|
+
});
|
|
70
|
+
},
|
|
71
|
+
async (argv) => {
|
|
72
|
+
const { vendorId: vendorIdStr } = argv;
|
|
73
|
+
let vendorId;
|
|
74
|
+
if (vendorIdStr.startsWith("0x")) {
|
|
75
|
+
const hexStr = vendorIdStr.replace(/^0x/i, "");
|
|
76
|
+
vendorId = parseInt(hexStr, 16);
|
|
77
|
+
} else {
|
|
78
|
+
vendorId = parseInt(vendorIdStr, 10);
|
|
79
|
+
}
|
|
80
|
+
if (!isFinite(vendorId)) {
|
|
81
|
+
console.error(`Error: Invalid vendor ID "${vendorIdStr}"`);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
await theNode.start();
|
|
85
|
+
const vendor = theNode.vendorInfoService.infoFor(vendorId);
|
|
86
|
+
if (!vendor) {
|
|
87
|
+
console.error(`Vendor with ID ${vendorIdStr} not found`);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
console.log("\nVendor Details:");
|
|
91
|
+
console.log(import_general.Diagnostic.json(vendor));
|
|
92
|
+
}
|
|
93
|
+
).command(
|
|
94
|
+
"update",
|
|
95
|
+
"Update vendor information from DCL",
|
|
96
|
+
() => {
|
|
97
|
+
},
|
|
98
|
+
async () => {
|
|
99
|
+
await theNode.start();
|
|
100
|
+
console.log("Updating vendor information from DCL...");
|
|
101
|
+
try {
|
|
102
|
+
await theNode.vendorInfoService.update();
|
|
103
|
+
console.log(
|
|
104
|
+
`Successfully updated. ${theNode.vendorInfoService.vendors.size} vendor(s) now available.`
|
|
105
|
+
);
|
|
106
|
+
} catch (error) {
|
|
107
|
+
console.error(
|
|
108
|
+
`Failed to update vendor information: ${error instanceof Error ? error.message : error}`
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
),
|
|
113
|
+
handler: async (argv) => {
|
|
114
|
+
argv.unhandled = true;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=cmd_vendor.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/shell/cmd_vendor.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,qBAA2B;AAN3B;AAAA;AAAA;AAAA;AAAA;AAUe,SAAR,SAA0B,SAAqB;AAClD,SAAO;AAAA,IACH,SAAS;AAAA,IACT,UAAU;AAAA,IACV,SAAS,CAAC,UACN,MACK;AAAA,MACG,CAAC,KAAK,MAAM;AAAA,MACZ;AAAA,MACA,MAAM;AAAA,MAAC;AAAA,MACP,YAAY;AACR,cAAM,QAAQ,MAAM;AACpB,cAAM,UAAU,CAAC,GAAG,QAAQ,kBAAkB,QAAQ,OAAO,CAAC;AAE9D,YAAI,QAAQ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AkB,WAAW,YAAY;AACvD;AAAA,QACJ;AAEA,gBAAQ,IAAI,mBAAmB;AAC/B,gBAAQ,IAAI,0BAAW,KAAK,MAAM,CAAC;AAAA,MACvC;AAAA,IACJ,EACC;AAAA,MACG;AAAA,MACA;AAAA,MACA,MAAM;AAAA,MAAC;AAAA,MACP,YAAY;AACR,cAAM,QAAQ,MAAM;AACpB,gBAAQ,IAAI,yCAAyC;AAErD,YAAI;AACA,gBAAM,QAAQ,kBAAkB,OAAO;AACvC,kBAAQ;AAAA,YACJ,yBAAyB,QAAQ,kBAAkB,QAAQ,IAAI;AAAA,UACnE;AAAA,QACJ,SAAS,OAAO;AACZ,kBAAQ;AAAA,YACJ,wCAAwC,iBAAiB,QAAQ,MAAM,UAAU,KAAK;AAAA,UAC1F;AAAA,QACJ;AAAA,MACJ;AAAA,IACJ;AAAA,IACR,SAAS,OAAO,SAAc;AAC1B,WAAK,YAAY;AAAA,IACrB;AAAA,EACJ;AACJ;",
|
|
5
|
+
"names": ["yargs"]
|
|
6
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matter/nodejs-shell",
|
|
3
|
-
"version": "0.16.0-alpha.0-
|
|
3
|
+
"version": "0.16.0-alpha.0-20251125-16883ca92",
|
|
4
4
|
"description": "Shell app for Matter controller",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"iot",
|
|
@@ -42,15 +42,15 @@
|
|
|
42
42
|
"#types": "@matter/types"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@matter/general": "0.16.0-alpha.0-
|
|
46
|
-
"@matter/model": "0.16.0-alpha.0-
|
|
47
|
-
"@matter/node": "0.16.0-alpha.0-
|
|
48
|
-
"@matter/nodejs": "0.16.0-alpha.0-
|
|
49
|
-
"@matter/nodejs-ble": "0.16.0-alpha.0-
|
|
50
|
-
"@matter/protocol": "0.16.0-alpha.0-
|
|
51
|
-
"@matter/tools": "0.16.0-alpha.0-
|
|
52
|
-
"@matter/types": "0.16.0-alpha.0-
|
|
53
|
-
"@project-chip/matter.js": "0.16.0-alpha.0-
|
|
45
|
+
"@matter/general": "0.16.0-alpha.0-20251125-16883ca92",
|
|
46
|
+
"@matter/model": "0.16.0-alpha.0-20251125-16883ca92",
|
|
47
|
+
"@matter/node": "0.16.0-alpha.0-20251125-16883ca92",
|
|
48
|
+
"@matter/nodejs": "0.16.0-alpha.0-20251125-16883ca92",
|
|
49
|
+
"@matter/nodejs-ble": "0.16.0-alpha.0-20251125-16883ca92",
|
|
50
|
+
"@matter/protocol": "0.16.0-alpha.0-20251125-16883ca92",
|
|
51
|
+
"@matter/tools": "0.16.0-alpha.0-20251125-16883ca92",
|
|
52
|
+
"@matter/types": "0.16.0-alpha.0-20251125-16883ca92",
|
|
53
|
+
"@project-chip/matter.js": "0.16.0-alpha.0-20251125-16883ca92",
|
|
54
54
|
"ws": "^8.18.3",
|
|
55
55
|
"yargs": "^18.0.0"
|
|
56
56
|
},
|