Skip to content

Commit

Permalink
Merge branch 'main' into nightly-release
Browse files Browse the repository at this point in the history
  • Loading branch information
Apollon77 authored Sep 19, 2024
2 parents b38258a + e72f47a commit 998d5e9
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 17 deletions.
35 changes: 24 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,13 @@ The main work (all changes without a GitHub username in brackets in the below li
- BREAKING: The "ByteArray" type is removed, replaced with native-JS Uint8Array and a small collection of utility functions in the "Bytes" namespace
- Feature: The default "Time" implementation is now fully functional across all standard JS runtimes

- @matter.js/main:
- This package is a new "one-and-done" dependency for applications. It automatically loads platform specialization and reexports pacakages above as appropriate

- @matter.js/model:
- The Matter object model previously exported as `@project-chip/matter.js/model` now resides in `@matter.js/model`
- Individual elements exported by name are now models (fully funcitonal classes) rather than elements (raw JSON data). This should be backwards compatible but makes them more useful operationally

- @matter.js/types:
- Various definitions previously defined in `@project-chip/matter.js` now reside in `@matter.js/types`. This includes most TLV structures, cluster definitions, and various support types
- Clusters are not exported in `@project-chip/matter.js`. You can import via `@project-chip/types/clusters` or individually (e.g. `@project-chip/types/clusters/window-covering`)

- @matter.js/protocol:
- Low-level Matter logic previously defined in `@project-chip/matter.js` now resides in `@matter.js/protocol`. This includes network communication, fabric management and cluster invocation, read/write, events, etc.
- BREAKING: Various types that were previously specialized with template parameters are no longer generic. This should be largely transparent to API consumers. Compatibility exports still support the generic parameters in some, but not all, cases.

- @matter.js/node:
- The high-level APIs previously defined in `@project-chip/matter.js` now reside in `@matter.js/node`. The Node API includes node management, behavior definitions and endpoint definitions
- We export behaviors under `@matter.js/node/behaviors` or individually (e.g. `@matter.js/node/behaviors/on-off`)
Expand All @@ -46,11 +41,29 @@ The main work (all changes without a GitHub username in brackets in the below li
- @matter.js/nodejs-ble
- The BLE specialization for Node.js is moved here. `@project-chip/matter-node-ble.js` remains as a compatibility import.

- matter.js-protocol:
- @matter.js/nodejs-shell:
- Enhancement: Added option to specify if attributes are loaded from remote or locally

- @matter.js/protocol:
- Low-level Matter logic previously defined in `@project-chip/matter.js` now resides in `@matter.js/protocol`. This includes network communication, fabric management and cluster invocation, read/write, events, etc.
- BREAKING: Various types that were previously specialized with template parameters are no longer generic. This should be largely transparent to API consumers. Compatibility exports still support the generic parameters in some, but not all, cases.
- Limits the number of parallel exchanges to 5

- @matter.js/main:
- This package is a new "one-and-done" dependency for applications. It automatically loads platform specialization and reexports pacakages above as appropriate
- @matter.js/types:
- Various definitions previously defined in `@project-chip/matter.js` now reside in `@matter.js/types`. This includes most TLV structures, cluster definitions, and various support types
- Clusters are not exported in `@project-chip/matter.js`. You can import via `@project-chip/types/clusters` or individually (e.g. `@project-chip/types/clusters/window-covering`)

## 0.10.4 (2024-09-16)

- matter.js API:
- Fix: Prevent trying to access PowerTopology attribute which is not always present
- Fix: Always add the endpoint device types first to the device type list

## 0.10.3 (2024-09-15)

- Matter-Core functionality:
- Fix: Fixes channel cleanup
- Fix: Fixes Subscription error handling

## 0.10.1 (2024-09-08)

Expand Down
4 changes: 3 additions & 1 deletion packages/nodejs-shell/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,16 @@ To unpair a node use `commission unpair <node-id>`. This will remove the node fr
The shell supports reading and writing attributes (top level command `attributes` or `a` as alias), reading events (`events`/`e`) and invoking commands (`commands`/`c`) on the node. Below these top level commands the full list of the officially defined clusters is available to be used. See the help for the relevant cluster for more details.

For reading attributes also a bulk read for all attributes is supported and with the `by-id` variant you can read and attribute from any cluster including custom clusters.
Attribute reads are done locally (when connected with a subscription and attribute is subscribable) by default. For remote reads (always from the node) add the `--remote` parameter. Unknown attributes or attributes from unknown clusters are always read remotely.

Writing attributes and executing commands (when the request requires data) these can be provided as JSON when it is no simple type. The shell will try to parse the JSON and send the data to the node. Binary data and Numbers >56bit needs to be provided as strings in this JSON and are automatically converted.
For convenience reasons any number in the value to write or invoke data can be provided as hex string by prefixing it with `0x` (e.g. `"0x1234"`) and is then also converted automatically.
When sending complex JSON content ideally use single quotes around the json because double quotes are used to define the JSON content.

Some examples:

- `attributes basicinformation read all 5000 0` reads all attributes from the Basic Information cluster from node 5000 endpoint 0
- `attributes basicinformation read all 5000 0` reads all attributes from the Basic Information cluster from node 5000 endpoint 0 (reads values locally when connected with subscription, else remote)
- `attributes basicinformation read all 5000 0 --remote` reads all attributes from the Basic Information cluster from node 5000 endpoint 0 always from remote (also when connected with a subscription)
- `attributes basicinformation read nodelabel 5000 0` reads the attribute "nodelabel" from the Basic Information cluster from node 5000 endpoint 0
- `attributes basicinformation read 0x5 5000 0` reads the attribute "nodelabel" (aliased with it's hex attribute id) from the Basic Information cluster from node 5000 endpoint 0
- `attributes by-id 0x28 read 0x5 5000 0` also reads the attribute "nodelabel" from the Basic Information cluster from node 5000 endpoint 0, but as generic read from the cluster with id 0x28 (also the decimal value 40 can be used)
Expand Down
24 changes: 20 additions & 4 deletions packages/nodejs-shell/src/shell/cmd_cluster-attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,19 @@ function generateClusterAttributeHandlers(yargs: Argv, cluster: ClusterModel, th
describe: "node id to read",
type: "string",
demandOption: true,
})
.options({
remote: {
describe: "request value always remote",
default: false,
type: "boolean",
},
});
},
async argv => {
const clusterId = cluster.id;
const { nodeId, endpointId } = argv;
const { nodeId, endpointId, remote } = argv;
const requestRemote = remote ? true : undefined;
const node = (await theNode.connectAndGetNodes(nodeId))[0];

const clusterClient = node
Expand All @@ -133,7 +141,7 @@ function generateClusterAttributeHandlers(yargs: Argv, cluster: ClusterModel, th
continue;
}
console.log(
` ${attributeName} (${attribute.id}): ${Logger.toJSON(await attributeClient.get())}`,
` ${attributeName} (${attribute.id}): ${Logger.toJSON(await attributeClient.get(requestRemote))}`,
);
}
},
Expand Down Expand Up @@ -200,9 +208,17 @@ function generateAttributeReadHandler(
describe: "node id to read",
type: "string",
demandOption: true,
})
.options({
remote: {
describe: "request value always remote",
default: false,
type: "boolean",
},
}),
async argv => {
const { nodeId, endpointId } = argv;
const { nodeId, endpointId, remote } = argv;
const requestRemote = remote ? true : undefined;
const node = (await theNode.connectAndGetNodes(nodeId))[0];

const clusterClient = node.getDeviceById(endpointId)?.getClusterClientById(ClusterId(clusterId));
Expand All @@ -219,7 +235,7 @@ function generateAttributeReadHandler(
}
try {
console.log(
`Attribute value for ${attributeName} ${node.nodeId.toString()}/${endpointId}/${clusterId}/${attribute.id}: ${Logger.toJSON(await attributeClient.get())}`,
`Attribute value for ${attributeName} ${node.nodeId.toString()}/${endpointId}/${clusterId}/${attribute.id}: ${Logger.toJSON(await attributeClient.get(requestRemote))}`,
);
} catch (error) {
console.log(`ERROR: Could not get attribute ${attribute.name}: ${error}`);
Expand Down
2 changes: 1 addition & 1 deletion packages/nodejs-shell/src/shell/cmd_nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export default function commands(theNode: MatterNode) {
)
.command(
"connect <node-id> [min-subscription-interval] [max-subscription-interval]",
"Connects to one or all cmmissioned nodes",
"Connects to one or all commissioned nodes",
yargs => {
return yargs
.positional("node-id", {
Expand Down

0 comments on commit 998d5e9

Please sign in to comment.