|
| 1 | +# Running the drinks machine app and controller |
| 2 | + |
| 3 | +To run this example matter application, you need a version of the example app |
| 4 | +and a controller. The example app can be compiled with gn / ninja, the |
| 5 | +controller functions can be used through the chip-repl python shell |
| 6 | + |
| 7 | +## App |
| 8 | + |
| 9 | +### Compiling the app on linux |
| 10 | + |
| 11 | +From the root of the chip tree |
| 12 | + |
| 13 | +``` |
| 14 | +cd examples/valve/linux |
| 15 | +gn gen out/debug |
| 16 | +ninja -C out/debug |
| 17 | +``` |
| 18 | + |
| 19 | +### Running the app on linux |
| 20 | + |
| 21 | +From the root of the chip tree |
| 22 | + |
| 23 | +``` |
| 24 | +./examples/valve/linux/out/debug/valve-app --KVS /tmp/valve_kvs.json |
| 25 | +``` |
| 26 | + |
| 27 | +The KVS file is where the commissioning data is stored for the app, so be sure |
| 28 | +to start the app with the same kvs file if you do not want to re-commission it |
| 29 | +every time. All the standard linux app flags also work for this app. Use --help |
| 30 | +to see the available options. |
| 31 | + |
| 32 | +## Controller |
| 33 | + |
| 34 | +### Compiling the chip-repl |
| 35 | + |
| 36 | +To compile the chip-repl, from the root of the chip tree: |
| 37 | + |
| 38 | +``` |
| 39 | +. scripts/activate.sh |
| 40 | +./scripts/build_python.sh -i out/pyenv |
| 41 | +source out/pyenv/activate |
| 42 | +out/pyenv/chip-repl -- |
| 43 | +``` |
| 44 | + |
| 45 | +The chip-repl is a shell that lets you directly call python functions. It |
| 46 | +instantiates a controller object that can be used to communicate with devices. |
| 47 | +The controller is called devCtrl. By default, its KVS is at |
| 48 | +/tmp/repl-storage.json, but this can be changed on the command line if desired. |
| 49 | +Use --help to see options. |
| 50 | + |
| 51 | +### Commissioning the valve app |
| 52 | + |
| 53 | +As long as the controller and the application KVSs are kept constant, the app |
| 54 | +should only need to be commissioned once. |
| 55 | + |
| 56 | +To commission the device use: |
| 57 | + |
| 58 | +``` |
| 59 | +from chip import ChipDeviceCtrl |
| 60 | +await devCtrl.CommissionOnNetwork(nodeId=1, setupPinCode=20202021, filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=3840) |
| 61 | +``` |
| 62 | + |
| 63 | +### Interacting with teh valve app |
| 64 | + |
| 65 | +To create a drinks machine controller: |
| 66 | + |
| 67 | +``` |
| 68 | +import examples.valve.controller as DrinksController |
| 69 | +dm = DrinksController.DrinkMachine(devCtrl, 1) |
| 70 | +``` |
| 71 | + |
| 72 | +You can now call functions on the drinks machine controller. Tab completion will |
| 73 | +work within the repl, so you can see the available options. |
0 commit comments