forked from project-chip/connectedhomeip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add readme and additional functions for controller
- Loading branch information
Showing
2 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Running the drinks machine app and controller | ||
|
||
To run this example matter application, you need a version of the example app | ||
and a controller. The example app can be compiled with gn / ninja, the | ||
controller functions can be used through the chip-repl python shell | ||
|
||
## App | ||
|
||
### Compiling the app on linux | ||
|
||
From the root of the chip tree | ||
|
||
``` | ||
cd examples/valve/linux | ||
gn gen out/debug | ||
ninja -C out/debug | ||
``` | ||
|
||
### Running the app on linux | ||
|
||
From the root of the chip tree | ||
|
||
``` | ||
./examples/valve/linux/out/debug/valve-app --KVS /tmp/valve_kvs.json | ||
``` | ||
|
||
The KVS file is where the commissioning data is stored for the app, so be sure | ||
to start the app with the same kvs file if you do not want to re-commission it | ||
every time. All the standard linux app flags also work for this app. Use --help | ||
to see the available options. | ||
|
||
## Controller | ||
|
||
### Compiling the chip-repl | ||
|
||
To compile the chip-repl, from the root of the chip tree: | ||
|
||
``` | ||
. scripts/activate.sh | ||
./scripts/build_python.sh -i out/pyenv | ||
source out/pyenv/activate | ||
out/pyenv/chip-repl -- | ||
``` | ||
|
||
The chip-repl is a shell that lets you directly call python functions. It | ||
instantiates a controller object that can be used to communicate with devices. | ||
The controller is called devCtrl. By default, its KVS is at | ||
/tmp/repl-storage.json, but this can be changed on the command line if desired. | ||
Use --help to see options. | ||
|
||
### Commissioning the valve app | ||
|
||
As long as the controller and the application KVSs are kept constant, the app | ||
should only need to be commissioned once. | ||
|
||
To commission the device use: | ||
|
||
``` | ||
from chip import ChipDeviceCtrl | ||
await devCtrl.CommissionOnNetwork(nodeId=1, setupPinCode=20202021, filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=3840) | ||
``` | ||
|
||
### Interacting with teh valve app | ||
|
||
To create a drinks machine controller: | ||
|
||
``` | ||
import examples.valve.controller as DrinksController | ||
dm = DrinksController.DrinkMachine(devCtrl, 1) | ||
``` | ||
|
||
You can now call functions on the drinks machine controller. Tab completion will | ||
work within the repl, so you can see the available options. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters