@project-chip/matter-node.js-examples 0.10.1 → 0.11.0-alpha.0-20240911-db8f7c80

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. package/dist/esm/examples/BridgedDevicesNode.js +2 -3
  2. package/dist/esm/examples/BridgedDevicesNode.js.map +2 -2
  3. package/dist/esm/examples/BridgedDevicesNodeLegacy.js +14 -15
  4. package/dist/esm/examples/BridgedDevicesNodeLegacy.js.map +2 -2
  5. package/dist/esm/examples/ComposedDeviceNode.js +2 -3
  6. package/dist/esm/examples/ComposedDeviceNode.js.map +2 -2
  7. package/dist/esm/examples/ComposedDeviceNodeLegacy.js +15 -16
  8. package/dist/esm/examples/ComposedDeviceNodeLegacy.js.map +2 -2
  9. package/dist/esm/examples/ControllerNode.js +2 -5
  10. package/dist/esm/examples/ControllerNode.js.map +2 -2
  11. package/dist/esm/examples/ControllerNodeLegacy.js +21 -22
  12. package/dist/esm/examples/ControllerNodeLegacy.js.map +2 -2
  13. package/dist/esm/examples/DeviceNode.js +2 -3
  14. package/dist/esm/examples/DeviceNode.js.map +2 -2
  15. package/dist/esm/examples/DeviceNodeFull.js +4 -8
  16. package/dist/esm/examples/DeviceNodeFull.js.map +2 -2
  17. package/dist/esm/examples/DeviceNodeFullLegacy.js +16 -18
  18. package/dist/esm/examples/DeviceNodeFullLegacy.js.map +2 -2
  19. package/dist/esm/examples/IlluminatedRollerShade.js +1 -1
  20. package/dist/esm/examples/IlluminatedRollerShade.js.map +1 -1
  21. package/dist/esm/examples/LegacyStorageConverter.js +2 -3
  22. package/dist/esm/examples/LegacyStorageConverter.js.map +2 -2
  23. package/dist/esm/examples/LightDevice.js +1 -1
  24. package/dist/esm/examples/LightDevice.js.map +1 -1
  25. package/dist/esm/examples/MultiDeviceNode.js +2 -3
  26. package/dist/esm/examples/MultiDeviceNode.js.map +2 -2
  27. package/dist/esm/examples/MultiDeviceNodeLegacy.js +13 -14
  28. package/dist/esm/examples/MultiDeviceNodeLegacy.js.map +2 -2
  29. package/dist/esm/examples/SensorDeviceNode.js +2 -3
  30. package/dist/esm/examples/SensorDeviceNode.js.map +2 -2
  31. package/dist/esm/examples/cluster/DummyThreadNetworkCommissioningServer.js +11 -8
  32. package/dist/esm/examples/cluster/DummyThreadNetworkCommissioningServer.js.map +2 -2
  33. package/dist/esm/examples/cluster/DummyWifiNetworkCommissioningServer.js +15 -11
  34. package/dist/esm/examples/cluster/DummyWifiNetworkCommissioningServer.js.map +2 -2
  35. package/dist/esm/examples/cluster/DummyWifiNetworkCommissioningServerLegacy.js +12 -10
  36. package/dist/esm/examples/cluster/DummyWifiNetworkCommissioningServerLegacy.js.map +2 -2
  37. package/dist/esm/examples/cluster/MyFancyOwnFunctionality.js +8 -8
  38. package/dist/esm/examples/cluster/MyFancyOwnFunctionality.js.map +2 -2
  39. package/dist/esm/tutorial/example01.js +1 -1
  40. package/dist/esm/tutorial/example01.js.map +1 -1
  41. package/dist/esm/tutorial/example02.js +1 -1
  42. package/dist/esm/tutorial/example02.js.map +1 -1
  43. package/dist/esm/tutorial/example03.js +1 -1
  44. package/dist/esm/tutorial/example03.js.map +1 -1
  45. package/dist/esm/tutorial/example04.js +1 -1
  46. package/dist/esm/tutorial/example04.js.map +1 -1
  47. package/dist/esm/tutorial/example05.js +1 -1
  48. package/dist/esm/tutorial/example05.js.map +1 -1
  49. package/package.json +8 -8
  50. package/src/examples/BridgedDevicesNode.ts +2 -3
  51. package/src/examples/BridgedDevicesNodeLegacy.ts +15 -16
  52. package/src/examples/ComposedDeviceNode.ts +2 -3
  53. package/src/examples/ComposedDeviceNodeLegacy.ts +15 -16
  54. package/src/examples/ControllerNode.ts +2 -6
  55. package/src/examples/ControllerNodeLegacy.ts +22 -23
  56. package/src/examples/DeviceNode.ts +2 -3
  57. package/src/examples/DeviceNodeFull.ts +5 -10
  58. package/src/examples/DeviceNodeFullLegacy.ts +16 -18
  59. package/src/examples/IlluminatedRollerShade.ts +1 -1
  60. package/src/examples/LegacyStorageConverter.ts +3 -3
  61. package/src/examples/LightDevice.ts +1 -1
  62. package/src/examples/MultiDeviceNode.ts +2 -3
  63. package/src/examples/MultiDeviceNodeLegacy.ts +15 -15
  64. package/src/examples/SensorDeviceNode.ts +2 -3
  65. package/src/examples/cluster/DummyThreadNetworkCommissioningServer.ts +11 -8
  66. package/src/examples/cluster/DummyWifiNetworkCommissioningServer.ts +15 -11
  67. package/src/examples/cluster/DummyWifiNetworkCommissioningServerLegacy.ts +12 -10
  68. package/src/examples/cluster/MyFancyOwnFunctionality.ts +9 -9
  69. package/src/tsconfig.json +1 -1
  70. package/src/tutorial/example01.ts +1 -1
  71. package/src/tutorial/example02.ts +1 -1
  72. package/src/tutorial/example03.ts +1 -1
  73. package/src/tutorial/example04.ts +1 -1
  74. package/src/tutorial/example05.ts +1 -1
