@project-chip/matter-node.js-examples 0.6.1-alpha.0-20231031-f3417b3 → 0.6.1-alpha.0-20231101-4ef32c9
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/esm/examples/BridgedDevicesNode.js +141 -0
- package/dist/{cjs → esm}/examples/BridgedDevicesNode.js.map +1 -1
- package/dist/esm/examples/ComposedDeviceNode.js +138 -0
- package/dist/{cjs → esm}/examples/ComposedDeviceNode.js.map +1 -1
- package/dist/{cjs → esm}/examples/ControllerNode.js +58 -48
- package/dist/{cjs → esm}/examples/ControllerNode.js.map +2 -2
- package/dist/esm/examples/DeviceNode.js +159 -0
- package/dist/{cjs → esm}/examples/DeviceNode.js.map +2 -2
- package/dist/esm/examples/MultiDeviceNode.js +146 -0
- package/dist/{cjs → esm}/examples/MultiDeviceNode.js.map +1 -1
- package/dist/{cjs → esm}/examples/cluster/DummyWifiNetworkCommissioningClusterServer.js +29 -45
- package/dist/{cjs → esm}/examples/cluster/DummyWifiNetworkCommissioningClusterServer.js.map +1 -1
- package/package.json +6 -5
- package/src/tsconfig.json +1 -1
- package/dist/cjs/examples/BridgedDevicesNode.js +0 -136
- package/dist/cjs/examples/ComposedDeviceNode.js +0 -133
- package/dist/cjs/examples/DeviceNode.js +0 -175
- package/dist/cjs/examples/MultiDeviceNode.js +0 -141
- package/dist/cjs/package.json +0 -1
@@ -0,0 +1,159 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
/**
|
3
|
+
* @license
|
4
|
+
* Copyright 2022 The node-matter Authors
|
5
|
+
* SPDX-License-Identifier: Apache-2.0
|
6
|
+
*/
|
7
|
+
import { CommissioningServer, MatterServer } from "@project-chip/matter-node.js";
|
8
|
+
import { BleNode } from "@project-chip/matter-node-ble.js/ble";
|
9
|
+
import { Ble } from "@project-chip/matter-node.js/ble";
|
10
|
+
import { OnOffLightDevice, OnOffPluginUnitDevice, logEndpoint } from "@project-chip/matter-node.js/device";
|
11
|
+
import { Format, Level, Logger } from "@project-chip/matter-node.js/log";
|
12
|
+
import { QrCode } from "@project-chip/matter-node.js/schema";
|
13
|
+
import { StorageBackendDisk, StorageManager } from "@project-chip/matter-node.js/storage";
|
14
|
+
import { Time } from "@project-chip/matter-node.js/time";
|
15
|
+
import {
|
16
|
+
commandExecutor,
|
17
|
+
getIntParameter,
|
18
|
+
getParameter,
|
19
|
+
hasParameter,
|
20
|
+
requireMinNodeVersion,
|
21
|
+
singleton
|
22
|
+
} from "@project-chip/matter-node.js/util";
|
23
|
+
import { DeviceTypeId, VendorId } from "@project-chip/matter.js/datatype";
|
24
|
+
import DummyWifiNetworkCommissioningClusterServer from "./cluster/DummyWifiNetworkCommissioningClusterServer.js";
|
25
|
+
const logger = Logger.get("Device");
|
26
|
+
requireMinNodeVersion(16);
|
27
|
+
switch (getParameter("loglevel")) {
|
28
|
+
case "fatal":
|
29
|
+
Logger.defaultLogLevel = Level.FATAL;
|
30
|
+
break;
|
31
|
+
case "error":
|
32
|
+
Logger.defaultLogLevel = Level.ERROR;
|
33
|
+
break;
|
34
|
+
case "warn":
|
35
|
+
Logger.defaultLogLevel = Level.WARN;
|
36
|
+
break;
|
37
|
+
case "info":
|
38
|
+
Logger.defaultLogLevel = Level.INFO;
|
39
|
+
break;
|
40
|
+
}
|
41
|
+
switch (getParameter("logformat")) {
|
42
|
+
case "plain":
|
43
|
+
Logger.format = Format.PLAIN;
|
44
|
+
break;
|
45
|
+
case "html":
|
46
|
+
Logger.format = Format.HTML;
|
47
|
+
break;
|
48
|
+
default:
|
49
|
+
if (process.stdin?.isTTY)
|
50
|
+
Logger.format = Format.ANSI;
|
51
|
+
}
|
52
|
+
if (hasParameter("ble")) {
|
53
|
+
Ble.get = singleton(
|
54
|
+
() => new BleNode({
|
55
|
+
hciId: getIntParameter("ble-hci-id")
|
56
|
+
})
|
57
|
+
);
|
58
|
+
}
|
59
|
+
const storageLocation = getParameter("store") ?? ".device-node";
|
60
|
+
const storage = new StorageBackendDisk(storageLocation, hasParameter("clearstorage"));
|
61
|
+
logger.info(`Storage location: ${storageLocation} (Directory)`);
|
62
|
+
logger.info(
|
63
|
+
'Use the parameter "-store NAME" to specify a different storage location, use -clearstorage to start with an empty storage.'
|
64
|
+
);
|
65
|
+
class Device {
|
66
|
+
async start() {
|
67
|
+
logger.info(`node-matter`);
|
68
|
+
const storageManager = new StorageManager(storage);
|
69
|
+
await storageManager.initialize();
|
70
|
+
const deviceStorage = storageManager.createContext("Device");
|
71
|
+
if (deviceStorage.has("isSocket")) {
|
72
|
+
logger.info("Device type found in storage. -type parameter is ignored.");
|
73
|
+
}
|
74
|
+
const isSocket = deviceStorage.get("isSocket", getParameter("type") === "socket");
|
75
|
+
const deviceName = "Matter test device";
|
76
|
+
const vendorName = "matter-node.js";
|
77
|
+
const passcode = getIntParameter("passcode") ?? deviceStorage.get("passcode", 20202021);
|
78
|
+
const discriminator = getIntParameter("discriminator") ?? deviceStorage.get("discriminator", 3840);
|
79
|
+
const vendorId = getIntParameter("vendorid") ?? deviceStorage.get("vendorid", 65521);
|
80
|
+
const productName = `node-matter OnOff ${isSocket ? "Socket" : "Light"}`;
|
81
|
+
const productId = getIntParameter("productid") ?? deviceStorage.get("productid", 32768);
|
82
|
+
const netAnnounceInterface = getParameter("announceinterface");
|
83
|
+
const port = getIntParameter("port") ?? 5540;
|
84
|
+
const uniqueId = getIntParameter("uniqueid") ?? deviceStorage.get("uniqueid", Time.nowMs());
|
85
|
+
deviceStorage.set("passcode", passcode);
|
86
|
+
deviceStorage.set("discriminator", discriminator);
|
87
|
+
deviceStorage.set("vendorid", vendorId);
|
88
|
+
deviceStorage.set("productid", productId);
|
89
|
+
deviceStorage.set("isSocket", isSocket);
|
90
|
+
deviceStorage.set("uniqueid", uniqueId);
|
91
|
+
const onOffDevice = isSocket ? new OnOffPluginUnitDevice() : new OnOffLightDevice();
|
92
|
+
onOffDevice.addOnOffListener((on) => commandExecutor(on ? "on" : "off")?.());
|
93
|
+
onOffDevice.addCommandHandler(
|
94
|
+
"identify",
|
95
|
+
async ({ request: { identifyTime } }) => logger.info(`Identify called for OnOffDevice: ${identifyTime}`)
|
96
|
+
);
|
97
|
+
this.matterServer = new MatterServer(storageManager, { mdnsAnnounceInterface: netAnnounceInterface });
|
98
|
+
const commissioningServer = new CommissioningServer({
|
99
|
+
port,
|
100
|
+
deviceName,
|
101
|
+
deviceType: DeviceTypeId(onOffDevice.deviceType),
|
102
|
+
passcode,
|
103
|
+
discriminator,
|
104
|
+
basicInformation: {
|
105
|
+
vendorName,
|
106
|
+
vendorId: VendorId(vendorId),
|
107
|
+
nodeLabel: productName,
|
108
|
+
productName,
|
109
|
+
productLabel: productName,
|
110
|
+
productId,
|
111
|
+
serialNumber: `node-matter-${uniqueId}`
|
112
|
+
},
|
113
|
+
delayedAnnouncement: hasParameter("ble")
|
114
|
+
// Delay announcement when BLE is used to show how limited advertisement works
|
115
|
+
});
|
116
|
+
commissioningServer.addCommandHandler(
|
117
|
+
"testEventTrigger",
|
118
|
+
async ({ request: { enableKey, eventTrigger } }) => logger.info(`testEventTrigger called on GeneralDiagnostic cluster: ${enableKey} ${eventTrigger}`)
|
119
|
+
);
|
120
|
+
if (hasParameter("ble")) {
|
121
|
+
commissioningServer.addRootClusterServer(DummyWifiNetworkCommissioningClusterServer);
|
122
|
+
}
|
123
|
+
commissioningServer.addDevice(onOffDevice);
|
124
|
+
this.matterServer.addCommissioningServer(commissioningServer);
|
125
|
+
await this.matterServer.start();
|
126
|
+
logEndpoint(commissioningServer.getRootEndpoint());
|
127
|
+
if (hasParameter("ble")) {
|
128
|
+
await commissioningServer.advertise({ ble: true });
|
129
|
+
}
|
130
|
+
logger.info("Listening");
|
131
|
+
if (!commissioningServer.isCommissioned()) {
|
132
|
+
const pairingData = commissioningServer.getPairingCode({
|
133
|
+
ble: hasParameter("ble"),
|
134
|
+
softAccessPoint: false,
|
135
|
+
onIpNetwork: false
|
136
|
+
});
|
137
|
+
const { qrPairingCode, manualPairingCode } = pairingData;
|
138
|
+
console.log(QrCode.get(qrPairingCode));
|
139
|
+
logger.info(
|
140
|
+
`QR Code URL: https://project-chip.github.io/connectedhomeip/qrcode.html?data=${qrPairingCode}`
|
141
|
+
);
|
142
|
+
logger.info(`Manual pairing code: ${manualPairingCode}`);
|
143
|
+
} else {
|
144
|
+
logger.info("Device is already commissioned. Waiting for controllers to connect ...");
|
145
|
+
}
|
146
|
+
}
|
147
|
+
async stop() {
|
148
|
+
await this.matterServer?.close();
|
149
|
+
}
|
150
|
+
}
|
151
|
+
const device = new Device();
|
152
|
+
device.start().then(() => {
|
153
|
+
}).catch((err) => console.error(err));
|
154
|
+
process.on("SIGINT", () => {
|
155
|
+
device.stop().then(() => {
|
156
|
+
storage.close().then(() => process.exit(0)).catch((err) => console.error(err));
|
157
|
+
}).catch((err) => console.error(err));
|
158
|
+
});
|
159
|
+
//# sourceMappingURL=DeviceNode.js.map
|
@@ -2,6 +2,6 @@
|
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../src/examples/DeviceNode.ts"],
|
4
4
|
"sourcesContent": ["#!/usr/bin/env node\n/**\n * @license\n * Copyright 2022 The node-matter Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/**\n * This example shows how to create a simple on-off Matter device.\n * It can be used as CLI script and starting point for your own device node implementation.\n */\n\n/**\n * Import needed modules from @project-chip/matter-node.js\n */\n// Include this first to auto-register Crypto, Network and Time Node.js implementations\nimport { CommissioningServer, MatterServer } from \"@project-chip/matter-node.js\";\n\nimport { BleNode } from \"@project-chip/matter-node-ble.js/ble\";\nimport { Ble } from \"@project-chip/matter-node.js/ble\";\nimport { OnOffLightDevice, OnOffPluginUnitDevice, logEndpoint } from \"@project-chip/matter-node.js/device\";\nimport { Format, Level, Logger } from \"@project-chip/matter-node.js/log\";\nimport { QrCode } from \"@project-chip/matter-node.js/schema\";\nimport { StorageBackendDisk, StorageManager } from \"@project-chip/matter-node.js/storage\";\nimport { Time } from \"@project-chip/matter-node.js/time\";\nimport {\n commandExecutor,\n getIntParameter,\n getParameter,\n hasParameter,\n requireMinNodeVersion,\n singleton,\n} from \"@project-chip/matter-node.js/util\";\nimport { DeviceTypeId, VendorId } from \"@project-chip/matter.js/datatype\";\nimport DummyWifiNetworkCommissioningClusterServer from \"./cluster/DummyWifiNetworkCommissioningClusterServer.js\";\n\nconst logger = Logger.get(\"Device\");\n\nrequireMinNodeVersion(16);\n\n/** Configure logging */\nswitch (getParameter(\"loglevel\")) {\n case \"fatal\":\n Logger.defaultLogLevel = Level.FATAL;\n break;\n case \"error\":\n Logger.defaultLogLevel = Level.ERROR;\n break;\n case \"warn\":\n Logger.defaultLogLevel = Level.WARN;\n break;\n case \"info\":\n Logger.defaultLogLevel = Level.INFO;\n break;\n}\n\nswitch (getParameter(\"logformat\")) {\n case \"plain\":\n Logger.format = Format.PLAIN;\n break;\n case \"html\":\n Logger.format = Format.HTML;\n break;\n default:\n if (process.stdin?.isTTY) Logger.format = Format.ANSI;\n}\n\nif (hasParameter(\"ble\")) {\n // Initialize Ble\n Ble.get = singleton(\n () =>\n new BleNode({\n hciId: getIntParameter(\"ble-hci-id\"),\n }),\n );\n}\n\nconst storageLocation = getParameter(\"store\") ?? \".device-node\";\nconst storage = new StorageBackendDisk(storageLocation, hasParameter(\"clearstorage\"));\nlogger.info(`Storage location: ${storageLocation} (Directory)`);\nlogger.info(\n 'Use the parameter \"-store NAME\" to specify a different storage location, use -clearstorage to start with an empty storage.',\n);\n\nclass Device {\n private matterServer: MatterServer | undefined;\n\n async start() {\n logger.info(`node-matter`);\n\n /**\n * Initialize the storage system.\n *\n * The storage manager is then also used by the Matter server, so this code block in general is required,\n * but you can choose a different storage backend as long as it implements the required API.\n */\n\n const storageManager = new StorageManager(storage);\n await storageManager.initialize();\n\n /**\n * Collect all needed data\n *\n * This block makes sure to collect all needed data from cli or storage. Replace this with where ever your data\n * come from.\n *\n * Note: This example also uses the initialized storage system to store the device parameter data for convenience\n * and easy reuse. When you also do that be careful to not overlap with Matter-Server own contexts\n * (so maybe better not ;-)).\n */\n\n const deviceStorage = storageManager.createContext(\"Device\");\n\n if (deviceStorage.has(\"isSocket\")) {\n logger.info(\"Device type found in storage. -type parameter is ignored.\");\n }\n const isSocket = deviceStorage.get(\"isSocket\", getParameter(\"type\") === \"socket\");\n const deviceName = \"Matter test device\";\n const vendorName = \"matter-node.js\";\n const passcode = getIntParameter(\"passcode\") ?? deviceStorage.get(\"passcode\", 20202021);\n const discriminator = getIntParameter(\"discriminator\") ?? deviceStorage.get(\"discriminator\", 3840);\n // product name / id and vendor id should match what is in the device certificate\n const vendorId = getIntParameter(\"vendorid\") ?? deviceStorage.get(\"vendorid\", 0xfff1);\n const productName = `node-matter OnOff ${isSocket ? \"Socket\" : \"Light\"}`;\n const productId = getIntParameter(\"productid\") ?? deviceStorage.get(\"productid\", 0x8000);\n\n const netAnnounceInterface = getParameter(\"announceinterface\");\n const port = getIntParameter(\"port\") ?? 5540;\n\n const uniqueId = getIntParameter(\"uniqueid\") ?? deviceStorage.get(\"uniqueid\", Time.nowMs());\n\n deviceStorage.set(\"passcode\", passcode);\n deviceStorage.set(\"discriminator\", discriminator);\n deviceStorage.set(\"vendorid\", vendorId);\n deviceStorage.set(\"productid\", productId);\n deviceStorage.set(\"isSocket\", isSocket);\n deviceStorage.set(\"uniqueid\", uniqueId);\n\n /**\n * Create Device instance and add needed Listener\n *\n * Create an instance of the matter device class you want to use.\n * This example uses the OnOffLightDevice or OnOffPluginUnitDevice depending on the value of the type parameter.\n * To execute the on/off scripts defined as parameters a listener for the onOff attribute is registered via the\n * device specific API.\n *\n * The below logic also adds command handlers for commands of clusters that normally are handled device internally\n * like identify that can be implemented with the logic when these commands are called.\n */\n\n const onOffDevice = isSocket ? new OnOffPluginUnitDevice() : new OnOffLightDevice();\n onOffDevice.addOnOffListener(on => commandExecutor(on ? \"on\" : \"off\")?.());\n\n onOffDevice.addCommandHandler(\"identify\", async ({ request: { identifyTime } }) =>\n logger.info(`Identify called for OnOffDevice: ${identifyTime}`),\n );\n\n /**\n * Create Matter Server and CommissioningServer Node\n *\n * To allow the device to be announced, found, paired and operated we need a MatterServer instance and add a\n * commissioningServer to it and add the just created device instance to it.\n * The CommissioningServer node defines the port where the server listens for the UDP packages of the Matter protocol\n * and initializes deice specific certificates and such.\n *\n * The below logic also adds command handlers for commands of clusters that normally are handled internally\n * like testEventTrigger (General Diagnostic Cluster) that can be implemented with the logic when these commands\n * are called.\n */\n\n this.matterServer = new MatterServer(storageManager, { mdnsAnnounceInterface: netAnnounceInterface });\n\n const commissioningServer = new CommissioningServer({\n port,\n deviceName,\n deviceType: DeviceTypeId(onOffDevice.deviceType),\n passcode,\n discriminator,\n basicInformation: {\n vendorName,\n vendorId: VendorId(vendorId),\n nodeLabel: productName,\n productName,\n productLabel: productName,\n productId,\n serialNumber: `node-matter-${uniqueId}`,\n },\n delayedAnnouncement: hasParameter(\"ble\"), // Delay announcement when BLE is used to show how limited advertisement works\n });\n\n // optionally add a listener for the testEventTrigger command from the GeneralDiagnostics cluster\n commissioningServer.addCommandHandler(\"testEventTrigger\", async ({ request: { enableKey, eventTrigger } }) =>\n logger.info(`testEventTrigger called on GeneralDiagnostic cluster: ${enableKey} ${eventTrigger}`),\n );\n\n /**\n * Modify automatically added clusters of the Root endpoint if needed\n * In this example we change the networkCommissioning cluster into one for \"Wifi only\" devices when BLE is used\n * for commissioning, to demonstrate how to do this.\n * If you want to implement Ethernet only devices that get connected to the network via LAN/Ethernet cable,\n * then all this is not needed.\n * The same as shown here for Wi-Fi is also possible theoretical for Thread only or combined devices.\n */\n\n if (hasParameter(\"ble\")) {\n // matter.js will create a Ethernet-only device by default when ut comes to Network Commissioning Features.\n // To offer e.g. a \"Wi-Fi only device\" (or any other combination) we need to override the Network Commissioning\n // cluster and implement all the need handling here. This is a \"static implementation\" for pure demonstration\n // purposes and just \"simulates\" the actions to be done. In a real world implementation this would be done by\n // the device implementor based on the relevant networking stack.\n // The NetworkCommissioningCluster and all logics are described in Matter Core Specifications section 11.8\n commissioningServer.addRootClusterServer(DummyWifiNetworkCommissioningClusterServer);\n }\n\n commissioningServer.addDevice(onOffDevice);\n\n this.matterServer.addCommissioningServer(commissioningServer);\n\n /**\n * Start the Matter Server\n *\n * After everything was plugged together we can start the server. When not delayed announcement is set for the\n * CommissioningServer node then this command also starts the announcement of the device into the network.\n */\n\n await this.matterServer.start();\n\n logEndpoint(commissioningServer.getRootEndpoint());\n\n // When we want to limit the initial announcement to one medium (e.g. BLE) then we need to delay the\n // announcement and provide the limiting information.\n // Without delaying the announcement is directly triggered with the above \"start()\" call.\n if (hasParameter(\"ble\")) {\n // Announce operational in BLE network only if we have ble enabled, else everywhere\n await commissioningServer.advertise({ ble: true });\n }\n\n /**\n * Print Pairing Information\n *\n * If the device is not already commissioned (this info is stored in the storage system) then get and print the\n * pairing details. This includes the QR code that can be scanned by the Matter app to pair the device.\n */\n\n logger.info(\"Listening\");\n if (!commissioningServer.isCommissioned()) {\n const pairingData = commissioningServer.getPairingCode({\n ble: hasParameter(\"ble\"),\n softAccessPoint: false,\n onIpNetwork: false,\n });\n\n const { qrPairingCode, manualPairingCode } = pairingData;\n\n console.log(QrCode.get(qrPairingCode));\n logger.info(\n `QR Code URL: https://project-chip.github.io/connectedhomeip/qrcode.html?data=${qrPairingCode}`,\n );\n logger.info(`Manual pairing code: ${manualPairingCode}`);\n } else {\n logger.info(\"Device is already commissioned. Waiting for controllers to connect ...\");\n }\n }\n\n async stop() {\n await this.matterServer?.close();\n }\n}\n\nconst device = new Device();\ndevice\n .start()\n .then(() => {\n /* done */\n })\n .catch(err => console.error(err));\n\nprocess.on(\"SIGINT\", () => {\n device\n .stop()\n .then(() => {\n // Pragmatic way to make sure the storage is correctly closed before the process ends.\n storage\n .close()\n .then(() => process.exit(0))\n .catch(err => console.error(err));\n })\n .catch(err => console.error(err));\n});\n"],
|
5
|
-
"mappings": "
|
6
|
-
"names": [
|
5
|
+
"mappings": ";AACA;AAAA;AAAA;AAAA;AAAA;AAeA,SAAS,qBAAqB,oBAAoB;AAElD,SAAS,eAAe;AACxB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,MAAM,EACN,KAAK,MAAM;AAEZ,CAAC,EACA,MAAM,SAAO,QAAQ,MAAM,GAAG,CAAC;AAEpC,QAAQ,GAAG,UAAU,MAAM;AACvB,SACK,KAAK,EACL,KAAK,MAAM;AAER,YACK,MAAM,EACN,KAAK,MAAM,QAAQ,KAAK,CAAC,CAAC,EAC1B,MAAM,SAAO,QAAQ,MAAM,GAAG,CAAC;AAAA,EACxC,CAAC,EACA,MAAM,SAAO,QAAQ,MAAM,GAAG,CAAC;AACxC,CAAC;",
|
6
|
+
"names": []
|
7
7
|
}
|
@@ -0,0 +1,146 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
/**
|
3
|
+
* @license
|
4
|
+
* Copyright 2022 The node-matter Authors
|
5
|
+
* SPDX-License-Identifier: Apache-2.0
|
6
|
+
*/
|
7
|
+
import { CommissioningServer, MatterServer } from "@project-chip/matter-node.js";
|
8
|
+
import { DeviceTypes, OnOffLightDevice, OnOffPluginUnitDevice } from "@project-chip/matter-node.js/device";
|
9
|
+
import { Format, Level, Logger } from "@project-chip/matter-node.js/log";
|
10
|
+
import { QrCode } from "@project-chip/matter-node.js/schema";
|
11
|
+
import { StorageBackendDisk, StorageManager } from "@project-chip/matter-node.js/storage";
|
12
|
+
import { Time } from "@project-chip/matter-node.js/time";
|
13
|
+
import {
|
14
|
+
commandExecutor,
|
15
|
+
getIntParameter,
|
16
|
+
getParameter,
|
17
|
+
hasParameter,
|
18
|
+
requireMinNodeVersion
|
19
|
+
} from "@project-chip/matter-node.js/util";
|
20
|
+
import { VendorId } from "@project-chip/matter.js/datatype";
|
21
|
+
const logger = Logger.get("MultiDevice");
|
22
|
+
requireMinNodeVersion(16);
|
23
|
+
switch (getParameter("loglevel")) {
|
24
|
+
case "fatal":
|
25
|
+
Logger.defaultLogLevel = Level.FATAL;
|
26
|
+
break;
|
27
|
+
case "error":
|
28
|
+
Logger.defaultLogLevel = Level.ERROR;
|
29
|
+
break;
|
30
|
+
case "warn":
|
31
|
+
Logger.defaultLogLevel = Level.WARN;
|
32
|
+
break;
|
33
|
+
case "info":
|
34
|
+
Logger.defaultLogLevel = Level.INFO;
|
35
|
+
break;
|
36
|
+
}
|
37
|
+
switch (getParameter("logformat")) {
|
38
|
+
case "plain":
|
39
|
+
Logger.format = Format.PLAIN;
|
40
|
+
break;
|
41
|
+
case "html":
|
42
|
+
Logger.format = Format.HTML;
|
43
|
+
break;
|
44
|
+
default:
|
45
|
+
if (process.stdin?.isTTY)
|
46
|
+
Logger.format = Format.ANSI;
|
47
|
+
}
|
48
|
+
const storageLocation = getParameter("store") ?? ".device-node";
|
49
|
+
const storage = new StorageBackendDisk(storageLocation, hasParameter("clearstorage"));
|
50
|
+
logger.info(`Storage location: ${storageLocation} (Directory)`);
|
51
|
+
logger.info(
|
52
|
+
'Use the parameter "-store NAME" to specify a different storage location, use -clearstorage to start with an empty storage.'
|
53
|
+
);
|
54
|
+
class Device {
|
55
|
+
async start() {
|
56
|
+
logger.info(`node-matter`);
|
57
|
+
const storageManager = new StorageManager(storage);
|
58
|
+
await storageManager.initialize();
|
59
|
+
const netAnnounceInterface = getParameter("announceinterface");
|
60
|
+
const deviceStorage = storageManager.createContext("Device");
|
61
|
+
this.matterServer = new MatterServer(storageManager, { mdnsAnnounceInterface: netAnnounceInterface });
|
62
|
+
const commissioningServers = new Array();
|
63
|
+
let defaultPasscode = 20202021;
|
64
|
+
let defaultDiscriminator = 3840;
|
65
|
+
let defaultPort = 5550;
|
66
|
+
const numDevices = getIntParameter("num") || 2;
|
67
|
+
for (let i = 1; i <= numDevices; i++) {
|
68
|
+
if (deviceStorage.has(`isSocket${i}`)) {
|
69
|
+
logger.info("Device type found in storage. -type parameter is ignored.");
|
70
|
+
}
|
71
|
+
const isSocket = deviceStorage.get(`isSocket${i}`, getParameter(`type${i}`) === "socket");
|
72
|
+
const deviceName = `Matter ${getParameter(`type${i}`) ?? "light"} device ${i}`;
|
73
|
+
const deviceType = getParameter(`type${i}`) === "socket" ? DeviceTypes.ON_OFF_PLUGIN_UNIT.code : DeviceTypes.ON_OFF_LIGHT.code;
|
74
|
+
const vendorName = "matter-node.js";
|
75
|
+
const passcode = getIntParameter(`passcode${i}`) ?? deviceStorage.get(`passcode${i}`, defaultPasscode++);
|
76
|
+
const discriminator = getIntParameter(`discriminator${i}`) ?? deviceStorage.get(`discriminator${i}`, defaultDiscriminator++);
|
77
|
+
const vendorId = getIntParameter(`vendorid${i}`) ?? deviceStorage.get(`vendorid${i}`, 65521);
|
78
|
+
const productName = `node-matter OnOff-Device ${i}`;
|
79
|
+
const productId = getIntParameter(`productid${i}`) ?? deviceStorage.get(`productid${i}`, 32768);
|
80
|
+
const port = getIntParameter(`port${i}`) ?? defaultPort++;
|
81
|
+
const uniqueId = getIntParameter(`uniqueid${i}`) ?? deviceStorage.get(`uniqueid${i}`, `${i}-${Time.nowMs()}`);
|
82
|
+
deviceStorage.set(`passcode${i}`, passcode);
|
83
|
+
deviceStorage.set(`discriminator${i}`, discriminator);
|
84
|
+
deviceStorage.set(`vendorid${i}`, vendorId);
|
85
|
+
deviceStorage.set(`productid${i}`, productId);
|
86
|
+
deviceStorage.set(`isSocket${i}`, isSocket);
|
87
|
+
deviceStorage.set(`uniqueid${i}`, uniqueId);
|
88
|
+
const commissioningServer = new CommissioningServer({
|
89
|
+
port,
|
90
|
+
deviceName,
|
91
|
+
deviceType,
|
92
|
+
passcode,
|
93
|
+
discriminator,
|
94
|
+
basicInformation: {
|
95
|
+
vendorName,
|
96
|
+
vendorId: VendorId(vendorId),
|
97
|
+
nodeLabel: productName,
|
98
|
+
productName,
|
99
|
+
productLabel: productName,
|
100
|
+
productId,
|
101
|
+
serialNumber: `node-matter-${uniqueId}`
|
102
|
+
}
|
103
|
+
});
|
104
|
+
console.log(
|
105
|
+
`Added device ${i} on port ${port} and unique id ${uniqueId}: Passcode: ${passcode}, Discriminator: ${discriminator}`
|
106
|
+
);
|
107
|
+
const onOffDevice = getParameter(`type${i}`) === "socket" ? new OnOffPluginUnitDevice() : new OnOffLightDevice();
|
108
|
+
onOffDevice.addFixedLabel("orientation", getParameter(`orientation${i}`) ?? `orientation ${i}`);
|
109
|
+
onOffDevice.addOnOffListener((on) => commandExecutor(on ? `on${i}` : `off${i}`)?.());
|
110
|
+
commissioningServer.addDevice(onOffDevice);
|
111
|
+
this.matterServer.addCommissioningServer(commissioningServer);
|
112
|
+
commissioningServers.push(commissioningServer);
|
113
|
+
}
|
114
|
+
await this.matterServer.start();
|
115
|
+
logger.info("Listening");
|
116
|
+
console.log();
|
117
|
+
commissioningServers.forEach((commissioningServer, index) => {
|
118
|
+
console.log("----------------------------");
|
119
|
+
console.log(`Device ${index + 1}:`);
|
120
|
+
if (!commissioningServer.isCommissioned()) {
|
121
|
+
const pairingData = commissioningServer.getPairingCode();
|
122
|
+
const { qrPairingCode, manualPairingCode } = pairingData;
|
123
|
+
console.log(QrCode.get(qrPairingCode));
|
124
|
+
console.log(
|
125
|
+
`QR Code URL: https://project-chip.github.io/connectedhomeip/qrcode.html?data=${qrPairingCode}`
|
126
|
+
);
|
127
|
+
console.log(`Manual pairing code: ${manualPairingCode}`);
|
128
|
+
} else {
|
129
|
+
console.log("Device is already commissioned. Waiting for controllers to connect ...");
|
130
|
+
}
|
131
|
+
console.log();
|
132
|
+
});
|
133
|
+
}
|
134
|
+
async stop() {
|
135
|
+
await this.matterServer?.close();
|
136
|
+
}
|
137
|
+
}
|
138
|
+
const device = new Device();
|
139
|
+
device.start().then(() => {
|
140
|
+
}).catch((err) => console.error(err));
|
141
|
+
process.on("SIGINT", () => {
|
142
|
+
device.stop().then(() => {
|
143
|
+
storage.close().then(() => process.exit(0)).catch((err) => console.error(err));
|
144
|
+
}).catch((err) => console.error(err));
|
145
|
+
});
|
146
|
+
//# sourceMappingURL=MultiDeviceNode.js.map
|
@@ -2,6 +2,6 @@
|
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../src/examples/MultiDeviceNode.ts"],
|
4
4
|
"sourcesContent": ["#!/usr/bin/env node\n/**\n * @license\n * Copyright 2022 The node-matter Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/**\n * This example shows how to create a new device node that is composed of multiple devices.\n * It creates multiple endpoints on the server. When you want to add a composed devices to a Aggregator you need to\n * add all endpoints of the composed device to an \"ComposedDevice\" instance! (not shown in this example).\n * It can be used as CLI script and starting point for your own device node implementation.\n */\n\n/**\n * Import needed modules from @project-chip/matter-node.js\n */\n// Include this first to auto-register Crypto, Network and Time Node.js implementations\nimport { CommissioningServer, MatterServer } from \"@project-chip/matter-node.js\";\n\nimport { DeviceTypes, OnOffLightDevice, OnOffPluginUnitDevice } from \"@project-chip/matter-node.js/device\";\nimport { Format, Level, Logger } from \"@project-chip/matter-node.js/log\";\nimport { QrCode } from \"@project-chip/matter-node.js/schema\";\nimport { StorageBackendDisk, StorageManager } from \"@project-chip/matter-node.js/storage\";\nimport { Time } from \"@project-chip/matter-node.js/time\";\nimport {\n commandExecutor,\n getIntParameter,\n getParameter,\n hasParameter,\n requireMinNodeVersion,\n} from \"@project-chip/matter-node.js/util\";\nimport { VendorId } from \"@project-chip/matter.js/datatype\";\n\nconst logger = Logger.get(\"MultiDevice\");\n\nrequireMinNodeVersion(16);\n\n/** Configure logging */\nswitch (getParameter(\"loglevel\")) {\n case \"fatal\":\n Logger.defaultLogLevel = Level.FATAL;\n break;\n case \"error\":\n Logger.defaultLogLevel = Level.ERROR;\n break;\n case \"warn\":\n Logger.defaultLogLevel = Level.WARN;\n break;\n case \"info\":\n Logger.defaultLogLevel = Level.INFO;\n break;\n}\n\nswitch (getParameter(\"logformat\")) {\n case \"plain\":\n Logger.format = Format.PLAIN;\n break;\n case \"html\":\n Logger.format = Format.HTML;\n break;\n default:\n if (process.stdin?.isTTY) Logger.format = Format.ANSI;\n}\n\nconst storageLocation = getParameter(\"store\") ?? \".device-node\";\nconst storage = new StorageBackendDisk(storageLocation, hasParameter(\"clearstorage\"));\nlogger.info(`Storage location: ${storageLocation} (Directory)`);\nlogger.info(\n 'Use the parameter \"-store NAME\" to specify a different storage location, use -clearstorage to start with an empty storage.',\n);\n\nclass Device {\n private matterServer: MatterServer | undefined;\n\n async start() {\n logger.info(`node-matter`);\n\n /**\n * Initialize the storage system.\n *\n * The storage manager is then also used by the Matter server, so this code block in general is required,\n * but you can choose a different storage backend as long as it implements the required API.\n */\n\n const storageManager = new StorageManager(storage);\n await storageManager.initialize();\n\n /**\n * Collect all needed data\n *\n * This block makes sure to collect all needed data from cli or storage. Replace this with where ever your data\n * come from.\n *\n * Note: This example also uses the initialized storage system to store the device parameter data for convenience\n * and easy reuse. When you also do that be careful to not overlap with Matter-Server own contexts\n * (so maybe better not ;-)).\n */\n const netAnnounceInterface = getParameter(\"announceinterface\");\n\n const deviceStorage = storageManager.createContext(\"Device\");\n\n /**\n * Create Matter Server and CommissioningServer Node\n *\n * To allow the device to be announced, found, paired and operated we need a MatterServer instance and add a\n * commissioningServer to it and add the just created device instance to it.\n * The CommissioningServer node defines the port where the server listens for the UDP packages of the Matter protocol\n * and initializes deice specific certificates and such.\n *\n * The below logic also adds command handlers for commands of clusters that normally are handled internally\n * like testEventTrigger (General Diagnostic Cluster) that can be implemented with the logic when these commands\n * are called.\n */\n\n this.matterServer = new MatterServer(storageManager, { mdnsAnnounceInterface: netAnnounceInterface });\n\n /**\n * Create Device instance and add needed Listener\n *\n * Create an instance of the matter device class you want to use.\n * This example uses the OnOffLightDevice or OnOffPluginUnitDevice depending on the value of the type parameter.\n * To execute the on/off scripts defined as parameters a listener for the onOff attribute is registered via the\n * device specific API.\n *\n * The below logic also adds command handlers for commands of clusters that normally are handled device internally\n * like identify that can be implemented with the logic when these commands are called.\n */\n\n const commissioningServers = new Array<CommissioningServer>();\n\n let defaultPasscode = 20202021;\n let defaultDiscriminator = 3840;\n let defaultPort = 5550;\n\n const numDevices = getIntParameter(\"num\") || 2;\n for (let i = 1; i <= numDevices; i++) {\n if (deviceStorage.has(`isSocket${i}`)) {\n logger.info(\"Device type found in storage. -type parameter is ignored.\");\n }\n const isSocket = deviceStorage.get(`isSocket${i}`, getParameter(`type${i}`) === \"socket\");\n const deviceName = `Matter ${getParameter(`type${i}`) ?? \"light\"} device ${i}`;\n const deviceType =\n getParameter(`type${i}`) === \"socket\"\n ? DeviceTypes.ON_OFF_PLUGIN_UNIT.code\n : DeviceTypes.ON_OFF_LIGHT.code;\n const vendorName = \"matter-node.js\";\n const passcode = getIntParameter(`passcode${i}`) ?? deviceStorage.get(`passcode${i}`, defaultPasscode++);\n const discriminator =\n getIntParameter(`discriminator${i}`) ?? deviceStorage.get(`discriminator${i}`, defaultDiscriminator++);\n // product name / id and vendor id should match what is in the device certificate\n const vendorId = getIntParameter(`vendorid${i}`) ?? deviceStorage.get(`vendorid${i}`, 0xfff1);\n const productName = `node-matter OnOff-Device ${i}`;\n const productId = getIntParameter(`productid${i}`) ?? deviceStorage.get(`productid${i}`, 0x8000);\n\n const port = getIntParameter(`port${i}`) ?? defaultPort++;\n\n const uniqueId =\n getIntParameter(`uniqueid${i}`) ?? deviceStorage.get(`uniqueid${i}`, `${i}-${Time.nowMs()}`);\n\n deviceStorage.set(`passcode${i}`, passcode);\n deviceStorage.set(`discriminator${i}`, discriminator);\n deviceStorage.set(`vendorid${i}`, vendorId);\n deviceStorage.set(`productid${i}`, productId);\n deviceStorage.set(`isSocket${i}`, isSocket);\n deviceStorage.set(`uniqueid${i}`, uniqueId);\n\n const commissioningServer = new CommissioningServer({\n port,\n deviceName,\n deviceType,\n passcode,\n discriminator,\n basicInformation: {\n vendorName,\n vendorId: VendorId(vendorId),\n nodeLabel: productName,\n productName,\n productLabel: productName,\n productId,\n serialNumber: `node-matter-${uniqueId}`,\n },\n });\n\n console.log(\n `Added device ${i} on port ${port} and unique id ${uniqueId}: Passcode: ${passcode}, Discriminator: ${discriminator}`,\n );\n\n const onOffDevice =\n getParameter(`type${i}`) === \"socket\" ? new OnOffPluginUnitDevice() : new OnOffLightDevice();\n onOffDevice.addFixedLabel(\"orientation\", getParameter(`orientation${i}`) ?? `orientation ${i}`);\n onOffDevice.addOnOffListener(on => commandExecutor(on ? `on${i}` : `off${i}`)?.());\n commissioningServer.addDevice(onOffDevice);\n\n this.matterServer.addCommissioningServer(commissioningServer);\n\n commissioningServers.push(commissioningServer);\n }\n\n /**\n * Start the Matter Server\n *\n * After everything was plugged together we can start the server. When not delayed announcement is set for the\n * CommissioningServer node then this command also starts the announcement of the device into the network.\n */\n\n await this.matterServer.start();\n\n /**\n * Print Pairing Information\n *\n * If the device is not already commissioned (this info is stored in the storage system) then get and print the\n * pairing details. This includes the QR code that can be scanned by the Matter app to pair the device.\n */\n\n logger.info(\"Listening\");\n console.log();\n commissioningServers.forEach((commissioningServer, index) => {\n console.log(\"----------------------------\");\n console.log(`Device ${index + 1}:`);\n if (!commissioningServer.isCommissioned()) {\n const pairingData = commissioningServer.getPairingCode();\n const { qrPairingCode, manualPairingCode } = pairingData;\n\n console.log(QrCode.get(qrPairingCode));\n console.log(\n `QR Code URL: https://project-chip.github.io/connectedhomeip/qrcode.html?data=${qrPairingCode}`,\n );\n console.log(`Manual pairing code: ${manualPairingCode}`);\n } else {\n console.log(\"Device is already commissioned. Waiting for controllers to connect ...\");\n }\n console.log();\n });\n }\n\n async stop() {\n await this.matterServer?.close();\n }\n}\n\nconst device = new Device();\ndevice\n .start()\n .then(() => {\n /* done */\n })\n .catch(err => console.error(err));\n\nprocess.on(\"SIGINT\", () => {\n device\n .stop()\n .then(() => {\n // Pragmatic way to make sure the storage is correctly closed before the process ends.\n storage\n .close()\n .then(() => process.exit(0))\n .catch(err => console.error(err));\n })\n .catch(err => console.error(err));\n});\n"],
|
5
|
-
"mappings": "
|
5
|
+
"mappings": ";AACA;AAAA;AAAA;AAAA;AAAA;AAiBA,SAAS,qBAAqB,oBAAoB;AAElD,SAAS,aAAa,kBAAkB,6BAA6B;AACrE,SAAS,QAAQ,OAAO,cAAc;AACtC,SAAS,cAAc;AACvB,SAAS,oBAAoB,sBAAsB;AACnD,SAAS,YAAY;AACr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AM,KAAK,cAAc,MAAM;AAAA,EACnC;AACJ;AAEA,MAAM,SAAS,IAAI,OAAO;AAC1B,OACK,MAAM,EACN,KAAK,MAAM;AAEZ,CAAC,EACA,MAAM,SAAO,QAAQ,MAAM,GAAG,CAAC;AAEpC,QAAQ,GAAG,UAAU,MAAM;AACvB,SACK,KAAK,EACL,KAAK,MAAM;AAER,YACK,MAAM,EACN,KAAK,MAAM,QAAQ,KAAK,CAAC,CAAC,EAC1B,MAAM,SAAO,QAAQ,MAAM,GAAG,CAAC;AAAA,EACxC,CAAC,EACA,MAAM,SAAO,QAAQ,MAAM,GAAG,CAAC;AACxC,CAAC;",
|
6
6
|
"names": []
|
7
7
|
}
|
@@ -1,37 +1,18 @@
|
|
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 DummyWifiNetworkCommissioningClusterServer_exports = {};
|
20
|
-
__export(DummyWifiNetworkCommissioningClusterServer_exports, {
|
21
|
-
default: () => DummyWifiNetworkCommissioningClusterServer_default
|
22
|
-
});
|
23
|
-
module.exports = __toCommonJS(DummyWifiNetworkCommissioningClusterServer_exports);
|
24
|
-
var import_cluster = require("@project-chip/matter-node.js/cluster");
|
25
|
-
var import_util = require("@project-chip/matter-node.js/util");
|
26
1
|
/**
|
27
2
|
* @license
|
28
3
|
* Copyright 2022 The node-matter Authors
|
29
4
|
* SPDX-License-Identifier: Apache-2.0
|
30
5
|
*/
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
6
|
+
import {
|
7
|
+
ClusterServer,
|
8
|
+
GeneralCommissioningCluster,
|
9
|
+
NetworkCommissioning
|
10
|
+
} from "@project-chip/matter-node.js/cluster";
|
11
|
+
import { ByteArray, getParameter } from "@project-chip/matter-node.js/util";
|
12
|
+
const firstNetworkId = new ByteArray(32);
|
13
|
+
const WifiNetworkCluster = NetworkCommissioning.Cluster.with(NetworkCommissioning.Feature.WiFiNetworkInterface);
|
14
|
+
var DummyWifiNetworkCommissioningClusterServer_default = ClusterServer(
|
15
|
+
NetworkCommissioning.Cluster.with(NetworkCommissioning.Feature.WiFiNetworkInterface),
|
35
16
|
{
|
36
17
|
maxNetworks: 1,
|
37
18
|
interfaceEnabled: true,
|
@@ -46,10 +27,10 @@ var DummyWifiNetworkCommissioningClusterServer_default = (0, import_cluster.Clus
|
|
46
27
|
scanNetworks: async ({ request: { ssid, breadcrumb }, attributes: { lastNetworkingStatus }, endpoint }) => {
|
47
28
|
console.log(`---> scanNetworks called on NetworkCommissioning cluster: ${ssid?.toHex()} ${breadcrumb}`);
|
48
29
|
if (breadcrumb !== void 0) {
|
49
|
-
const generalCommissioningCluster = endpoint.getClusterServer(
|
30
|
+
const generalCommissioningCluster = endpoint.getClusterServer(GeneralCommissioningCluster);
|
50
31
|
generalCommissioningCluster?.setBreadcrumbAttribute(breadcrumb);
|
51
32
|
}
|
52
|
-
const networkingStatus =
|
33
|
+
const networkingStatus = NetworkCommissioning.NetworkCommissioningStatus.Success;
|
53
34
|
lastNetworkingStatus?.setLocal(networkingStatus);
|
54
35
|
return {
|
55
36
|
networkingStatus,
|
@@ -62,9 +43,9 @@ var DummyWifiNetworkCommissioningClusterServer_default = (0, import_cluster.Clus
|
|
62
43
|
wpa2Personal: true,
|
63
44
|
wpa3Personal: true
|
64
45
|
},
|
65
|
-
ssid: ssid ||
|
46
|
+
ssid: ssid || ByteArray.fromString(getParameter("ble-wifi-scan-ssid") ?? "TestSSID"),
|
66
47
|
// Set a valid existing local Wi-Fi SSID here
|
67
|
-
bssid:
|
48
|
+
bssid: ByteArray.fromString(getParameter("ble-wifi-scan-bssid") ?? "00:00:00:00:00:00"),
|
68
49
|
channel: 1
|
69
50
|
}
|
70
51
|
]
|
@@ -81,14 +62,14 @@ var DummyWifiNetworkCommissioningClusterServer_default = (0, import_cluster.Clus
|
|
81
62
|
);
|
82
63
|
session.getContext().assertFailSafeArmed("Failsafe timer needs to be armed to add or update networks.");
|
83
64
|
if (breadcrumb !== void 0) {
|
84
|
-
const generalCommissioningCluster = endpoint.getClusterServer(
|
65
|
+
const generalCommissioningCluster = endpoint.getClusterServer(GeneralCommissioningCluster);
|
85
66
|
generalCommissioningCluster?.setBreadcrumbAttribute(breadcrumb);
|
86
67
|
}
|
87
|
-
const networkingStatus =
|
68
|
+
const networkingStatus = NetworkCommissioning.NetworkCommissioningStatus.Success;
|
88
69
|
lastNetworkingStatus?.setLocal(networkingStatus);
|
89
70
|
lastNetworkId?.setLocal(firstNetworkId);
|
90
71
|
return {
|
91
|
-
networkingStatus:
|
72
|
+
networkingStatus: NetworkCommissioning.NetworkCommissioningStatus.Success,
|
92
73
|
networkIndex: 0
|
93
74
|
};
|
94
75
|
},
|
@@ -103,14 +84,14 @@ var DummyWifiNetworkCommissioningClusterServer_default = (0, import_cluster.Clus
|
|
103
84
|
);
|
104
85
|
session.getContext().assertFailSafeArmed("Failsafe timer needs to be armed to add or update networks.");
|
105
86
|
if (breadcrumb !== void 0) {
|
106
|
-
const generalCommissioningCluster = endpoint.getClusterServer(
|
87
|
+
const generalCommissioningCluster = endpoint.getClusterServer(GeneralCommissioningCluster);
|
107
88
|
generalCommissioningCluster?.setBreadcrumbAttribute(breadcrumb);
|
108
89
|
}
|
109
|
-
const networkingStatus =
|
90
|
+
const networkingStatus = NetworkCommissioning.NetworkCommissioningStatus.Success;
|
110
91
|
lastNetworkingStatus?.setLocal(networkingStatus);
|
111
92
|
lastNetworkId?.setLocal(firstNetworkId);
|
112
93
|
return {
|
113
|
-
networkingStatus:
|
94
|
+
networkingStatus: NetworkCommissioning.NetworkCommissioningStatus.Success,
|
114
95
|
networkIndex: 0
|
115
96
|
};
|
116
97
|
},
|
@@ -125,20 +106,20 @@ var DummyWifiNetworkCommissioningClusterServer_default = (0, import_cluster.Clus
|
|
125
106
|
);
|
126
107
|
session.getContext().assertFailSafeArmed("Failsafe timer needs to be armed to add or update networks.");
|
127
108
|
if (breadcrumb !== void 0) {
|
128
|
-
const generalCommissioningCluster = endpoint.getClusterServer(
|
109
|
+
const generalCommissioningCluster = endpoint.getClusterServer(GeneralCommissioningCluster);
|
129
110
|
generalCommissioningCluster?.setBreadcrumbAttribute(breadcrumb);
|
130
111
|
}
|
131
112
|
const networkList = networks.getLocal();
|
132
113
|
networkList[0].connected = true;
|
133
114
|
networks.setLocal(networkList);
|
134
|
-
const networkingStatus =
|
115
|
+
const networkingStatus = NetworkCommissioning.NetworkCommissioningStatus.Success;
|
135
116
|
lastNetworkingStatus?.setLocal(networkingStatus);
|
136
117
|
lastNetworkId?.setLocal(firstNetworkId);
|
137
118
|
lastConnectErrorValue?.setLocal(null);
|
138
119
|
const device = session.getContext();
|
139
120
|
await device.startAnnouncement();
|
140
121
|
return {
|
141
|
-
networkingStatus:
|
122
|
+
networkingStatus: NetworkCommissioning.NetworkCommissioningStatus.Success,
|
142
123
|
errorValue: null
|
143
124
|
};
|
144
125
|
},
|
@@ -151,16 +132,19 @@ var DummyWifiNetworkCommissioningClusterServer_default = (0, import_cluster.Clus
|
|
151
132
|
`---> reorderNetwork called on NetworkCommissioning cluster: ${networkId.toHex()} ${networkIndex} ${breadcrumb}`
|
152
133
|
);
|
153
134
|
if (breadcrumb !== void 0) {
|
154
|
-
const generalCommissioningCluster = endpoint.getClusterServer(
|
135
|
+
const generalCommissioningCluster = endpoint.getClusterServer(GeneralCommissioningCluster);
|
155
136
|
generalCommissioningCluster?.setBreadcrumbAttribute(breadcrumb);
|
156
137
|
}
|
157
|
-
const networkingStatus =
|
138
|
+
const networkingStatus = NetworkCommissioning.NetworkCommissioningStatus.Success;
|
158
139
|
lastNetworkingStatus?.setLocal(networkingStatus);
|
159
140
|
return {
|
160
|
-
networkingStatus:
|
141
|
+
networkingStatus: NetworkCommissioning.NetworkCommissioningStatus.Success,
|
161
142
|
networkIndex: 0
|
162
143
|
};
|
163
144
|
}
|
164
145
|
}
|
165
146
|
);
|
147
|
+
export {
|
148
|
+
DummyWifiNetworkCommissioningClusterServer_default as default
|
149
|
+
};
|
166
150
|
//# sourceMappingURL=DummyWifiNetworkCommissioningClusterServer.js.map
|
@@ -2,6 +2,6 @@
|
|
2
2
|
"version": 3,
|
3
3
|
"sources": ["../../../../src/examples/cluster/DummyWifiNetworkCommissioningClusterServer.ts"],
|
4
4
|
"sourcesContent": ["/**\n * @license\n * Copyright 2022 The node-matter Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n ClusterServer,\n ClusterServerObjForCluster,\n GeneralCommissioningCluster,\n NetworkCommissioning,\n} from \"@project-chip/matter-node.js/cluster\";\nimport { ByteArray, getParameter } from \"@project-chip/matter-node.js/util\";\n\nconst firstNetworkId = new ByteArray(32);\n\nconst WifiNetworkCluster = NetworkCommissioning.Cluster.with(NetworkCommissioning.Feature.WiFiNetworkInterface);\n\n/**\n * This represents a Dummy version of a Wifi Network Commissioning Cluster Server without real Wifi related logic, beside\n * returning some values provided as CLI parameters. This dummy implementation is only there for tests/as showcase for BLE\n * commissioning of a device.\n */\nexport default ClusterServer(\n NetworkCommissioning.Cluster.with(NetworkCommissioning.Feature.WiFiNetworkInterface),\n {\n maxNetworks: 1,\n interfaceEnabled: true,\n lastConnectErrorValue: 0,\n lastNetworkId: null,\n lastNetworkingStatus: null,\n networks: [{ networkId: firstNetworkId, connected: false }],\n scanMaxTimeSeconds: 3,\n connectMaxTimeSeconds: 3,\n },\n {\n scanNetworks: async ({ request: { ssid, breadcrumb }, attributes: { lastNetworkingStatus }, endpoint }) => {\n console.log(`---> scanNetworks called on NetworkCommissioning cluster: ${ssid?.toHex()} ${breadcrumb}`);\n\n // Simulate successful scan\n if (breadcrumb !== undefined) {\n const generalCommissioningCluster = endpoint.getClusterServer(GeneralCommissioningCluster);\n generalCommissioningCluster?.setBreadcrumbAttribute(breadcrumb);\n }\n\n const networkingStatus = NetworkCommissioning.NetworkCommissioningStatus.Success;\n lastNetworkingStatus?.setLocal(networkingStatus);\n\n return {\n networkingStatus,\n wiFiScanResults: [\n {\n security: {\n unencrypted: false,\n wep: false,\n wpaPersonal: false,\n wpa2Personal: true,\n wpa3Personal: true,\n },\n ssid: ssid || ByteArray.fromString(getParameter(\"ble-wifi-scan-ssid\") ?? \"TestSSID\"), // Set a valid existing local Wi-Fi SSID here\n bssid: ByteArray.fromString(getParameter(\"ble-wifi-scan-bssid\") ?? \"00:00:00:00:00:00\"),\n channel: 1,\n },\n ],\n };\n },\n addOrUpdateWiFiNetwork: async ({\n request: { ssid, credentials, breadcrumb },\n attributes: { lastNetworkingStatus, lastNetworkId },\n endpoint,\n session,\n }) => {\n console.log(\n `---> addOrUpdateWiFiNetwork called on NetworkCommissioning cluster: ${ssid.toHex()} ${credentials.toHex()} ${breadcrumb}`,\n );\n\n session.getContext().assertFailSafeArmed(\"Failsafe timer needs to be armed to add or update networks.\");\n\n // Simulate successful add or update\n if (breadcrumb !== undefined) {\n const generalCommissioningCluster = endpoint.getClusterServer(GeneralCommissioningCluster);\n generalCommissioningCluster?.setBreadcrumbAttribute(breadcrumb);\n }\n\n const networkingStatus = NetworkCommissioning.NetworkCommissioningStatus.Success;\n lastNetworkingStatus?.setLocal(networkingStatus);\n lastNetworkId?.setLocal(firstNetworkId);\n\n return {\n networkingStatus: NetworkCommissioning.NetworkCommissioningStatus.Success,\n networkIndex: 0,\n };\n },\n removeNetwork: async ({\n request: { networkId, breadcrumb },\n attributes: { lastNetworkingStatus, lastNetworkId },\n endpoint,\n session,\n }) => {\n console.log(\n `---> removeNetwork called on NetworkCommissioning cluster: ${networkId.toHex()} ${breadcrumb}`,\n );\n\n session.getContext().assertFailSafeArmed(\"Failsafe timer needs to be armed to add or update networks.\");\n\n // Simulate successful add or update\n if (breadcrumb !== undefined) {\n const generalCommissioningCluster = endpoint.getClusterServer(GeneralCommissioningCluster);\n generalCommissioningCluster?.setBreadcrumbAttribute(breadcrumb);\n }\n\n const networkingStatus = NetworkCommissioning.NetworkCommissioningStatus.Success;\n lastNetworkingStatus?.setLocal(networkingStatus);\n lastNetworkId?.setLocal(firstNetworkId);\n\n return {\n networkingStatus: NetworkCommissioning.NetworkCommissioningStatus.Success,\n networkIndex: 0,\n };\n },\n connectNetwork: async ({\n request: { networkId, breadcrumb },\n attributes: { lastNetworkingStatus, lastNetworkId, lastConnectErrorValue, networks },\n endpoint,\n session,\n }) => {\n console.log(\n `---> connectNetwork called on NetworkCommissioning cluster: ${networkId.toHex()} ${breadcrumb}`,\n );\n\n session.getContext().assertFailSafeArmed(\"Failsafe timer needs to be armed to add or update networks.\");\n\n // Simulate successful connection\n if (breadcrumb !== undefined) {\n const generalCommissioningCluster = endpoint.getClusterServer(GeneralCommissioningCluster);\n generalCommissioningCluster?.setBreadcrumbAttribute(breadcrumb);\n }\n\n const networkList = networks.getLocal();\n networkList[0].connected = true;\n networks.setLocal(networkList);\n\n const networkingStatus = NetworkCommissioning.NetworkCommissioningStatus.Success;\n lastNetworkingStatus?.setLocal(networkingStatus);\n lastNetworkId?.setLocal(firstNetworkId);\n lastConnectErrorValue?.setLocal(null);\n\n // Announce operational in IP network\n const device = session.getContext();\n await device.startAnnouncement();\n\n return {\n networkingStatus: NetworkCommissioning.NetworkCommissioningStatus.Success,\n errorValue: null,\n };\n },\n reorderNetwork: async ({\n request: { networkId, networkIndex, breadcrumb },\n attributes: { lastNetworkingStatus },\n endpoint,\n }) => {\n console.log(\n `---> reorderNetwork called on NetworkCommissioning cluster: ${networkId.toHex()} ${networkIndex} ${breadcrumb}`,\n );\n\n // Simulate successful connection\n if (breadcrumb !== undefined) {\n const generalCommissioningCluster = endpoint.getClusterServer(GeneralCommissioningCluster);\n generalCommissioningCluster?.setBreadcrumbAttribute(breadcrumb);\n }\n\n const networkingStatus = NetworkCommissioning.NetworkCommissioningStatus.Success;\n lastNetworkingStatus?.setLocal(networkingStatus);\n\n return {\n networkingStatus: NetworkCommissioning.NetworkCommissioningStatus.Success,\n networkIndex: 0,\n };\n },\n },\n) as ClusterServerObjForCluster<typeof WifiNetworkCluster>;\n"],
|
5
|
-
"mappings": "
|
5
|
+
"mappings": "AAAA;AAAA;AAAA;AAAA;AAAA;AAMA;AAAA,EACI;AAAA,EAEA;AAAA,EACA;AAAA,OACG;AACP,SAAS,WAAW,oBAAoB;AAExC,MAAM,iBAAiB,IAAI,UAAU,EAAE;AAEvC,MAAM,qBAAqB,qBAAqB,QAAQ,KAAK,qBAAqB,QAAQ,oBAAoB;AAO9G,IAAO,qDAAQ;AAAA,EACX,qBAAqB,QAAQ,KAAK,qBAAqB,QAAQ,oBAAoB;AAAA,EACnF;AAAA,IACI,aAAa;AAAA,IACb,kBAAkB;AAAA,IAClB,uBAAuB;AAAA,IACvB,eAAe;AAAA,IACf,sBAAsB;AAAA,IACtB,UAAU,CAAC,EAAE,WAAW,gBAAgB,WAAW,MAAM,CAAC;AAAA,IAC1D,oBAAoB;AAAA,IACpB,uBAAuB;AAAA,EAC3B;AAAA,EACA;AAAA,IACI,cAAc,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,GAAG,YAAY,EAAE,qBAAqB,GAAG,SAAS,MAAM;AACvG,cAAQ,IAAI,6DAA6D,MAAM,MAAM,CAAC,IAAI,UAAU,EAAE;AAGtG,UAAI,eAAe,QAAW;AAC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AAY,EAAE,qBAAqB;AAAA,MACnC;AAAA,IACJ,MAAM;AACF,cAAQ;AAAA,QACJ,+DAA+D,UAAU,MAAM,CAAC,IAAI,YAAY,IAAI,UAAU;AAAA,MAClH;AAGA,UAAI,eAAe,QAAW;AAC1B,cAAM,8BAA8B,SAAS,iBAAiB,2BAA2B;AACzF,qCAA6B,uBAAuB,UAAU;AAAA,MAClE;AAEA,YAAM,mBAAmB,qBAAqB,2BAA2B;AACzE,4BAAsB,SAAS,gBAAgB;AAE/C,aAAO;AAAA,QACH,kBAAkB,qBAAqB,2BAA2B;AAAA,QAClE,cAAc;AAAA,MAClB;AAAA,IACJ;AAAA,EACJ;AACJ;",
|
6
6
|
"names": []
|
7
7
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@project-chip/matter-node.js-examples",
|
3
|
-
"version": "0.6.1-alpha.0-
|
3
|
+
"version": "0.6.1-alpha.0-20231101-4ef32c9",
|
4
4
|
"description": "CLI/Reference implementation scripts for Matter protocol for node.js",
|
5
5
|
"keywords": [
|
6
6
|
"iot",
|
@@ -43,12 +43,12 @@
|
|
43
43
|
"matter-controller": "./dist/cjs/examples/ControllerNode.js"
|
44
44
|
},
|
45
45
|
"devDependencies": {
|
46
|
-
"@project-chip/matter.js-tools": "0.6.1-alpha.0-
|
46
|
+
"@project-chip/matter.js-tools": "0.6.1-alpha.0-20231101-4ef32c9",
|
47
47
|
"typescript": "^5.2.2"
|
48
48
|
},
|
49
49
|
"dependencies": {
|
50
|
-
"@project-chip/matter-node-ble.js": "0.6.1-alpha.0-
|
51
|
-
"@project-chip/matter-node.js": "0.6.1-alpha.0-
|
50
|
+
"@project-chip/matter-node-ble.js": "0.6.1-alpha.0-20231101-4ef32c9",
|
51
|
+
"@project-chip/matter-node.js": "0.6.1-alpha.0-20231101-4ef32c9"
|
52
52
|
},
|
53
53
|
"engines": {
|
54
54
|
"_comment": "For Crypto.hkdf support",
|
@@ -60,8 +60,9 @@
|
|
60
60
|
"LICENSE",
|
61
61
|
"README.md"
|
62
62
|
],
|
63
|
+
"type": "module",
|
63
64
|
"publishConfig": {
|
64
65
|
"access": "public"
|
65
66
|
},
|
66
|
-
"gitHead": "
|
67
|
+
"gitHead": "5cbc87881ce9bd83f6e54312cf1f7911545b7a83"
|
67
68
|
}
|