@project-chip/matter-node.js-examples 0.11.0-alpha.0-20240909-b3b29745 → 0.11.0-alpha.0-20241006-eccb81ae1
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 +3 -271
- package/dist/esm/examples/BridgedDevicesNodeLegacy.js +14 -14
- package/dist/esm/examples/BridgedDevicesNodeLegacy.js.map +1 -2
- package/dist/esm/examples/ComposedDeviceNodeLegacy.js +15 -15
- package/dist/esm/examples/ComposedDeviceNodeLegacy.js.map +1 -2
- package/dist/esm/examples/ControllerNodeLegacy.js +22 -22
- package/dist/esm/examples/ControllerNodeLegacy.js.map +1 -2
- package/dist/esm/examples/DeviceNodeFullLegacy.js +16 -16
- package/dist/esm/examples/DeviceNodeFullLegacy.js.map +1 -2
- package/dist/esm/examples/LegacyStorageConverter.js +1 -2
- package/dist/esm/examples/LegacyStorageConverter.js.map +1 -2
- package/dist/esm/examples/MultiDeviceNodeLegacy.js +14 -14
- package/dist/esm/examples/MultiDeviceNodeLegacy.js.map +1 -2
- package/dist/esm/examples/cluster/DummyWifiNetworkCommissioningServerLegacy.js +16 -13
- package/dist/esm/examples/cluster/DummyWifiNetworkCommissioningServerLegacy.js.map +1 -2
- package/dist/esm/package.json +3 -0
- package/package.json +16 -36
- package/src/examples/BridgedDevicesNodeLegacy.ts +14 -14
- package/src/examples/ComposedDeviceNodeLegacy.ts +15 -15
- package/src/examples/ControllerNodeLegacy.ts +24 -24
- package/src/examples/DeviceNodeFullLegacy.ts +17 -17
- package/src/examples/LegacyStorageConverter.ts +2 -2
- package/src/examples/MultiDeviceNodeLegacy.ts +14 -14
- package/src/examples/cluster/DummyWifiNetworkCommissioningServerLegacy.ts +16 -13
- package/src/tsconfig.json +13 -13
- package/dist/esm/examples/BridgedDevicesNode.js +0 -145
- package/dist/esm/examples/BridgedDevicesNode.js.map +0 -7
- package/dist/esm/examples/ComposedDeviceNode.js +0 -124
- package/dist/esm/examples/ComposedDeviceNode.js.map +0 -7
- package/dist/esm/examples/ControllerNode.js +0 -197
- package/dist/esm/examples/ControllerNode.js.map +0 -7
- package/dist/esm/examples/DeviceNode.js +0 -128
- package/dist/esm/examples/DeviceNode.js.map +0 -7
- package/dist/esm/examples/DeviceNodeFull.js +0 -257
- package/dist/esm/examples/DeviceNodeFull.js.map +0 -7
- package/dist/esm/examples/IlluminatedRollerShade.js +0 -60
- package/dist/esm/examples/IlluminatedRollerShade.js.map +0 -7
- package/dist/esm/examples/LightDevice.js +0 -35
- package/dist/esm/examples/LightDevice.js.map +0 -7
- package/dist/esm/examples/MultiDeviceNode.js +0 -141
- package/dist/esm/examples/MultiDeviceNode.js.map +0 -7
- package/dist/esm/examples/SensorDeviceNode.js +0 -176
- package/dist/esm/examples/SensorDeviceNode.js.map +0 -7
- package/dist/esm/examples/cluster/DummyThreadNetworkCommissioningServer.js +0 -118
- package/dist/esm/examples/cluster/DummyThreadNetworkCommissioningServer.js.map +0 -7
- package/dist/esm/examples/cluster/DummyWifiNetworkCommissioningServer.js +0 -117
- package/dist/esm/examples/cluster/DummyWifiNetworkCommissioningServer.js.map +0 -7
- package/dist/esm/examples/cluster/MyFancyOwnFunctionality.js +0 -110
- package/dist/esm/examples/cluster/MyFancyOwnFunctionality.js.map +0 -7
- package/dist/esm/tutorial/example01.js +0 -5
- package/dist/esm/tutorial/example01.js.map +0 -7
- package/dist/esm/tutorial/example02.js +0 -7
- package/dist/esm/tutorial/example02.js.map +0 -7
- package/dist/esm/tutorial/example03.js +0 -15
- package/dist/esm/tutorial/example03.js.map +0 -7
- package/dist/esm/tutorial/example04.js +0 -10
- package/dist/esm/tutorial/example04.js.map +0 -7
- package/dist/esm/tutorial/example05.js +0 -14
- package/dist/esm/tutorial/example05.js.map +0 -7
- package/src/examples/BridgedDevicesNode.ts +0 -260
- package/src/examples/ComposedDeviceNode.ts +0 -197
- package/src/examples/ControllerNode.ts +0 -318
- package/src/examples/DeviceNode.ts +0 -202
- package/src/examples/DeviceNodeFull.ts +0 -445
- package/src/examples/IlluminatedRollerShade.ts +0 -96
- package/src/examples/LightDevice.ts +0 -61
- package/src/examples/MultiDeviceNode.ts +0 -209
- package/src/examples/SensorDeviceNode.ts +0 -248
- package/src/examples/cluster/DummyThreadNetworkCommissioningServer.ts +0 -153
- package/src/examples/cluster/DummyWifiNetworkCommissioningServer.ts +0 -150
- package/src/examples/cluster/MyFancyOwnFunctionality.ts +0 -185
- package/src/tutorial/example01.ts +0 -6
- package/src/tutorial/example02.ts +0 -9
- package/src/tutorial/example03.ts +0 -19
- package/src/tutorial/example04.ts +0 -13
- package/src/tutorial/example05.ts +0 -19
@@ -19,22 +19,22 @@
|
|
19
19
|
* Import needed modules from @project-chip/matter-node.js
|
20
20
|
*/
|
21
21
|
// Include this first to auto-register Crypto, Network and Time Node.js implementations
|
22
|
-
import { CommissioningServer, MatterServer } from "@project-chip/matter-node.js";
|
23
|
-
|
24
|
-
import { VendorId } from "@project-chip/matter-node.js/datatype";
|
25
|
-
import { Aggregator, DeviceTypes, OnOffLightDevice, OnOffPluginUnitDevice } from "@project-chip/matter-node.js/device";
|
26
|
-
import { Format, Level, Logger } from "@project-chip/matter-node.js/log";
|
27
|
-
import { QrCode } from "@project-chip/matter-node.js/schema";
|
28
22
|
import { StorageBackendDisk, StorageManager } from "@project-chip/matter-node.js/storage";
|
29
|
-
import { Time } from "@project-chip/matter-node.js/time";
|
30
23
|
import {
|
31
24
|
commandExecutor,
|
32
25
|
getIntParameter,
|
33
26
|
getParameter,
|
34
27
|
hasParameter,
|
35
28
|
requireMinNodeVersion,
|
29
|
+
Time,
|
36
30
|
} from "@project-chip/matter-node.js/util";
|
37
31
|
|
32
|
+
import { LogFormat, Logger, LogLevel } from "@project-chip/matter-node.js/log";
|
33
|
+
import { CommissioningServer, MatterServer } from "@project-chip/matter.js";
|
34
|
+
import { VendorId } from "@project-chip/matter.js/datatype";
|
35
|
+
import { Aggregator, DeviceTypes, OnOffLightDevice, OnOffPluginUnitDevice } from "@project-chip/matter.js/device";
|
36
|
+
import { QrCode } from "@project-chip/matter.js/schema";
|
37
|
+
|
38
38
|
const logger = Logger.get("Device");
|
39
39
|
|
40
40
|
requireMinNodeVersion(16);
|
@@ -42,28 +42,28 @@ requireMinNodeVersion(16);
|
|
42
42
|
/** Configure logging */
|
43
43
|
switch (getParameter("loglevel")) {
|
44
44
|
case "fatal":
|
45
|
-
Logger.defaultLogLevel =
|
45
|
+
Logger.defaultLogLevel = LogLevel.FATAL;
|
46
46
|
break;
|
47
47
|
case "error":
|
48
|
-
Logger.defaultLogLevel =
|
48
|
+
Logger.defaultLogLevel = LogLevel.ERROR;
|
49
49
|
break;
|
50
50
|
case "warn":
|
51
|
-
Logger.defaultLogLevel =
|
51
|
+
Logger.defaultLogLevel = LogLevel.WARN;
|
52
52
|
break;
|
53
53
|
case "info":
|
54
|
-
Logger.defaultLogLevel =
|
54
|
+
Logger.defaultLogLevel = LogLevel.INFO;
|
55
55
|
break;
|
56
56
|
}
|
57
57
|
|
58
58
|
switch (getParameter("logformat")) {
|
59
59
|
case "plain":
|
60
|
-
Logger.format =
|
60
|
+
Logger.format = LogFormat.PLAIN;
|
61
61
|
break;
|
62
62
|
case "html":
|
63
|
-
Logger.format =
|
63
|
+
Logger.format = LogFormat.HTML;
|
64
64
|
break;
|
65
65
|
default:
|
66
|
-
if (process.stdin?.isTTY) Logger.format =
|
66
|
+
if (process.stdin?.isTTY) Logger.format = LogFormat.ANSI;
|
67
67
|
}
|
68
68
|
|
69
69
|
const storageLocation = getParameter("store") ?? ".device-node";
|
@@ -21,22 +21,22 @@
|
|
21
21
|
* Import needed modules from @project-chip/matter-node.js
|
22
22
|
*/
|
23
23
|
// Include this first to auto-register Crypto, Network and Time Node.js implementations
|
24
|
-
import { CommissioningServer, MatterServer } from "@project-chip/matter-node.js";
|
25
|
-
|
26
|
-
import { VendorId } from "@project-chip/matter-node.js/datatype";
|
27
|
-
import { DeviceTypes, OnOffLightDevice, OnOffPluginUnitDevice } from "@project-chip/matter-node.js/device";
|
28
|
-
import { Format, Level, Logger } from "@project-chip/matter-node.js/log";
|
29
|
-
import { QrCode } from "@project-chip/matter-node.js/schema";
|
30
|
-
import { StorageBackendDisk, StorageManager } from "@project-chip/matter-node.js/storage";
|
31
|
-
import { Time } from "@project-chip/matter-node.js/time";
|
32
24
|
import {
|
33
25
|
commandExecutor,
|
34
26
|
getIntParameter,
|
35
27
|
getParameter,
|
36
28
|
hasParameter,
|
37
29
|
requireMinNodeVersion,
|
30
|
+
Time,
|
38
31
|
} from "@project-chip/matter-node.js/util";
|
39
32
|
|
33
|
+
import { LogFormat, Logger, LogLevel } from "@project-chip/matter-node.js/log";
|
34
|
+
import { StorageBackendDisk, StorageManager } from "@project-chip/matter-node.js/storage";
|
35
|
+
import { CommissioningServer, MatterServer } from "@project-chip/matter.js";
|
36
|
+
import { VendorId } from "@project-chip/matter.js/datatype";
|
37
|
+
import { DeviceTypes, OnOffLightDevice, OnOffPluginUnitDevice } from "@project-chip/matter.js/device";
|
38
|
+
import { QrCode } from "@project-chip/matter.js/schema";
|
39
|
+
|
40
40
|
const logger = Logger.get("Device");
|
41
41
|
|
42
42
|
requireMinNodeVersion(16);
|
@@ -44,28 +44,28 @@ requireMinNodeVersion(16);
|
|
44
44
|
/** Configure logging */
|
45
45
|
switch (getParameter("loglevel")) {
|
46
46
|
case "fatal":
|
47
|
-
Logger.defaultLogLevel =
|
47
|
+
Logger.defaultLogLevel = LogLevel.FATAL;
|
48
48
|
break;
|
49
49
|
case "error":
|
50
|
-
Logger.defaultLogLevel =
|
50
|
+
Logger.defaultLogLevel = LogLevel.ERROR;
|
51
51
|
break;
|
52
52
|
case "warn":
|
53
|
-
Logger.defaultLogLevel =
|
53
|
+
Logger.defaultLogLevel = LogLevel.WARN;
|
54
54
|
break;
|
55
55
|
case "info":
|
56
|
-
Logger.defaultLogLevel =
|
56
|
+
Logger.defaultLogLevel = LogLevel.INFO;
|
57
57
|
break;
|
58
58
|
}
|
59
59
|
|
60
60
|
switch (getParameter("logformat")) {
|
61
61
|
case "plain":
|
62
|
-
Logger.format =
|
62
|
+
Logger.format = LogFormat.PLAIN;
|
63
63
|
break;
|
64
64
|
case "html":
|
65
|
-
Logger.format =
|
65
|
+
Logger.format = LogFormat.HTML;
|
66
66
|
break;
|
67
67
|
default:
|
68
|
-
if (process.stdin?.isTTY) Logger.format =
|
68
|
+
if (process.stdin?.isTTY) Logger.format = LogFormat.ANSI;
|
69
69
|
}
|
70
70
|
|
71
71
|
const storageLocation = getParameter("store") ?? ".device-node";
|
@@ -15,22 +15,6 @@
|
|
15
15
|
* Import needed modules from @project-chip/matter-node.js
|
16
16
|
*/
|
17
17
|
// Include this first to auto-register Crypto, Network and Time Node.js implementations
|
18
|
-
import { CommissioningController, MatterServer, NodeCommissioningOptions } from "@project-chip/matter-node.js";
|
19
|
-
|
20
|
-
import { BleNode } from "@project-chip/matter-node-ble.js/ble";
|
21
|
-
import { Ble } from "@project-chip/matter-node.js/ble";
|
22
|
-
import {
|
23
|
-
BasicInformationCluster,
|
24
|
-
DescriptorCluster,
|
25
|
-
GeneralCommissioning,
|
26
|
-
OnOffCluster,
|
27
|
-
} from "@project-chip/matter-node.js/cluster";
|
28
|
-
import { NodeId } from "@project-chip/matter-node.js/datatype";
|
29
|
-
import { NodeStateInformation } from "@project-chip/matter-node.js/device";
|
30
|
-
import { Format, Level, Logger } from "@project-chip/matter-node.js/log";
|
31
|
-
import { CommissioningOptions } from "@project-chip/matter-node.js/protocol";
|
32
|
-
import { ManualPairingCodeCodec } from "@project-chip/matter-node.js/schema";
|
33
|
-
import { StorageBackendDisk, StorageManager } from "@project-chip/matter-node.js/storage";
|
34
18
|
import {
|
35
19
|
getIntParameter,
|
36
20
|
getParameter,
|
@@ -39,6 +23,22 @@ import {
|
|
39
23
|
singleton,
|
40
24
|
} from "@project-chip/matter-node.js/util";
|
41
25
|
|
26
|
+
import { NodeJsBle } from "@project-chip/matter-node-ble.js/ble";
|
27
|
+
import { LogFormat, LogLevel, Logger } from "@project-chip/matter-node.js/log";
|
28
|
+
import { StorageBackendDisk, StorageManager } from "@project-chip/matter-node.js/storage";
|
29
|
+
import { CommissioningController, MatterServer, NodeCommissioningOptions } from "@project-chip/matter.js";
|
30
|
+
import { Ble } from "@project-chip/matter.js/ble";
|
31
|
+
import {
|
32
|
+
BasicInformationCluster,
|
33
|
+
DescriptorCluster,
|
34
|
+
GeneralCommissioning,
|
35
|
+
OnOffCluster,
|
36
|
+
} from "@project-chip/matter.js/cluster";
|
37
|
+
import { NodeId } from "@project-chip/matter.js/datatype";
|
38
|
+
import { NodeStateInformation } from "@project-chip/matter.js/device";
|
39
|
+
import { CommissioningOptions } from "@project-chip/matter.js/protocol";
|
40
|
+
import { ManualPairingCodeCodec } from "@project-chip/matter.js/schema";
|
41
|
+
|
42
42
|
const logger = Logger.get("Controller");
|
43
43
|
|
44
44
|
requireMinNodeVersion(16);
|
@@ -46,35 +46,35 @@ requireMinNodeVersion(16);
|
|
46
46
|
/** Configure logging */
|
47
47
|
switch (getParameter("loglevel")) {
|
48
48
|
case "fatal":
|
49
|
-
Logger.defaultLogLevel =
|
49
|
+
Logger.defaultLogLevel = LogLevel.FATAL;
|
50
50
|
break;
|
51
51
|
case "error":
|
52
|
-
Logger.defaultLogLevel =
|
52
|
+
Logger.defaultLogLevel = LogLevel.ERROR;
|
53
53
|
break;
|
54
54
|
case "warn":
|
55
|
-
Logger.defaultLogLevel =
|
55
|
+
Logger.defaultLogLevel = LogLevel.WARN;
|
56
56
|
break;
|
57
57
|
case "info":
|
58
|
-
Logger.defaultLogLevel =
|
58
|
+
Logger.defaultLogLevel = LogLevel.INFO;
|
59
59
|
break;
|
60
60
|
}
|
61
61
|
|
62
62
|
switch (getParameter("logformat")) {
|
63
63
|
case "plain":
|
64
|
-
Logger.format =
|
64
|
+
Logger.format = LogFormat.PLAIN;
|
65
65
|
break;
|
66
66
|
case "html":
|
67
|
-
Logger.format =
|
67
|
+
Logger.format = LogFormat.HTML;
|
68
68
|
break;
|
69
69
|
default:
|
70
|
-
if (process.stdin?.isTTY) Logger.format =
|
70
|
+
if (process.stdin?.isTTY) Logger.format = LogFormat.ANSI;
|
71
71
|
}
|
72
72
|
|
73
73
|
if (hasParameter("ble")) {
|
74
74
|
// Initialize Ble
|
75
75
|
Ble.get = singleton(
|
76
76
|
() =>
|
77
|
-
new
|
77
|
+
new NodeJsBle({
|
78
78
|
hciId: getIntParameter("ble-hci-id"),
|
79
79
|
}),
|
80
80
|
);
|
@@ -19,16 +19,8 @@
|
|
19
19
|
* Import needed modules from @project-chip/matter-node.js
|
20
20
|
*/
|
21
21
|
// Include this first to auto-register Crypto, Network and Time Node.js implementations
|
22
|
-
import { CommissioningServer, MatterServer } from "@project-chip/matter-node.js";
|
23
|
-
|
24
|
-
import { BleNode } from "@project-chip/matter-node-ble.js/ble";
|
25
|
-
import { Ble } from "@project-chip/matter-node.js/ble";
|
26
|
-
import { OnOffLightDevice, OnOffPluginUnitDevice, logEndpoint } from "@project-chip/matter-node.js/device";
|
27
|
-
import { Format, Level, Logger } from "@project-chip/matter-node.js/log";
|
28
|
-
import { QrCode } from "@project-chip/matter-node.js/schema";
|
29
|
-
import { StorageBackendDisk, StorageManager } from "@project-chip/matter-node.js/storage";
|
30
|
-
import { Time } from "@project-chip/matter-node.js/time";
|
31
22
|
import {
|
23
|
+
Time,
|
32
24
|
commandExecutor,
|
33
25
|
getIntParameter,
|
34
26
|
getParameter,
|
@@ -36,7 +28,15 @@ import {
|
|
36
28
|
requireMinNodeVersion,
|
37
29
|
singleton,
|
38
30
|
} from "@project-chip/matter-node.js/util";
|
31
|
+
|
32
|
+
import { NodeJsBle } from "@project-chip/matter-node-ble.js/ble";
|
33
|
+
import { LogFormat, LogLevel, Logger } from "@project-chip/matter-node.js/log";
|
34
|
+
import { StorageBackendDisk, StorageManager } from "@project-chip/matter-node.js/storage";
|
35
|
+
import { CommissioningServer, MatterServer } from "@project-chip/matter.js";
|
36
|
+
import { Ble } from "@project-chip/matter.js/ble";
|
39
37
|
import { DeviceTypeId, VendorId } from "@project-chip/matter.js/datatype";
|
38
|
+
import { OnOffLightDevice, OnOffPluginUnitDevice, logEndpoint } from "@project-chip/matter.js/device";
|
39
|
+
import { QrCode } from "@project-chip/matter.js/schema";
|
40
40
|
import DummyWifiNetworkCommissioningClusterServer from "./cluster/DummyWifiNetworkCommissioningServerLegacy.js";
|
41
41
|
|
42
42
|
const logger = Logger.get("Device");
|
@@ -46,35 +46,35 @@ requireMinNodeVersion(16);
|
|
46
46
|
/** Configure logging */
|
47
47
|
switch (getParameter("loglevel")) {
|
48
48
|
case "fatal":
|
49
|
-
Logger.defaultLogLevel =
|
49
|
+
Logger.defaultLogLevel = LogLevel.FATAL;
|
50
50
|
break;
|
51
51
|
case "error":
|
52
|
-
Logger.defaultLogLevel =
|
52
|
+
Logger.defaultLogLevel = LogLevel.ERROR;
|
53
53
|
break;
|
54
54
|
case "warn":
|
55
|
-
Logger.defaultLogLevel =
|
55
|
+
Logger.defaultLogLevel = LogLevel.WARN;
|
56
56
|
break;
|
57
57
|
case "info":
|
58
|
-
Logger.defaultLogLevel =
|
58
|
+
Logger.defaultLogLevel = LogLevel.INFO;
|
59
59
|
break;
|
60
60
|
}
|
61
61
|
|
62
62
|
switch (getParameter("logformat")) {
|
63
63
|
case "plain":
|
64
|
-
Logger.format =
|
64
|
+
Logger.format = LogFormat.PLAIN;
|
65
65
|
break;
|
66
66
|
case "html":
|
67
|
-
Logger.format =
|
67
|
+
Logger.format = LogFormat.HTML;
|
68
68
|
break;
|
69
69
|
default:
|
70
|
-
if (process.stdin?.isTTY) Logger.format =
|
70
|
+
if (process.stdin?.isTTY) Logger.format = LogFormat.ANSI;
|
71
71
|
}
|
72
72
|
|
73
73
|
if (hasParameter("ble")) {
|
74
74
|
// Initialize Ble
|
75
75
|
Ble.get = singleton(
|
76
76
|
() =>
|
77
|
-
new
|
77
|
+
new NodeJsBle({
|
78
78
|
hciId: getIntParameter("ble-hci-id"),
|
79
79
|
}),
|
80
80
|
);
|
@@ -5,10 +5,10 @@
|
|
5
5
|
* SPDX-License-Identifier: Apache-2.0
|
6
6
|
*/
|
7
7
|
|
8
|
-
import "@project-chip/matter-node.js";
|
9
8
|
import { StorageBackendDisk } from "@project-chip/matter-node.js/storage";
|
9
|
+
|
10
|
+
import { Time } from "@project-chip/matter-node.js/util";
|
10
11
|
import { Environment, StorageService } from "@project-chip/matter.js/environment";
|
11
|
-
import { Time } from "@project-chip/matter.js/time";
|
12
12
|
import { LocalStorage } from "node-localstorage";
|
13
13
|
|
14
14
|
const environment = Environment.default;
|
@@ -21,21 +21,21 @@
|
|
21
21
|
* Import needed modules from @project-chip/matter-node.js
|
22
22
|
*/
|
23
23
|
// Include this first to auto-register Crypto, Network and Time Node.js implementations
|
24
|
-
import { CommissioningServer, MatterServer } from "@project-chip/matter-node.js";
|
25
|
-
|
26
|
-
import { DeviceTypes, OnOffLightDevice, OnOffPluginUnitDevice } from "@project-chip/matter-node.js/device";
|
27
|
-
import { Format, Level, Logger } from "@project-chip/matter-node.js/log";
|
28
|
-
import { QrCode } from "@project-chip/matter-node.js/schema";
|
29
|
-
import { StorageBackendDisk, StorageManager } from "@project-chip/matter-node.js/storage";
|
30
|
-
import { Time } from "@project-chip/matter-node.js/time";
|
31
24
|
import {
|
32
25
|
commandExecutor,
|
33
26
|
getIntParameter,
|
34
27
|
getParameter,
|
35
28
|
hasParameter,
|
36
29
|
requireMinNodeVersion,
|
30
|
+
Time,
|
37
31
|
} from "@project-chip/matter-node.js/util";
|
32
|
+
|
33
|
+
import { LogFormat, Logger, LogLevel } from "@project-chip/matter-node.js/log";
|
34
|
+
import { StorageBackendDisk, StorageManager } from "@project-chip/matter-node.js/storage";
|
35
|
+
import { CommissioningServer, MatterServer } from "@project-chip/matter.js";
|
38
36
|
import { VendorId } from "@project-chip/matter.js/datatype";
|
37
|
+
import { DeviceTypes, OnOffLightDevice, OnOffPluginUnitDevice } from "@project-chip/matter.js/device";
|
38
|
+
import { QrCode } from "@project-chip/matter.js/schema";
|
39
39
|
|
40
40
|
const logger = Logger.get("MultiDevice");
|
41
41
|
|
@@ -44,28 +44,28 @@ requireMinNodeVersion(16);
|
|
44
44
|
/** Configure logging */
|
45
45
|
switch (getParameter("loglevel")) {
|
46
46
|
case "fatal":
|
47
|
-
Logger.defaultLogLevel =
|
47
|
+
Logger.defaultLogLevel = LogLevel.FATAL;
|
48
48
|
break;
|
49
49
|
case "error":
|
50
|
-
Logger.defaultLogLevel =
|
50
|
+
Logger.defaultLogLevel = LogLevel.ERROR;
|
51
51
|
break;
|
52
52
|
case "warn":
|
53
|
-
Logger.defaultLogLevel =
|
53
|
+
Logger.defaultLogLevel = LogLevel.WARN;
|
54
54
|
break;
|
55
55
|
case "info":
|
56
|
-
Logger.defaultLogLevel =
|
56
|
+
Logger.defaultLogLevel = LogLevel.INFO;
|
57
57
|
break;
|
58
58
|
}
|
59
59
|
|
60
60
|
switch (getParameter("logformat")) {
|
61
61
|
case "plain":
|
62
|
-
Logger.format =
|
62
|
+
Logger.format = LogFormat.PLAIN;
|
63
63
|
break;
|
64
64
|
case "html":
|
65
|
-
Logger.format =
|
65
|
+
Logger.format = LogFormat.HTML;
|
66
66
|
break;
|
67
67
|
default:
|
68
|
-
if (process.stdin?.isTTY) Logger.format =
|
68
|
+
if (process.stdin?.isTTY) Logger.format = LogFormat.ANSI;
|
69
69
|
}
|
70
70
|
|
71
71
|
const storageLocation = getParameter("store") ?? ".device-node";
|
@@ -5,15 +5,16 @@
|
|
5
5
|
*/
|
6
6
|
|
7
7
|
import { getParameter } from "@project-chip/matter-node.js/util";
|
8
|
+
import { MatterDevice } from "@project-chip/matter.js";
|
8
9
|
import {
|
9
10
|
ClusterServer,
|
10
11
|
ClusterServerObj,
|
11
12
|
GeneralCommissioningCluster,
|
12
13
|
NetworkCommissioning,
|
13
14
|
} from "@project-chip/matter.js/cluster";
|
14
|
-
import {
|
15
|
+
import { Bytes } from "@project-chip/matter.js/util";
|
15
16
|
|
16
|
-
const firstNetworkId = new
|
17
|
+
const firstNetworkId = new Uint8Array(32);
|
17
18
|
|
18
19
|
const WifiNetworkCluster = NetworkCommissioning.Cluster.with(NetworkCommissioning.Feature.WiFiNetworkInterface);
|
19
20
|
|
@@ -37,7 +38,9 @@ const Server: ClusterServerObj<typeof WifiNetworkCluster> = ClusterServer(
|
|
37
38
|
},
|
38
39
|
{
|
39
40
|
scanNetworks: async ({ request: { ssid, breadcrumb }, attributes: { lastNetworkingStatus }, endpoint }) => {
|
40
|
-
console.log(
|
41
|
+
console.log(
|
42
|
+
`---> scanNetworks called on NetworkCommissioning cluster: ${ssid ? Bytes.toHex(ssid) : undefined} ${breadcrumb}`,
|
43
|
+
);
|
41
44
|
|
42
45
|
// Simulate successful scan
|
43
46
|
if (breadcrumb !== undefined) {
|
@@ -59,8 +62,8 @@ const Server: ClusterServerObj<typeof WifiNetworkCluster> = ClusterServer(
|
|
59
62
|
wpa2Personal: true,
|
60
63
|
wpa3Personal: true,
|
61
64
|
},
|
62
|
-
ssid: ssid ||
|
63
|
-
bssid:
|
65
|
+
ssid: ssid || Bytes.fromString(getParameter("ble-wifi-scan-ssid") ?? "TestSSID"), // Set a valid existing local Wi-Fi SSID here
|
66
|
+
bssid: Bytes.fromString(getParameter("ble-wifi-scan-bssid") ?? "00:00:00:00:00:00"),
|
64
67
|
channel: 1,
|
65
68
|
},
|
66
69
|
],
|
@@ -73,10 +76,10 @@ const Server: ClusterServerObj<typeof WifiNetworkCluster> = ClusterServer(
|
|
73
76
|
session,
|
74
77
|
}) => {
|
75
78
|
console.log(
|
76
|
-
`---> addOrUpdateWiFiNetwork called on NetworkCommissioning cluster: ${
|
79
|
+
`---> addOrUpdateWiFiNetwork called on NetworkCommissioning cluster: ${Bytes.toHex(ssid)} ${Bytes.toHex(credentials)} ${breadcrumb}`,
|
77
80
|
);
|
78
81
|
|
79
|
-
session.
|
82
|
+
MatterDevice.of(session).assertFailSafeArmed("Failsafe timer needs to be armed to add or update networks.");
|
80
83
|
|
81
84
|
// Simulate successful add or update
|
82
85
|
if (breadcrumb !== undefined) {
|
@@ -100,10 +103,10 @@ const Server: ClusterServerObj<typeof WifiNetworkCluster> = ClusterServer(
|
|
100
103
|
session,
|
101
104
|
}) => {
|
102
105
|
console.log(
|
103
|
-
`---> removeNetwork called on NetworkCommissioning cluster: ${
|
106
|
+
`---> removeNetwork called on NetworkCommissioning cluster: ${Bytes.toHex(networkId)} ${breadcrumb}`,
|
104
107
|
);
|
105
108
|
|
106
|
-
session.
|
109
|
+
MatterDevice.of(session).assertFailSafeArmed("Failsafe timer needs to be armed to add or update networks.");
|
107
110
|
|
108
111
|
// Simulate successful add or update
|
109
112
|
if (breadcrumb !== undefined) {
|
@@ -127,10 +130,10 @@ const Server: ClusterServerObj<typeof WifiNetworkCluster> = ClusterServer(
|
|
127
130
|
session,
|
128
131
|
}) => {
|
129
132
|
console.log(
|
130
|
-
`---> connectNetwork called on NetworkCommissioning cluster: ${
|
133
|
+
`---> connectNetwork called on NetworkCommissioning cluster: ${Bytes.toHex(networkId)} ${breadcrumb}`,
|
131
134
|
);
|
132
135
|
|
133
|
-
session.
|
136
|
+
MatterDevice.of(session).assertFailSafeArmed("Failsafe timer needs to be armed to add or update networks.");
|
134
137
|
|
135
138
|
// Simulate successful connection
|
136
139
|
if (breadcrumb !== undefined) {
|
@@ -148,7 +151,7 @@ const Server: ClusterServerObj<typeof WifiNetworkCluster> = ClusterServer(
|
|
148
151
|
lastConnectErrorValue?.setLocal(null);
|
149
152
|
|
150
153
|
// Announce operational in IP network
|
151
|
-
const device = session
|
154
|
+
const device = MatterDevice.of(session);
|
152
155
|
await device.startAnnouncement();
|
153
156
|
|
154
157
|
return {
|
@@ -162,7 +165,7 @@ const Server: ClusterServerObj<typeof WifiNetworkCluster> = ClusterServer(
|
|
162
165
|
endpoint,
|
163
166
|
}) => {
|
164
167
|
console.log(
|
165
|
-
`---> reorderNetwork called on NetworkCommissioning cluster: ${
|
168
|
+
`---> reorderNetwork called on NetworkCommissioning cluster: ${Bytes.toHex(networkId)} ${networkIndex} ${breadcrumb}`,
|
166
169
|
);
|
167
170
|
|
168
171
|
// Simulate successful connection
|
package/src/tsconfig.json
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
{
|
2
|
-
"extends": "
|
2
|
+
"extends": "../../../packages/tools/tsc/tsconfig.app.json",
|
3
3
|
"compilerOptions": {
|
4
|
-
"
|
5
|
-
|
6
|
-
|
7
|
-
// See https://github.com/microsoft/TypeScript/issues/47663#issuecomment-1519138189
|
8
|
-
// r.e. error TS2742
|
9
|
-
// Probably referencing matter.js project directly would also solve but there's no reason for us to emit
|
10
|
-
// declarations anyway
|
11
|
-
"declaration": false,
|
12
|
-
"composite": false,
|
13
|
-
"declarationMap": false,
|
4
|
+
"types": [
|
5
|
+
"node"
|
6
|
+
]
|
14
7
|
},
|
15
|
-
"references": [
|
16
|
-
|
8
|
+
"references": [
|
9
|
+
{
|
10
|
+
"path": "../../matter-node-ble.js/src"
|
11
|
+
},
|
12
|
+
{
|
13
|
+
"path": "../../../packages/matter.js/src"
|
14
|
+
}
|
15
|
+
]
|
16
|
+
}
|
@@ -1,145 +0,0 @@
|
|
1
|
-
#!/usr/bin/env node
|
2
|
-
/**
|
3
|
-
* @license
|
4
|
-
* Copyright 2022-2024 Matter.js Authors
|
5
|
-
* SPDX-License-Identifier: Apache-2.0
|
6
|
-
*/
|
7
|
-
import "@project-chip/matter-node.js";
|
8
|
-
import { requireMinNodeVersion } from "@project-chip/matter-node.js/util";
|
9
|
-
import { BridgedDeviceBasicInformationServer } from "@project-chip/matter.js/behavior/definitions/bridged-device-basic-information";
|
10
|
-
import { VendorId } from "@project-chip/matter.js/datatype";
|
11
|
-
import { logEndpoint } from "@project-chip/matter.js/device";
|
12
|
-
import { OnOffLightDevice } from "@project-chip/matter.js/devices/OnOffLightDevice";
|
13
|
-
import { OnOffPlugInUnitDevice } from "@project-chip/matter.js/devices/OnOffPlugInUnitDevice";
|
14
|
-
import { Endpoint, EndpointServer } from "@project-chip/matter.js/endpoint";
|
15
|
-
import { AggregatorEndpoint } from "@project-chip/matter.js/endpoints/AggregatorEndpoint";
|
16
|
-
import { Environment, StorageService } from "@project-chip/matter.js/environment";
|
17
|
-
import { ServerNode } from "@project-chip/matter.js/node";
|
18
|
-
import { Time } from "@project-chip/matter.js/time";
|
19
|
-
import { execSync } from "child_process";
|
20
|
-
requireMinNodeVersion(16);
|
21
|
-
const { isSocket, deviceName, vendorName, passcode, discriminator, vendorId, productName, productId, port, uniqueId } = await getConfiguration();
|
22
|
-
const server = await ServerNode.create({
|
23
|
-
// Required: Give the Node a unique ID which is used to store the state of this node
|
24
|
-
id: uniqueId,
|
25
|
-
// Provide Network relevant configuration like the port
|
26
|
-
// Optional when operating only one device on a host, Default port is 5540
|
27
|
-
network: {
|
28
|
-
port
|
29
|
-
},
|
30
|
-
// Provide Commissioning relevant settings
|
31
|
-
// Optional for development/testing purposes
|
32
|
-
commissioning: {
|
33
|
-
passcode,
|
34
|
-
discriminator
|
35
|
-
},
|
36
|
-
// Provide Node announcement settings
|
37
|
-
// Optional: If Ommitted some development defaults are used
|
38
|
-
productDescription: {
|
39
|
-
name: deviceName,
|
40
|
-
deviceType: AggregatorEndpoint.deviceType
|
41
|
-
},
|
42
|
-
// Provide defaults for the BasicInformation cluster on the Root endpoint
|
43
|
-
// Optional: If Omitted some development defaults are used
|
44
|
-
basicInformation: {
|
45
|
-
vendorName,
|
46
|
-
vendorId: VendorId(vendorId),
|
47
|
-
nodeLabel: productName,
|
48
|
-
productName,
|
49
|
-
productLabel: productName,
|
50
|
-
productId,
|
51
|
-
serialNumber: `matterjs-${uniqueId}`,
|
52
|
-
uniqueId
|
53
|
-
}
|
54
|
-
});
|
55
|
-
const aggregator = new Endpoint(AggregatorEndpoint, { id: "aggregator" });
|
56
|
-
await server.add(aggregator);
|
57
|
-
for (let idx = 0; idx < isSocket.length; idx++) {
|
58
|
-
const i = idx + 1;
|
59
|
-
const isASocket = isSocket[idx];
|
60
|
-
const name = `OnOff ${isASocket ? "Socket" : "Light"} ${i}`;
|
61
|
-
const endpoint = new Endpoint(
|
62
|
-
isASocket ? (
|
63
|
-
// For a Bridged Device we need to add a BridgedDeviceBasicInformation cluster as server
|
64
|
-
OnOffPlugInUnitDevice.with(BridgedDeviceBasicInformationServer)
|
65
|
-
) : OnOffLightDevice.with(BridgedDeviceBasicInformationServer),
|
66
|
-
{
|
67
|
-
id: `onoff-${i}`,
|
68
|
-
bridgedDeviceBasicInformation: {
|
69
|
-
nodeLabel: name,
|
70
|
-
// Main end user name for the device
|
71
|
-
productName: name,
|
72
|
-
productLabel: name,
|
73
|
-
serialNumber: `node-matter-${uniqueId}-${i}`,
|
74
|
-
reachable: true
|
75
|
-
}
|
76
|
-
}
|
77
|
-
);
|
78
|
-
await aggregator.add(endpoint);
|
79
|
-
endpoint.events.identify.startIdentifying.on(() => {
|
80
|
-
console.log(`Run identify logic for ${name}, ideally blink a light every 0.5s ...`);
|
81
|
-
});
|
82
|
-
endpoint.events.identify.stopIdentifying.on(() => {
|
83
|
-
console.log(`Stop identify logic for ${name} ...`);
|
84
|
-
});
|
85
|
-
endpoint.events.onOff.onOff$Changed.on((value) => {
|
86
|
-
executeCommand(value ? `on${i}` : `off${i}`);
|
87
|
-
console.log(`${name} is now ${value ? "ON" : "OFF"}`);
|
88
|
-
});
|
89
|
-
}
|
90
|
-
await server.start();
|
91
|
-
logEndpoint(EndpointServer.forEndpoint(server));
|
92
|
-
function executeCommand(scriptParamName) {
|
93
|
-
const script = Environment.default.vars.string(scriptParamName);
|
94
|
-
if (script === void 0) return void 0;
|
95
|
-
console.log(`${scriptParamName}: ${execSync(script).toString().slice(0, -1)}`);
|
96
|
-
}
|
97
|
-
async function getConfiguration() {
|
98
|
-
const environment = Environment.default;
|
99
|
-
const storageService = environment.get(StorageService);
|
100
|
-
console.log(`Storage location: ${storageService.location} (Directory)`);
|
101
|
-
console.log(
|
102
|
-
'Use the parameter "--storage-path=NAME-OR-PATH" to specify a different storage location in this directory, use --storage-clear to start with an empty storage.'
|
103
|
-
);
|
104
|
-
const deviceStorage = (await storageService.open("device")).createContext("data");
|
105
|
-
const isSocket2 = Array();
|
106
|
-
const numDevices = environment.vars.number("num") || 2;
|
107
|
-
if (await deviceStorage.has("isSocket")) {
|
108
|
-
console.log(`Device types found in storage. --type parameter is ignored.`);
|
109
|
-
(await deviceStorage.get("isSocket")).forEach((type) => isSocket2.push(type));
|
110
|
-
}
|
111
|
-
for (let i = 1; i <= numDevices; i++) {
|
112
|
-
if (isSocket2[i - 1] !== void 0) continue;
|
113
|
-
isSocket2.push(environment.vars.string(`type${i}`) === "socket");
|
114
|
-
}
|
115
|
-
const deviceName2 = "Matter test device";
|
116
|
-
const vendorName2 = "matter-node.js";
|
117
|
-
const passcode2 = environment.vars.number("passcode") ?? await deviceStorage.get("passcode", 20202021);
|
118
|
-
const discriminator2 = environment.vars.number("discriminator") ?? await deviceStorage.get("discriminator", 3840);
|
119
|
-
const vendorId2 = environment.vars.number("vendorid") ?? await deviceStorage.get("vendorid", 65521);
|
120
|
-
const productName2 = `node-matter OnOff ${isSocket2 ? "Socket" : "Light"}`;
|
121
|
-
const productId2 = environment.vars.number("productid") ?? await deviceStorage.get("productid", 32768);
|
122
|
-
const port2 = environment.vars.number("port") ?? 5540;
|
123
|
-
const uniqueId2 = environment.vars.string("uniqueid") ?? await deviceStorage.get("uniqueid", Time.nowMs().toString());
|
124
|
-
await deviceStorage.set({
|
125
|
-
passcode: passcode2,
|
126
|
-
discriminator: discriminator2,
|
127
|
-
vendorid: vendorId2,
|
128
|
-
productid: productId2,
|
129
|
-
isSocket: isSocket2,
|
130
|
-
uniqueid: uniqueId2
|
131
|
-
});
|
132
|
-
return {
|
133
|
-
isSocket: isSocket2,
|
134
|
-
deviceName: deviceName2,
|
135
|
-
vendorName: vendorName2,
|
136
|
-
passcode: passcode2,
|
137
|
-
discriminator: discriminator2,
|
138
|
-
vendorId: vendorId2,
|
139
|
-
productName: productName2,
|
140
|
-
productId: productId2,
|
141
|
-
port: port2,
|
142
|
-
uniqueId: uniqueId2
|
143
|
-
};
|
144
|
-
}
|
145
|
-
//# sourceMappingURL=BridgedDevicesNode.js.map
|