@matter/nodejs-shell 0.11.0-alpha.0-20241007-547af42a8
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 +201 -0
- package/README.md +192 -0
- package/dist/cjs/MatterNode.js +115 -0
- package/dist/cjs/MatterNode.js.map +6 -0
- package/dist/cjs/app.js +162 -0
- package/dist/cjs/app.js.map +6 -0
- package/dist/cjs/package.json +7 -0
- package/dist/cjs/shell/Shell.js +195 -0
- package/dist/cjs/shell/Shell.js.map +6 -0
- package/dist/cjs/shell/cmd_cluster-attributes.js +310 -0
- package/dist/cjs/shell/cmd_cluster-attributes.js.map +6 -0
- package/dist/cjs/shell/cmd_cluster-commands.js +158 -0
- package/dist/cjs/shell/cmd_cluster-commands.js.map +6 -0
- package/dist/cjs/shell/cmd_cluster-events.js +104 -0
- package/dist/cjs/shell/cmd_cluster-events.js.map +6 -0
- package/dist/cjs/shell/cmd_commission.js +237 -0
- package/dist/cjs/shell/cmd_commission.js.map +6 -0
- package/dist/cjs/shell/cmd_config.js +315 -0
- package/dist/cjs/shell/cmd_config.js.map +6 -0
- package/dist/cjs/shell/cmd_discover.js +123 -0
- package/dist/cjs/shell/cmd_discover.js.map +6 -0
- package/dist/cjs/shell/cmd_identify.js +66 -0
- package/dist/cjs/shell/cmd_identify.js.map +6 -0
- package/dist/cjs/shell/cmd_nodes.js +244 -0
- package/dist/cjs/shell/cmd_nodes.js.map +6 -0
- package/dist/cjs/shell/cmd_session.js +43 -0
- package/dist/cjs/shell/cmd_session.js.map +6 -0
- package/dist/cjs/shell/cmd_subscribe.js +59 -0
- package/dist/cjs/shell/cmd_subscribe.js.map +6 -0
- package/dist/cjs/shell/cmd_tlv.js +175 -0
- package/dist/cjs/shell/cmd_tlv.js.map +6 -0
- package/dist/cjs/util/CommandlineParser.js +106 -0
- package/dist/cjs/util/CommandlineParser.js.map +6 -0
- package/dist/cjs/util/Json.js +66 -0
- package/dist/cjs/util/Json.js.map +6 -0
- package/dist/cjs/util/String.js +32 -0
- package/dist/cjs/util/String.js.map +6 -0
- package/package.json +58 -0
- package/src/MatterNode.ts +141 -0
- package/src/app.ts +158 -0
- package/src/shell/Shell.ts +184 -0
- package/src/shell/cmd_cluster-attributes.ts +340 -0
- package/src/shell/cmd_cluster-commands.ts +174 -0
- package/src/shell/cmd_cluster-events.ts +99 -0
- package/src/shell/cmd_commission.ts +273 -0
- package/src/shell/cmd_config.ts +366 -0
- package/src/shell/cmd_discover.ts +127 -0
- package/src/shell/cmd_identify.ts +51 -0
- package/src/shell/cmd_nodes.ts +249 -0
- package/src/shell/cmd_session.ts +23 -0
- package/src/shell/cmd_subscribe.ts +43 -0
- package/src/shell/cmd_tlv.ts +169 -0
- package/src/tsconfig.json +22 -0
- package/src/util/CommandlineParser.ts +123 -0
- package/src/util/Json.ts +50 -0
- package/src/util/String.ts +9 -0
|
@@ -0,0 +1,123 @@
|
|
|
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_discover_exports = {};
|
|
20
|
+
__export(cmd_discover_exports, {
|
|
21
|
+
default: () => commands
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(cmd_discover_exports);
|
|
24
|
+
var import_general = require("@matter/general");
|
|
25
|
+
var import_datatype = require("@project-chip/matter.js/datatype");
|
|
26
|
+
var import_schema = require("@project-chip/matter.js/schema");
|
|
27
|
+
/**
|
|
28
|
+
* @license
|
|
29
|
+
* Copyright 2022-2024 Matter.js Authors
|
|
30
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
31
|
+
*/
|
|
32
|
+
function commands(theNode) {
|
|
33
|
+
return {
|
|
34
|
+
command: "discover",
|
|
35
|
+
describe: "Handle device discovery",
|
|
36
|
+
builder: (yargs) => yargs.command(
|
|
37
|
+
"commissionable [timeout-seconds]",
|
|
38
|
+
"Discover commissionable devices",
|
|
39
|
+
() => {
|
|
40
|
+
return yargs.positional("timeout-seconds", {
|
|
41
|
+
describe: "Discovery timeout in seconds",
|
|
42
|
+
default: 900,
|
|
43
|
+
type: "number"
|
|
44
|
+
}).options({
|
|
45
|
+
pairingCode: {
|
|
46
|
+
describe: "pairing code",
|
|
47
|
+
default: void 0,
|
|
48
|
+
type: "string"
|
|
49
|
+
},
|
|
50
|
+
discriminator: {
|
|
51
|
+
alias: "d",
|
|
52
|
+
description: "Long discriminator",
|
|
53
|
+
default: void 0,
|
|
54
|
+
type: "number"
|
|
55
|
+
},
|
|
56
|
+
shortDiscriminator: {
|
|
57
|
+
alias: "s",
|
|
58
|
+
description: "Short discriminator",
|
|
59
|
+
default: void 0,
|
|
60
|
+
type: "number"
|
|
61
|
+
},
|
|
62
|
+
vendorId: {
|
|
63
|
+
alias: "v",
|
|
64
|
+
description: "Vendor ID",
|
|
65
|
+
default: void 0,
|
|
66
|
+
type: "number"
|
|
67
|
+
},
|
|
68
|
+
productId: {
|
|
69
|
+
alias: "p",
|
|
70
|
+
description: "Product ID",
|
|
71
|
+
default: void 0,
|
|
72
|
+
type: "number"
|
|
73
|
+
},
|
|
74
|
+
deviceType: {
|
|
75
|
+
alias: "t",
|
|
76
|
+
description: "Device Type",
|
|
77
|
+
default: void 0,
|
|
78
|
+
type: "number"
|
|
79
|
+
},
|
|
80
|
+
ble: {
|
|
81
|
+
alias: "b",
|
|
82
|
+
description: "Also discover over BLE",
|
|
83
|
+
default: false,
|
|
84
|
+
type: "boolean"
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
async (argv) => {
|
|
89
|
+
const { ble = false, pairingCode, vendorId, productId, deviceType, timeoutSeconds } = argv;
|
|
90
|
+
let { discriminator, shortDiscriminator } = argv;
|
|
91
|
+
if (typeof pairingCode === "string") {
|
|
92
|
+
const { shortDiscriminator: pairingCodeShortDiscriminator } = import_schema.ManualPairingCodeCodec.decode(pairingCode);
|
|
93
|
+
shortDiscriminator = pairingCodeShortDiscriminator;
|
|
94
|
+
discriminator = void 0;
|
|
95
|
+
}
|
|
96
|
+
await theNode.start();
|
|
97
|
+
if (theNode.commissioningController === void 0) {
|
|
98
|
+
throw new Error("CommissioningController not initialized");
|
|
99
|
+
}
|
|
100
|
+
const identifierData = discriminator !== void 0 ? { longDiscriminator: discriminator } : shortDiscriminator !== void 0 ? { shortDiscriminator } : vendorId !== void 0 ? { vendorId: (0, import_datatype.VendorId)(vendorId) } : productId !== void 0 ? { productId } : deviceType !== void 0 ? { deviceType } : {};
|
|
101
|
+
console.log(
|
|
102
|
+
`Discover devices with identifier ${import_general.Logger.toJSON(
|
|
103
|
+
identifierData
|
|
104
|
+
)} for ${timeoutSeconds} seconds.`
|
|
105
|
+
);
|
|
106
|
+
const results = await theNode.commissioningController.discoverCommissionableDevices(
|
|
107
|
+
identifierData,
|
|
108
|
+
{
|
|
109
|
+
ble,
|
|
110
|
+
onIpNetwork: true
|
|
111
|
+
},
|
|
112
|
+
(device) => console.log(`Discovered device ${import_general.Logger.toJSON(device)}`),
|
|
113
|
+
timeoutSeconds
|
|
114
|
+
);
|
|
115
|
+
console.log(`Discovered ${results.length} devices`, results);
|
|
116
|
+
}
|
|
117
|
+
),
|
|
118
|
+
handler: async (argv) => {
|
|
119
|
+
argv.unhandled = true;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=cmd_discover.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/shell/cmd_discover.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,qBAAuB;AAEvB,sBAAyB;AACzB,oBAAuC;AATvC;AAAA;AAAA;AAAA;AAAA;AAae,SAAR,SAA0B,SAAqB;AAClD,SAAO;AAAA,IACH,SAAS;AAAA,IACT,UAAU;AAAA,IACV,SAAS,CAAC,UACN,MAEK;AAAA,MACG;AAAA,MACA;AAAA,MACA,MAAM;AACF,eAAO,MACF,WAAW,mBAAmB;AAAA,UAC3B,UAAU;AAAA,UACV,SAAS;AAAA,UACT,MAAM;AAAA,QACV,CAAC,EACA,QAAQ;AAAA,UACL,aAAa;AAAA,YACT,UAAU;AAAA,YACV,SAAS;AAAA,YACT,MAAM;AAAA,UACV;AAAA,UACA,eAAe;AAAA,YACX,OAAO;AAAA,YACP,aAAa;AAAA,YACb,SAAS;AAAA,YACT,MAAM;AAAA,UACV;AAAA,UACA,oBAAoB;AAAA,YAChB,OAAO;AAAA,YACP,aAAa;AAAA,YACb,SAAS;AAAA,YACT,MAAM;AAAA,UACV;AAAA,UACA,UAAU;AAAA,YACN,OAAO;AAAA,YACP,aAAa;AAAA,YACb,SAAS;AAAA,YACT,MAAM;AAAA,UACV;AAAA,UACA,WAAW;AAAA,YACP,OAAO;AAAA,YACP,aAAa;AAAA,YACb,SAAS;AAAA,YACT,MAAM;AAAA,UACV;AAAA,UACA,YAAY;AAAA,YACR,OAAO;AAAA,YACP,aAAa;AAAA,YACb,SAAS;AAAA,YACT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
|
|
|
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_identify_exports = {};
|
|
20
|
+
__export(cmd_identify_exports, {
|
|
21
|
+
default: () => commands
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(cmd_identify_exports);
|
|
24
|
+
var import_cluster = require("@project-chip/matter.js/cluster");
|
|
25
|
+
/**
|
|
26
|
+
* @license
|
|
27
|
+
* Copyright 2022-2024 Matter.js Authors
|
|
28
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
29
|
+
*/
|
|
30
|
+
function commands(theNode) {
|
|
31
|
+
return {
|
|
32
|
+
command: "identify [time] [node-id] [endpoint-id]",
|
|
33
|
+
describe: "Trigger Identify command with given time (default 10s). Execute on one node or endpoint, else all onoff clusters will be controlled",
|
|
34
|
+
builder: (yargs) => {
|
|
35
|
+
return yargs.positional("time", {
|
|
36
|
+
describe: "time in seconds",
|
|
37
|
+
default: 10,
|
|
38
|
+
type: "number"
|
|
39
|
+
}).positional("node-id", {
|
|
40
|
+
describe: "node id",
|
|
41
|
+
default: void 0,
|
|
42
|
+
type: "string"
|
|
43
|
+
}).positional("endpoint-id", {
|
|
44
|
+
describe: "endpoint id",
|
|
45
|
+
default: void 0,
|
|
46
|
+
type: "number"
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
handler: async (argv) => {
|
|
50
|
+
const { nodeId, time = 10, endpointId } = argv;
|
|
51
|
+
await theNode.iterateNodeDevices(
|
|
52
|
+
await theNode.connectAndGetNodes(nodeId),
|
|
53
|
+
async (device, node) => {
|
|
54
|
+
const identifyCluster = device.getClusterClient(import_cluster.IdentifyCluster);
|
|
55
|
+
if (identifyCluster === void 0) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
console.log("Invoke Identify for", node.nodeId.toString());
|
|
59
|
+
await identifyCluster.identify({ identifyTime: time });
|
|
60
|
+
},
|
|
61
|
+
endpointId
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=cmd_identify.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/shell/cmd_identify.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,qBAAgC;AANhC;AAAA;AAAA;AAAA;AAAA;AAUe,SAAR,SAA0B,SAAqB;AAClD,SAAO;AAAA,IACH,SAAS;AAAA,IACT,UACI;AAAA,IACJ,SAAS,CAAC,UAAgB;AACtB,aAAO,MACF,WAAW,QAAQ;AAAA,QAChB,UAAU;AAAA,QACV,SAAS;AAAA,QACT,MAAM;AAAA,MACV,CAAC,EACA,WAAW,WAAW;AAAA,QACnB,UAAU;AAAA,QACV,SAAS;AAAA,QACT,MAAM;AAAA,MACV,CAAC,EACA,WAAW,eAAe;AAAA,QACvB,UAAU;AAAA,QACV,SAAS;AAAA,QACT,MAAM;AAAA,MACV,CAAC;AAAA,IACT;AAAA,IAEA,SAAS,OAAO,SAAc;AAC1B,YAAM,EAAE,QAAQ,OAAO,IAAI,WAAW,IAAI;AAC1C,YAAM,QAAQ;AAAA,QACV,MAAM,QAAQ,mBAAmB,MAAM;AAAA,QACvC,OAAO,QAAQ,SAAS;AACpB,gBAAM,kBAAkB,OAAO,iBAAiB,8BAAe;AAC/D,cAAI,oBAAoB,QAAW;AAC/B;AAAA,UACJ;AACA,kBAAQ,IAAI,uBAAuB,KAAK,OAAO,SAAS,CAAC;AACzD,gBAAM,gBAAgB,SAAS,EAAE,cAAc,KAAK,CAAC;AAAA,QACzD;AAAA,QACA;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ;AACJ;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1,244 @@
|
|
|
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_nodes_exports = {};
|
|
20
|
+
__export(cmd_nodes_exports, {
|
|
21
|
+
createDiagnosticCallbacks: () => createDiagnosticCallbacks,
|
|
22
|
+
default: () => commands
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(cmd_nodes_exports);
|
|
25
|
+
var import_general = require("@matter/general");
|
|
26
|
+
var import_datatype = require("@project-chip/matter.js/datatype");
|
|
27
|
+
var import_device = require("@project-chip/matter.js/device");
|
|
28
|
+
/**
|
|
29
|
+
* @license
|
|
30
|
+
* Copyright 2022-2024 Matter.js Authors
|
|
31
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
32
|
+
*/
|
|
33
|
+
function createDiagnosticCallbacks() {
|
|
34
|
+
return {
|
|
35
|
+
attributeChangedCallback: (peerNodeId, { path: { nodeId, clusterId, endpointId, attributeName }, value }) => console.log(
|
|
36
|
+
`attributeChangedCallback ${peerNodeId}: Attribute ${nodeId}/${endpointId}/${clusterId}/${attributeName} changed to ${import_general.Logger.toJSON(
|
|
37
|
+
value
|
|
38
|
+
)}`
|
|
39
|
+
),
|
|
40
|
+
eventTriggeredCallback: (peerNodeId, { path: { nodeId, clusterId, endpointId, eventName }, events }) => console.log(
|
|
41
|
+
`eventTriggeredCallback ${peerNodeId}: Event ${nodeId}/${endpointId}/${clusterId}/${eventName} triggered with ${import_general.Logger.toJSON(
|
|
42
|
+
events
|
|
43
|
+
)}`
|
|
44
|
+
),
|
|
45
|
+
stateInformationCallback: (peerNodeId, info) => {
|
|
46
|
+
switch (info) {
|
|
47
|
+
case import_device.NodeStateInformation.Connected:
|
|
48
|
+
console.log(`stateInformationCallback Node ${peerNodeId} connected`);
|
|
49
|
+
break;
|
|
50
|
+
case import_device.NodeStateInformation.Disconnected:
|
|
51
|
+
console.log(`stateInformationCallback Node ${peerNodeId} disconnected`);
|
|
52
|
+
break;
|
|
53
|
+
case import_device.NodeStateInformation.Reconnecting:
|
|
54
|
+
console.log(`stateInformationCallback Node ${peerNodeId} reconnecting`);
|
|
55
|
+
break;
|
|
56
|
+
case import_device.NodeStateInformation.WaitingForDeviceDiscovery:
|
|
57
|
+
console.log(
|
|
58
|
+
`stateInformationCallback Node ${peerNodeId} waiting that device gets discovered again`
|
|
59
|
+
);
|
|
60
|
+
break;
|
|
61
|
+
case import_device.NodeStateInformation.StructureChanged:
|
|
62
|
+
console.log(`stateInformationCallback Node ${peerNodeId} structure changed`);
|
|
63
|
+
break;
|
|
64
|
+
case import_device.NodeStateInformation.Decommissioned:
|
|
65
|
+
console.log(`stateInformationCallback Node ${peerNodeId} decommissioned`);
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function commands(theNode) {
|
|
72
|
+
return {
|
|
73
|
+
command: ["nodes", "node"],
|
|
74
|
+
describe: "Manage nodes",
|
|
75
|
+
builder: (yargs) => yargs.command(
|
|
76
|
+
["*", "list [status]"],
|
|
77
|
+
"List all commissioned nodes",
|
|
78
|
+
(yargs2) => {
|
|
79
|
+
return yargs2.positional("status", {
|
|
80
|
+
describe: "status",
|
|
81
|
+
options: ["commissioned", "connected"],
|
|
82
|
+
default: "commissioned",
|
|
83
|
+
type: "string"
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
async (argv) => {
|
|
87
|
+
const { status } = argv;
|
|
88
|
+
await theNode.start();
|
|
89
|
+
if (theNode.commissioningController === void 0) {
|
|
90
|
+
throw new Error("CommissioningController not initialized");
|
|
91
|
+
}
|
|
92
|
+
switch (status) {
|
|
93
|
+
case "commissioned": {
|
|
94
|
+
const details = theNode.commissioningController.getCommissionedNodesDetails();
|
|
95
|
+
details.map((detail) => ({
|
|
96
|
+
...detail,
|
|
97
|
+
nodeId: detail.nodeId.toString()
|
|
98
|
+
})).forEach((detail) => {
|
|
99
|
+
console.log(detail);
|
|
100
|
+
});
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
case "connected": {
|
|
104
|
+
const nodeIds = theNode.commissioningController.getCommissionedNodes().filter((nodeId) => !!theNode.commissioningController?.getPairedNode(nodeId));
|
|
105
|
+
console.log(nodeIds.map((nodeId) => nodeId.toString()));
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
).command(
|
|
111
|
+
"log [node-id]",
|
|
112
|
+
"Log the Structure of one node",
|
|
113
|
+
(yargs2) => {
|
|
114
|
+
return yargs2.positional("node-id", {
|
|
115
|
+
describe: "node id to log - if omitted the first node is logged.",
|
|
116
|
+
default: void 0,
|
|
117
|
+
type: "string"
|
|
118
|
+
});
|
|
119
|
+
},
|
|
120
|
+
async (argv) => {
|
|
121
|
+
const { nodeId } = argv;
|
|
122
|
+
const node = (await theNode.connectAndGetNodes(nodeId))[0];
|
|
123
|
+
console.log("Logging structure of Node ", node.nodeId.toString());
|
|
124
|
+
node.logStructure({});
|
|
125
|
+
}
|
|
126
|
+
).command(
|
|
127
|
+
"connect <node-id> [min-subscription-interval] [max-subscription-interval]",
|
|
128
|
+
"Connects to one or all commissioned nodes",
|
|
129
|
+
(yargs2) => {
|
|
130
|
+
return yargs2.positional("node-id", {
|
|
131
|
+
describe: "node id to connect. Use 'all' to connect to all nodes.",
|
|
132
|
+
default: void 0,
|
|
133
|
+
type: "string",
|
|
134
|
+
demandOption: true
|
|
135
|
+
}).positional("min-subscription-interval", {
|
|
136
|
+
describe: "Minimum subscription interval in seconds. If set then the node is subscribed to all attributes and events.",
|
|
137
|
+
type: "number"
|
|
138
|
+
}).positional("max-subscription-interval", {
|
|
139
|
+
describe: "Maximum subscription interval in seconds. If minimum interval is set and this not it will be determined automatically.",
|
|
140
|
+
type: "number"
|
|
141
|
+
});
|
|
142
|
+
},
|
|
143
|
+
async (argv) => {
|
|
144
|
+
const { nodeId: nodeIdStr, maxSubscriptionInterval, minSubscriptionInterval } = argv;
|
|
145
|
+
await theNode.start();
|
|
146
|
+
if (theNode.commissioningController === void 0) {
|
|
147
|
+
throw new Error("CommissioningController not initialized");
|
|
148
|
+
}
|
|
149
|
+
let nodeIds = theNode.commissioningController.getCommissionedNodes();
|
|
150
|
+
if (nodeIdStr !== "all") {
|
|
151
|
+
const cmdNodeId = (0, import_datatype.NodeId)(BigInt(nodeIdStr));
|
|
152
|
+
nodeIds = nodeIds.filter((nodeId) => nodeId === cmdNodeId);
|
|
153
|
+
if (!nodeIds.length) {
|
|
154
|
+
throw new Error(`Node ${nodeIdStr} not commissioned`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const autoSubscribe = minSubscriptionInterval !== void 0;
|
|
158
|
+
for (const nodeIdToProcess of nodeIds) {
|
|
159
|
+
await theNode.commissioningController.connectNode(nodeIdToProcess, {
|
|
160
|
+
autoSubscribe,
|
|
161
|
+
subscribeMinIntervalFloorSeconds: autoSubscribe ? minSubscriptionInterval : void 0,
|
|
162
|
+
subscribeMaxIntervalCeilingSeconds: autoSubscribe ? maxSubscriptionInterval : void 0,
|
|
163
|
+
...createDiagnosticCallbacks()
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
).command(
|
|
168
|
+
"disconnect <node-id>",
|
|
169
|
+
"Disconnects from one or all nodes",
|
|
170
|
+
(yargs2) => {
|
|
171
|
+
return yargs2.positional("node-id", {
|
|
172
|
+
describe: "node id to disconnect. Use 'all' to disconnect from all nodes.",
|
|
173
|
+
default: void 0,
|
|
174
|
+
type: "string",
|
|
175
|
+
demandOption: true
|
|
176
|
+
});
|
|
177
|
+
},
|
|
178
|
+
async (argv) => {
|
|
179
|
+
const { nodeId: nodeIdStr } = argv;
|
|
180
|
+
if (theNode.commissioningController === void 0) {
|
|
181
|
+
console.log("Controller not initialized, nothing to disconnect.");
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
let nodeIds = theNode.commissioningController.getCommissionedNodes();
|
|
185
|
+
if (nodeIdStr !== "all") {
|
|
186
|
+
const cmdNodeId = (0, import_datatype.NodeId)(BigInt(nodeIdStr));
|
|
187
|
+
nodeIds = nodeIds.filter((nodeId) => nodeId === cmdNodeId);
|
|
188
|
+
if (!nodeIds.length) {
|
|
189
|
+
throw new Error(`Node ${nodeIdStr} not commissioned`);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
for (const nodeIdToProcess of nodeIds) {
|
|
193
|
+
const node = theNode.commissioningController.getPairedNode(nodeIdToProcess);
|
|
194
|
+
if (node === void 0) {
|
|
195
|
+
console.log(`Node ${nodeIdToProcess} not connected`);
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
await node.disconnect();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
).command(
|
|
202
|
+
"status <node-ids>",
|
|
203
|
+
"Logs the connection status for all or specified nodes",
|
|
204
|
+
(yargs2) => {
|
|
205
|
+
return yargs2.positional("node-ids", {
|
|
206
|
+
describe: "node ids to connect (comma separated list allowed). Use 'all' to log status for all nodes.",
|
|
207
|
+
default: void 0,
|
|
208
|
+
type: "string",
|
|
209
|
+
demandOption: true
|
|
210
|
+
});
|
|
211
|
+
},
|
|
212
|
+
async (argv) => {
|
|
213
|
+
const { nodeIds: nodeIdStr } = argv;
|
|
214
|
+
await theNode.start();
|
|
215
|
+
if (theNode.commissioningController === void 0) {
|
|
216
|
+
throw new Error("CommissioningController not initialized");
|
|
217
|
+
}
|
|
218
|
+
let nodeIds = theNode.commissioningController.getCommissionedNodes();
|
|
219
|
+
if (nodeIdStr !== "all") {
|
|
220
|
+
const nodeIdList = nodeIdStr.split(",").map((nodeId) => (0, import_datatype.NodeId)(BigInt(nodeId)));
|
|
221
|
+
nodeIds = nodeIds.filter((nodeId) => nodeIdList.includes(nodeId));
|
|
222
|
+
if (!nodeIds.length) {
|
|
223
|
+
throw new Error(`Node ${nodeIdStr} not commissioned`);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
for (const nodeIdToProcess of nodeIds) {
|
|
227
|
+
const node = theNode.commissioningController.getPairedNode(nodeIdToProcess);
|
|
228
|
+
if (node === void 0) {
|
|
229
|
+
console.log(`Node ${nodeIdToProcess}: Not initialized`);
|
|
230
|
+
} else {
|
|
231
|
+
const basicInfo = node.basicInformation;
|
|
232
|
+
console.log(
|
|
233
|
+
`Node ${nodeIdToProcess}: Node Status: ${(0, import_general.capitalize)((0, import_general.decamelize)(import_device.NodeStateInformation[node.nodeState], " "))}${basicInfo !== void 0 ? ` (${basicInfo.vendorName} ${basicInfo.productName})` : ""}`
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
),
|
|
239
|
+
handler: async (argv) => {
|
|
240
|
+
argv.unhandled = true;
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
//# sourceMappingURL=cmd_nodes.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/shell/cmd_nodes.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,qBAA+C;AAC/C,sBAAuB;AACvB,oBAAyE;AARzE;AAAA;AAAA;AAAA;AAAA;AAYO,SAAS,4BAAyE;AACrF,SAAO;AAAA,IACH,0BAA0B,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,WAAW,YAAY,cAAc,GAAG,MAAM,MACnG,QAAQ;AAAA,MACJ,4BAA4B,UAAU,eAAe,MAAM,IAAI,UAAU,IAAI,SAAS,IAAI,aAAa,eAAe,sBAAO;AAAA,QACzH;AAAA,MACJ,CAAC;AAAA,IACL;AAAA,IACJ,wBAAwB,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,WAAW,YAAY,UAAU,GAAG,OAAO,MAC9F,QAAQ;AAAA,MACJ,0BAA0B,UAAU,WAAW,MAAM,IAAI,UAAU,IAAI,SAAS,IAAI,SAAS,mBAAmB,sBAAO;AAAA,QACnH;AAAA,MACJ,CAAC;AAAA,IACL;AAAA,IACJ,0BAA0B,CAAC,YAAY,SAAS;AAC5C,cAAQ,MAAM;AAAA,QACV,KAAK,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43 @@
|
|
|
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_session_exports = {};
|
|
20
|
+
__export(cmd_session_exports, {
|
|
21
|
+
default: () => commands
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(cmd_session_exports);
|
|
24
|
+
/**
|
|
25
|
+
* @license
|
|
26
|
+
* Copyright 2022-2024 Matter.js Authors
|
|
27
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
28
|
+
*/
|
|
29
|
+
function commands(theNode) {
|
|
30
|
+
return {
|
|
31
|
+
command: "session",
|
|
32
|
+
describe: "Manage session",
|
|
33
|
+
builder: {},
|
|
34
|
+
handler: async () => {
|
|
35
|
+
if (!theNode.commissioningController) {
|
|
36
|
+
throw new Error("CommissioningController not initialized");
|
|
37
|
+
}
|
|
38
|
+
const sessions = theNode.commissioningController?.getActiveSessionInformation();
|
|
39
|
+
console.log(sessions);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=cmd_session.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/shell/cmd_session.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQe,SAAR,SAA0B,SAAqB;AAClD,SAAO;AAAA,IACH,SAAS;AAAA,IACT,UAAU;AAAA,IACV,SAAS,CAAC;AAAA,IACV,SAAS,YAAY;AACjB,UAAI,CAAC,QAAQ,yBAAyB;AAClC,cAAM,IAAI,MAAM,yCAAyC;AAAA,MAC7D;AAEA,YAAM,WAAW,QAAQ,yBAAyB,4BAA4B;AAC9E,cAAQ,IAAI,QAAQ;AAAA,IACxB;AAAA,EACJ;AACJ;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
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_subscribe_exports = {};
|
|
20
|
+
__export(cmd_subscribe_exports, {
|
|
21
|
+
default: () => commands
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(cmd_subscribe_exports);
|
|
24
|
+
var import_general = require("@matter/general");
|
|
25
|
+
/**
|
|
26
|
+
* @license
|
|
27
|
+
* Copyright 2022-2024 Matter.js Authors
|
|
28
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
29
|
+
*/
|
|
30
|
+
function commands(theNode) {
|
|
31
|
+
return {
|
|
32
|
+
command: "subscribe [node-id]",
|
|
33
|
+
describe: "Subscribe to all events and attributes of a node",
|
|
34
|
+
builder: (yargs) => {
|
|
35
|
+
return yargs.positional("node-id", {
|
|
36
|
+
describe: "node id",
|
|
37
|
+
default: void 0,
|
|
38
|
+
type: "string"
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
handler: async (argv) => {
|
|
42
|
+
const { nodeId } = argv;
|
|
43
|
+
const node = (await theNode.connectAndGetNodes(nodeId))[0];
|
|
44
|
+
await node.subscribeAllAttributesAndEvents({
|
|
45
|
+
attributeChangedCallback: ({ path: { nodeId: nodeId2, clusterId, endpointId, attributeName }, value }) => console.log(
|
|
46
|
+
`${nodeId2}: Attribute ${nodeId2}/${endpointId}/${clusterId}/${attributeName} changed to ${import_general.Logger.toJSON(
|
|
47
|
+
value
|
|
48
|
+
)}`
|
|
49
|
+
),
|
|
50
|
+
eventTriggeredCallback: ({ path: { nodeId: nodeId2, clusterId, endpointId, eventName }, events }) => console.log(
|
|
51
|
+
`${nodeId2} Event ${nodeId2}/${endpointId}/${clusterId}/${eventName} triggered with ${import_general.Logger.toJSON(
|
|
52
|
+
events
|
|
53
|
+
)}`
|
|
54
|
+
)
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=cmd_subscribe.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": 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