@matter/examples 0.16.0-alpha.0-20250912-0d12bf718 → 0.16.0-alpha.0-20250916-d577beb1d
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/dist/esm/controller/ControllerNode.js +21 -24
- package/dist/esm/controller/ControllerNode.js.map +1 -1
- package/dist/esm/device-onoff-advanced/DeviceNodeFull.js +3 -12
- package/dist/esm/device-onoff-advanced/DeviceNodeFull.js.map +1 -1
- package/package.json +6 -6
- package/src/controller/ControllerNode.ts +32 -30
- package/src/controller/README.md +1 -1
- package/src/device-onoff-advanced/DeviceNodeFull.ts +8 -16
|
@@ -4,23 +4,16 @@
|
|
|
4
4
|
* Copyright 2022-2025 Matter.js Authors
|
|
5
5
|
* SPDX-License-Identifier: Apache-2.0
|
|
6
6
|
*/
|
|
7
|
-
import { Diagnostic, Environment, Logger,
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { Diagnostic, Environment, Logger, StorageService, Time } from "@matter/main";
|
|
8
|
+
import { DescriptorClient } from "@matter/main/behaviors/descriptor";
|
|
9
|
+
import { OnOffClient } from "@matter/main/behaviors/on-off";
|
|
10
|
+
import { BasicInformationCluster, Descriptor, GeneralCommissioning } from "@matter/main/clusters";
|
|
10
11
|
import { ManualPairingCodeCodec, NodeId } from "@matter/main/types";
|
|
11
|
-
import { NodeJsBle } from "@matter/nodejs-ble";
|
|
12
12
|
import { CommissioningController } from "@project-chip/matter.js";
|
|
13
13
|
import { NodeStates } from "@project-chip/matter.js/device";
|
|
14
|
+
import "@matter/nodejs-ble";
|
|
14
15
|
const logger = Logger.get("Controller");
|
|
15
16
|
const environment = Environment.default;
|
|
16
|
-
if (environment.vars.get("ble")) {
|
|
17
|
-
Ble.get = singleton(
|
|
18
|
-
() => new NodeJsBle({
|
|
19
|
-
environment,
|
|
20
|
-
hciId: environment.vars.number("ble.hci.id")
|
|
21
|
-
})
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
17
|
const storageService = environment.get(StorageService);
|
|
25
18
|
console.log(`Storage location: ${storageService.location} (Directory)`);
|
|
26
19
|
logger.info(
|
|
@@ -159,10 +152,17 @@ class ControllerNode {
|
|
|
159
152
|
await node.events.initialized;
|
|
160
153
|
}
|
|
161
154
|
node.logStructure();
|
|
162
|
-
const
|
|
155
|
+
const descriptorState = node.stateOf(DescriptorClient);
|
|
156
|
+
if (descriptorState !== void 0) {
|
|
157
|
+
console.log("deviceTypeList", descriptorState.deviceTypeList);
|
|
158
|
+
} else {
|
|
159
|
+
console.log("No Descriptor Cluster found. This should never happen!");
|
|
160
|
+
}
|
|
161
|
+
const descriptor = node.getRootClusterClient(Descriptor.Complete);
|
|
163
162
|
if (descriptor !== void 0) {
|
|
164
|
-
console.log(
|
|
163
|
+
console.log(descriptor.getTagListAttributeFromCache());
|
|
165
164
|
console.log(await descriptor.getServerListAttribute());
|
|
165
|
+
console.log(await descriptor.attributes.clientList.get());
|
|
166
166
|
} else {
|
|
167
167
|
console.log("No Descriptor Cluster found. This should never happen!");
|
|
168
168
|
}
|
|
@@ -172,18 +172,15 @@ class ControllerNode {
|
|
|
172
172
|
} else {
|
|
173
173
|
console.log("No BasicInformation Cluster found. This should never happen!");
|
|
174
174
|
}
|
|
175
|
-
const
|
|
176
|
-
if (
|
|
177
|
-
const
|
|
178
|
-
if (
|
|
179
|
-
let onOffStatus =
|
|
175
|
+
const endpointOne = node.parts.get(1);
|
|
176
|
+
if (endpointOne) {
|
|
177
|
+
const onOffState = endpointOne.stateOf(OnOffClient);
|
|
178
|
+
if (onOffState !== void 0) {
|
|
179
|
+
let onOffStatus = onOffState.onOff;
|
|
180
180
|
console.log("initial onOffStatus", onOffStatus);
|
|
181
|
-
|
|
182
|
-
console.log("subscription onOffStatus", value);
|
|
183
|
-
onOffStatus = value;
|
|
184
|
-
});
|
|
181
|
+
const onOffCommands = endpointOne.commandsOf(OnOffClient);
|
|
185
182
|
setInterval(() => {
|
|
186
|
-
|
|
183
|
+
onOffCommands.toggle().then(() => {
|
|
187
184
|
onOffStatus = !onOffStatus;
|
|
188
185
|
console.log("onOffStatus", onOffStatus);
|
|
189
186
|
}).catch((error) => logger.error(error));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/controller/ControllerNode.ts"],
|
|
4
|
-
"mappings": ";AACA;AAAA;AAAA;AAAA;AAAA;AAYA,SAAS,YAAY,aAAa,QAAQ,
|
|
4
|
+
"mappings": ";AACA;AAAA;AAAA;AAAA;AAAA;AAYA,SAAS,YAAY,aAAa,QAAQ,gBAAgB,YAAY;AACtE,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB,YAAY,4BAA4B;AAC1E,SAAS,wBAAwB,cAAc;AAC/C,SAAS,+BAAyD;AAClE,SAAS,kBAAkB;AAG3B,OAAO;AAEP,MAAM,SAAS,OAAO,IAAI,YAAY;AAEtC,MAAM,cAAc,YAAY;AAEhC,MAAM,iBAAiB,YAAY,IAAI,cAAc;AAErD,QAAQ,IAAI,qBAAqB,eAAe,QAAQ,cAAc;AACtE,OAAO;AAAA,EACH;AACJ;AAEA,MAAM,eAAe;AAAA,EACjB,MAAM,QAAQ;AACV,WAAO,KAAK,gCAAgC;AAa5C,UAAM,qBAAqB,MAAM,eAAe,KAAK,YAAY,GAAG,cAAc,MAAM;AACxF,UAAM,KAAM,MAAM,kBAAkB,IAAI,IAAI,IACtC,MAAM,kBAAkB,IAAY,IAAI,IACxC,YAAY,KAAK,OAAO,IAAI;AAClC,UAAM,OAAQ,MAAM,kBAAkB,IAAI,MAAM,IAC1C,MAAM,kBAAkB,IAAY,MAAM,IAC1C,YAAY,KAAK,OAAO,MAAM;AACpC,UAAM,WAAY,MAAM,kBAAkB,IAAI,UAAU,IAClD,MAAM,kBAAkB,IAAY,UAAU,IAC7C,YAAY,KAAK,OAAO,UAAU,KAAK,KAAK,MAAM,SAAS;AAClE,UAAM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O,MAAM,KAAK,CAAC;",
|
|
5
5
|
"names": ["node", "nodeId", "info"]
|
|
6
6
|
}
|
|
@@ -15,8 +15,7 @@ import {
|
|
|
15
15
|
ServerNode,
|
|
16
16
|
StorageService,
|
|
17
17
|
Time,
|
|
18
|
-
VendorId
|
|
19
|
-
singleton
|
|
18
|
+
VendorId
|
|
20
19
|
} from "@matter/main";
|
|
21
20
|
import { OnOffServer } from "@matter/main/behaviors";
|
|
22
21
|
import { NetworkCommissioning, OnOff } from "@matter/main/clusters";
|
|
@@ -25,23 +24,15 @@ import { RootRequirements } from "@matter/main/endpoints";
|
|
|
25
24
|
import { Ble, FabricAction } from "@matter/main/protocol";
|
|
26
25
|
import { QrCode } from "@matter/main/types";
|
|
27
26
|
import { createFileLogger } from "@matter/nodejs";
|
|
28
|
-
import { NodeJsBle } from "@matter/nodejs-ble";
|
|
29
27
|
import { execSync } from "node:child_process";
|
|
30
28
|
import { DummyThreadNetworkCommissioningServer } from "./cluster/DummyThreadNetworkCommissioningServer.js";
|
|
31
29
|
import { DummyWifiNetworkCommissioningServer } from "./cluster/DummyWifiNetworkCommissioningServer.js";
|
|
32
30
|
import {
|
|
33
31
|
MyFancyOwnFunctionalityBehavior
|
|
34
32
|
} from "./cluster/MyFancyOwnFunctionality.js";
|
|
33
|
+
import "@matter/nodejs-ble";
|
|
35
34
|
const logger = Logger.get("DeviceNodeFull");
|
|
36
35
|
const environment = Environment.default;
|
|
37
|
-
if (environment.vars.get("ble.enable")) {
|
|
38
|
-
Ble.get = singleton(
|
|
39
|
-
() => new NodeJsBle({
|
|
40
|
-
environment,
|
|
41
|
-
hciId: environment.vars.number("ble.hciId")
|
|
42
|
-
})
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
36
|
function executeCommand(scriptParamName) {
|
|
46
37
|
const script = environment.vars.string(scriptParamName);
|
|
47
38
|
if (script === void 0) return void 0;
|
|
@@ -157,7 +148,7 @@ const server = await ServerNode.create(RootEndpoint, {
|
|
|
157
148
|
}
|
|
158
149
|
});
|
|
159
150
|
const networkId = new Uint8Array(32);
|
|
160
|
-
if (Ble
|
|
151
|
+
if (environment.has(Ble)) {
|
|
161
152
|
if (environment.vars.has("ble.wifi.fake")) {
|
|
162
153
|
server.behaviors.require(DummyWifiNetworkCommissioningServer, {
|
|
163
154
|
maxNetworks: 1,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/device-onoff-advanced/DeviceNodeFull.ts"],
|
|
4
|
-
"mappings": ";AACA;AAAA;AAAA;AAAA;AAAA;AAqBA;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,
|
|
4
|
+
"mappings": ";AACA;AAAA;AAAA;AAAA;AAAA;AAqBA;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AACP,SAAS,mBAAmB;AAC5B,SAA6B,sBAAsB,aAAa;AAChE,SAAS,kBAAkB,6BAA6B;AACxD,SAAS,wBAAwB;AACjC,SAAS,KAAK,oBAAoB;AAClC,SAAS,cAAc;AACvB,SAAS,wBAAwB;AACjC,SAAS,gBAAgB;AACzB,SAAS,6CAA6C;AACtD,SAAS,2CAA2C;AACpD;AAAA,EAGI;AAAA,OACG;AAOP,OAAO;AAEP,MAAM,SAAS,OAAO,IAAI,gBAAgB;AAe1C,MAAM,cAAc,YAAY;AAEhC,SAAS,eAAe,iBAAyB;AAC7C,QAAM,SAAS,YAAY,KAAK,OAAO,eAAe;AACtD,MAAI,WAAW,OAAW,QAAO;AACjC,UAAQ,IAAI,GAAG,eAAe,KAAK,SAAS,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,EAAE,CAAC,EAAE;AACjF;AAYA,M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C1E,CAAC;AAED,SAAS,OAAO,SAAS,gBAAgB,GAAG,MAAM;AAC9C,UAAQ,IAAI,yBAAyB;AACzC,CAAC;AAOD,OAAO,KAAK,MAAM;AAOlB,MAAM,OAAO,MAAM;AAKnB,IAAI,CAAC,OAAO,UAAU,gBAAgB;AAClC,QAAM,EAAE,eAAe,kBAAkB,IAAI,OAAO,MAAM,cAAc;AAExE,UAAQ,IAAI,OAAO,IAAI,aAAa,CAAC;AACrC,UAAQ,IAAI,gFAAgF,aAAa,EAAE;AAC3G,UAAQ,IAAI,wBAAwB,iBAAiB,EAAE;AAC3D,OAAO;AACH,UAAQ,IAAI,wEAAwE;AASpF,QAAM,aAAa,SAAS,MAAM,MAAM;AACxC,UAAQ,IAAI,4BAA4B,UAAU,EAAE;AAEpD,MAAI,aAAa,OAAQ;AAErB,UAAM,SAAS,IAAI;AAAA,MACf,OAAO;AAAA,QACH,OAAO,CAAC;AAAA,MACZ;AAAA;AAAA,MAEA,yBAAyB;AAAA,QACrB,cAAc;AAAA,MAClB;AAAA,IACJ,CAAC;AAAA,EACL,OAAO;AAEH,UAAM,SAAS,IAAI;AAAA,MACf,OAAO;AAAA,QACH,OAAO,CAAC;AAAA,MACZ;AAAA,IACJ,CAAC;AAAA,EACL;AACJ;AAKA,QAAQ,GAAG,UAAU,MAAM;AAEvB,SACK,MAAM,EACN,KAAK,MAAM,QAAQ,KAAK,CAAC,CAAC,EAC1B,MAAM,SAAO,QAAQ,MAAM,GAAG,CAAC;AACxC,CAAC;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matter/examples",
|
|
3
|
-
"version": "0.16.0-alpha.0-
|
|
3
|
+
"version": "0.16.0-alpha.0-20250916-d577beb1d",
|
|
4
4
|
"description": "Matter.js examples and reference implementations",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"iot",
|
|
@@ -55,14 +55,14 @@
|
|
|
55
55
|
"matter-controller": "dist/esm/controller/ControllerNode.js"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@matter/main": "0.16.0-alpha.0-
|
|
59
|
-
"@matter/nodejs": "0.16.0-alpha.0-
|
|
60
|
-
"@matter/tools": "0.16.0-alpha.0-
|
|
61
|
-
"@project-chip/matter.js": "0.16.0-alpha.0-
|
|
58
|
+
"@matter/main": "0.16.0-alpha.0-20250916-d577beb1d",
|
|
59
|
+
"@matter/nodejs": "0.16.0-alpha.0-20250916-d577beb1d",
|
|
60
|
+
"@matter/tools": "0.16.0-alpha.0-20250916-d577beb1d",
|
|
61
|
+
"@project-chip/matter.js": "0.16.0-alpha.0-20250916-d577beb1d",
|
|
62
62
|
"esbuild": "^0.25.9"
|
|
63
63
|
},
|
|
64
64
|
"optionalDependencies": {
|
|
65
|
-
"@matter/nodejs-ble": "0.16.0-alpha.0-
|
|
65
|
+
"@matter/nodejs-ble": "0.16.0-alpha.0-20250916-d577beb1d"
|
|
66
66
|
},
|
|
67
67
|
"engines": {
|
|
68
68
|
"node": ">=20.19.0 <22.0.0 || >=22.13.0"
|
|
@@ -11,29 +11,21 @@
|
|
|
11
11
|
* because you need to adjust the code in any way depending on your use case.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import { Diagnostic, Environment, Logger,
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
14
|
+
import { Diagnostic, Environment, Logger, StorageService, Time } from "@matter/main";
|
|
15
|
+
import { DescriptorClient } from "@matter/main/behaviors/descriptor";
|
|
16
|
+
import { OnOffClient } from "@matter/main/behaviors/on-off";
|
|
17
|
+
import { BasicInformationCluster, Descriptor, GeneralCommissioning } from "@matter/main/clusters";
|
|
17
18
|
import { ManualPairingCodeCodec, NodeId } from "@matter/main/types";
|
|
18
|
-
import { NodeJsBle } from "@matter/nodejs-ble";
|
|
19
19
|
import { CommissioningController, NodeCommissioningOptions } from "@project-chip/matter.js";
|
|
20
20
|
import { NodeStates } from "@project-chip/matter.js/device";
|
|
21
21
|
|
|
22
|
+
// This installs BLE support if configuration variable "ble.enable" is true
|
|
23
|
+
import "@matter/nodejs-ble";
|
|
24
|
+
|
|
22
25
|
const logger = Logger.get("Controller");
|
|
23
26
|
|
|
24
27
|
const environment = Environment.default;
|
|
25
28
|
|
|
26
|
-
if (environment.vars.get("ble")) {
|
|
27
|
-
// Initialize Ble
|
|
28
|
-
Ble.get = singleton(
|
|
29
|
-
() =>
|
|
30
|
-
new NodeJsBle({
|
|
31
|
-
environment,
|
|
32
|
-
hciId: environment.vars.number("ble.hci.id"),
|
|
33
|
-
}),
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
29
|
const storageService = environment.get(StorageService);
|
|
38
30
|
|
|
39
31
|
console.log(`Storage location: ${storageService.location} (Directory)`);
|
|
@@ -229,16 +221,28 @@ class ControllerNode {
|
|
|
229
221
|
|
|
230
222
|
node.logStructure();
|
|
231
223
|
|
|
232
|
-
// Example to
|
|
233
|
-
|
|
224
|
+
// Example to conveniently access cluster states in a typed manner and read the data from the local cache
|
|
225
|
+
// This is the new preferred way to access the latest known cluster data
|
|
226
|
+
const descriptorState = node.stateOf(DescriptorClient);
|
|
227
|
+
if (descriptorState !== undefined) {
|
|
228
|
+
console.log("deviceTypeList", descriptorState.deviceTypeList); // you can access the state that way
|
|
229
|
+
} else {
|
|
230
|
+
console.log("No Descriptor Cluster found. This should never happen!");
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// Alternatively you can access concrete fields as API methods by creating a ClusterClient and
|
|
234
|
+
// reading the data from the device or local cache
|
|
235
|
+
const descriptor = node.getRootClusterClient(Descriptor.Complete);
|
|
234
236
|
if (descriptor !== undefined) {
|
|
235
|
-
console.log(
|
|
236
|
-
console.log(await descriptor.getServerListAttribute()); //
|
|
237
|
+
console.log(descriptor.getTagListAttributeFromCache()); // Convenient that way from local cache
|
|
238
|
+
console.log(await descriptor.getServerListAttribute()); // Convenient that way (async!)
|
|
239
|
+
console.log(await descriptor.attributes.clientList.get()); // or more low level that way (async!)
|
|
237
240
|
} else {
|
|
238
241
|
console.log("No Descriptor Cluster found. This should never happen!");
|
|
239
242
|
}
|
|
240
243
|
|
|
241
|
-
// Example to subscribe to a field and get the value
|
|
244
|
+
// Example to subscribe to a field and get the value, normally this is not needed because by default
|
|
245
|
+
// all attributes are subscribed automatically!
|
|
242
246
|
const info = node.getRootClusterClient(BasicInformationCluster);
|
|
243
247
|
if (info !== undefined) {
|
|
244
248
|
console.log(await info.getProductNameAttribute()); // This call is executed remotely
|
|
@@ -260,25 +264,23 @@ class ControllerNode {
|
|
|
260
264
|
//const attributesBasicInformation = await interactionClient.getMultipleAttributes([{ endpointId: 0, clusterId: BasicInformationCluster.id} ]);
|
|
261
265
|
//console.log("Attributes-BasicInformation:", JSON.stringify(attributesBasicInformation, null, 2));
|
|
262
266
|
|
|
263
|
-
const
|
|
264
|
-
if (
|
|
267
|
+
const endpointOne = node.parts.get(1);
|
|
268
|
+
if (endpointOne) {
|
|
265
269
|
// Example to subscribe to all Attributes of endpoint 1 of the commissioned node: */*/*
|
|
266
270
|
//await interactionClient.subscribeMultipleAttributes([{ endpointId: 1, /* subscribe anything from endpoint 1 */ }], 0, 180, data => {
|
|
267
271
|
// console.log("Subscribe-All Data:", Diagnostic.json(data));
|
|
268
272
|
//});
|
|
269
273
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
274
|
+
// Example using the new convenient typed access to state and commands of the OnOff cluster
|
|
275
|
+
const onOffState = endpointOne.stateOf(OnOffClient);
|
|
276
|
+
if (onOffState !== undefined) {
|
|
277
|
+
let onOffStatus = onOffState.onOff;
|
|
273
278
|
console.log("initial onOffStatus", onOffStatus);
|
|
274
279
|
|
|
275
|
-
|
|
276
|
-
console.log("subscription onOffStatus", value);
|
|
277
|
-
onOffStatus = value;
|
|
278
|
-
});
|
|
280
|
+
const onOffCommands = endpointOne.commandsOf(OnOffClient);
|
|
279
281
|
// read data every minute to keep up the connection to show the subscription is working
|
|
280
282
|
setInterval(() => {
|
|
281
|
-
|
|
283
|
+
onOffCommands
|
|
282
284
|
.toggle()
|
|
283
285
|
.then(() => {
|
|
284
286
|
onOffStatus = !onOffStatus;
|
package/src/controller/README.md
CHANGED
|
@@ -35,7 +35,7 @@ The following parameters are available and used to initially commission a device
|
|
|
35
35
|
* --longDiscriminator: the discriminator to use for pairing (default: 3840, value between 0 and 4095)
|
|
36
36
|
* --passcode: the passcode to use for pairing (default: 20202021)
|
|
37
37
|
* When the device to commission is not already in the IP network and also not an Ethernet device commission can be done via ble. In this case the following parameters are used:
|
|
38
|
-
* --ble: enable BLE support (default: false) If this is enabled the controller will try to connect via BLE first (15s timeout) and then via IP if not commissioned yet!
|
|
38
|
+
* --ble-enable: enable BLE support (default: false) If this is enabled the controller will try to connect via BLE first (15s timeout) and then via IP if not commissioned yet!
|
|
39
39
|
* --ble-hci-id: Optionally, HCI ID to use (Linux only, default 0)
|
|
40
40
|
* --ble-wifi-ssid: SSID/Name of the Wifi network to connect to - The device will scan especially for this network and commissioning will fail if not found
|
|
41
41
|
* --ble-wifi-credentials: Credentials for the Wifi network to connect to
|
|
@@ -32,7 +32,6 @@ import {
|
|
|
32
32
|
StorageService,
|
|
33
33
|
Time,
|
|
34
34
|
VendorId,
|
|
35
|
-
singleton,
|
|
36
35
|
} from "@matter/main";
|
|
37
36
|
import { OnOffServer } from "@matter/main/behaviors";
|
|
38
37
|
import { GeneralDiagnostics, NetworkCommissioning, OnOff } from "@matter/main/clusters";
|
|
@@ -41,7 +40,6 @@ import { RootRequirements } from "@matter/main/endpoints";
|
|
|
41
40
|
import { Ble, FabricAction } from "@matter/main/protocol";
|
|
42
41
|
import { QrCode } from "@matter/main/types";
|
|
43
42
|
import { createFileLogger } from "@matter/nodejs";
|
|
44
|
-
import { NodeJsBle } from "@matter/nodejs-ble";
|
|
45
43
|
import { execSync } from "node:child_process";
|
|
46
44
|
import { DummyThreadNetworkCommissioningServer } from "./cluster/DummyThreadNetworkCommissioningServer.js";
|
|
47
45
|
import { DummyWifiNetworkCommissioningServer } from "./cluster/DummyWifiNetworkCommissioningServer.js";
|
|
@@ -51,6 +49,13 @@ import {
|
|
|
51
49
|
MyFancyOwnFunctionalityBehavior,
|
|
52
50
|
} from "./cluster/MyFancyOwnFunctionality.js";
|
|
53
51
|
|
|
52
|
+
// This installs BLE support if:
|
|
53
|
+
//
|
|
54
|
+
// - The environment.vars value "ble.enable" is true
|
|
55
|
+
// - The command line flag "--ble-enable" is set
|
|
56
|
+
// - The system environment variable "BLE_ENABLE" is set
|
|
57
|
+
import "@matter/nodejs-ble";
|
|
58
|
+
|
|
54
59
|
const logger = Logger.get("DeviceNodeFull");
|
|
55
60
|
|
|
56
61
|
/**
|
|
@@ -68,19 +73,6 @@ const logger = Logger.get("DeviceNodeFull");
|
|
|
68
73
|
|
|
69
74
|
const environment = Environment.default;
|
|
70
75
|
|
|
71
|
-
// Alternatively "--ble-enable" or environment variable "BLE_ENABLED"
|
|
72
|
-
// Alternatively "--ble-hciId" or environment variable "BLE_HCIID"
|
|
73
|
-
if (environment.vars.get("ble.enable")) {
|
|
74
|
-
// Initialize Ble
|
|
75
|
-
Ble.get = singleton(
|
|
76
|
-
() =>
|
|
77
|
-
new NodeJsBle({
|
|
78
|
-
environment,
|
|
79
|
-
hciId: environment.vars.number("ble.hciId"),
|
|
80
|
-
}),
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
76
|
function executeCommand(scriptParamName: string) {
|
|
85
77
|
const script = environment.vars.string(scriptParamName);
|
|
86
78
|
if (script === undefined) return undefined;
|
|
@@ -261,7 +253,7 @@ const server = await ServerNode.create(RootEndpoint, {
|
|
|
261
253
|
});
|
|
262
254
|
|
|
263
255
|
const networkId = new Uint8Array(32);
|
|
264
|
-
if (Ble
|
|
256
|
+
if (environment.has(Ble)) {
|
|
265
257
|
// matter.js will create an Ethernet-only device by default when it comes to Network Commissioning Features.
|
|
266
258
|
// To offer e.g. a "Wi-Fi only device" (or any other combination) we need to override the Network Commissioning
|
|
267
259
|
// cluster and implement all the need handling here. This is a "static implementation" for pure demonstration
|