@@ -4,12 +4,12 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
+ import { Bytes } from "@project-chip/matter.js-general";
7
8
  import { GeneralCommissioningBehavior } from "@project-chip/matter.js/behavior/definitions/general-commissioning";
8
9
  import { NetworkCommissioningBehavior } from "@project-chip/matter.js/behavior/definitions/network-commissioning";
9
10
  import { NetworkCommissioning } from "@project-chip/matter.js/cluster";
10
- import { ByteArray } from "@project-chip/matter.js/util";
11
11
 
12
- const firstNetworkId = new ByteArray(32);
12
+ const firstNetworkId = new Uint8Array(32);
13
13
 
14
14
  /**
15
15
  * This represents a Dummy version of a Wifi Network Commissioning Cluster Server without real Wifi related logic, beside
@@ -20,7 +20,9 @@ export class DummyWifiNetworkCommissioningServer extends NetworkCommissioningBeh
20
20
  NetworkCommissioning.Feature.WiFiNetworkInterface,
21
21
  ) {
22
22
  override scanNetworks({ ssid, breadcrumb }: NetworkCommissioning.ScanNetworksRequest) {
23
- console.log(`---> scanNetworks called on NetworkCommissioning cluster: ${ssid?.toHex()} ${breadcrumb}`);
23
+ console.log(
24
+ `---> scanNetworks called on NetworkCommissioning cluster: ${ssid ? Bytes.toHex(ssid) : undefined} ${breadcrumb}`,
25
+ );
24
26
 
25
27
  // Simulate successful scan
26
28
  if (breadcrumb !== undefined) {
@@ -42,10 +44,8 @@ export class DummyWifiNetworkCommissioningServer extends NetworkCommissioningBeh
42
44
  wpa2Personal: true,
43
45
  wpa3Personal: true,
44
46
  },
45
- ssid: ssid || ByteArray.fromString(this.endpoint.env.vars.get("ble.wifi.scanSsid") ?? "TestSSID"), // Set a valid existing local Wi-Fi SSID here
46
- bssid: ByteArray.fromString(
47
- this.endpoint.env.vars.get("ble.wifi.scanBssid") ?? "00:00:00:00:00:00",
48
- ),
47
+ ssid: ssid || Bytes.fromString(this.endpoint.env.vars.get("ble.wifi.scanSsid") ?? "TestSSID"), // Set a valid existing local Wi-Fi SSID here
48
+ bssid: Bytes.fromString(this.endpoint.env.vars.get("ble.wifi.scanBssid") ?? "00:00:00:00:00:00"),
49
49
  channel: 1,
50
50
  },
51
51
  ],
@@ -58,7 +58,7 @@ export class DummyWifiNetworkCommissioningServer extends NetworkCommissioningBeh
58
58
  breadcrumb,
59
59
  }: NetworkCommissioning.AddOrUpdateWiFiNetworkRequest) {
60
60
  console.log(
61
- `---> addOrUpdateWiFiNetwork called on NetworkCommissioning cluster: ${ssid.toHex()} ${credentials.toHex()} ${breadcrumb}`,
61
+ `---> addOrUpdateWiFiNetwork called on NetworkCommissioning cluster: ${Bytes.toHex(ssid)} ${Bytes.toHex(credentials)} ${breadcrumb}`,
62
62
  );
63
63
 
64
64
  this.session.context.assertFailSafeArmed("Failsafe timer needs to be armed to add or update networks.");
@@ -80,7 +80,9 @@ export class DummyWifiNetworkCommissioningServer extends NetworkCommissioningBeh
80
80
  }
81
81
 
82
82
  override removeNetwork({ networkId, breadcrumb }: NetworkCommissioning.RemoveNetworkRequest) {
83
- console.log(`---> removeNetwork called on NetworkCommissioning cluster: ${networkId.toHex()} ${breadcrumb}`);
83
+ console.log(
84
+ `---> removeNetwork called on NetworkCommissioning cluster: ${Bytes.toHex(networkId)} ${breadcrumb}`,
85
+ );
84
86
 
85
87
  this.session.context.assertFailSafeArmed("Failsafe timer needs to be armed to add or update networks.");
86
88
 
@@ -101,7 +103,9 @@ export class DummyWifiNetworkCommissioningServer extends NetworkCommissioningBeh
101
103
  }
102
104
 
103
105
  override async connectNetwork({ networkId, breadcrumb }: NetworkCommissioning.ConnectNetworkRequest) {
104
- console.log(`---> connectNetwork called on NetworkCommissioning cluster: ${networkId.toHex()} ${breadcrumb}`);
106
+ console.log(
107
+ `---> connectNetwork called on NetworkCommissioning cluster: ${Bytes.toHex(networkId)} ${breadcrumb}`,
108
+ );
105
109
 
106
110
  this.session.context.assertFailSafeArmed("Failsafe timer needs to be armed to add or update networks.");
107
111
 
@@ -130,7 +134,7 @@ export class DummyWifiNetworkCommissioningServer extends NetworkCommissioningBeh
130
134
 
131
135
  override reorderNetwork({ networkId, networkIndex, breadcrumb }: NetworkCommissioning.ReorderNetworkRequest) {
132
136
  console.log(
133
- `---> reorderNetwork called on NetworkCommissioning cluster: ${networkId.toHex()} ${networkIndex} ${breadcrumb}`,
137
+ `---> reorderNetwork called on NetworkCommissioning cluster: ${Bytes.toHex(networkId)} ${networkIndex} ${breadcrumb}`,
134
138
  );
135
139
 
136
140
  // Simulate successful connection
@@ -4,16 +4,16 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
- import { getParameter } from "@project-chip/matter-node.js/util";
7
+ import { getParameter } from "@project-chip/matter.js-nodejs";
8
8
  import {
9
9
  ClusterServer,
10
10
  ClusterServerObj,
11
11
  GeneralCommissioningCluster,
12
12
  NetworkCommissioning,
13
13
  } from "@project-chip/matter.js/cluster";
14
- import { ByteArray } from "@project-chip/matter.js/util";
14
+ import { Bytes } from "../../../../general/dist/cjs/index.js";
15
15
 
16
- const firstNetworkId = new ByteArray(32);
16
+ const firstNetworkId = new Uint8Array(32);
17
17
 
18
18
  const WifiNetworkCluster = NetworkCommissioning.Cluster.with(NetworkCommissioning.Feature.WiFiNetworkInterface);
19
19
 
@@ -37,7 +37,9 @@ const Server: ClusterServerObj<typeof WifiNetworkCluster> = ClusterServer(
37
37
  },
38
38
  {
39
39
  scanNetworks: async ({ request: { ssid, breadcrumb }, attributes: { lastNetworkingStatus }, endpoint }) => {
40
- console.log(`---> scanNetworks called on NetworkCommissioning cluster: ${ssid?.toHex()} ${breadcrumb}`);
40
+ console.log(
41
+ `---> scanNetworks called on NetworkCommissioning cluster: ${ssid ? Bytes.toHex(ssid) : undefined} ${breadcrumb}`,
42
+ );
41
43
 
42
44
  // Simulate successful scan
43
45
  if (breadcrumb !== undefined) {
@@ -59,8 +61,8 @@ const Server: ClusterServerObj<typeof WifiNetworkCluster> = ClusterServer(
59
61
  wpa2Personal: true,
60
62
  wpa3Personal: true,
61
63
  },
62
- ssid: ssid || ByteArray.fromString(getParameter("ble-wifi-scan-ssid") ?? "TestSSID"), // Set a valid existing local Wi-Fi SSID here
63
- bssid: ByteArray.fromString(getParameter("ble-wifi-scan-bssid") ?? "00:00:00:00:00:00"),
64
+ ssid: ssid || Bytes.fromString(getParameter("ble-wifi-scan-ssid") ?? "TestSSID"), // Set a valid existing local Wi-Fi SSID here
65
+ bssid: Bytes.fromString(getParameter("ble-wifi-scan-bssid") ?? "00:00:00:00:00:00"),
64
66
  channel: 1,
65
67
  },
66
68
  ],
@@ -73,7 +75,7 @@ const Server: ClusterServerObj<typeof WifiNetworkCluster> = ClusterServer(
73
75
  session,
74
76
  }) => {
75
77
  console.log(
76
- `---> addOrUpdateWiFiNetwork called on NetworkCommissioning cluster: ${ssid.toHex()} ${credentials.toHex()} ${breadcrumb}`,
78
+ `---> addOrUpdateWiFiNetwork called on NetworkCommissioning cluster: ${Bytes.toHex(ssid)} ${Bytes.toHex(credentials)} ${breadcrumb}`,
77
79
  );
78
80
 
79
81
  session.context.assertFailSafeArmed("Failsafe timer needs to be armed to add or update networks.");
@@ -100,7 +102,7 @@ const Server: ClusterServerObj<typeof WifiNetworkCluster> = ClusterServer(
100
102
  session,
101
103
  }) => {
102
104
  console.log(
103
- `---> removeNetwork called on NetworkCommissioning cluster: ${networkId.toHex()} ${breadcrumb}`,
105
+ `---> removeNetwork called on NetworkCommissioning cluster: ${Bytes.toHex(networkId)} ${breadcrumb}`,
104
106
  );
105
107
 
106
108
  session.context.assertFailSafeArmed("Failsafe timer needs to be armed to add or update networks.");
@@ -127,7 +129,7 @@ const Server: ClusterServerObj<typeof WifiNetworkCluster> = ClusterServer(
127
129
  session,
128
130
  }) => {
129
131
  console.log(
130
- `---> connectNetwork called on NetworkCommissioning cluster: ${networkId.toHex()} ${breadcrumb}`,
132
+ `---> connectNetwork called on NetworkCommissioning cluster: ${Bytes.toHex(networkId)} ${breadcrumb}`,
131
133
  );
132
134
 
133
135
  session.context.assertFailSafeArmed("Failsafe timer needs to be armed to add or update networks.");
@@ -162,7 +164,7 @@ const Server: ClusterServerObj<typeof WifiNetworkCluster> = ClusterServer(
162
164
  endpoint,
163
165
  }) => {
164
166
  console.log(
165
- `---> reorderNetwork called on NetworkCommissioning cluster: ${networkId.toHex()} ${networkIndex} ${breadcrumb}`,
167
+ `---> reorderNetwork called on NetworkCommissioning cluster: ${Bytes.toHex(networkId)} ${networkIndex} ${breadcrumb}`,
166
168
  );
167
169
 
168
170
  // Simulate successful connection
@@ -4,6 +4,15 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
+ import { Identity, MaybePromise } from "@project-chip/matter.js-general";
8
+ import {
9
+ AttributeElement,
10
+ ClusterElement,
11
+ ClusterModel,
12
+ CommandElement,
13
+ EventElement,
14
+ FieldElement,
15
+ } from "@project-chip/matter.js-model";
7
16
  import { ClusterBehavior } from "@project-chip/matter.js/behavior/cluster";
8
17
  import {
9
18
  Attribute,
@@ -14,16 +23,7 @@ import {
14
23
  MutableCluster,
15
24
  } from "@project-chip/matter.js/cluster";
16
25
  import { ClusterId, VendorId } from "@project-chip/matter.js/datatype";
17
- import {
18
- AttributeElement,
19
- ClusterElement,
20
- ClusterModel,
21
- CommandElement,
22
- EventElement,
23
- FieldElement,
24
- } from "@project-chip/matter.js/model";
25
26
  import { TlvField, TlvInt16, TlvNullable, TlvObject, TlvString, TypeFromSchema } from "@project-chip/matter.js/tlv";
26
- import { Identity, MaybePromise } from "@project-chip/matter.js/util";
27
27
 
28
28
  /** Define the Cluster ID, custom clusters use a special extended formt that also contains the Vendor Id */
