|
| 1 | +# Matter Telink Air Quality Sensor Example Application |
| 2 | + |
| 3 | +You can use this example as a reference for creating your own application. |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | +## Build and flash |
| 8 | + |
| 9 | +1. Run the Docker container: |
| 10 | + |
| 11 | + ```bash |
| 12 | + $ docker run -it --rm -v $PWD:/host -w /host ghcr.io/project-chip/chip-build-telink:$(wget -q -O - https://raw.githubusercontent.com/project-chip/connectedhomeip/master/.github/workflows/examples-telink.yaml 2> /dev/null | grep chip-build-telink | awk -F: '{print $NF}') |
| 13 | + ``` |
| 14 | + |
| 15 | + Compatible docker image version can be found in next file: |
| 16 | + |
| 17 | + ```bash |
| 18 | + $ .github/workflows/examples-telink.yaml |
| 19 | + ``` |
| 20 | + |
| 21 | +2. Activate the build environment: |
| 22 | + |
| 23 | + ```bash |
| 24 | + $ source ./scripts/activate.sh |
| 25 | + ``` |
| 26 | + |
| 27 | +3. In the example dir run (replace _<build_target>_ with your board name, for |
| 28 | + example, `tlsr9518adk80d` or `tlsr9528a`): |
| 29 | + |
| 30 | + ```bash |
| 31 | + $ west build -b <build_target> |
| 32 | + ``` |
| 33 | + |
| 34 | +4. Flash binary: |
| 35 | + |
| 36 | + ``` |
| 37 | + $ west flash --erase |
| 38 | + ``` |
| 39 | + |
| 40 | +## Usage |
| 41 | + |
| 42 | +### UART |
| 43 | + |
| 44 | +To get output from device, connect UART to following pins: |
| 45 | + |
| 46 | +| Name | Pin | |
| 47 | +| :--: | :---------------------------- | |
| 48 | +| RX | PB3 (pin 17 of J34 connector) | |
| 49 | +| TX | PB2 (pin 16 of J34 connector) | |
| 50 | +| GND | GND | |
| 51 | + |
| 52 | +### Buttons |
| 53 | + |
| 54 | +The following buttons are available on **tlsr9518adk80d** board: |
| 55 | + |
| 56 | +| Name | Function | Description | |
| 57 | +| :------- | :--------------------- | :----------------------------------------------------------------------------------------------------- | |
| 58 | +| Button 1 | Factory reset | Perform factory reset to forget currently commissioned Thread network and back to uncommissioned state | |
| 59 | +| Button 2 | `AirQuality` control | Manually triggers the `AirQuality` state | |
| 60 | +| Button 3 | Thread start | Commission thread with static credentials and enables the Thread on device | |
| 61 | +| Button 4 | Open commission window | The button is opening commissioning window to perform commissioning over BLE | |
| 62 | + |
| 63 | +### LEDs |
| 64 | + |
| 65 | +#### Indicate current state of Thread network |
| 66 | + |
| 67 | +**Red** LED indicates current state of Thread network. It is able to be in |
| 68 | +following states: |
| 69 | + |
| 70 | +| State | Description | |
| 71 | +| :-------------------------- | :--------------------------------------------------------------------------- | |
| 72 | +| Blinks with short pulses | Device is not commissioned to Thread, Thread is disabled | |
| 73 | +| Blinks with frequent pulses | Device is commissioned, Thread enabled. Device trying to JOIN thread network | |
| 74 | +| Blinks with wide pulses | Device commissioned and joined to thread network as CHILD | |
| 75 | + |
| 76 | +#### Indicate identify of device |
| 77 | + |
| 78 | +**Green** LED used to identify the device. The LED starts blinking when the |
| 79 | +Identify command of the Identify cluster is received. The command's argument can |
| 80 | +be used to specify the the effect. It is able to be in following effects: |
| 81 | +
|
| 82 | +| Effect | Description | |
| 83 | +| :------------------------------ | :--------------------------------------------------------------------------- | |
| 84 | +| Blinks (200 ms on/200 ms off) | Blink (`Clusters::Identify::EffectIdentifierEnum::kBlink`) | |
| 85 | +| Breathe (during 1000 ms) | Breathe (`Clusters::Identify::EffectIdentifierEnum::kBreathe`) | |
| 86 | +| Blinks (50 ms on/950 ms off) | Okay (`Clusters::Identify::EffectIdentifierEnum::kOkay`) | |
| 87 | +| Blinks (1000 ms on/1000 ms off) | Channel Change ( `Clusters::Identify::EffectIdentifierEnum::kChannelChange`) | |
| 88 | +| Blinks (950 ms on/50 ms off) | Finish ( `Clusters::Identify::EffectIdentifierEnum::kFinishEffect`) | |
| 89 | +| LED off | Stop (`Clusters::Identify::EffectIdentifierEnum::kStopEffect`) | |
| 90 | +
|
| 91 | +### CHIP tool commands |
| 92 | +
|
| 93 | +1. Build |
| 94 | + [chip-tool cli](https://github.com/project-chip/connectedhomeip/blob/master/examples/chip-tool/README.md) |
| 95 | +
|
| 96 | +2. Pair with device |
| 97 | +
|
| 98 | + ``` |
| 99 | + ${CHIP_TOOL_DIR}/chip-tool pairing ble-thread ${NODE_ID} hex:${DATASET} ${PIN_CODE} ${DISCRIMINATOR} |
| 100 | + ``` |
| 101 | +
|
| 102 | + Example: |
| 103 | +
|
| 104 | + ``` |
| 105 | + ./chip-tool pairing ble-thread 1234 hex:0e080000000000010000000300000f35060004001fffe0020811111111222222220708fd61f77bd3df233e051000112233445566778899aabbccddeeff030e4f70656e54687265616444656d6f010212340410445f2b5ca6f2a93a55ce570a70efeecb0c0402a0fff8 20202021 3840 |
| 106 | + ``` |
| 107 | +
|
| 108 | +### OTA with Linux OTA Provider |
| 109 | +
|
| 110 | +OTA feature enabled by default only for ota-requestor-app example. To enable OTA |
| 111 | +feature for another Telink example: |
| 112 | +
|
| 113 | +- set CONFIG_CHIP_OTA_REQUESTOR=y in corresponding "prj.conf" configuration |
| 114 | + file. |
| 115 | +
|
| 116 | +After build application with enabled OTA feature, use next binary files: |
| 117 | +
|
| 118 | +- zephyr.bin - main binary to flash PCB (Use 2MB PCB). |
| 119 | +- zephyr-ota.bin - binary for OTA Provider |
| 120 | +
|
| 121 | +All binaries has the same SW version. To test OTA “zephyr-ota.bin” should have |
| 122 | +higher SW version than base SW. Set CONFIG_CHIP_DEVICE_SOFTWARE_VERSION=2 in |
| 123 | +corresponding “prj.conf” configuration file. |
| 124 | +
|
| 125 | +Usage of OTA: |
| 126 | +
|
| 127 | +- Build the [Linux OTA Provider](../../ota-provider-app/linux) |
| 128 | +
|
| 129 | + ``` |
| 130 | + ./scripts/examples/gn_build_example.sh examples/ota-provider-app/linux out/ota-provider-app chip_config_network_layer_ble=false |
| 131 | + ``` |
| 132 | +
|
| 133 | +- Run the Linux OTA Provider with OTA image. |
| 134 | +
|
| 135 | + ``` |
| 136 | + ./chip-ota-provider-app -f zephyr-ota.bin |
| 137 | + ``` |
| 138 | +
|
| 139 | +- Provision the Linux OTA Provider using chip-tool |
| 140 | +
|
| 141 | + ``` |
| 142 | + ./chip-tool pairing onnetwork ${OTA_PROVIDER_NODE_ID} 20202021 |
| 143 | + ``` |
| 144 | +
|
| 145 | + here: |
| 146 | +
|
| 147 | + - \${OTA_PROVIDER_NODE_ID} is the node id of Linux OTA Provider |
| 148 | +
|
| 149 | +- Configure the ACL of the ota-provider-app to allow access |
| 150 | +
|
| 151 | + ``` |
| 152 | + ./chip-tool accesscontrol write acl '[{"fabricIndex": 1, "privilege": 5, "authMode": 2, "subjects": [112233], "targets": null}, {"fabricIndex": 1, "privilege": 3, "authMode": 2, "subjects": null, "targets": null}]' ${OTA_PROVIDER_NODE_ID} 0 |
| 153 | + ``` |
| 154 | +
|
| 155 | + here: |
| 156 | +
|
| 157 | + - \${OTA_PROVIDER_NODE_ID} is the node id of Linux OTA Provider |
| 158 | +
|
| 159 | +- Use the chip-tool to announce the ota-provider-app to start the OTA process |
| 160 | +
|
| 161 | + ``` |
| 162 | + ./chip-tool otasoftwareupdaterequestor announce-otaprovider ${OTA_PROVIDER_NODE_ID} 0 0 0 ${DEVICE_NODE_ID} 0 |
| 163 | + ``` |
| 164 | +
|
| 165 | + here: |
| 166 | +
|
| 167 | + - \${OTA_PROVIDER_NODE_ID} is the node id of Linux OTA Provider |
| 168 | + - \${DEVICE_NODE_ID} is the node id of paired device |
| 169 | +
|
| 170 | +Once the transfer is complete, OTA requestor sends ApplyUpdateRequest command to |
| 171 | +OTA provider for applying the image. Device will restart on successful |
| 172 | +application of OTA image. |
0 commit comments