@project-chip/matter-node.js-examples 0.7.5-alpha.0-20240222-8696097f → 0.8.0-alpha.0-20240309-64eaef67
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +44 -0
- package/dist/esm/examples/BridgedDeviceNode.js +147 -0
- package/dist/esm/examples/BridgedDeviceNode.js.map +7 -0
- package/dist/esm/examples/{BridgedDevicesNode.js → BridgedDevicesNodeLegacy.js} +2 -2
- package/dist/esm/examples/BridgedDevicesNodeLegacy.js.map +7 -0
- package/dist/esm/examples/ComposedDeviceNode.js +116 -127
- package/dist/esm/examples/ComposedDeviceNode.js.map +3 -3
- package/dist/esm/examples/ComposedDeviceNodeLegacy.js +138 -0
- package/dist/esm/examples/ComposedDeviceNodeLegacy.js.map +7 -0
- package/dist/esm/examples/ControllerNode.js +24 -20
- package/dist/esm/examples/ControllerNode.js.map +2 -2
- package/dist/esm/examples/ControllerNodeLegacy.js +227 -0
- package/dist/esm/examples/ControllerNodeLegacy.js.map +7 -0
- package/dist/esm/examples/DeviceNode.js +118 -159
- package/dist/esm/examples/DeviceNode.js.map +2 -2
- package/dist/esm/examples/DeviceNodeFull.js +253 -0
- package/dist/esm/examples/DeviceNodeFull.js.map +7 -0
- package/dist/esm/examples/DeviceNodeFullLegacy.js +171 -0
- package/dist/esm/examples/DeviceNodeFullLegacy.js.map +7 -0
- package/dist/esm/examples/IlluminatedRollerShade.js +85 -0
- package/dist/esm/examples/IlluminatedRollerShade.js.map +7 -0
- package/dist/esm/examples/LightDevice.js +34 -0
- package/dist/esm/examples/LightDevice.js.map +7 -0
- package/dist/esm/examples/MultiDeviceNode.js +133 -134
- package/dist/esm/examples/MultiDeviceNode.js.map +3 -3
- package/dist/esm/examples/MultiDeviceNodeLegacy.js +146 -0
- package/dist/esm/examples/MultiDeviceNodeLegacy.js.map +7 -0
- package/dist/esm/examples/SensorDeviceNode.js +167 -0
- package/dist/esm/examples/SensorDeviceNode.js.map +7 -0
- package/dist/esm/examples/cluster/DummyThreadNetworkCommissioningServer.js +115 -0
- package/dist/esm/examples/cluster/DummyThreadNetworkCommissioningServer.js.map +7 -0
- package/dist/esm/examples/cluster/DummyWifiNetworkCommissioningServer.js +115 -0
- package/dist/esm/examples/cluster/DummyWifiNetworkCommissioningServer.js.map +7 -0
- package/dist/esm/examples/cluster/{DummyWifiNetworkCommissioningClusterServer.js → DummyWifiNetworkCommissioningServerLegacy.js} +16 -14
- package/dist/esm/examples/cluster/DummyWifiNetworkCommissioningServerLegacy.js.map +7 -0
- package/dist/esm/examples/cluster/MyFancyOwnFunctionality.js +110 -0
- package/dist/esm/examples/cluster/MyFancyOwnFunctionality.js.map +7 -0
- package/dist/esm/tutorial/example01.js +5 -0
- package/dist/esm/tutorial/example01.js.map +7 -0
- package/dist/esm/tutorial/example02.js +7 -0
- package/dist/esm/tutorial/example02.js.map +7 -0
- package/dist/esm/tutorial/example03.js +15 -0
- package/dist/esm/tutorial/example03.js.map +7 -0
- package/dist/esm/tutorial/example04.js +10 -0
- package/dist/esm/tutorial/example04.js.map +7 -0
- package/dist/esm/tutorial/example05.js +14 -0
- package/dist/esm/tutorial/example05.js.map +7 -0
- package/package.json +9 -6
- package/src/examples/BridgedDeviceNode.ts +260 -0
- package/src/examples/{BridgedDevicesNode.ts → BridgedDevicesNodeLegacy.ts} +6 -1
- package/src/examples/ComposedDeviceNode.ts +173 -223
- package/src/examples/ComposedDeviceNodeLegacy.ts +252 -0
- package/src/examples/ControllerNode.ts +28 -22
- package/src/examples/ControllerNodeLegacy.ts +354 -0
- package/src/examples/DeviceNode.ts +173 -273
- package/src/examples/DeviceNodeFull.ts +440 -0
- package/src/examples/DeviceNodeFullLegacy.ts +307 -0
- package/src/examples/IlluminatedRollerShade.ts +130 -0
- package/src/examples/LightDevice.ts +60 -0
- package/src/examples/MultiDeviceNode.ts +184 -236
- package/src/examples/MultiDeviceNodeLegacy.ts +267 -0
- package/src/examples/SensorDeviceNode.ts +236 -0
- package/src/examples/cluster/DummyThreadNetworkCommissioningServer.ts +156 -0
- package/src/examples/cluster/DummyWifiNetworkCommissioningServer.ts +153 -0
- package/src/examples/cluster/{DummyWifiNetworkCommissioningClusterServer.ts → DummyWifiNetworkCommissioningServerLegacy.ts} +16 -13
- package/src/examples/cluster/MyFancyOwnFunctionality.ts +185 -0
- package/src/tsconfig.json +9 -1
- package/src/tutorial/example01.ts +6 -0
- package/src/tutorial/example02.ts +9 -0
- package/src/tutorial/example03.ts +19 -0
- package/src/tutorial/example04.ts +13 -0
- package/src/tutorial/example05.ts +19 -0
- package/dist/esm/examples/BridgedDevicesNode.js.map +0 -7
- package/dist/esm/examples/cluster/DummyWifiNetworkCommissioningClusterServer.js.map +0 -7
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../../src/examples/cluster/DummyWifiNetworkCommissioningServer.ts"],
|
4
|
+
"sourcesContent": ["/**\n * @license\n * Copyright 2022-2024 Matter.js Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { GeneralCommissioningBehavior } from \"@project-chip/matter.js/behavior/definitions/general-commissioning\";\nimport {\n AddOrUpdateWiFiNetworkRequest,\n ConnectNetworkRequest,\n NetworkCommissioningBehavior,\n RemoveNetworkRequest,\n ReorderNetworkRequest,\n ScanNetworksRequest,\n} from \"@project-chip/matter.js/behavior/definitions/network-commissioning\";\nimport { NetworkCommissioning } from \"@project-chip/matter.js/cluster\";\nimport { ByteArray } from \"@project-chip/matter.js/util\";\n\nconst firstNetworkId = new ByteArray(32);\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 class DummyWifiNetworkCommissioningServer extends NetworkCommissioningBehavior.with(\n NetworkCommissioning.Feature.WiFiNetworkInterface,\n) {\n override scanNetworks({ ssid, breadcrumb }: ScanNetworksRequest) {\n console.log(`---> scanNetworks called on NetworkCommissioning cluster: ${ssid?.toHex()} ${breadcrumb}`);\n\n // Simulate successful scan\n if (breadcrumb !== undefined) {\n const generalCommissioningCluster = this.agent.get(GeneralCommissioningBehavior);\n generalCommissioningCluster.state.breadcrumb = breadcrumb;\n }\n\n const networkingStatus = NetworkCommissioning.NetworkCommissioningStatus.Success;\n this.state.lastNetworkingStatus = 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(this.endpoint.env.vars.get(\"ble.wifi.scanSsid\") ?? \"TestSSID\"), // Set a valid existing local Wi-Fi SSID here\n bssid: ByteArray.fromString(\n this.endpoint.env.vars.get(\"ble.wifi.scanBssid\") ?? \"00:00:00:00:00:00\",\n ),\n channel: 1,\n },\n ],\n };\n }\n\n override addOrUpdateWiFiNetwork({ ssid, credentials, breadcrumb }: AddOrUpdateWiFiNetworkRequest) {\n console.log(\n `---> addOrUpdateWiFiNetwork called on NetworkCommissioning cluster: ${ssid.toHex()} ${credentials.toHex()} ${breadcrumb}`,\n );\n\n this.session.context.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 = this.agent.get(GeneralCommissioningBehavior);\n generalCommissioningCluster.state.breadcrumb = breadcrumb;\n }\n\n const networkingStatus = NetworkCommissioning.NetworkCommissioningStatus.Success;\n this.state.lastNetworkingStatus = networkingStatus;\n this.state.lastNetworkId = firstNetworkId;\n\n return {\n networkingStatus,\n networkIndex: 0,\n };\n }\n\n override removeNetwork({ networkId, breadcrumb }: RemoveNetworkRequest) {\n console.log(`---> removeNetwork called on NetworkCommissioning cluster: ${networkId.toHex()} ${breadcrumb}`);\n\n this.session.context.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 = this.agent.get(GeneralCommissioningBehavior);\n generalCommissioningCluster.state.breadcrumb = breadcrumb;\n }\n\n const networkingStatus = NetworkCommissioning.NetworkCommissioningStatus.Success;\n this.state.lastNetworkingStatus = networkingStatus;\n this.state.lastNetworkId = firstNetworkId;\n\n return {\n networkingStatus,\n networkIndex: 0,\n };\n }\n\n override async connectNetwork({ networkId, breadcrumb }: ConnectNetworkRequest) {\n console.log(`---> connectNetwork called on NetworkCommissioning cluster: ${networkId.toHex()} ${breadcrumb}`);\n\n this.session.context.assertFailSafeArmed(\"Failsafe timer needs to be armed to add or update networks.\");\n\n // Simulate successful connection\n if (breadcrumb !== undefined) {\n const generalCommissioningCluster = this.agent.get(GeneralCommissioningBehavior);\n generalCommissioningCluster.state.breadcrumb = breadcrumb;\n }\n\n this.state.networks[0].connected = true;\n\n const networkingStatus = NetworkCommissioning.NetworkCommissioningStatus.Success;\n this.state.lastNetworkingStatus = networkingStatus;\n this.state.lastNetworkId = firstNetworkId;\n this.state.lastConnectErrorValue = null;\n\n // Announce operational in IP network\n const device = this.session.context;\n await device.startAnnouncement();\n\n return {\n networkingStatus,\n errorValue: null,\n };\n }\n\n override reorderNetwork({ networkId, networkIndex, breadcrumb }: ReorderNetworkRequest) {\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 = this.agent.get(GeneralCommissioningBehavior);\n generalCommissioningCluster.state.breadcrumb = breadcrumb;\n }\n\n const networkingStatus = NetworkCommissioning.NetworkCommissioningStatus.Success;\n this.state.lastNetworkingStatus = networkingStatus;\n\n return {\n networkingStatus,\n networkIndex: 0,\n };\n }\n}\n"],
|
5
|
+
"mappings": "AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,SAAS,oCAAoC;AAC7C;AAAA,EAGI;AAAA,OAIG;AACP,SAAS,4BAA4B;AACrC,SAAS,iBAAiB;AAE1B,MAAM,iBAAiB,IAAI,UAAU,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AEA,UAAM,mBAAmB,qBAAqB,2BAA2B;AACzE,SAAK,MAAM,uBAAuB;AAElC,WAAO;AAAA,MACH;AAAA,MACA,cAAc;AAAA,IAClB;AAAA,EACJ;AACJ;",
|
6
|
+
"names": []
|
7
|
+
}
|
@@ -1,17 +1,18 @@
|
|
1
1
|
/**
|
2
2
|
* @license
|
3
|
-
* Copyright 2022
|
3
|
+
* Copyright 2022-2024 Matter.js Authors
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
5
5
|
*/
|
6
|
+
import { getParameter } from "@project-chip/matter-node.js/util";
|
6
7
|
import {
|
7
8
|
ClusterServer,
|
8
9
|
GeneralCommissioningCluster,
|
9
10
|
NetworkCommissioning
|
10
|
-
} from "@project-chip/matter
|
11
|
-
import { ByteArray
|
11
|
+
} from "@project-chip/matter.js/cluster";
|
12
|
+
import { ByteArray } from "@project-chip/matter.js/util";
|
12
13
|
const firstNetworkId = new ByteArray(32);
|
13
14
|
const WifiNetworkCluster = NetworkCommissioning.Cluster.with(NetworkCommissioning.Feature.WiFiNetworkInterface);
|
14
|
-
|
15
|
+
const Server = ClusterServer(
|
15
16
|
NetworkCommissioning.Cluster.with(NetworkCommissioning.Feature.WiFiNetworkInterface),
|
16
17
|
{
|
17
18
|
maxNetworks: 1,
|
@@ -60,7 +61,7 @@ var DummyWifiNetworkCommissioningClusterServer_default = ClusterServer(
|
|
60
61
|
console.log(
|
61
62
|
`---> addOrUpdateWiFiNetwork called on NetworkCommissioning cluster: ${ssid.toHex()} ${credentials.toHex()} ${breadcrumb}`
|
62
63
|
);
|
63
|
-
session.
|
64
|
+
session.context.assertFailSafeArmed("Failsafe timer needs to be armed to add or update networks.");
|
64
65
|
if (breadcrumb !== void 0) {
|
65
66
|
const generalCommissioningCluster = endpoint.getClusterServer(GeneralCommissioningCluster);
|
66
67
|
generalCommissioningCluster?.setBreadcrumbAttribute(breadcrumb);
|
@@ -69,7 +70,7 @@ var DummyWifiNetworkCommissioningClusterServer_default = ClusterServer(
|
|
69
70
|
lastNetworkingStatus?.setLocal(networkingStatus);
|
70
71
|
lastNetworkId?.setLocal(firstNetworkId);
|
71
72
|
return {
|
72
|
-
networkingStatus
|
73
|
+
networkingStatus,
|
73
74
|
networkIndex: 0
|
74
75
|
};
|
75
76
|
},
|
@@ -82,7 +83,7 @@ var DummyWifiNetworkCommissioningClusterServer_default = ClusterServer(
|
|
82
83
|
console.log(
|
83
84
|
`---> removeNetwork called on NetworkCommissioning cluster: ${networkId.toHex()} ${breadcrumb}`
|
84
85
|
);
|
85
|
-
session.
|
86
|
+
session.context.assertFailSafeArmed("Failsafe timer needs to be armed to add or update networks.");
|
86
87
|
if (breadcrumb !== void 0) {
|
87
88
|
const generalCommissioningCluster = endpoint.getClusterServer(GeneralCommissioningCluster);
|
88
89
|
generalCommissioningCluster?.setBreadcrumbAttribute(breadcrumb);
|
@@ -91,7 +92,7 @@ var DummyWifiNetworkCommissioningClusterServer_default = ClusterServer(
|
|
91
92
|
lastNetworkingStatus?.setLocal(networkingStatus);
|
92
93
|
lastNetworkId?.setLocal(firstNetworkId);
|
93
94
|
return {
|
94
|
-
networkingStatus
|
95
|
+
networkingStatus,
|
95
96
|
networkIndex: 0
|
96
97
|
};
|
97
98
|
},
|
@@ -104,7 +105,7 @@ var DummyWifiNetworkCommissioningClusterServer_default = ClusterServer(
|
|
104
105
|
console.log(
|
105
106
|
`---> connectNetwork called on NetworkCommissioning cluster: ${networkId.toHex()} ${breadcrumb}`
|
106
107
|
);
|
107
|
-
session.
|
108
|
+
session.context.assertFailSafeArmed("Failsafe timer needs to be armed to add or update networks.");
|
108
109
|
if (breadcrumb !== void 0) {
|
109
110
|
const generalCommissioningCluster = endpoint.getClusterServer(GeneralCommissioningCluster);
|
110
111
|
generalCommissioningCluster?.setBreadcrumbAttribute(breadcrumb);
|
@@ -116,10 +117,10 @@ var DummyWifiNetworkCommissioningClusterServer_default = ClusterServer(
|
|
116
117
|
lastNetworkingStatus?.setLocal(networkingStatus);
|
117
118
|
lastNetworkId?.setLocal(firstNetworkId);
|
118
119
|
lastConnectErrorValue?.setLocal(null);
|
119
|
-
const device = session.
|
120
|
+
const device = session.context;
|
120
121
|
await device.startAnnouncement();
|
121
122
|
return {
|
122
|
-
networkingStatus
|
123
|
+
networkingStatus,
|
123
124
|
errorValue: null
|
124
125
|
};
|
125
126
|
},
|
@@ -138,13 +139,14 @@ var DummyWifiNetworkCommissioningClusterServer_default = ClusterServer(
|
|
138
139
|
const networkingStatus = NetworkCommissioning.NetworkCommissioningStatus.Success;
|
139
140
|
lastNetworkingStatus?.setLocal(networkingStatus);
|
140
141
|
return {
|
141
|
-
networkingStatus
|
142
|
+
networkingStatus,
|
142
143
|
networkIndex: 0
|
143
144
|
};
|
144
145
|
}
|
145
146
|
}
|
146
147
|
);
|
148
|
+
var DummyWifiNetworkCommissioningServerLegacy_default = Server;
|
147
149
|
export {
|
148
|
-
|
150
|
+
DummyWifiNetworkCommissioningServerLegacy_default as default
|
149
151
|
};
|
150
|
-
//# sourceMappingURL=
|
152
|
+
//# sourceMappingURL=DummyWifiNetworkCommissioningServerLegacy.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../../src/examples/cluster/DummyWifiNetworkCommissioningServerLegacy.ts"],
|
4
|
+
"sourcesContent": ["/**\n * @license\n * Copyright 2022-2024 Matter.js Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { getParameter } from \"@project-chip/matter-node.js/util\";\nimport {\n ClusterServer,\n ClusterServerObjForCluster,\n GeneralCommissioningCluster,\n NetworkCommissioning,\n} from \"@project-chip/matter.js/cluster\";\nimport { ByteArray } from \"@project-chip/matter.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 */\nconst Server: ClusterServerObjForCluster<typeof WifiNetworkCluster> = 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.context.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,\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.context.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,\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.context.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.context;\n await device.startAnnouncement();\n\n return {\n networkingStatus,\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,\n networkIndex: 0,\n };\n },\n },\n);\n\nexport default Server;\n"],
|
5
|
+
"mappings": "AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,SAAS,oBAAoB;AAC7B;AAAA,EACI;AAAA,EAEA;AAAA,EACA;AAAA,OACG;AACP,SAAS,iBAAiB;AAE1B,MAAM,iBAAiB,IAAI,UAAU,EAAE;AAEvC,MAAM,qBAAqB,qBAAqB,QAAQ,KAAK,qBAAqB,QAAQ,oBAAoB;AAO9G,MAAM,SAAgE;AAAA,EAClE,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,UAA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AAA,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;AAAA,QACA,cAAc;AAAA,MAClB;AAAA,IACJ;AAAA,EACJ;AACJ;AAEA,IAAO,oDAAQ;",
|
6
|
+
"names": []
|
7
|
+
}
|
@@ -0,0 +1,110 @@
|
|
1
|
+
/**
|
2
|
+
* @license
|
3
|
+
* Copyright 2022-2024 Matter.js Authors
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
5
|
+
*/
|
6
|
+
import { ClusterBehavior } from "@project-chip/matter.js/behavior/cluster";
|
7
|
+
import {
|
8
|
+
Attribute,
|
9
|
+
ClusterRegistry,
|
10
|
+
Command,
|
11
|
+
Event,
|
12
|
+
EventPriority,
|
13
|
+
MutableCluster
|
14
|
+
} from "@project-chip/matter.js/cluster";
|
15
|
+
import { ClusterId, VendorId } from "@project-chip/matter.js/datatype";
|
16
|
+
import {
|
17
|
+
AttributeElement,
|
18
|
+
ClusterElement,
|
19
|
+
ClusterModel,
|
20
|
+
CommandElement,
|
21
|
+
EventElement,
|
22
|
+
FieldElement
|
23
|
+
} from "@project-chip/matter.js/model";
|
24
|
+
import { TlvField, TlvInt16, TlvNullable, TlvObject, TlvString } from "@project-chip/matter.js/tlv";
|
25
|
+
const myFancyClusterId = ClusterId.buildVendorSpecific(VendorId(65524), 64512);
|
26
|
+
var MyFancyOwnFunctionality;
|
27
|
+
((MyFancyOwnFunctionality2) => {
|
28
|
+
MyFancyOwnFunctionality2.TlvMyFancyCommandRequest = TlvObject({ value: TlvField(0, TlvString) });
|
29
|
+
MyFancyOwnFunctionality2.TlvMyFancyCommandResponse = TlvObject({ response: TlvField(0, TlvString) });
|
30
|
+
MyFancyOwnFunctionality2.TlvMyFancyEvent = TlvObject({ eventValue: TlvField(0, TlvString) });
|
31
|
+
MyFancyOwnFunctionality2.ClusterInstance = MutableCluster({
|
32
|
+
id: myFancyClusterId,
|
33
|
+
name: "MyFancyOwnFunctionality",
|
34
|
+
revision: 1,
|
35
|
+
attributes: {
|
36
|
+
/** My fancy attribute */
|
37
|
+
myFancyValue: Attribute(0, TlvNullable(TlvInt16))
|
38
|
+
},
|
39
|
+
commands: {
|
40
|
+
/** My fancy command */
|
41
|
+
myFancyCommand: Command(1, MyFancyOwnFunctionality2.TlvMyFancyCommandRequest, 2, MyFancyOwnFunctionality2.TlvMyFancyCommandResponse)
|
42
|
+
},
|
43
|
+
events: {
|
44
|
+
/** My fancy event */
|
45
|
+
myFancyEvent: Event(5, EventPriority.Info, MyFancyOwnFunctionality2.TlvMyFancyEvent)
|
46
|
+
}
|
47
|
+
});
|
48
|
+
MyFancyOwnFunctionality2.Cluster = MyFancyOwnFunctionality2.ClusterInstance;
|
49
|
+
MyFancyOwnFunctionality2.Complete = MyFancyOwnFunctionality2.Cluster;
|
50
|
+
})(MyFancyOwnFunctionality || (MyFancyOwnFunctionality = {}));
|
51
|
+
const MyFancyOwnFunctionalityCluster = MyFancyOwnFunctionality.Cluster;
|
52
|
+
ClusterRegistry.register(MyFancyOwnFunctionality.Complete);
|
53
|
+
const MyFancySchema = ClusterElement({
|
54
|
+
name: "MyFancyOwnFunctionality",
|
55
|
+
id: myFancyClusterId,
|
56
|
+
classification: "application",
|
57
|
+
description: "My Fancy Functionality",
|
58
|
+
children: [
|
59
|
+
AttributeElement({ name: "ClusterRevision", id: 65533, type: "ClusterRevision", default: 1 }),
|
60
|
+
AttributeElement({
|
61
|
+
name: "MyFancyValue",
|
62
|
+
id: 0,
|
63
|
+
type: "int16",
|
64
|
+
access: "R V",
|
65
|
+
conformance: "M",
|
66
|
+
quality: "X"
|
67
|
+
}),
|
68
|
+
CommandElement({
|
69
|
+
name: "MyFancyCommand",
|
70
|
+
id: 1,
|
71
|
+
access: "O",
|
72
|
+
conformance: "M",
|
73
|
+
direction: "request",
|
74
|
+
response: "MyFancyCommandResponse",
|
75
|
+
children: [FieldElement({ name: "value", id: 0, type: "string", conformance: "M" })]
|
76
|
+
}),
|
77
|
+
CommandElement({
|
78
|
+
name: "MyFancyCommandResponse",
|
79
|
+
id: 2,
|
80
|
+
conformance: "M",
|
81
|
+
direction: "request",
|
82
|
+
children: [FieldElement({ name: "response", id: 0, type: "string", conformance: "M" })]
|
83
|
+
}),
|
84
|
+
EventElement({
|
85
|
+
name: "MyFancyEvent",
|
86
|
+
id: 5,
|
87
|
+
access: "V",
|
88
|
+
conformance: "O",
|
89
|
+
priority: "info",
|
90
|
+
children: [
|
91
|
+
FieldElement({
|
92
|
+
name: "EventValue",
|
93
|
+
id: 0,
|
94
|
+
type: "string",
|
95
|
+
conformance: "M"
|
96
|
+
})
|
97
|
+
]
|
98
|
+
})
|
99
|
+
]
|
100
|
+
});
|
101
|
+
const MyFancyOwnFunctionalityBehavior = ClusterBehavior.withInterface().for(
|
102
|
+
MyFancyOwnFunctionality.Cluster,
|
103
|
+
new ClusterModel(MyFancySchema)
|
104
|
+
);
|
105
|
+
export {
|
106
|
+
MyFancyOwnFunctionality,
|
107
|
+
MyFancyOwnFunctionalityBehavior,
|
108
|
+
MyFancyOwnFunctionalityCluster
|
109
|
+
};
|
110
|
+
//# sourceMappingURL=MyFancyOwnFunctionality.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../../src/examples/cluster/MyFancyOwnFunctionality.ts"],
|
4
|
+
"sourcesContent": ["/**\n * @license\n * Copyright 2022-2024 Matter.js Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { ClusterBehavior } from \"@project-chip/matter.js/behavior/cluster\";\nimport {\n Attribute,\n ClusterRegistry,\n Command,\n Event,\n EventPriority,\n MutableCluster,\n} from \"@project-chip/matter.js/cluster\";\nimport { ClusterId, VendorId } from \"@project-chip/matter.js/datatype\";\nimport {\n AttributeElement,\n ClusterElement,\n ClusterModel,\n CommandElement,\n EventElement,\n FieldElement,\n} from \"@project-chip/matter.js/model\";\nimport { TlvField, TlvInt16, TlvNullable, TlvObject, TlvString, TypeFromSchema } from \"@project-chip/matter.js/tlv\";\nimport { Identity, MaybePromise } from \"@project-chip/matter.js/util\";\n\n/** Define the Cluster ID, custom clusters use a special extended formt that also contains the Vendor Id */\nconst myFancyClusterId = ClusterId.buildVendorSpecific(VendorId(0xfff4), 0xfc00);\n\n/**\n * Defines the Cluster on Tlv Schema level in a special namespace structure to match the official cluster\n * structures of matter.js.\n * All places that contains \"MyFancy...\" belong to the custom cluster details, all rest can be left statically like the\n * given names.\n * For more examples and usages of features in such clusters and how the code should look then check the standard\n * cluster Tlv definitions in packages/matter.js/cluster/definitions/*\n */\nexport namespace MyFancyOwnFunctionality {\n /**\n * Input to the MyFancyOwnFunctionality myFancyCommand command\n */\n export const TlvMyFancyCommandRequest = TlvObject({ value: TlvField(0, TlvString) });\n\n /**\n * Response of the MyFancyOwnFunctionality myFancyCommand command\n */\n export const TlvMyFancyCommandResponse = TlvObject({ response: TlvField(0, TlvString) });\n\n /**\n * Event for the MyFancyOwnFunctionality myFancyEvent event\n */\n export const TlvMyFancyEvent = TlvObject({ eventValue: TlvField(0, TlvString) });\n\n /**\n * @see {@link Cluster}\n */\n export const ClusterInstance = MutableCluster({\n id: myFancyClusterId,\n name: \"MyFancyOwnFunctionality\",\n revision: 1,\n\n attributes: {\n /** My fancy attribute */\n myFancyValue: Attribute(0x0, TlvNullable(TlvInt16)),\n },\n\n commands: {\n /** My fancy command */\n myFancyCommand: Command(0x1, TlvMyFancyCommandRequest, 0x2, TlvMyFancyCommandResponse),\n },\n\n events: {\n /** My fancy event */\n myFancyEvent: Event(0x5, EventPriority.Info, TlvMyFancyEvent),\n },\n });\n\n /**\n * My Fancy Cluster\n *\n * This cluster provides an interface to some fancy custom functions.\n */\n export interface Cluster extends Identity<typeof ClusterInstance> {}\n\n export const Cluster: Cluster = ClusterInstance;\n\n export const Complete = Cluster;\n}\n\nexport type MyFancyOwnFunctionalityCluster = MyFancyOwnFunctionality.Cluster;\nexport const MyFancyOwnFunctionalityCluster = MyFancyOwnFunctionality.Cluster;\nClusterRegistry.register(MyFancyOwnFunctionality.Complete);\n\n/**\n * matter.js Model Schema for the cluster, need to match with the Tlv Schema above.\n * See more details in packages/matter.js/behavior/definitions/*\n */\nconst MyFancySchema = ClusterElement({\n name: \"MyFancyOwnFunctionality\",\n id: myFancyClusterId,\n classification: \"application\",\n description: \"My Fancy Functionality\",\n\n children: [\n AttributeElement({ name: \"ClusterRevision\", id: 0xfffd, type: \"ClusterRevision\", default: 1 }),\n\n AttributeElement({\n name: \"MyFancyValue\",\n id: 0x0,\n type: \"int16\",\n access: \"R V\",\n conformance: \"M\",\n quality: \"X\",\n }),\n\n CommandElement({\n name: \"MyFancyCommand\",\n id: 0x1,\n access: \"O\",\n conformance: \"M\",\n direction: \"request\",\n response: \"MyFancyCommandResponse\",\n\n children: [FieldElement({ name: \"value\", id: 0x0, type: \"string\", conformance: \"M\" })],\n }),\n CommandElement({\n name: \"MyFancyCommandResponse\",\n id: 0x2,\n conformance: \"M\",\n direction: \"request\",\n\n children: [FieldElement({ name: \"response\", id: 0x0, type: \"string\", conformance: \"M\" })],\n }),\n\n EventElement({\n name: \"MyFancyEvent\",\n id: 0x5,\n access: \"V\",\n conformance: \"O\",\n priority: \"info\",\n children: [\n FieldElement({\n name: \"EventValue\",\n id: 0x0,\n type: \"string\",\n conformance: \"M\",\n }),\n ],\n }),\n ],\n});\n\n/**\n * Interface definitions - exposes the Implementation interface for the cluster and some types to be used in the\n * cluster implementations.\n */\nexport type MyFancyCommandRequest = TypeFromSchema<typeof MyFancyOwnFunctionality.TlvMyFancyCommandRequest>;\nexport type MyFancyCommandResponse = TypeFromSchema<typeof MyFancyOwnFunctionality.TlvMyFancyCommandResponse>;\nexport type MyFancyEvent = TypeFromSchema<typeof MyFancyOwnFunctionality.TlvMyFancyEvent>;\n\nexport namespace MyFancyOwnFunctionalityInterface {\n export interface Base {\n myFancyCommand(request: MyFancyCommandRequest): MaybePromise<MyFancyCommandResponse>;\n }\n}\n\nexport type MyFancyOwnFunctionalityInterface = {\n components: [{ flags: {}; methods: MyFancyOwnFunctionalityInterface.Base }];\n};\n\n/**\n * Behavior definition for the cluster command handler implementation\n */\nexport const MyFancyOwnFunctionalityBehavior = ClusterBehavior.withInterface<MyFancyOwnFunctionalityInterface>().for(\n MyFancyOwnFunctionality.Cluster,\n new ClusterModel(MyFancySchema),\n);\n\ntype MyFancyOwnFunctionalityBehaviorType = InstanceType<typeof MyFancyOwnFunctionalityBehavior>;\nexport interface TemperatureMeasurementBehavior extends MyFancyOwnFunctionalityBehaviorType {}\ntype StateType = InstanceType<typeof MyFancyOwnFunctionalityBehavior.State>;\nexport namespace MyFancyOwnFunctionalityBehavior {\n export interface State extends StateType {}\n}\n"],
|
5
|
+
"mappings": "AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,SAAS,uBAAuB;AAChC;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AACP,SAAS,WAAW,gBAAgB;AACpC;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AACP,SAAS,UAAU,UAAU,aAAa,WAAW,iBAAiC;AAItF,MAAM,mBAAmB,UAAU,oBAAoB,SAAS,KAAM,GAAG,KAAM;AAUxE,IAAU;AAAA,CAAV,CAAUA,6BAAV;AAII,EAAMA,yBAAA,2BAA2B,UAAU,EAAE,OAAO,SAAS,GAAG,SAAS,EAAE,CAAC;AAK5E,EAAMA,yBAAA,4BAA4B,UAAU,EAAE,UAAU,SAAS,GAAG,SAAS,EAAE,CAAC;AAKhF,EAAMA,yBAAA,kBAAkB,UA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ACJ,aAAa;AAAA,MACb,WAAW;AAAA,MAEX,UAAU,CAAC,aAAa,EAAE,MAAM,YAAY,IAAI,GAAK,MAAM,UAAU,aAAa,IAAI,CAAC,CAAC;AAAA,IAC5F,CAAC;AAAA,IAED,aAAa;AAAA,MACT,MAAM;AAAA,MACN,IAAI;AAAA,MACJ,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,UAAU;AAAA,MACV,UAAU;AAAA,QACN,aAAa;AAAA,UACT,MAAM;AAAA,UACN,IAAI;AAAA,UACJ,MAAM;AAAA,UACN,aAAa;AAAA,QACjB,CAAC;AAAA,MACL;AAAA,IACJ,CAAC;AAAA,EACL;AACJ,CAAC;AAuBM,MAAM,kCAAkC,gBAAgB,cAAgD,EAAE;AAAA,EAC7G,wBAAwB;AAAA,EACxB,IAAI,aAAa,aAAa;AAClC;",
|
6
|
+
"names": ["MyFancyOwnFunctionality"]
|
7
|
+
}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../src/tutorial/example01.ts"],
|
4
|
+
"sourcesContent": ["import \"@project-chip/matter-node.js\";\nimport { ServerNode } from \"@project-chip/matter.js/node\";\n\nconst node = await ServerNode.create();\n\nawait node.run();\n"],
|
5
|
+
"mappings": "AAAA,OAAO;AACP,SAAS,kBAAkB;AAE3B,MAAM,OAAO,MAAM,WAAW,OAAO;AAErC,MAAM,KAAK,IAAI;",
|
6
|
+
"names": []
|
7
|
+
}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import "@project-chip/matter-node.js";
|
2
|
+
import { OnOffLightDevice } from "@project-chip/matter.js/devices/OnOffLightDevice";
|
3
|
+
import { ServerNode } from "@project-chip/matter.js/node";
|
4
|
+
const node = await ServerNode.create();
|
5
|
+
await node.add(OnOffLightDevice);
|
6
|
+
await node.run();
|
7
|
+
//# sourceMappingURL=example02.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../src/tutorial/example02.ts"],
|
4
|
+
"sourcesContent": ["import \"@project-chip/matter-node.js\";\nimport { OnOffLightDevice } from \"@project-chip/matter.js/devices/OnOffLightDevice\";\nimport { ServerNode } from \"@project-chip/matter.js/node\";\n\nconst node = await ServerNode.create();\n\nawait node.add(OnOffLightDevice);\n\nawait node.run();\n"],
|
5
|
+
"mappings": "AAAA,OAAO;AACP,SAAS,wBAAwB;AACjC,SAAS,kBAAkB;AAE3B,MAAM,OAAO,MAAM,WAAW,OAAO;AAErC,MAAM,KAAK,IAAI,gBAAgB;AAE/B,MAAM,KAAK,IAAI;",
|
6
|
+
"names": []
|
7
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import "@project-chip/matter-node.js";
|
2
|
+
import { OnOffLightDevice, OnOffLightRequirements } from "@project-chip/matter.js/devices/OnOffLightDevice";
|
3
|
+
import { ServerNode } from "@project-chip/matter.js/node";
|
4
|
+
class MyOnOffServer extends OnOffLightRequirements.OnOffServer {
|
5
|
+
on() {
|
6
|
+
console.log("Turning on");
|
7
|
+
}
|
8
|
+
off() {
|
9
|
+
console.log("Turning off");
|
10
|
+
}
|
11
|
+
}
|
12
|
+
const node = await ServerNode.create();
|
13
|
+
await node.add(OnOffLightDevice.with(MyOnOffServer));
|
14
|
+
await node.run();
|
15
|
+
//# sourceMappingURL=example03.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../src/tutorial/example03.ts"],
|
4
|
+
"sourcesContent": ["import \"@project-chip/matter-node.js\";\nimport { OnOffLightDevice, OnOffLightRequirements } from \"@project-chip/matter.js/devices/OnOffLightDevice\";\nimport { ServerNode } from \"@project-chip/matter.js/node\";\n\nclass MyOnOffServer extends OnOffLightRequirements.OnOffServer {\n override on() {\n console.log(\"Turning on\");\n }\n\n override off() {\n console.log(\"Turning off\");\n }\n}\n\nconst node = await ServerNode.create();\n\nawait node.add(OnOffLightDevice.with(MyOnOffServer));\n\nawait node.run();\n"],
|
5
|
+
"mappings": "AAAA,OAAO;AACP,SAAS,kBAAkB,8BAA8B;AACzD,SAAS,kBAAkB;AAE3B,MAAM,sBAAsB,uBAAuB,YAAY;AAAA,EAClD,KAAK;AACV,YAAQ,IAAI,YAAY;AAAA,EAC5B;AAAA,EAES,MAAM;AACX,YAAQ,IAAI,aAAa;AAAA,EAC7B;AACJ;AAEA,MAAM,OAAO,MAAM,WAAW,OAAO;AAErC,MAAM,KAAK,IAAI,iBAAiB,KAAK,aAAa,CAAC;AAEnD,MAAM,KAAK,IAAI;",
|
6
|
+
"names": []
|
7
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import "@project-chip/matter-node.js";
|
2
|
+
import { OnOffLightDevice } from "@project-chip/matter.js/devices/OnOffLightDevice";
|
3
|
+
import { ServerNode } from "@project-chip/matter.js/node";
|
4
|
+
const node = await ServerNode.create();
|
5
|
+
const light = await node.add(OnOffLightDevice);
|
6
|
+
light.events.onOff.onOff$Change.on((newValue) => {
|
7
|
+
console.log(`Light is ${newValue ? "on" : "off"}`);
|
8
|
+
});
|
9
|
+
await node.run();
|
10
|
+
//# sourceMappingURL=example04.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../src/tutorial/example04.ts"],
|
4
|
+
"sourcesContent": ["import \"@project-chip/matter-node.js\";\nimport { OnOffLightDevice } from \"@project-chip/matter.js/devices/OnOffLightDevice\";\nimport { ServerNode } from \"@project-chip/matter.js/node\";\n\nconst node = await ServerNode.create();\n\nconst light = await node.add(OnOffLightDevice);\n\nlight.events.onOff.onOff$Change.on(newValue => {\n console.log(`Light is ${newValue ? \"on\" : \"off\"}`);\n});\n\nawait node.run();\n"],
|
5
|
+
"mappings": "AAAA,OAAO;AACP,SAAS,wBAAwB;AACjC,SAAS,kBAAkB;AAE3B,MAAM,OAAO,MAAM,WAAW,OAAO;AAErC,MAAM,QAAQ,MAAM,KAAK,IAAI,gBAAgB;AAE7C,MAAM,OAAO,MAAM,aAAa,GAAG,cAAY;AAC3C,UAAQ,IAAI,YAAY,WAAW,OAAO,KAAK,EAAE;AACrD,CAAC;AAED,MAAM,KAAK,IAAI;",
|
6
|
+
"names": []
|
7
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import "@project-chip/matter-node.js";
|
2
|
+
import { OnOffLightDevice } from "@project-chip/matter.js/devices/OnOffLightDevice";
|
3
|
+
import { ServerNode } from "@project-chip/matter.js/node";
|
4
|
+
const node = await ServerNode.create();
|
5
|
+
const light = await node.add(OnOffLightDevice);
|
6
|
+
await node.bringOnline();
|
7
|
+
await light.act(async (agent) => {
|
8
|
+
await agent.onOff.toggle();
|
9
|
+
console.log("On/off state after first toggle", agent.onOff.state);
|
10
|
+
await agent.onOff.toggle();
|
11
|
+
console.log("On/off state after second toggle", agent.onOff.state);
|
12
|
+
});
|
13
|
+
await node.close();
|
14
|
+
//# sourceMappingURL=example05.js.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
{
|
2
|
+
"version": 3,
|
3
|
+
"sources": ["../../../src/tutorial/example05.ts"],
|
4
|
+
"sourcesContent": ["import \"@project-chip/matter-node.js\";\nimport { OnOffLightDevice } from \"@project-chip/matter.js/devices/OnOffLightDevice\";\nimport { ServerNode } from \"@project-chip/matter.js/node\";\n\nconst node = await ServerNode.create();\n\nconst light = await node.add(OnOffLightDevice);\n\nawait node.bringOnline();\n\nawait light.act(async agent => {\n await agent.onOff.toggle();\n console.log(\"On/off state after first toggle\", agent.onOff.state);\n\n await agent.onOff.toggle();\n console.log(\"On/off state after second toggle\", agent.onOff.state);\n});\n\nawait node.close();\n"],
|
5
|
+
"mappings": "AAAA,OAAO;AACP,SAAS,wBAAwB;AACjC,SAAS,kBAAkB;AAE3B,MAAM,OAAO,MAAM,WAAW,OAAO;AAErC,MAAM,QAAQ,MAAM,KAAK,IAAI,gBAAgB;AAE7C,MAAM,KAAK,YAAY;AAEvB,MAAM,MAAM,IAAI,OAAM,UAAS;AAC3B,QAAM,MAAM,MAAM,OAAO;AACzB,UAAQ,IAAI,mCAAmC,MAAM,MAAM,KAAK;AAEhE,QAAM,MAAM,MAAM,OAAO;AACzB,UAAQ,IAAI,oCAAoC,MAAM,MAAM,KAAK;AACrE,CAAC;AAED,MAAM,KAAK,MAAM;",
|
6
|
+
"names": []
|
7
|
+
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@project-chip/matter-node.js-examples",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.8.0-alpha.0-20240309-64eaef67",
|
4
4
|
"description": "CLI/Reference implementation scripts for Matter protocol for node.js",
|
5
5
|
"keywords": [
|
6
6
|
"iot",
|
@@ -27,12 +27,14 @@
|
|
27
27
|
"clean": "matter-build clean",
|
28
28
|
"build": "matter-build",
|
29
29
|
"build-clean": "matter-build --clean",
|
30
|
+
"light": "matter-run src/examples/LightDevice.ts",
|
31
|
+
"excelsior1000": "matter-run src/examples/IlluminatedRollerShade.ts",
|
30
32
|
"matter-device": "matter-run src/examples/DeviceNode.ts",
|
31
33
|
"matter-bridge": "matter-run src/examples/BridgedDevicesNode.ts",
|
32
34
|
"matter-composeddevice": "matter-run src/examples/ComposedDeviceNode.ts",
|
33
35
|
"matter-multidevice": "matter-run src/examples/MultiDeviceNode.ts",
|
34
36
|
"matter-controller": "matter-run src/examples/ControllerNode.ts",
|
35
|
-
"bundle-device": "esbuild src/examples/DeviceNode.ts --bundle --platform=node --conditions=esbuild --external:@
|
37
|
+
"bundle-device": "esbuild src/examples/DeviceNode.ts --bundle --platform=node --conditions=esbuild --external:@stoprocent/bleno --external:@stoprocent/bluetooth-hci-socket --sourcemap --minify --outfile=build/bundle/DeviceNode.cjs",
|
36
38
|
"matter-device-bundled": "node --enable-source-maps build/bundle/DeviceNode.cjs"
|
37
39
|
},
|
38
40
|
"bin": {
|
@@ -46,9 +48,10 @@
|
|
46
48
|
"typescript": "^5.3.3"
|
47
49
|
},
|
48
50
|
"dependencies": {
|
49
|
-
"@project-chip/matter-node-ble.js": "0.
|
50
|
-
"@project-chip/matter-node.js": "0.
|
51
|
-
"@project-chip/matter.js
|
51
|
+
"@project-chip/matter-node-ble.js": "0.8.0-alpha.0-20240309-64eaef67",
|
52
|
+
"@project-chip/matter-node.js": "0.8.0-alpha.0-20240309-64eaef67",
|
53
|
+
"@project-chip/matter.js": "0.8.0-alpha.0-20240309-64eaef67",
|
54
|
+
"@project-chip/matter.js-tools": "0.8.0-alpha.0-20240309-64eaef67"
|
52
55
|
},
|
53
56
|
"engines": {
|
54
57
|
"_comment": "For Crypto.hkdf support",
|
@@ -64,5 +67,5 @@
|
|
64
67
|
"publishConfig": {
|
65
68
|
"access": "public"
|
66
69
|
},
|
67
|
-
"gitHead": "
|
70
|
+
"gitHead": "091e2d911a7396e4a67736099b7ceb31713b5863"
|
68
71
|
}
|