Skip to content

Commit

Permalink
Enhance example device readme (#1598)
Browse files Browse the repository at this point in the history
  • Loading branch information
Apollon77 authored Dec 31, 2024
1 parent 3d402d8 commit c3ec2d7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
26 changes: 25 additions & 1 deletion packages/examples/src/device-onoff-advanced/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,34 @@ This example shows how to build a simple Device node with just one socket or lig

For general documentation about the CLI parameters or environment variables that can be used for matter.js please refer to the [Examples README](../../../README.md#cli-usage).

The CLI parameter are else documented at the [Device Node Readme](../device-onoff-cli/README.md).
The CLI parameter are else documented at the [Device Node Readme](../device-onoff/README.md).

This example is not exposed as npm script so starting requires to run the ts file or the build file.

```bash
node .dist/examples/device-onoff-advanced-cli/DeviceNodeFull.js
```

## How to test BLE commissioning
For this to work you first of all need to enable BLE by using `--ble-enable` to enable the BLE only commissioning. The device simulates that it is not on any IP network for the start.
Please also make sure you follow the [BLE enablement steps for your operating system](../../../nodejs-ble/README.md#prerequisites-and-limitations).

The following parameters are available:
* --ble: enable BLE support (default: false) If this is enabled the device will announce itself _only_ via BLE if not commissioned and also presents a "Wifi only" device for commissioning to show this feature!
* --ble-hci-id: Optionally, HCI ID to use (Linux only, default 0)

Additionally, you need to choose if the device should simulate a Thread or a Wifi enabled device. This can be done by adding `--ble-fake-wifi` or `--ble-fake-thread` to the command line. Then a dummy WifiNetworkCommissioning or ThreadNetworkCommissioning cluster is added to the device node.

Depending on the method you chose you probably need to also add additional parameters for either Wifi or thread which are returned when the device is asked to scn for available networks.

For Wifi the parameters to use are:
* --ble-wifi-scan-ssid: The Wi-Fi SSID returned by the "ScanNetworks" call of the Wifi Network commissioning cluster used when using BLE commissioning (default: "TestSSID"). Ideally use a really existing SSID that also the commissioner (Apple, Alexa, ...) knows to make it easier to commission. Else you could get errors while commissioning.
* --ble-wifi-scan-bssid: The Wi-Fi BSSID returned by the "ScanNetworks" call of the Wifi Network commissioning cluster used when using BLE commissioning (default: "00:00:00:00:00:00").

For Thread the parameters to use are:
* --ble.thread.pan-id: The PAN ID to use for the Thread network
* --ble.thread.extended-pan-id: The extended PAN ID to use for the Thread network
* --ble.thread.network-name: The network name to use for the Thread network
* --ble.thread.channel: The channel to use for the Thread network
* --ble.thread.address: The address to use for the Thread network
Thread parameters are as of now only needed when commissioning with Amazon because the others are currently not scanning for Thread networks.
6 changes: 0 additions & 6 deletions packages/examples/src/device-onoff/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,11 @@ The following parameters are available:
* --uniqueid: a unique ID for this device to be used in naming and to store structure information (default: ms time now)
* --type: the device type to use for pairing (default: light, alternative value is "socket")
* --netinterface: limit mdns announcements and scanning to the provided network interface, e.g. "en0" (default: all interfaces available)
* --ble: enable BLE support (default: false) If this is enabled the device will announce itself _only_ via BLE if not commissioned and also presents a "Wifi only" device for commissioning to show this feature!
* --ble-hci-id: Optionally, HCI ID to use (Linux only, default 0)
* --port: the port to listen on for the device (default: 5540)
* --store: the storage location (directory) to use for storing the pairing information (default: .device-node). Ideally use names starting with a ".". Delete the directory or provide an alternative name to reset the device
* --on: the command to run when the device is turned on (see example above)
* --off: the command to run when the device is turned off (see example above)

Additionally, there are some Testing parameters:
* --ble-wifi-scan-ssid: The Wi-Fi SSID returned by the "ScanNetworks" call of the Wifi Network commissioning cluster used when using BLE commissioning (default: "TestSSID"). Ideally use a really existing SSID that also the commissioner (Apple, Alexa, ...) knows to make it easier to commission. Else you could get errors while commissioning.
* --ble-wifi-scan-bssid: The Wi-Fi BSSID returned by the "ScanNetworks" call of the Wifi Network commissioning cluster used when using BLE commissioning (default: "00:00:00:00:00:00").

## Bundling

For production environments where space and/or CPU is at a premium, you might consider using a bundler to distribute your application. This project includes an example demonstrating how to create such a bundle using [esbuild](https://esbuild.github.io/).
Expand Down

0 comments on commit c3ec2d7

Please sign in to comment.