@matter/create
Advanced tools
Comparing version 0.12.4-alpha.0-20250209-00d44975c to 0.12.4-alpha.0-20250210-ad8edf096
@@ -124,15 +124,3 @@ #!/usr/bin/env node | ||
/** | ||
* Create Matter Server and Controller Node | ||
* | ||
* To allow the device to be announced, found, paired and operated we need a MatterServer instance and add a | ||
* CommissioningController to it and add the just created device instance to it. | ||
* The Controller node defines the port where the server listens for the UDP packages of the Matter protocol | ||
* and initializes deice specific certificates and such. | ||
* | ||
* The below logic also adds command handlers for commands of clusters that normally are handled internally | ||
* like testEventTrigger (General Diagnostic Cluster) that can be implemented with the logic when these commands | ||
* are called. | ||
*/ | ||
/** Create Matter Controller Node and bind it to the Environment. */ | ||
const commissioningController = new CommissioningController({ | ||
@@ -143,16 +131,12 @@ environment: { | ||
}, | ||
autoConnect: false, | ||
autoConnect: false, // Do not auto connect to the commissioned nodes | ||
adminFabricLabel, | ||
}); | ||
/** | ||
* Start the Matter Server | ||
* | ||
* After everything was plugged together we can start the server. When not delayed announcement is set for the | ||
* CommissioningServer node then this command also starts the announcement of the device into the network. | ||
*/ | ||
/** Start the Matter Controller Node */ | ||
await commissioningController.start(); | ||
// When we do not have a commissioned node we need to commission the device provided by CLI parameters | ||
if (!commissioningController.isCommissioned()) { | ||
const options = { | ||
const options: NodeCommissioningOptions = { | ||
commissioning: commissioningOptions, | ||
@@ -172,3 +156,3 @@ discovery: { | ||
passcode: setupPin, | ||
} as NodeCommissioningOptions; | ||
}; | ||
logger.info(`Commissioning ... ${Logger.toJSON(options)}`); | ||
@@ -180,5 +164,3 @@ const nodeId = await commissioningController.commissionNode(options); | ||
/** | ||
* TBD | ||
*/ | ||
// After commissioning or if we have a commissioned node we can connect to it | ||
try { | ||
@@ -193,7 +175,9 @@ const nodes = commissioningController.getCommissionedNodes(); | ||
// Trigger node connection. Returns once process started, events are there to wait for completion | ||
// By default will subscript to all attributes and events | ||
const node = await commissioningController.connectNode(nodeId); | ||
const nodeDetails = commissioningController.getCommissionedNodesDetails(); | ||
console.log("Commissioned nodes details:", Logger.toJSON(nodeDetails.find(node => node.nodeId === nodeId))); | ||
// React on generic events | ||
// Get the node instance | ||
const node = await commissioningController.getNode(nodeId); | ||
// Subscribe to events of the node | ||
node.events.attributeChanged.on(({ path: { nodeId, clusterId, endpointId, attributeName }, value }) => | ||
@@ -233,5 +217,12 @@ console.log( | ||
// Now wait till the structure of the node gor initialized (potentially with persisted data) | ||
await node.events.initialized; | ||
// Connect to the node if not already connected, this will automatically subscribe to all attributes and events | ||
if (!node.isConnected) { | ||
node.connect(); | ||
} | ||
// Wait for initialization oif not yet initialized - this should only happen if we just commissioned it | ||
if (!node.initialized) { | ||
await node.events.initialized; | ||
} | ||
// Or use this to wait for full remote initialization and reconnection. | ||
@@ -238,0 +229,0 @@ // Will only return when node is connected! |
@@ -8,5 +8,5 @@ { | ||
"dependencies": { | ||
"@matter/main": "~0.12.4-alpha.0-20250209-00d44975c", | ||
"@matter/nodejs-ble": "~0.12.4-alpha.0-20250209-00d44975c", | ||
"@project-chip/matter.js": "~0.12.4-alpha.0-20250209-00d44975c" | ||
"@matter/main": "~0.12.4-alpha.0-20250210-ad8edf096", | ||
"@matter/nodejs-ble": "~0.12.4-alpha.0-20250210-ad8edf096", | ||
"@project-chip/matter.js": "~0.12.4-alpha.0-20250210-ad8edf096" | ||
}, | ||
@@ -19,3 +19,3 @@ "description": "Controller example to commission and connect devices", | ||
"dependencies": { | ||
"@matter/main": "~0.12.4-alpha.0-20250209-00d44975c" | ||
"@matter/main": "~0.12.4-alpha.0-20250210-ad8edf096" | ||
}, | ||
@@ -28,3 +28,3 @@ "description": "Bridge for multiple OnOff light/sockets with a CLI command execution interface", | ||
"dependencies": { | ||
"@matter/main": "~0.12.4-alpha.0-20250209-00d44975c" | ||
"@matter/main": "~0.12.4-alpha.0-20250210-ad8edf096" | ||
}, | ||
@@ -37,3 +37,3 @@ "description": "Composed device for multiple OnOff light/sockets with a CLI command execution interface", | ||
"dependencies": { | ||
"@matter/main": "~0.12.4-alpha.0-20250209-00d44975c" | ||
"@matter/main": "~0.12.4-alpha.0-20250210-ad8edf096" | ||
}, | ||
@@ -46,3 +46,3 @@ "description": "Composed device with Window covering and a light endpoint that logs changes", | ||
"dependencies": { | ||
"@matter/main": "~0.12.4-alpha.0-20250209-00d44975c" | ||
"@matter/main": "~0.12.4-alpha.0-20250210-ad8edf096" | ||
}, | ||
@@ -67,5 +67,5 @@ "description": "Socket device that reports random Energy and Power measurements", | ||
"dependencies": { | ||
"@matter/nodejs": "~0.12.4-alpha.0-20250209-00d44975c", | ||
"@matter/nodejs-ble": "~0.12.4-alpha.0-20250209-00d44975c", | ||
"@matter/main": "~0.12.4-alpha.0-20250209-00d44975c" | ||
"@matter/nodejs": "~0.12.4-alpha.0-20250210-ad8edf096", | ||
"@matter/nodejs-ble": "~0.12.4-alpha.0-20250210-ad8edf096", | ||
"@matter/main": "~0.12.4-alpha.0-20250210-ad8edf096" | ||
}, | ||
@@ -78,3 +78,3 @@ "description": "OnOff light/socket device with BLE support and advanced API usage", | ||
"dependencies": { | ||
"@matter/main": "~0.12.4-alpha.0-20250209-00d44975c" | ||
"@matter/main": "~0.12.4-alpha.0-20250210-ad8edf096" | ||
}, | ||
@@ -87,3 +87,3 @@ "description": "OnOff light example which logs the state changes to the console", | ||
"dependencies": { | ||
"@matter/main": "~0.12.4-alpha.0-20250209-00d44975c" | ||
"@matter/main": "~0.12.4-alpha.0-20250210-ad8edf096" | ||
}, | ||
@@ -96,3 +96,3 @@ "description": "Temperature/Humidity sensor with a CLI command interface to get the value", | ||
"dependencies": { | ||
"@matter/main": "~0.12.4-alpha.0-20250209-00d44975c" | ||
"@matter/main": "~0.12.4-alpha.0-20250210-ad8edf096" | ||
}, | ||
@@ -99,0 +99,0 @@ "description": "A simple on/off device", |
{ | ||
"name": "@matter/create", | ||
"version": "0.12.4-alpha.0-20250209-00d44975c", | ||
"version": "0.12.4-alpha.0-20250210-ad8edf096", | ||
"description": "Matter.js skeleton project generator", | ||
@@ -35,3 +35,3 @@ "type": "module", | ||
"devDependencies": { | ||
"@matter/tools": "0.12.4-alpha.0-20250209-00d44975c", | ||
"@matter/tools": "0.12.4-alpha.0-20250210-ad8edf096", | ||
"@types/node": "^22.10.10", | ||
@@ -38,0 +38,0 @@ "@types/tar-stream": "^3.1.3" |
200929
4121