29
29
  const myFancyClusterId = ClusterId.buildVendorSpecific(VendorId(0xfff4), 0xfc00);
package/src/tsconfig.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "extends": "../../matter.js-tools/tsconfig.base.json",
2
+ "extends": "../../tools/tsconfig.base.json",
3
3
  "compilerOptions": {
4
4
  "outDir": "../dist/esm",
5
5
  "types": ["node"],
@@ -1,4 +1,4 @@
1
- import "@project-chip/matter-node.js";
1
+ import "@project-chip/matter.js-nodejs";
2
2
  import { ServerNode } from "@project-chip/matter.js/node";
3
3
 
4
4
  const node = await ServerNode.create();
@@ -1,4 +1,4 @@
1
- import "@project-chip/matter-node.js";
1
+ import "@project-chip/matter.js-nodejs";
2
2
  import { OnOffLightDevice } from "@project-chip/matter.js/devices/OnOffLightDevice";
3
3
  import { ServerNode } from "@project-chip/matter.js/node";
4
4
 
@@ -1,4 +1,4 @@
1
- import "@project-chip/matter-node.js";
1
+ import "@project-chip/matter.js-nodejs";
2
2
  import { OnOffLightDevice, OnOffLightRequirements } from "@project-chip/matter.js/devices/OnOffLightDevice";
3
3
  import { ServerNode } from "@project-chip/matter.js/node";
4
4
 
@@ -1,4 +1,4 @@
1
- import "@project-chip/matter-node.js";
1
+ import "@project-chip/matter.js-nodejs";
2
2
  import { OnOffLightDevice } from "@project-chip/matter.js/devices/OnOffLightDevice";
3
3
  import { ServerNode } from "@project-chip/matter.js/node";
4
4
 
@@ -1,4 +1,4 @@
1
- import "@project-chip/matter-node.js";
1
+ import "@project-chip/matter.js-nodejs";
2
2
  import { OnOffLightDevice } from "@project-chip/matter.js/devices/OnOffLightDevice";
3
3
  import { ServerNode } from "@project-chip/matter.js/node";
4
4