Skip to content

Instantly share code, notes, and snippets.

@oidebrett
Last active February 9, 2024 12:49
Show Gist options
  • Select an option

  • Save oidebrett/ff18b267289e68e2f070048a0b97b623 to your computer and use it in GitHub Desktop.

Select an option

Save oidebrett/ff18b267289e68e2f070048a0b97b623 to your computer and use it in GitHub Desktop.
OTA for Matter Light Example
0. Build the lighting app example in the connectedhomeip repo as this supports the OTA functionality
~/Projects/esp-matter/connectedhomeip/connectedhomeip/examples/lighting-app/esp32/
1. Commission and pair the previpusly coded Matter light using the chip-tool and verify the software version.
./out/host/chip-tool basicinformation read software-version 1 0
2. Change the CONFIG_APP_PROJECT_VER_FROM_CONFIG option in the file ~/Projects/esp-matter/connectedhomeip/connectedhomeip/examples/lighting-app/esp32/sdkconfig
from
# CONFIG_APP_PROJECT_VER_FROM_CONFIG is not set
to
CONFIG_APP_PROJECT_VER_FROM_CONFIG=y
3. Set the Software Version
With the CONFIG_APP_PROJECT_VER_FROM_CONFIG option enabled, you need to set the version using the following configuration options to set the Software Version:
use idf.py menuconfig
Set the CONFIG_DEVICE_SOFTWARE_VERSION_NUMBER option. (Component config -> CHIP Device Layer -> Device Identification Options -> Device Software Version Number)
Software Version String
Set the CONFIG_APP_PROJECT_VER option. (Application manager -> Get the project version from Kconfig)
Ensure to increment that software version number i.e. 2
4. Rebuild the application using idf.py build and flash. Then check that the software version has gone to "2" using the chip-tool
./out/host/chip-tool basicinformation read software-version 1 0
5. Enable the CONFIG_ENABLE_OTA_REQUESTOR option to enable Matter OTA Requestor function
(Component config -> CHIP Core -> Enable OTA requestor)
use idf.py menuconfig
(Component config -> CHIP Device Layer -> Matter OTA image)
use idf.py build
Confirm that the ota image is produced in the build folder such as "build/light-ota.bin"
6. Redo the steps to increase the version number to "3"
and do idf.py build (but dont flash)
7. Build the OTA provider example app in connectedhomeip
scripts/build/build_examples.py \
--target linux-x64-ota-provider-ipv6only \
build \
&& mv out/linux-x64-ota-provider-ipv6only/chip-ota-provider-app out/host/chip-ota-provider-app \
&& rm -rf out/linux-x64-ota-provider-ipv6only
;;
8. Run the OTA provider app and point it to the ota image you created in the last step.
./out/host/chip-ota-provider-app --filepath ~/Projects/esp-matter/connectedhomeip/connectedhomeip/examples/lighting-app/esp32/build/chip-lighting-app-ota.bin
9. Commission / Pair the OTA provider onto the Matter fabric - note it has node id 2
./out/host/chip-tool pairing onnetwork-long 2 20202021 3840
10. Issue the AnnounceOTAProvider command
./out/host/chip-tool otasoftwareupdaterequestor announce-otaprovider 2 0 0 0 1 0
The OTA Requestor application with node ID 1 will process this command and send a QueryImage command to the OTA Provider with node ID 2, as specified in the AnnounceOTAProvider command.
11. Notice the Access Denied on the OTA provider
[1707424999.215964][142792:142792] CHIP:DMG: AccessControl: checking f=1 a=c s=0x0000000000000001 t= c=0x0000_0029 e=0 p=o
[1707424999.216085][142792:142792] CHIP:DMG: AccessControl: denied
12. Install necessary ACL entries. write the ACL attribute with two entries:
./out/host/chip-tool accesscontrol write acl '[{"fabricIndex": 1, "privilege": 5, "authMode": 2, "subjects": [112233], "targets": null}, {"fabricIndex": 1, "privilege": 3, "authMode": 2, "subjects": null, "targets": [{"cluster": 41, "endpoint": null, "deviceType": null}]}]' 2 0
Entry 1: This is the original entry created as part of commissioning which grants administer privilege to the node ID 112233 (default controller node ID) for all clusters on every endpoint
Entry 2: This is the new entry being added which grants operate privileges to all nodes for the OTA Provider cluster (0x0029) on every endpoint
In the example above, the provider is on fabric index 1 with provider node ID being 2
13. Issue the AnnounceOTAProvider command again
./out/host/chip-tool otasoftwareupdaterequestor announce-otaprovider 2 0 0 0 1 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment