diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index aecc5372bcc41c..838e19e75a5c64 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -17,7 +17,7 @@ "build": { "dockerfile": "Dockerfile", "args": { - "BUILD_VERSION": "0.6.30" + "BUILD_VERSION": "0.6.35" } }, "remoteUser": "vscode", diff --git a/.github/.wordlist.txt b/.github/.wordlist.txt index e7f2686627524c..f7d6f3995dc039 100644 --- a/.github/.wordlist.txt +++ b/.github/.wordlist.txt @@ -159,7 +159,7 @@ bouffalolab BRD breakpoint bredr -BridgedDeviceBasic +BridgedDeviceBasicInformation bridgedLightEndpoint bringup BromateConcentrationMeasurement @@ -416,6 +416,7 @@ diffsyms dimmable dirname dirs +disableNotifyUpdateApplied disambiguated discoverable DispatchEvent @@ -1209,6 +1210,7 @@ Silabs's SiliconLabs SimpleFileExFlags SimpleLink +SiWx sizedb sl SLAAC @@ -1454,6 +1456,7 @@ wic WiFiNetworkDiagnostics WindowCovering WindowCoveringGoToLiftPercentage +WiseMCU wlan wmm WPA diff --git a/.github/workflows/bloat_check.yaml b/.github/workflows/bloat_check.yaml index ce9d5b2d0f5968..494a0f42ec2acf 100644 --- a/.github/workflows/bloat_check.yaml +++ b/.github/workflows/bloat_check.yaml @@ -27,10 +27,13 @@ jobs: pull_request_update: name: Report on pull requests + # Don't run on forked repos + if: github.repository_owner == 'project-chip' + runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.6.31 + image: connectedhomeip/chip-build:0.6.35 steps: - uses: Wandalen/wretry.action@v1.0.36 diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 67f0edc2357bb9..8a847a3e034df6 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -36,7 +36,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.31 + image: connectedhomeip/chip-build:0.6.35 volumes: - "/tmp/log_output:/tmp/test_logs" options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 @@ -138,7 +138,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.31 + image: connectedhomeip/chip-build:0.6.35 volumes: - "/tmp/log_output:/tmp/test_logs" options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 @@ -298,7 +298,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.31 + image: connectedhomeip/chip-build:0.6.35 volumes: - "/tmp/log_output:/tmp/test_logs" options: --sysctl "net.ipv6.conf.all.disable_ipv6=0 @@ -352,12 +352,6 @@ jobs: timeout-minutes: 200 runs-on: macos-latest if: github.actor != 'restyled-io[bot]' - - env: - # NOTE: Generally kept in sync within the repo using - # scripts/tools/zap/version_update.py - ZAP_VERSION: v2023.01.09-nightly - ZAP_INSTALL_PATH: /usr/local/zap/zap-v2023.01.09-nightly steps: - uses: Wandalen/wretry.action@v1.0.36 @@ -388,16 +382,6 @@ jobs: ls -la /usr/local/Cellar/openssl@1.1 OPEN_SSL_VERSION=`ls -la /usr/local/Cellar/openssl@1.1 | cat | tail -n1 | awk '{print $NF}'` ln -s /usr/local/Cellar/openssl@1.1/$OPEN_SSL_VERSION/lib/pkgconfig/* . - - name: Install zap - run: | - sudo mkdir -p $ZAP_INSTALL_PATH - sudo chown `whoami` $ZAP_INSTALL_PATH - curl -L https://github.com/project-chip/zap/releases/download/${ZAP_VERSION}/zap-mac.zip \ - --output $ZAP_INSTALL_PATH/zap-mac.zip - cd $ZAP_INSTALL_PATH - unzip zap-mac.zip zap-cli - rm zap-mac.zip - ./zap-cli --version - name: Bootstrap timeout-minutes: 25 run: scripts/build/gn_bootstrap.sh @@ -471,7 +455,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.31 + image: connectedhomeip/chip-build:0.6.35 volumes: - "/tmp/log_output:/tmp/test_logs" options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 diff --git a/.github/workflows/chef.yaml b/.github/workflows/chef.yaml index bc3f8c7db8c04e..e3f9709180380a 100644 --- a/.github/workflows/chef.yaml +++ b/.github/workflows/chef.yaml @@ -29,7 +29,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.31 + image: connectedhomeip/chip-build:0.6.35 options: --user root steps: @@ -57,7 +57,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32:0.6.31 + image: connectedhomeip/chip-build-esp32:0.6.35 options: --user root steps: @@ -85,7 +85,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-nrf-platform:0.6.31 + image: connectedhomeip/chip-build-nrf-platform:0.6.35 options: --user root steps: diff --git a/.github/workflows/cirque.yaml b/.github/workflows/cirque.yaml index 742866f1be3061..ec999e2170b7e8 100644 --- a/.github/workflows/cirque.yaml +++ b/.github/workflows/cirque.yaml @@ -29,7 +29,7 @@ jobs: timeout-minutes: 90 env: - DOCKER_RUN_VERSION: 0.6.31 + DOCKER_RUN_VERSION: 0.6.35 GITHUB_CACHE_PATH: /tmp/cirque-cache/ runs-on: ubuntu-latest @@ -38,7 +38,7 @@ jobs: # need to run with privilege, which isn't supported by job.XXX.contaner # https://github.com/actions/container-action/issues/2 # container: - # image: connectedhomeip/chip-build-cirque:0.6.31 + # image: connectedhomeip/chip-build-cirque:0.6.35 # volumes: # - "/tmp:/tmp" # - "/dev/pts:/dev/pts" diff --git a/.github/workflows/darwin-tests.yaml b/.github/workflows/darwin-tests.yaml index 4050aacefdebb0..7d1db5f479dc6c 100644 --- a/.github/workflows/darwin-tests.yaml +++ b/.github/workflows/darwin-tests.yaml @@ -39,10 +39,6 @@ jobs: env: BUILD_VARIANT: ${{matrix.build_variant}} LSAN_OPTIONS: detect_leaks=1 malloc_context_size=40 suppressions=scripts/tests/chiptest/lsan-mac-suppressions.txt - # NOTE: Generally kept in sync within the repo using - # scripts/tools/zap/version_update.py - ZAP_VERSION: v2023.01.09-nightly - ZAP_INSTALL_PATH: /usr/local/zap/zap-v2023.01.09-nightly if: github.actor != 'restyled-io[bot]' runs-on: macos-latest @@ -76,16 +72,6 @@ jobs: ls -la /usr/local/Cellar/openssl@1.1 OPEN_SSL_VERSION=`ls -la /usr/local/Cellar/openssl@1.1 | cat | tail -n1 | awk '{print $NF}'` ln -s /usr/local/Cellar/openssl@1.1/$OPEN_SSL_VERSION/lib/pkgconfig/* . - - name: Install zap - run: | - sudo mkdir -p $ZAP_INSTALL_PATH - sudo chown `whoami` $ZAP_INSTALL_PATH - curl -L https://github.com/project-chip/zap/releases/download/${ZAP_VERSION}/zap-mac.zip \ - --output $ZAP_INSTALL_PATH/zap-mac.zip - cd $ZAP_INSTALL_PATH - unzip zap-mac.zip zap-cli - rm zap-mac.zip - ./zap-cli --version - name: Bootstrap timeout-minutes: 25 run: scripts/build/gn_bootstrap.sh diff --git a/.github/workflows/darwin.yaml b/.github/workflows/darwin.yaml index 0c47b619a69013..fb29e67cd0ce98 100644 --- a/.github/workflows/darwin.yaml +++ b/.github/workflows/darwin.yaml @@ -31,12 +31,6 @@ jobs: if: github.actor != 'restyled-io[bot]' runs-on: macos-latest - env: - # NOTE: Generally kept in sync within the repo using - # scripts/tools/zap/version_update.py - ZAP_VERSION: v2023.01.09-nightly - ZAP_INSTALL_PATH: /usr/local/zap/zap-v2023.01.09-nightly - steps: - uses: Wandalen/wretry.action@v1.0.36 name: Checkout @@ -58,16 +52,6 @@ jobs: ls -la /usr/local/Cellar/openssl@1.1 OPEN_SSL_VERSION=`ls -la /usr/local/Cellar/openssl@1.1 | cat | tail -n1 | awk '{print $NF}'` ln -s /usr/local/Cellar/openssl@1.1/$OPEN_SSL_VERSION/lib/pkgconfig/* . - - name: Install zap - run: | - sudo mkdir -p $ZAP_INSTALL_PATH - sudo chown `whoami` $ZAP_INSTALL_PATH - curl -L https://github.com/project-chip/zap/releases/download/${ZAP_VERSION}/zap-mac.zip \ - --output $ZAP_INSTALL_PATH/zap-mac.zip - cd $ZAP_INSTALL_PATH - unzip zap-mac.zip zap-cli - rm zap-mac.zip - ./zap-cli --version - name: Bootstrap timeout-minutes: 25 run: scripts/build/gn_bootstrap.sh @@ -79,6 +63,12 @@ jobs: path: | .environment/gn_out/.ninja_log .environment/pigweed-venv/*.log + - name: Block zap-cli from being used + # xcodebuild is NOT expected to require zap-cli + run: scripts/run_in_build_env.sh 'mv $PW_ENVIRONMENT_ROOT/cipd/packages/zap/zap-cli $PW_ENVIRONMENT_ROOT/cipd/packages/zap/zap-cli.moved' + - name: Validate zap-cli is NOT available + # run_in_build_env.sh is used to ensure PATH is set to something that would otherwise find zap-cli + run: scripts/run_in_build_env.sh '(zap-cli --version && exit 1) || exit 0' - name: Run iOS Build Debug timeout-minutes: 50 working-directory: src/darwin/Framework @@ -118,6 +108,10 @@ jobs: - name: Clean Build run: xcodebuild clean working-directory: src/darwin/Framework + - name: Make zap-cli work again + run: scripts/run_in_build_env.sh 'mv $PW_ENVIRONMENT_ROOT/cipd/packages/zap/zap-cli.moved $PW_ENVIRONMENT_ROOT/cipd/packages/zap/zap-cli' + - name: Validate zap-cli is again available + run: scripts/run_in_build_env.sh 'zap-cli --version' - name: Build example All Clusters Server timeout-minutes: 15 run: | diff --git a/.github/workflows/docker_img.yaml b/.github/workflows/docker_img.yaml index a0fc677dfc06d4..b7d93bc49279ce 100644 --- a/.github/workflows/docker_img.yaml +++ b/.github/workflows/docker_img.yaml @@ -54,6 +54,7 @@ jobs: - "-telink" - "-ti" - "-tizen" + - "-tizen-qemu" - "-openiotsdk" # NOTE: vscode image consumes ~52 GB disk space but GitHub-hosted runners provide ~10 GB free disk space(https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources) #- "-vscode" diff --git a/.github/workflows/doxygen.yaml b/.github/workflows/doxygen.yaml index 6814ed4d8f4823..53975923422d84 100644 --- a/.github/workflows/doxygen.yaml +++ b/.github/workflows/doxygen.yaml @@ -82,7 +82,7 @@ jobs: runs-on: ubuntu-20.04 container: - image: connectedhomeip/chip-build-doxygen:0.6.31 + image: connectedhomeip/chip-build-doxygen:0.6.35 if: github.actor != 'restyled-io[bot]' diff --git a/.github/workflows/examples-ameba.yaml b/.github/workflows/examples-ameba.yaml index dc5d598a194da9..23c52d94fe0bf6 100644 --- a/.github/workflows/examples-ameba.yaml +++ b/.github/workflows/examples-ameba.yaml @@ -35,7 +35,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-ameba:0.6.31 + image: connectedhomeip/chip-build-ameba:0.6.35 options: --user root steps: diff --git a/.github/workflows/examples-bouffalolab.yaml b/.github/workflows/examples-bouffalolab.yaml index fd7afcc5a8db97..f18f9b933b310e 100644 --- a/.github/workflows/examples-bouffalolab.yaml +++ b/.github/workflows/examples-bouffalolab.yaml @@ -35,7 +35,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-bouffalolab:0.6.31 + image: connectedhomeip/chip-build-bouffalolab:0.6.35 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-cc13x2x7_26x2x7.yaml b/.github/workflows/examples-cc13x2x7_26x2x7.yaml index 83ca902133eb1a..c95d076834e0c9 100644 --- a/.github/workflows/examples-cc13x2x7_26x2x7.yaml +++ b/.github/workflows/examples-cc13x2x7_26x2x7.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-ti:0.6.31 + image: connectedhomeip/chip-build-ti:0.6.35 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-efr32.yaml b/.github/workflows/examples-efr32.yaml index c88a2e43d53a7e..f9b247af85b5e8 100644 --- a/.github/workflows/examples-efr32.yaml +++ b/.github/workflows/examples-efr32.yaml @@ -38,7 +38,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-efr32:0.6.31 + image: connectedhomeip/chip-build-efr32:0.6.35 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: @@ -51,7 +51,7 @@ jobs: attempt_limit: 3 attempt_delay: 2000 - name: Checkout submodules - run: scripts/checkout_submodules.py --shallow --recursive --platform efr32 + run: scripts/checkout_submodules.py --shallow --platform efr32 # - name: Out of Tree verification # run: third_party/silabs/out_of_tree_verification.sh @@ -82,6 +82,7 @@ jobs: --enable-flashbundle \ --target efr32-brd4187c-window-covering \ --target efr32-brd4187c-switch \ + --target efr32-brd4187c-switch-sed \ --target efr32-brd4187c-unit-test \ --target efr32-brd4187c-light \ --target efr32-brd4187c-light-rpc \ @@ -101,15 +102,6 @@ jobs: /tmp/bloat_reports/ - name: Clean out build output run: rm -rf ./out - - name: Build example EFR32 Lighting App for BRD4161A with RPCs - timeout-minutes: 15 - run: | - scripts/examples/gn_efr32_example.sh examples/lighting-app/silabs/efr32/ out/lighting_app_debug_rpc BRD4161A "is_debug=false" \ - disable_lcd=true 'import("//with_pw_rpc.gni")' - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py efr32 BRD4161A+rpc lighting-app \ - out/lighting_app_debug_rpc/BRD4161A/chip-efr32-lighting-example.out /tmp/bloat_reports/ - - name: Clean out build output - run: rm -rf ./out - name: Build example EFR32+WF200 WiFi Lock app for BRD4161A timeout-minutes: 15 run: | diff --git a/.github/workflows/examples-esp32.yaml b/.github/workflows/examples-esp32.yaml index 6650825d090343..d28ba2d1c4657e 100644 --- a/.github/workflows/examples-esp32.yaml +++ b/.github/workflows/examples-esp32.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32:0.6.31 + image: connectedhomeip/chip-build-esp32:0.6.35 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" @@ -148,7 +148,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32:0.6.31 + image: connectedhomeip/chip-build-esp32:0.6.35 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-infineon.yaml b/.github/workflows/examples-infineon.yaml index 9845f5f5e451ab..503312465b9d56 100644 --- a/.github/workflows/examples-infineon.yaml +++ b/.github/workflows/examples-infineon.yaml @@ -35,7 +35,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-infineon:0.6.31 + image: connectedhomeip/chip-build-infineon:0.6.35 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-k32w.yaml b/.github/workflows/examples-k32w.yaml index 4d625b9705202a..43d72b2f26cef7 100644 --- a/.github/workflows/examples-k32w.yaml +++ b/.github/workflows/examples-k32w.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-k32w:0.6.31 + image: connectedhomeip/chip-build-k32w:0.6.35 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-linux-arm.yaml b/.github/workflows/examples-linux-arm.yaml index 3a054918c60f87..0d3c6af18258e7 100644 --- a/.github/workflows/examples-linux-arm.yaml +++ b/.github/workflows/examples-linux-arm.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-crosscompile:0.6.31 + image: connectedhomeip/chip-build-crosscompile:0.6.35 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" @@ -73,7 +73,7 @@ jobs: run: | ./scripts/run_in_build_env.sh \ "./scripts/build/build_examples.py \ - --target linux-arm64-chip-cert \ + --target linux-arm64-chip-cert-clang \ --target linux-arm64-all-clusters-clang \ --target linux-arm64-chip-tool-ipv6only-clang \ --target linux-arm64-lock-clang \ diff --git a/.github/workflows/examples-linux-imx.yaml b/.github/workflows/examples-linux-imx.yaml index 405aeec2845106..5fb3d8a17a35ff 100644 --- a/.github/workflows/examples-linux-imx.yaml +++ b/.github/workflows/examples-linux-imx.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-imx:0.6.31 + image: connectedhomeip/chip-build-imx:0.6.35 steps: - uses: Wandalen/wretry.action@v1.0.36 diff --git a/.github/workflows/examples-linux-standalone.yaml b/.github/workflows/examples-linux-standalone.yaml index ac40486ce1055c..9cb447501b9c18 100644 --- a/.github/workflows/examples-linux-standalone.yaml +++ b/.github/workflows/examples-linux-standalone.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.31 + image: connectedhomeip/chip-build:0.6.35 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-mbed.yaml b/.github/workflows/examples-mbed.yaml index 313af85b2a4ce7..6f24da71558367 100644 --- a/.github/workflows/examples-mbed.yaml +++ b/.github/workflows/examples-mbed.yaml @@ -40,7 +40,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-mbed-os:0.6.31 + image: connectedhomeip/chip-build-mbed-os:0.6.35 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-mw320.yaml b/.github/workflows/examples-mw320.yaml index 4c187ef05ffaa5..69f6e23ae06b85 100755 --- a/.github/workflows/examples-mw320.yaml +++ b/.github/workflows/examples-mw320.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.31 + image: connectedhomeip/chip-build:0.6.35 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-nrfconnect.yaml b/.github/workflows/examples-nrfconnect.yaml index f776e537f7fac8..1d84e4629db0b8 100644 --- a/.github/workflows/examples-nrfconnect.yaml +++ b/.github/workflows/examples-nrfconnect.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-nrf-platform:0.6.31 + image: connectedhomeip/chip-build-nrf-platform:0.6.35 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-openiotsdk.yaml b/.github/workflows/examples-openiotsdk.yaml index d755b6c3bf63d1..975ebce2e9510b 100644 --- a/.github/workflows/examples-openiotsdk.yaml +++ b/.github/workflows/examples-openiotsdk.yaml @@ -35,7 +35,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-openiotsdk:0.6.31 + image: connectedhomeip/chip-build-openiotsdk:0.6.35 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" options: --privileged diff --git a/.github/workflows/examples-qpg.yaml b/.github/workflows/examples-qpg.yaml index c585d124d307c1..67f4db03565fbc 100644 --- a/.github/workflows/examples-qpg.yaml +++ b/.github/workflows/examples-qpg.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.31 + image: connectedhomeip/chip-build:0.6.35 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 4ed8e346b7127d..4e025b0917f900 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -35,7 +35,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-telink:0.6.31 + image: connectedhomeip/chip-build-telink:0.6.35 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-tizen.yaml b/.github/workflows/examples-tizen.yaml index 8d1fb9dc1b92c4..a4ed8444b01c90 100644 --- a/.github/workflows/examples-tizen.yaml +++ b/.github/workflows/examples-tizen.yaml @@ -33,7 +33,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-tizen:0.6.31 + image: connectedhomeip/chip-build-tizen:0.6.35 options: --user root volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" @@ -61,9 +61,9 @@ jobs: --enable-flashbundle \ --target tizen-arm-all-clusters \ --target tizen-arm-all-clusters-minimal-no-wifi \ - --target chip-tool-ubsan \ - --target light \ - --target light-no-ble-no-wifi \ + --target tizen-arm-chip-tool-ubsan \ + --target tizen-arm-light \ + --target tizen-arm-light-no-ble-no-wifi \ build \ --copy-artifacts-to out/artifacts \ " diff --git a/.github/workflows/full-android.yaml b/.github/workflows/full-android.yaml index 9d10c53dd298ac..d8a5a13396c386 100644 --- a/.github/workflows/full-android.yaml +++ b/.github/workflows/full-android.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-android:0.6.31 + image: connectedhomeip/chip-build-android:0.6.35 volumes: - "/tmp/log_output:/tmp/test_logs" diff --git a/.github/workflows/fuzzing-build.yaml b/.github/workflows/fuzzing-build.yaml index 57af4e5f358bda..3f8e0424010bf5 100644 --- a/.github/workflows/fuzzing-build.yaml +++ b/.github/workflows/fuzzing-build.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.31 + image: connectedhomeip/chip-build:0.6.35 volumes: - "/tmp/log_output:/tmp/test_logs" @@ -88,12 +88,6 @@ jobs: runs-on: macos-latest if: github.actor != 'restyled-io[bot]' - env: - # NOTE: Generally kept in sync within the repo using - # scripts/tools/zap/version_update.py - ZAP_VERSION: v2023.01.09-nightly - ZAP_INSTALL_PATH: /usr/local/zap/zap-v2023.01.09-nightly - steps: - uses: Wandalen/wretry.action@v1.0.36 name: Checkout @@ -117,16 +111,6 @@ jobs: ls -la /usr/local/Cellar/openssl@1.1 OPEN_SSL_VERSION=`ls -la /usr/local/Cellar/openssl@1.1 | cat | tail -n1 | awk '{print $NF}'` ln -s /usr/local/Cellar/openssl@1.1/$OPEN_SSL_VERSION/lib/pkgconfig/* . - - name: Install zap - run: | - sudo mkdir -p $ZAP_INSTALL_PATH - sudo chown `whoami` $ZAP_INSTALL_PATH - curl -L https://github.com/project-chip/zap/releases/download/${ZAP_VERSION}/zap-mac.zip \ - --output $ZAP_INSTALL_PATH/zap-mac.zip - cd $ZAP_INSTALL_PATH - unzip zap-mac.zip zap-cli - rm zap-mac.zip - ./zap-cli --version - name: Bootstrap timeout-minutes: 25 run: scripts/build/gn_bootstrap.sh diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 0aba07866a6209..1e0ae2f0e508c3 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -28,7 +28,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.31 + image: connectedhomeip/chip-build:0.6.35 steps: - uses: Wandalen/wretry.action@v1.0.36 @@ -116,7 +116,7 @@ jobs: uses: gaurav-nelson/github-action-markdown-link-check@v1 # git grep exits with 0 if it finds a match, but we want - # to fail (exit nonzero) on match. And we wasnt to exclude this file, + # to fail (exit nonzero) on match. And we want to exclude this file, # to avoid our grep regexp matching itself. - name: Check for incorrect error use in VerifyOrExit if: always() @@ -124,7 +124,7 @@ jobs: git grep -n "VerifyOrExit(.*, [A-Za-z]*_ERROR" -- './*' ':(exclude).github/workflows/lint.yml' && exit 1 || exit 0 # git grep exits with 0 if it finds a match, but we want - # to fail (exit nonzero) on match. And we wasnt to exclude this file, + # to fail (exit nonzero) on match. And we want to exclude this file, # to avoid our grep regexp matching itself. - name: Check for use of PRI*8, which are not supported on some libcs. if: always() @@ -132,7 +132,7 @@ jobs: git grep -n "PRI.8" -- './*' ':(exclude).github/workflows/lint.yml' ':(exclude)third_party/lwip/repo/lwip/src/include/lwip/arch.h' && exit 1 || exit 0 # git grep exits with 0 if it finds a match, but we want - # to fail (exit nonzero) on match. And we wasnt to exclude this file, + # to fail (exit nonzero) on match. And we want to exclude this file, # to avoid our grep regexp matching itself. - name: Check for use of PRI*16, which are not supported on some libcs. if: always() @@ -140,7 +140,7 @@ jobs: git grep -n "PRI.16" -- './*' ':(exclude).github/workflows/lint.yml' ':(exclude)third_party/lwip/repo/lwip/src/include/lwip/arch.h' && exit 1 || exit 0 # git grep exits with 0 if it finds a match, but we want - # to fail (exit nonzero) on match. And we wasnt to exclude this file, + # to fail (exit nonzero) on match. And we want to exclude this file, # to avoid our grep regexp matching itself. - name: Check for use of %zu, which are not supported on some libcs. if: always() @@ -167,7 +167,7 @@ jobs: scripts/tools/check_test_pics.py src/app/tests/suites/certification/ci-pics-values src/app/tests/suites/certification/PICS.yaml # git grep exits with 0 if it finds a match, but we want - # to fail (exit nonzero) on match. And we wasnt to exclude this file, + # to fail (exit nonzero) on match. And we want to exclude this file, # to avoid our grep regexp matching itself. - name: Check for use of 0x%u and the like, which lead to misleading output. if: always() @@ -175,9 +175,16 @@ jobs: git grep -n '0x%[0-9l.-]*[^0-9lxX".-]' -- './*' ':(exclude).github/workflows/lint.yml' && exit 1 || exit 0 # git grep exits with 0 if it finds a match, but we want - # to fail (exit nonzero) on match. And we wasnt to exclude this file, + # to fail (exit nonzero) on match. And we want to exclude this file, # to avoid our grep regexp matching itself. - name: Check for use of '"0x" PRIu*' and the like, which lead to misleading output. if: always() run: | git grep -n '0x%[0-9-]*" *PRI[^xX]' -- './*' ':(exclude).github/workflows/lint.yml' && exit 1 || exit 0 + + # git grep exits with 0 if it finds a match, but we want + # to fail (exit nonzero) on match. + - name: Check for use of NSLog instead of Matter logging in Matter framework + if: always() + run: | + git grep -n 'NSLog(' -- src/darwin/Framework/CHIP && exit 1 || exit 0 diff --git a/.github/workflows/qemu.yaml b/.github/workflows/qemu.yaml index 73f8937471e9a6..293ee31f955c64 100644 --- a/.github/workflows/qemu.yaml +++ b/.github/workflows/qemu.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32-qemu:0.6.31 + image: connectedhomeip/chip-build-esp32-qemu:0.6.35 volumes: - "/tmp/log_output:/tmp/test_logs" diff --git a/.github/workflows/release_artifacts.yaml b/.github/workflows/release_artifacts.yaml index c709bfb23949a9..1b773d8c28d52c 100644 --- a/.github/workflows/release_artifacts.yaml +++ b/.github/workflows/release_artifacts.yaml @@ -29,7 +29,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build-esp32:0.6.31 + image: connectedhomeip/chip-build-esp32:0.6.35 steps: - uses: Wandalen/wretry.action@v1.0.36 @@ -75,7 +75,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build-efr32:0.6.31 + image: connectedhomeip/chip-build-efr32:0.6.35 steps: - uses: Wandalen/wretry.action@v1.0.36 name: Checkout diff --git a/.github/workflows/smoketest-android.yaml b/.github/workflows/smoketest-android.yaml index c7908fb810ff3c..1007d93e99f7ea 100644 --- a/.github/workflows/smoketest-android.yaml +++ b/.github/workflows/smoketest-android.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-android:0.6.31 + image: connectedhomeip/chip-build-android:0.6.35 volumes: - "/tmp/log_output:/tmp/test_logs" diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 4231e7b0decea0..ffc0644df2c889 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -47,7 +47,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.6.31 + image: connectedhomeip/chip-build:0.6.35 options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1" @@ -116,36 +116,42 @@ jobs: src/app/zap-templates/zcl/data-model/chip/application-basic-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/application-launcher-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/audio-output-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/ballast-configuration-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/basic-information-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/binding-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/boolean-state-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/actions-cluster.xml \ - src/app/zap-templates/zcl/data-model/chip/bridged-device-basic.xml \ + src/app/zap-templates/zcl/data-model/chip/bridged-device-basic-information.xml \ src/app/zap-templates/zcl/data-model/chip/chip-ota.xml \ src/app/zap-templates/zcl/data-model/chip/chip-types.xml \ src/app/zap-templates/zcl/data-model/chip/channel-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/clusters-extensions.xml \ + src/app/zap-templates/zcl/data-model/chip/color-control-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/content-launch-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/descriptor-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/diagnostic-logs-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/door-lock-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/ethernet-network-diagnostics-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/fan-control-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/fault-injection-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/fixed-label-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/flow-measurement-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/general-commissioning-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/general-diagnostics-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/global-attributes.xml \ + src/app/zap-templates/zcl/data-model/chip/groups-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/group-key-mgmt-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/identify-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/illuminance-measurement-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/keypad-input-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/level-control-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/localization-configuration-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/low-power-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/media-input-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/media-playback-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/mode-select-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/network-commissioning-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/occupancy-sensing-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/onoff-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/operational-credentials-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/pressure-measurement-cluster.xml \ @@ -163,6 +169,7 @@ jobs: src/app/zap-templates/zcl/data-model/chip/target-navigator-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/temperature-measurement-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/test-cluster.xml \ + src/app/zap-templates/zcl/data-model/chip/thermostat-user-interface-configuration-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/thermostat-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/thread-network-diagnostics-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/time-format-localization-cluster.xml \ @@ -173,16 +180,17 @@ jobs: src/app/zap-templates/zcl/data-model/chip/wifi-network-diagnostics-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/window-covering.xml \ src/app/zap-templates/zcl/data-model/chip/matter-devices.xml \ - src/app/zap-templates/zcl/data-model/silabs/general.xml \ + src/app/zap-templates/zcl/data-model/draft/barrier-control-cluster.xml \ + src/app/zap-templates/zcl/data-model/draft/electrical-measurement-cluster.xml \ + src/app/zap-templates/zcl/data-model/draft/input-output-value-clusters.xml \ + src/app/zap-templates/zcl/data-model/draft/onoff-switch-configuration-cluster.xml \ src/app/zap-templates/zcl/data-model/silabs/ha-devices.xml \ - src/app/zap-templates/zcl/data-model/silabs/ha.xml \ src/app/zap-templates/zcl/data-model/silabs/lo-devices.xml \ - src/app/zap-templates/zcl/data-model/silabs/types.xml \ + src/app/zap-templates/zcl/data-model/silabs/types-silabs.xml \ src/app/zap-templates/zcl/data-model/silabs/zll-devices.xml \ - src/app/zap-templates/zcl/data-model/silabs/zll.xml \ " - name: Build Apps - timeout-minutes: 45 + timeout-minutes: 60 run: | scripts/run_in_build_env.sh './scripts/build_python.sh --install_wheel build-env' ./scripts/run_in_build_env.sh \ @@ -214,11 +222,10 @@ jobs: --bridge-app ./out/linux-x64-bridge-${BUILD_VARIANT}/chip-bridge-app \ " - name: Run Tests using chip-repl - timeout-minutes: 5 + timeout-minutes: 45 run: | ./scripts/run_in_build_env.sh \ "./scripts/tests/run_test_suite.py \ - --chip-tool ./out/linux-x64-chip-tool${CHIP_TOOL_VARIANT}-${BUILD_VARIANT}/chip-tool \ --run-yamltests-with-chip-repl \ run \ --iterations 1 \ @@ -260,10 +267,6 @@ jobs: CHIP_TOOL_VARIANT: ${{matrix.chip_tool}} TSAN_OPTIONS: "halt_on_error=1" LSAN_OPTIONS: detect_leaks=1 suppressions=scripts/tests/chiptest/lsan-mac-suppressions.txt - # NOTE: Generally kept in sync within the repo using - # scripts/tools/zap/version_update.py - ZAP_VERSION: v2023.01.09-nightly - ZAP_INSTALL_PATH: /usr/local/zap/zap-v2023.01.09-nightly if: github.actor != 'restyled-io[bot]' runs-on: macos-latest @@ -297,15 +300,6 @@ jobs: ls -la /usr/local/Cellar/openssl@1.1 OPEN_SSL_VERSION=`ls -la /usr/local/Cellar/openssl@1.1 | cat | tail -n1 | awk '{print $NF}'` ln -s /usr/local/Cellar/openssl@1.1/$OPEN_SSL_VERSION/lib/pkgconfig/* . - - name: Install zap - run: | - sudo mkdir -p $ZAP_INSTALL_PATH - sudo chown `whoami` $ZAP_INSTALL_PATH - curl -L https://github.com/project-chip/zap/releases/download/${ZAP_VERSION}/zap-mac.zip \ - --output $ZAP_INSTALL_PATH/zap-mac.zip - cd $ZAP_INSTALL_PATH - unzip zap-mac.zip zap-cli - rm zap-mac.zip - name: Bootstrap timeout-minutes: 25 run: scripts/build/gn_bootstrap.sh @@ -383,7 +377,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.6.31 + image: connectedhomeip/chip-build:0.6.35 options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=0 net.ipv6.conf.all.forwarding=0" @@ -428,6 +422,8 @@ jobs: scripts/run_in_build_env.sh './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_decode 1" --script "src/python_testing/TC_SC_3_6.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021"' scripts/run_in_build_env.sh './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_decode 1" --script "src/python_testing/TC_DA_1_7.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --bool-arg allow_sdk_dac:true"' scripts/run_in_build_env.sh './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_decode 1 --enable-key 000102030405060708090a0b0c0d0e0f" --script "src/python_testing/TC_TestEventTrigger.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --bool-arg allow_sdk_dac:true"' + scripts/run_in_build_env.sh './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_decode 1" --script "src/python_testing/TC_ACE_1_4.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --int-arg PIXIT.ACE.APPENDPOINT:1 PIXIT.ACE.APPDEVTYPEID:0x0100 --string-arg PIXIT.ACE.APPCLUSTER:OnOff PIXIT.ACE.APPATTRIBUTE:OnOff"' + scripts/run_in_build_env.sh './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_decode 1" --script "src/python_testing/TC_ACE_1_3.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021"' - name: Uploading core files uses: actions/upload-artifact@v3 if: ${{ failure() && !env.ACT }} @@ -457,7 +453,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.6.31 + image: connectedhomeip/chip-build:0.6.35 options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=0 net.ipv6.conf.all.forwarding=0" @@ -544,10 +540,6 @@ jobs: env: BUILD_VARIANT: ${{matrix.build_variant}} TSAN_OPTIONS: "halt_on_error=1" - # NOTE: Generally kept in sync within the repo using - # scripts/tools/zap/version_update.py - ZAP_VERSION: v2023.01.09-nightly - ZAP_INSTALL_PATH: /usr/local/zap/zap-v2023.01.09-nightly if: github.actor != 'restyled-io[bot]' && false runs-on: macos-latest @@ -575,15 +567,6 @@ jobs: ls -la /usr/local/Cellar/openssl@1.1 OPEN_SSL_VERSION=`ls -la /usr/local/Cellar/openssl@1.1 | cat | tail -n1 | awk '{print $NF}'` ln -s /usr/local/Cellar/openssl@1.1/$OPEN_SSL_VERSION/lib/pkgconfig/* . - - name: Install zap - run: | - sudo mkdir -p $ZAP_INSTALL_PATH - sudo chown `whoami` $ZAP_INSTALL_PATH - curl -L https://github.com/project-chip/zap/releases/download/${ZAP_VERSION}/zap-mac.zip \ - --output $ZAP_INSTALL_PATH/zap-mac.zip - cd $ZAP_INSTALL_PATH - unzip zap-mac.zip zap-cli - rm zap-mac.zip - name: Bootstrap timeout-minutes: 25 run: scripts/build/gn_bootstrap.sh diff --git a/.github/workflows/unit_integration_test.yaml b/.github/workflows/unit_integration_test.yaml index f502b52712b392..d01552761f847e 100644 --- a/.github/workflows/unit_integration_test.yaml +++ b/.github/workflows/unit_integration_test.yaml @@ -37,7 +37,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.6.31 + image: connectedhomeip/chip-build:0.6.35 volumes: - "/tmp/log_output:/tmp/test_logs" options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1" diff --git a/.github/workflows/zap_regeneration.yaml b/.github/workflows/zap_regeneration.yaml index 8d02e0ae40188f..35a48203405047 100644 --- a/.github/workflows/zap_regeneration.yaml +++ b/.github/workflows/zap_regeneration.yaml @@ -28,7 +28,7 @@ jobs: runs-on: ubuntu-20.04 container: - image: connectedhomeip/chip-build:0.6.31 + image: connectedhomeip/chip-build:0.6.35 defaults: run: shell: sh diff --git a/.github/workflows/zap_templates.yaml b/.github/workflows/zap_templates.yaml index 496a3147d86b9e..7a49bde308a9ad 100644 --- a/.github/workflows/zap_templates.yaml +++ b/.github/workflows/zap_templates.yaml @@ -29,7 +29,7 @@ jobs: runs-on: ubuntu-20.04 container: - image: connectedhomeip/chip-build:0.6.31 + image: connectedhomeip/chip-build:0.6.35 defaults: run: shell: sh diff --git a/.gitignore b/.gitignore index 8d4ea014d762c6..4c17bb63a84a8c 100644 --- a/.gitignore +++ b/.gitignore @@ -71,3 +71,12 @@ compile_commands.json # log files *.log examples/thermostat/ameba/build + +# Downloaded zap without a pigweed root (via zap_download.py) +.zap + +# When building esp-idf application, if any component is fetched using idf-component-manager then they are stored in +# managed_component directory. Along with that dependencies.lock file is generated. +# https://github.com/espressif/idf-component-manager#using-with-a-project +examples/*/esp32/managed_components +examples/*/esp32/dependencies.lock diff --git a/.gitmodules b/.gitmodules index 74addf59b3d0d7..048d1f48b7734b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -293,4 +293,4 @@ [submodule "third_party/libwebsockets/repo"] path = third_party/libwebsockets/repo url = https://github.com/warmcat/libwebsockets - platforms = linux,darwin + platforms = linux,darwin,tizen diff --git a/.pullapprove.yml b/.pullapprove.yml index a2837bd27dc0a1..74eee17032a03e 100644 --- a/.pullapprove.yml +++ b/.pullapprove.yml @@ -144,6 +144,14 @@ groups: teams: [reviewers-samsung] reviews: request: 10 + shared-reviewers-signify: + type: optional + conditions: + - files.include('*') + reviewers: + teams: [reviewers-signify] + reviews: + request: 10 shared-reviewers-silabs: type: optional conditions: @@ -152,6 +160,14 @@ groups: teams: [reviewers-silabs] reviews: request: 10 + shared-reviewers-somfy: + type: optional + conditions: + - files.include('*') + reviewers: + teams: [reviewers-somfy] + reviews: + request: 10 shared-reviewers-tcl: type: optional conditions: @@ -159,7 +175,7 @@ groups: reviewers: teams: [reviewers-tcl] reviews: - request: 1 + request: 10 ############################################################ # Base Required Reviewers diff --git a/.restyled.yaml b/.restyled.yaml index 4bafb5c29ec2e8..8c77704457a15d 100644 --- a/.restyled.yaml +++ b/.restyled.yaml @@ -76,8 +76,7 @@ exclude: - "examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/**/*" - "integrations/cloudbuild/*.yaml" # uglier long command line content - "scripts/run_codegen_targets.sh" # shellharden breaks for loops over command outputs - - "src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h" # Too big? - - "src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm" # Too big? + - "src/darwin/Framework/CHIP/zap-generated/*" # already clang-formatted by our zap tooling - "zzz_generated/**/*" # already clang-formatted by our zap tooling diff --git a/.vscode/launch.json b/.vscode/launch.json index bf83cc0d85d6e4..5a8cfbce9c8682 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -435,7 +435,13 @@ "armToolchainPath": "${env:ARM_GCC_TOOLCHAIN_PATH}/bin", "servertype": "external", "gdbTarget": "${input:openiotsdkRemoteHost}:31627", //GDBserver port on FVP - "overrideLaunchCommands": ["-enable-pretty-printing"], + "overrideLaunchCommands": [ + "-enable-pretty-printing", + "add-symbol-file ./build/bl2.elf 0x10000000", + "add-symbol-file ./build/tfm_s.elf 0x38000400", + "add-symbol-file ./build/chip-openiotsdk-${input:openiotsdkApp}-example_ns.elf 0x28060400", + "break main_ns.cpp:main" + ], "runToEntryPoint": "main", "preLaunchTask": "Debug Open IoT SDK example", "showDevDebugOutput": "parsed" diff --git a/README.md b/README.md index ed56ea18d308c1..5a332bba03a711 100644 --- a/README.md +++ b/README.md @@ -133,10 +133,7 @@ stack captured in the following Figure: 4) **Action Framing:** Once an action is constructed using the Interaction Model, it is serialized into a prescribed packed binary format to encode for - network transmission. Security: An encoded action frame is then processed by - the Security Layer: the message is encrypted and appended with a message - authentication code. These actions ensure the data remain confidential and - authentic between sender and receiver of the message. + network transmission. 5. **Security:** An encoded action frame is then sent down to the Security Layer to encrypt and sign the payload to ensure that data is secured and diff --git a/examples/persistent-storage/efr32/args.gni b/build_overrides/ot_efr32.gni similarity index 68% rename from examples/persistent-storage/efr32/args.gni rename to build_overrides/ot_efr32.gni index 45a6fed651fb8a..469c74f34c906a 100644 --- a/examples/persistent-storage/efr32/args.gni +++ b/build_overrides/ot_efr32.gni @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Project CHIP Authors +# Copyright (c) 2023 Project CHIP Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build_overrides/chip.gni") -import("${chip_root}/config/standalone/args.gni") -import("${chip_root}/src/platform/EFR32/args.gni") - -efr32_sdk_target = get_label_info(":sdk", "label_no_toolchain") +declare_args() { + openthread_efr32_root = "//third_party/silabs/gecko_sdk/protocol/openthread/platform-abstraction/efr32" +} diff --git a/config/esp32/components/chip/CMakeLists.txt b/config/esp32/components/chip/CMakeLists.txt index d7cb69a6a8fa34..fcd62b8757a36c 100644 --- a/config/esp32/components/chip/CMakeLists.txt +++ b/config/esp32/components/chip/CMakeLists.txt @@ -31,10 +31,10 @@ endif() include(${CMAKE_CURRENT_LIST_DIR}/ota-image.cmake) -set(CHIP_REQURIE_COMPONENTS freertos lwip bt mbedtls fatfs app_update console openthread nvs_flash) +set(CHIP_REQUIRE_COMPONENTS freertos lwip bt mbedtls fatfs app_update console openthread nvs_flash spi_flash) if((NOT "${IDF_TARGET}" STREQUAL "esp32h2") AND (NOT "${IDF_TARGET}" STREQUAL "esp32c2")) - list(APPEND CHIP_REQURIE_COMPONENTS mdns) + list(APPEND CHIP_REQUIRE_COMPONENTS mdns) endif() if (NOT CMAKE_BUILD_EARLY_EXPANSION) @@ -49,7 +49,7 @@ if (NOT CMAKE_BUILD_EARLY_EXPANSION) endif() idf_component_register(SRCS chip.c chip.cpp - PRIV_REQUIRES ${CHIP_REQURIE_COMPONENTS}) + PRIV_REQUIRES ${CHIP_REQUIRE_COMPONENTS}) # Prepare initial args file (lacking compile flags) # This will be saved as args.gn.in diff --git a/config/esp32/components/chip/Kconfig b/config/esp32/components/chip/Kconfig index dea6109649232f..34b2e0fb043345 100644 --- a/config/esp32/components/chip/Kconfig +++ b/config/esp32/components/chip/Kconfig @@ -673,7 +673,7 @@ menu "CHIP Device Layer" config ENABLE_ESP32_LOCATIONCAPABILITY depends on ENABLE_ESP32_FACTORY_DATA_PROVIDER - bool "Enable ESP32 Device LocationCapability " + bool "Enable ESP32 Device LocationCapability" default n help Enable ESP32 Device LocationCapability diff --git a/config/esp32/components/chip/idf_component.yml b/config/esp32/components/chip/idf_component.yml new file mode 100644 index 00000000000000..e47917975ce13d --- /dev/null +++ b/config/esp32/components/chip/idf_component.yml @@ -0,0 +1,6 @@ +## IDF Component Manager Manifest File +dependencies: + espressif/mdns: + version: "^1.0.3" + rules: + - if: "idf_version >=5.0" diff --git a/config/nrfconnect/chip-module/CMakeLists.txt b/config/nrfconnect/chip-module/CMakeLists.txt index 0ca4a816f5f1d2..c48d18c13bee02 100644 --- a/config/nrfconnect/chip-module/CMakeLists.txt +++ b/config/nrfconnect/chip-module/CMakeLists.txt @@ -212,6 +212,7 @@ chip_gn_arg_bool ("chip_config_network_layer_ble" CONFIG_BT) chip_gn_arg_bool ("chip_inet_config_enable_ipv4" CONFIG_NET_IPV4) chip_gn_arg_bool ("chip_enable_nfc" CONFIG_CHIP_NFC_COMMISSIONING) chip_gn_arg_bool ("chip_enable_ota_requestor" CONFIG_CHIP_OTA_REQUESTOR) +chip_gn_arg_bool ("chip_persist_subscriptions" CONFIG_CHIP_PERSISTENT_SUBSCRIPTIONS) chip_gn_arg_bool ("chip_build_tests" CONFIG_CHIP_BUILD_TESTS) chip_gn_arg_bool ("chip_monolithic_tests" CONFIG_CHIP_BUILD_TESTS) chip_gn_arg_bool ("chip_inet_config_enable_tcp_endpoint" CONFIG_CHIP_BUILD_TESTS) diff --git a/config/nrfconnect/chip-module/Kconfig b/config/nrfconnect/chip-module/Kconfig index ad61ab9e848112..b0ab15b75a9f4e 100644 --- a/config/nrfconnect/chip-module/Kconfig +++ b/config/nrfconnect/chip-module/Kconfig @@ -23,17 +23,16 @@ config CHIP_DEVICE_VENDOR_NAME default "Nordic Semiconductor ASA" config CHIP_APP_LOG_LEVEL - int "Set logging level in application" + int "Logging level in application" default LOG_DEFAULT_LEVEL depends on LOG help - Sets the logging level in Matter application. - This config should be used only within application. - To set the logging level for Matter stack use MATTER_LOG_LEVEL - config. + Sets the logging level in the Matter application. Use this configuration + option only within the application. To set the logging level for the + Matter stack, use the MATTER_LOG_LEVEL configuration option. config CHIP_NFC_COMMISSIONING - bool "Enable NFC commissioning support" + bool "Share onboarding payload in NFC tag" default n imply NFC_T2T_NRFXLIB imply NFC_NDEF @@ -42,7 +41,7 @@ config CHIP_NFC_COMMISSIONING imply NFC_NDEF_URI_REC imply NFC_NDEF_URI_MSG help - Enables NFC commissioning by sharing onboarding payload in NFC tag. + Enables sharing the onboarding payload in the NFC tag. # See config/zephyr/Kconfig for full definition config CHIP_OTA_REQUESTOR @@ -59,8 +58,8 @@ config CHIP_OTA_REQUESTOR_BUFFER_SIZE default 1024 depends on CHIP_OTA_REQUESTOR help - Configures size of the buffer used by OTA Requestor when downloading and - writing a new firmware image to flash. + Configures the size of the buffer used by OTA Requestor when downloading + and writing a new firmware image to flash. config CHIP_OTA_REQUESTOR_REBOOT_ON_APPLY bool "Auto-reboot when firmware update is applied" @@ -68,9 +67,9 @@ config CHIP_OTA_REQUESTOR_REBOOT_ON_APPLY depends on CHIP_OTA_REQUESTOR imply REBOOT help - When a user consents to apply a firmware update, and the update package is - downloaded, reboot the device automatically to swap the old and the new - firmware images. + Reboots the device automatically after downloading a new firmware update + to swap the old and the new firmware images. The reboot happens only when + a user consents to apply the firmware update. # See config/zephyr/Kconfig for full definition config CHIP_OTA_IMAGE_BUILD @@ -87,54 +86,55 @@ config CHIP_DEBUG_SYMBOLS bool "Generate debug symbols" default y help - Build the application with debug symbols. + Enables building the application with debug symbols. config CHIP_FACTORY_DATA - bool "Enable Factory Data support" + bool "Factory data provider" select ZCBOR select FPROTECT help - Enables support for reading factory data from flash memory partition. - It requires factory_data partition to exist in the partition manager - configuration file pm_static.yml. + Enables the default nRF Connect factory data provider implementation that + supports reading the factory data encoded in the CBOR format from the + flash memory partition. This option requires the factory_data partition in + Partition Manager configuration file (pm_static.yml). config CHIP_FACTORY_DATA_CUSTOM_BACKEND - bool "Enable Factory Data custom backend" + bool "Custom factory data provider" depends on !CHIP_FACTORY_DATA help - Enables user custom factory data implementation. It cannot be used - with the CHIP_FACTORY_DATA that enabled default nRF Connect factory data - implementation. + Enables user's custom factory data provider implementation. This option + cannot be used with the CHIP_FACTORY_DATA, which enables the default nRF + Connect factory data provider implementation. config CHIP_FACTORY_DATA_BUILD - bool "Enable Factory Data build" + bool "Generate factory data contents" default n help - Enables generation of factory data during the building. - It requires factory_data partition to exist in the partition manager - configuration file pm_static.yml. - As a result a new output file factory_data.hex will be created. + Enables generation of the factory data contents during the building. This + option requires the factory_data partition in Partition Manager + configuration file (pm_static.yml). As a result, a new output file is + created (factory_data.hex). config CHIP_FACTORY_DATA_VERSION int default 1 help - The Factory data version contains a current version of a factory data - parameter set that the user cannot change. - After moving to the next version of the factory data set, change the default value. - This config is used to validate the version of a factory data set on a device-side - with the version of factory data saved in the Flash memory. + Provides the version of the generated factory data parameter set. This is + a hidden configuration option that the user cannot change. You can use + this value in the factory data provider implementation to verify that the + factory data saved in the flash memory has the expected version. if CHIP_FACTORY_DATA_BUILD # Factory data definitions config CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE - bool "Enable merging generated factory data with the build target .hex file" + bool "Merge generated factory data with merged.hex output build file" default y help - Enables merging generated factory data with the build target merged.hex file. - As a result, a new output file merged.hex will consist of all partitions including - factory data. + Enables merging the generated factory data with the merged.hex output + build file. As a result, the merged.hex build output file, which is used + when flashing the firmware using the west tool, includes the factory data + as well. # Select source of the certificates choice CHIP_FACTORY_DATA_CERT_SOURCE @@ -144,52 +144,56 @@ choice CHIP_FACTORY_DATA_CERT_SOURCE config CHIP_FACTORY_DATA_USE_DEFAULT_CERTS bool "Use pre-generated development certificates" help - Use pre-generated certificate files from the credentials/development/attestation/ - directory that match the configured Product ID. This can be used for development - purpose. + Uses pre-generated certificate files from the + credentials/development/attestation/ directory that match the + configured Product ID. This can be used for development purpose. + config CHIP_FACTORY_DATA_CERT_SOURCE_GENERATED bool "Auto-generate certificates" help - Generate new certificates instead of using pre-generated ones. - The certificates are generated on every build. + Generates new certificates instead of using pre-generated ones. The + certificates are generated on every build. + config CHIP_FACTORY_DATA_CERT_SOURCE_USER bool "Use user-provided certificate files" help - Use user-provided certificate files. - The user needs to specify the absolute path to all necessary files. + Uses user-provided certificate files. The user needs to specify the + absolute paths to all necessary files. + endchoice if CHIP_FACTORY_DATA_CERT_SOURCE_USER config CHIP_FACTORY_DATA_USER_CERTS_DAC_CERT - string "Path to the DAC certificate *.der-file" + string "Path to the DAC certificate (DER format)" help - Absolute path to the DAC certificate file in binary format. + Provides the absolute path to the DAC certificate file in the DER format. + config CHIP_FACTORY_DATA_USER_CERTS_DAC_KEY - string "Path to the DAC private key *.der-file" + string "Path to the DAC private key (DER format)" help - Absolute path to the DAC keysfile in binary format. - Note that both public and private keys must be present (will be extracted automatically). + Provides the absolute path to the DAC keypair file in the DER format. Both + public and private keys must be present (the private key will be extracted + automatically). + config CHIP_FACTORY_DATA_USER_CERTS_PAI_CERT - string "Path to the PAI certificate *.der-file" + string "Path to the PAI certificate (DER format)" help - Absolute path pointing to the PAI certificate in binary format. + Provides the absolute path to the PAI certificate in the DER format. endif -# Configs for SPAKE2 generation +# Configs for SPAKE2+ generation config CHIP_FACTORY_DATA_GENERATE_SPAKE2_VERIFIER - bool "Enable spake2 verifier generation" + bool "Generate SPAKE2+ verifier" help - Enables generation of spake2 verifier according to - given iteration counter, salt and passcode. - To generate Spake2 verifier a spake2p executable must be available - from system variables environment. + Enables the generation of the SPAKE2+ verifier for the configured SPAKE2+ + passcode, iteration count and salt. config CHIP_DEVICE_GENERATE_ROTATING_DEVICE_UID - bool "Enable generation of a new Rotating device id unique id" + bool "Generate Rotating device ID unique ID" default y help - Enables generation of a new Rotating device id unique id. + Enables the generation of a random Rotating device ID unique ID. endif #CHIP_FACTORY_DATA_BUILD @@ -203,7 +207,7 @@ endif config CHIP_LOG_SIZE_OPTIMIZATION bool "Disable some detailed logs to decrease flash usage" help - Disables some log levels for the specific log modules - providing detailed information that are not used in most cases. - You can find full configuration enabled by this option - in the platform/nrfconnect/CHIPPlatformConfig.h file. + Disables some log levels for specific Matter log modules that provide + information that is too detailed to be used in most cases. You can find + full configuration enabled by this option in the + platform/nrfconnect/CHIPPlatformConfig.h file. diff --git a/config/nrfconnect/chip-module/Kconfig.defaults b/config/nrfconnect/chip-module/Kconfig.defaults index f6010168f4b3da..26126987a5055c 100644 --- a/config/nrfconnect/chip-module/Kconfig.defaults +++ b/config/nrfconnect/chip-module/Kconfig.defaults @@ -104,9 +104,19 @@ config BT_PERIPHERAL_PREF_MIN_INT config BT_PERIPHERAL_PREF_MAX_INT default 36 +# Increase BT timeout to 5 s to improve connection reliability and avoid fast drop outs. +config BT_PERIPHERAL_PREF_TIMEOUT + default 500 + config BT_GAP_AUTO_UPDATE_CONN_PARAMS default y +# Decrease connection parameters update time, as some Matter controllers request +# enabling IP networking faster than BT connection parameters are updated, what may result +# in commissioning instabilities. +config BT_CONN_PARAM_UPDATE_TIMEOUT + default 1000 + config BT_GATT_DYNAMIC_DB default y @@ -117,9 +127,7 @@ config BT_DEVICE_NAME_MAX default 15 config BT_MAX_CONN - default 2 # a workaround for non-unreferenced BLE connection object - # when restaring the BLE advertising in disconnect callback - # TODO: analyze and revert to 1 if proper fix exists + default 1 config BT_L2CAP_TX_MTU default 247 diff --git a/config/nrfconnect/chip-module/Kconfig.features b/config/nrfconnect/chip-module/Kconfig.features index 662d7074ebe0b3..1a1bf027267601 100644 --- a/config/nrfconnect/chip-module/Kconfig.features +++ b/config/nrfconnect/chip-module/Kconfig.features @@ -43,8 +43,8 @@ config CHIP_WIFI config CHIP_QSPI_NOR bool "Enable QSPI NOR feature set" help - Enables QSPI NOR with the set of options - configuring pages and buffer sizes. + Enables QSPI NOR flash with a set of options for configuring pages and + buffer sizes. if CHIP_QSPI_NOR @@ -63,8 +63,8 @@ config CHIP_SPI_NOR imply MULTITHREADING imply PM_OVERRIDE_EXTERNAL_DRIVER_CHECK help - Enables SPI NOR with the set of options - configuring pages and buffer sizes. + Enables SPI NOR flash with a set of options for configuring pages and + buffer sizes. if CHIP_SPI_NOR @@ -83,11 +83,11 @@ config CHIP_DFU_OVER_BT_SMP select MCUMGR_CMD_IMG_MGMT select MCUMGR_CMD_OS_MGMT # Enable custom SMP request to erase settings partition. - select MCUMGR_GRP_ZEPHYR_BASIC if SOC_SERIES_NRF53X - select MCUMGR_GRP_BASIC_CMD_STORAGE_ERASE if SOC_SERIES_NRF53X + select MCUMGR_GRP_ZEPHYR_BASIC + select MCUMGR_GRP_BASIC_CMD_STORAGE_ERASE help - Enables Device Firmware Upgrade over Bluetoot LE with SMP - and configures set of options related to that feature. + Enables Device Firmware Upgrade over Bluetooth LE with SMP and configures + the set of options related to that feature. if CHIP_DFU_OVER_BT_SMP diff --git a/config/nrfconnect/chip-module/Kconfig.hci_rpmsg.defaults b/config/nrfconnect/chip-module/Kconfig.hci_rpmsg.defaults index 83290b2b492f28..173766a44941c1 100644 --- a/config/nrfconnect/chip-module/Kconfig.hci_rpmsg.defaults +++ b/config/nrfconnect/chip-module/Kconfig.hci_rpmsg.defaults @@ -63,6 +63,10 @@ config BT_HCI_RAW_RESERVE config BT_BUF_CMD_TX_COUNT default 10 +# Enable support for Wi-Fi and Bluetooth LE coexistance +config MPSL_CX + default y + config ASSERT default y diff --git a/config/openiotsdk/CMakeLists.txt b/config/openiotsdk/CMakeLists.txt index 414f591095f1dc..1e7a77a0f21615 100644 --- a/config/openiotsdk/CMakeLists.txt +++ b/config/openiotsdk/CMakeLists.txt @@ -97,20 +97,10 @@ endif() set(GN_ROOT_TARGET ${CHIP_ROOT}/config/openiotsdk/chip-gn) # Prepare compiler flags -# All Open IoT SDK targets -list(APPEND ALL_SDK_TARGETS) - -foreach(source_dir ${SDK_SOURCES_BINARY_DIRS}) - get_all_cmake_targets(SDK_TARGETS ${source_dir}) - list(APPEND ALL_SDK_TARGETS ${SDK_TARGETS}) -endforeach() - -# Exclude unnecessary targets -list(FILTER ALL_SDK_TARGETS EXCLUDE REGEX "^.*linker.*|.*example.*|.*apps.*|.*doc.*|dist|lib$") - -foreach(target ${ALL_SDK_TARGETS}) - get_target_common_compile_flags(SDK_TARGET_CFLAGS ${target}) - list(APPEND CHIP_CFLAGS ${SDK_TARGET_CFLAGS}) +# Get compiler flags from external targets +foreach(target ${EXTERNAL_TARGETS}) + get_target_common_compile_flags(EXTERNAL_TARGET_CFLAGS ${target}) + list(APPEND CHIP_CFLAGS ${EXTERNAL_TARGET_CFLAGS}) endforeach() # Remove duplicated flags @@ -200,6 +190,8 @@ chip_gn_arg_bool ("chip_detail_logging" CONFIG_CHIP_DETAIL_LOG chip_gn_arg_bool ("chip_progress_logging" CONFIG_CHIP_PROGRESS_LOGGING) chip_gn_arg_bool ("chip_automation_logging" CONFIG_CHIP_AUTOMATION_LOGGING) chip_gn_arg_bool ("chip_error_logging" CONFIG_CHIP_ERROR_LOGGING) +chip_gn_arg_bool ("chip_openiotsdk_use_tfm" TFM_SUPPORT) +chip_gn_arg_bool ("chip_openiotsdk_use_psa_ps" CONFIG_CHIP_OPEN_IOT_SDK_USE_PSA_PS) if (TARGET cmsis-rtos-api) chip_gn_arg_string("target_os" "cmsis-rtos") endif() @@ -249,22 +241,10 @@ target_include_directories(openiotsdk-chip INTERFACE target_link_directories(openiotsdk-chip INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/lib) target_link_libraries(openiotsdk-chip INTERFACE -Wl,--start-group ${CHIP_LIBRARIES} -Wl,--end-group) target_link_libraries(openiotsdk-chip INTERFACE - $<$:mcu-driver-hal> - $<$:mcu-driver-bootstrap> - $<$:mdh-reference-platforms-for-arm> - $<$:mbedtls> - $<$:lwipcore> - $<$:iotsdk-ip-network-api> - $<$:iotsdk-tdbstore> - $<$:iotsdk-blockdevice> - $<$:$> + ${EXTERNAL_TARGETS} ) add_dependencies(openiotsdk-chip chip-gn) -target_include_directories(openiotsdk-chip INTERFACE - ${CHIP_ROOT}/config/openiotsdk/mbedtls -) - if (NOT ${CMAKE_BUILD_TYPE} STREQUAL "Debug") target_compile_definitions(openiotsdk-chip INTERFACE NDEBUG diff --git a/config/openiotsdk/cmake/chip.cmake b/config/openiotsdk/cmake/chip.cmake index 985d7f05bf74db..9a7dcf629e3a06 100644 --- a/config/openiotsdk/cmake/chip.cmake +++ b/config/openiotsdk/cmake/chip.cmake @@ -19,6 +19,8 @@ # CMake for CHIP library configuration # +get_filename_component(GEN_DIR ${CHIP_ROOT}/zzz_generated/ REALPATH) + # Default CHIP build configuration set(CONFIG_CHIP_PROJECT_CONFIG "main/include/CHIPProjectConfig.h" CACHE STRING "") set(CONFIG_CHIP_LIB_TESTS NO CACHE BOOL "") @@ -29,5 +31,38 @@ set(CONFIG_CHIP_PROGRESS_LOGGING YES CACHE BOOL "Enable logging at progress leve set(CONFIG_CHIP_AUTOMATION_LOGGING YES CACHE BOOL "Enable logging at automation level") set(CONFIG_CHIP_ERROR_LOGGING YES CACHE BOOL "Enable logging at error level") +set(CONFIG_CHIP_OPEN_IOT_SDK_USE_PSA_PS NO CACHE BOOL "Enable using PSA Protected Storage") + +if(CONFIG_CHIP_OPEN_IOT_SDK_USE_PSA_PS AND NOT TFM_SUPPORT) + message( FATAL_ERROR "You can not use PSA Protected Storage without TF-M support" ) +endif() + # Add CHIP sources add_subdirectory(${OPEN_IOT_SDK_CONFIG} ./chip_build) + +# Additional openiotsdk-chip target configuration + +# TF-M support requires the right order of generating targets +if(TFM_SUPPORT) + add_dependencies(chip-gn tfm-ns-interface) +endif() + +function(chip_add_data_model target scope model_name) + target_include_directories(${target} + PUBLIC + ${GEN_DIR}/app-common + ${GEN_DIR}/${model_name}-app + ) + + target_compile_definitions(${target} + PUBLIC + USE_CHIP_DATA_MODEL + ) + + include(${CHIP_ROOT}/src/app/chip_data_model.cmake) + chip_configure_data_model(${target} + SCOPE ${scope} + INCLUDE_SERVER + ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../${model_name}-common/${model_name}-app.zap + ) +endfunction() diff --git a/config/openiotsdk/cmake/sdk.cmake b/config/openiotsdk/cmake/sdk.cmake index c87dad8412579d..52055cacdfc49a 100644 --- a/config/openiotsdk/cmake/sdk.cmake +++ b/config/openiotsdk/cmake/sdk.cmake @@ -24,41 +24,67 @@ include(FetchContent) get_filename_component(OPEN_IOT_SDK_SOURCE ${CHIP_ROOT}/third_party/open-iot-sdk/sdk REALPATH) get_filename_component(OPEN_IOT_SDK_STORAGE_SOURCE ${CHIP_ROOT}/third_party/open-iot-sdk/storage REALPATH) -# List of binary directories to Open IoT SDK sources -list(APPEND SDK_SOURCES_BINARY_DIRS) +# Open IoT SDK targets passed to CHIP build +list(APPEND EXTERNAL_TARGETS) + +# Additional Open IoT SDK build configuration +set(TFM_SUPPORT NO CACHE BOOL "Add Trusted Firmware-M (TF-M) support to application") +set(TFM_NS_APP_VERSION "0.0.0" CACHE STRING "TF-M non-secure application version (in the x.x.x format)") + +# Overwrite versions of Open IoT SDK components + +# Add a Matter specific version of Mbedtls +FetchContent_Declare( + mbedtls + GIT_REPOSITORY https://github.com/ARMmbed/mbedtls + GIT_TAG v3.2.1 + GIT_SHALLOW ON + GIT_PROGRESS ON +) # Open IoT SDK configuration -set(IOTSDK_MDH_ARM ON) -set(MDH_PLATFORM "ARM_AN552_MPS3") -set(MDH_ARM_BUILD_EXAMPLES OFF) -set(IOTSDK_CMSIS_RTOS_API ON) -set(IOTSDK_FREERTOS ON) -set(IOTSDK_MBEDTLS ON) -set(IOTSDK_LWIP ON) -set(FETCHCONTENT_QUIET OFF) -set(IOTSDK_EXAMPLES OFF) -set(BUILD_TESTING NO) +set(IOTSDK_FETCH_LIST + mcu-driver-reference-platforms-for-arm + cmsis-5 + cmsis-freertos + mbedtls + lwip + cmsis-sockets-api +) + +set(MDH_PLATFORM ARM_AN552_MPS3) set(VARIANT "FVP") +set(FETCHCONTENT_QUIET OFF) +if(TFM_SUPPORT) + list(APPEND IOTSDK_FETCH_LIST trusted-firmware-m) + set(TFM_PLATFORM ${OPEN_IOT_SDK_EXAMPLE_COMMON}/tf-m/targets/an552) + set(TFM_PSA_FIRMWARE_UPDATE ON) + set(MCUBOOT_IMAGE_VERSION_NS ${TFM_NS_APP_VERSION}) + set(TFM_CMAKE_ARGS "-DCONFIG_TFM_ENABLE_FP=ON;-DTFM_PROFILE=profile_medium") + if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") + set(TFM_CMAKE_ARGS "${TFM_CMAKE_ARGS};-DMCUBOOT_LOG_LEVEL=INFO;-DTFM_SPM_LOG_LEVEL=TFM_SPM_LOG_LEVEL_INFO;-DTFM_PARTITION_LOG_LEVEL=TFM_PARTITION_LOG_LEVEL_INFO") + else() + set(TFM_CMAKE_ARGS "${TFM_CMAKE_ARGS};-DMCUBOOT_LOG_LEVEL=ERROR;-DTFM_SPM_LOG_LEVEL=TFM_SPM_LOG_LEVEL_ERROR;-DTFM_PARTITION_LOG_LEVEL=TFM_PARTITION_LOG_LEVEL_ERROR") + endif() + if(TFM_PROJECT_CONFIG_HEADER_FILE) + set(TFM_CMAKE_ARGS "${TFM_CMAKE_ARGS};-DPROJECT_CONFIG_HEADER_FILE=${TFM_PROJECT_CONFIG_HEADER_FILE}") + endif() + set(LINKER_SCRIPT ${OPEN_IOT_SDK_CONFIG}/ld/cs300_gcc_tfm.ld) +endif() # Add Open IoT SDK source add_subdirectory(${OPEN_IOT_SDK_SOURCE} ./sdk_build) -list(APPEND SDK_SOURCES_BINARY_DIRS ${CMAKE_CURRENT_BINARY_DIR}/sdk_build) # Add Open IoT SDK modules to path list(APPEND CMAKE_MODULE_PATH ${open-iot-sdk_SOURCE_DIR}/cmake) +list(APPEND CMAKE_MODULE_PATH ${open-iot-sdk_SOURCE_DIR}/components/trusted-firmware-m) + +# Configure component properties -# CMSIS-RTOS configuration # CMSIS 5 require projects to provide configuration macros via RTE_Components.h # and CMSIS_device_header. The macro CMSIS_device_header is not automatically set # based on CMAKE_SYSTEM_PROCESSOR in the place where cmsis-core is first defined, # because a project may want to provide its own device header. -if(TARGET cmsis-rtos-api) - target_include_directories(cmsis-rtos-api - PUBLIC - cmsis-config - ) -endif() - if(TARGET cmsis-core) target_compile_definitions(cmsis-core INTERFACE @@ -66,6 +92,48 @@ if(TARGET cmsis-core) ) endif() +# Add RTOS configuration headers +# Link cmsis-rtos-api against a concrete implementation +if(TARGET cmsis-rtos-api) + target_include_directories(cmsis-core + INTERFACE + cmsis-config + ) + + target_compile_definitions(cmsis-rtos-api + PUBLIC + DOMAIN_NS=$,1,0> + ) + + if(TARGET freertos-kernel) + target_include_directories(freertos-kernel + PUBLIC + freertos-config + ) + + target_link_libraries(freertos-kernel + PUBLIC + cmsis-core + ) + + target_link_libraries(cmsis-rtos-api + PUBLIC + freertos-cmsis-rtos + freertos-kernel-heap-3 + ) + + target_compile_definitions(cmsis-rtos-api + INTERFACE + CONFIG_RUN_FREERTOS_SECURE_ONLY=$,0,1> + ) + elseif(TARGET cmsis-rtx) + target_link_libraries(cmsis-rtos-api + INTERFACE + cmsis-rtx + ) + endif() +endif() + # LwIP configuration if(TARGET lwip-cmsis-port) # lwipcore requires the config defined by lwip-cmsis-port @@ -94,6 +162,13 @@ if(TARGET ethernet-lan91c111) ) endif() +if(TARGET mcu-driver-hal) + target_compile_definitions(mcu-driver-hal + INTERFACE + DOMAIN_NS=$,1,0> + ) +endif() + # Mbedtls config if(TARGET mbedtls-config) target_include_directories(mbedtls-config @@ -101,14 +176,14 @@ if(TARGET mbedtls-config) ${OPEN_IOT_SDK_CONFIG}/mbedtls ) - target_sources(mbedtls-config + target_sources(mbedtls-config INTERFACE ${OPEN_IOT_SDK_CONFIG}/mbedtls/platform_alt.cpp ) target_compile_definitions(mbedtls-config INTERFACE - MBEDTLS_CONFIG_FILE="mbedtls_config.h" + MBEDTLS_CONFIG_FILE="${OPEN_IOT_SDK_CONFIG}/mbedtls/mbedtls_config.h" ) target_link_libraries(mbedtls-config @@ -117,28 +192,138 @@ if(TARGET mbedtls-config) ) endif() -# Declare RTOS interface target -add_library(cmsis-rtos-implementation INTERFACE) +if("mcu-driver-reference-platforms-for-arm" IN_LIST IOTSDK_FETCH_LIST) + list(APPEND EXTERNAL_TARGETS + mcu-driver-bootstrap + mcu-driver-hal + mdh-arm-corstone-300-common + target-interface + ) +endif() -if(TARGET freertos-kernel) - target_link_libraries(cmsis-rtos-implementation - INTERFACE - freertos-cmsis-rtos - freertos-kernel-heap-3 +if("cmsis-5" IN_LIST IOTSDK_FETCH_LIST) + list(APPEND EXTERNAL_TARGETS + cmsis-core + cmsis-rtos-api + iotsdk-ip-network-api ) - target_include_directories(cmsis-rtos-implementation - INTERFACE - ${CMAKE_CURRENT_SOURCE_DIR}/freertos-config +endif() + +if("cmsis-freertos" IN_LIST IOTSDK_FETCH_LIST) + list(APPEND EXTERNAL_TARGETS + freertos-cmsis-rtos ) -elseif(TARGET cmsis-rtx) - target_link_libraries(cmsis-rtos-implementation - INTERFACE - cmsis-rtx - cmsis-rtos-api - cmsis-rtx-freertos-alloc-wrapper +endif() + +if("mbedtls" IN_LIST IOTSDK_FETCH_LIST) + list(APPEND EXTERNAL_TARGETS + mbedtls + mbedtls-config + mbedtls-threading-cmsis-rtos ) endif() +if("lwip" IN_LIST IOTSDK_FETCH_LIST) + list(APPEND EXTERNAL_TARGETS + lwipcore + lwip-cmsis-port + lwip-cmsis-sys + lwip-cmsis-port-low-input-latency + lwipopts + ) +endif() + +if("cmsis-sockets-api" IN_LIST IOTSDK_FETCH_LIST) + list(APPEND EXTERNAL_TARGETS + cmsis-sockets-api + lwip-sockets + ) +endif() + +if("trusted-firmware-m" IN_LIST IOTSDK_FETCH_LIST) + list(APPEND EXTERNAL_TARGETS + tfm-ns-interface + tfm-ns-interface-cmsis-rtos + ) +endif() + +# Additional Open IoT SDK port components + # Add Open IoT SDK storage source add_subdirectory(${OPEN_IOT_SDK_STORAGE_SOURCE} ./sdk_storage_build) -list(APPEND SDK_SOURCES_BINARY_DIRS ${CMAKE_CURRENT_BINARY_DIR}/sdk_storage_build) +list(APPEND EXTERNAL_TARGETS + iotsdk-blockdevice + iotsdk-tdbstore +) + +# Add custom storage library +add_subdirectory(${OPEN_IOT_SDK_CONFIG}/storage storage_build) +list(APPEND EXTERNAL_TARGETS + openiotsdk-storage +) + +function(sdk_post_build target) + string(REPLACE "_ns" "" APP_NAME ${APP_TARGET}) +if(TFM_SUPPORT) + include(ConvertElfToBin) + include(SignTfmImage) + target_elf_to_bin(${APP_TARGET}) + iotsdk_tf_m_sign_image(${APP_TARGET}) + iotsdk_tf_m_merge_images(${APP_TARGET} 0x10000000 0x38000000 0x28060000) + ExternalProject_Get_Property(trusted-firmware-m-build BINARY_DIR) + # Cleanup + add_custom_command( + TARGET + ${APP_TARGET} + POST_BUILD + DEPENDS + $/tfm_s_signed.bin + $/${APP_TARGET}.bin + $/${APP_TARGET}_signed.bin + $/${APP_TARGET}_merged.hex + $/${APP_TARGET}_merged.elf + COMMAND + # Copy the TF-M secure elf image + ${CMAKE_COMMAND} -E copy + ${BINARY_DIR}/install/outputs/tfm_s.elf + $/ + COMMAND + # Rename output file + ${CMAKE_COMMAND} -E copy + $/${APP_TARGET}_merged.elf + $/${APP_NAME}.elf + COMMAND rm + ARGS -Rf + $/tfm_s_signed.bin + $/${APP_TARGET}.bin + $/${APP_TARGET}_signed.bin + $/${APP_TARGET}_merged.hex + $/${APP_TARGET}_merged.elf + VERBATIM + ) +else() + add_custom_command( + TARGET + ${APP_TARGET} + POST_BUILD + DEPENDS + $/${APP_TARGET}.elf + $/${APP_TARGET}.map + COMMAND + # Rename output elf file + ${CMAKE_COMMAND} -E copy + $/${APP_TARGET}.elf + $/${APP_NAME}.elf + COMMAND + # Rename output map file + ${CMAKE_COMMAND} -E copy + $/${APP_TARGET}.map + $/${APP_NAME}.map + COMMAND rm + ARGS -Rf + $/${APP_TARGET}.elf + $/${APP_TARGET}.map + VERBATIM + ) +endif() #TFM_SUPPORT +endfunction() diff --git a/config/openiotsdk/ld/cs300_gcc.ld b/config/openiotsdk/ld/cs300_gcc.ld index 850e91200bc0d5..97ec041ff09ed6 100644 --- a/config/openiotsdk/ld/cs300_gcc.ld +++ b/config/openiotsdk/ld/cs300_gcc.ld @@ -1,4 +1,20 @@ -; +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + MEMORY { ITCM (rx) : ORIGIN = 0x00000000, LENGTH = 32K diff --git a/config/openiotsdk/ld/cs300_gcc_tfm.ld b/config/openiotsdk/ld/cs300_gcc_tfm.ld new file mode 100644 index 00000000000000..523c96e8efb77c --- /dev/null +++ b/config/openiotsdk/ld/cs300_gcc_tfm.ld @@ -0,0 +1,172 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +MEMORY +{ + FLASH (rx) : ORIGIN = ((0x28000000) + (0x60000) + (0x400)), LENGTH = ((0x200000) - (0x400) - (0x800)) + RAM (rwx) : ORIGIN = 0x21000000, LENGTH = 0x100000 +} + +__stack_size__ = 0x1000; + +/* Library configurations */ +GROUP(libgcc.a libc.a libm.a libnosys.a) + +SECTIONS +{ + .text : + { + KEEP(*(.vectors)) + __Vectors_End = .; + __Vectors_Size = __Vectors_End - __Vectors; + __end__ = .; + + *(.text*) + + KEEP(*(.init)) + KEEP(*(.fini)) + + + /* .ctors */ + *crtbegin.o(.ctors) + *crtbegin?.o(.ctors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) + *(SORT(.ctors.*)) + *(.ctors) + + /* .dtors */ + *crtbegin.o(.dtors) + *crtbegin?.o(.dtors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) + *(SORT(.dtors.*)) + *(.dtors) + + *(.rodata*) + + KEEP(*(.eh_frame*)) + } > FLASH + + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + __exidx_start = .; + + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + + __exidx_end = .; + + /* To copy multiple ROM to RAM sections, + * define etext2/data2_start/data2_end */ + .copy.table : + { + . = ALIGN(4); + __copy_table_start__ = .; + LONG (__etext) + LONG (__data_start__) + LONG (__data_end__ - __data_start__) + LONG (DEFINED(__etext2) ? __etext2 : 0) + LONG (DEFINED(__data2_start__) ? __data2_start__ : 0) + LONG (DEFINED(__data2_start__) ? __data2_end__ - __data2_start__ : 0) + __copy_table_end__ = .; + } > FLASH + + .zero.table : + { + . = ALIGN(4); + __zero_table_start__ = .; + LONG (__bss_start__) + LONG (__bss_end__ - __bss_start__) + LONG (DEFINED(__bss2_start__) ? __bss2_start__ : 0) + LONG (DEFINED(__bss2_start__) ? __bss2_end__ - __bss2_start__ : 0) + __zero_table_end__ = .; + } > FLASH + + __etext = .; + + .data : AT (__etext) + { + __data_start__ = .; + *(vtable) + *(.data*) + + . = ALIGN(4); + /* preinit data */ + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP(*(.preinit_array)) + PROVIDE_HIDDEN (__preinit_array_end = .); + + . = ALIGN(4); + /* init data */ + PROVIDE_HIDDEN (__init_array_start = .); + KEEP(*(SORT(.init_array.*))) + KEEP(*(.init_array)) + PROVIDE_HIDDEN (__init_array_end = .); + + . = ALIGN(4); + /* finit data */ + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP(*(SORT(.fini_array.*))) + KEEP(*(.fini_array)) + PROVIDE_HIDDEN (__fini_array_end = .); + + KEEP(*(.jcr*)) + . = ALIGN(4); + /* All data end */ + __data_end__ = .; + } > RAM + + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + *(.bss*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM + + bss_size = __bss_end__ - __bss_start__; + + .stack : + { + . = ALIGN(8); + __StackLimit = .; + KEEP(*(.stack*)) + . += __stack_size__; + __StackTop = .; + } > RAM + PROVIDE(__stack = __StackTop); + + .heap (COPY): + { + . = ALIGN(8); + __HeapBase = .; + __end__ = .; + end = __end__; + KEEP(*(.heap*)) + . += (ORIGIN(RAM) + LENGTH(RAM) - .); + __HeapLimit = .; + __heap_limit = .; + } > RAM + + ASSERT(__HeapLimit <= (ORIGIN(RAM) + LENGTH(RAM)), "RAM region overflowed") +} diff --git a/config/openiotsdk/mbedtls/mbedtls_config.h b/config/openiotsdk/mbedtls/mbedtls_config.h index e12878adf14986..316d43c67940d0 100644 --- a/config/openiotsdk/mbedtls/mbedtls_config.h +++ b/config/openiotsdk/mbedtls/mbedtls_config.h @@ -24,12 +24,14 @@ * limitations under the License. */ -#ifndef MBEDTLS_CONFIG_H -#define MBEDTLS_CONFIG_H - -#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) -#define _CRT_SECURE_NO_DEPRECATE 1 -#endif +/** + * This is an optional version symbol that enables compatibility handling of + * config files. + * + * It is equal to the #MBEDTLS_VERSION_NUMBER of the Mbed TLS version that + * introduced the config format we want to be compatible with. + */ +//#define MBEDTLS_CONFIG_VERSION 0x03000000 /** * \name SECTION: System support @@ -47,8 +49,7 @@ * * Used in: * library/aria.c - * library/timing.c - * include/mbedtls/bn_mul.h + * library/bn_mul.h * * Required by: * MBEDTLS_AESNI_C @@ -128,7 +129,12 @@ * MBEDTLS_PLATFORM_TIME_MACRO, MBEDTLS_PLATFORM_TIME_TYPE_MACRO and * MBEDTLS_PLATFORM_STD_TIME. * - * Comment if your system does not support time functions + * Comment if your system does not support time functions. + * + * \note If MBEDTLS_TIMING_C is set - to enable the semi-portable timing + * interface - timing.c will include time.h on suitable platforms + * regardless of the setting of MBEDTLS_HAVE_TIME, unless + * MBEDTLS_TIMING_ALT is used. See timing.c for more information. */ #define MBEDTLS_HAVE_TIME @@ -219,6 +225,7 @@ * Uncomment a macro to enable alternate implementation of specific base * platform function */ +//#define MBEDTLS_PLATFORM_SETBUF_ALT //#define MBEDTLS_PLATFORM_EXIT_ALT //#define MBEDTLS_PLATFORM_TIME_ALT //#define MBEDTLS_PLATFORM_FPRINTF_ALT @@ -255,73 +262,7 @@ */ //#define MBEDTLS_DEPRECATED_REMOVED -/** - * \def MBEDTLS_CHECK_PARAMS - * - * This configuration option controls whether the library validates more of - * the parameters passed to it. - * - * When this flag is not defined, the library only attempts to validate an - * input parameter if: (1) they may come from the outside world (such as the - * network, the filesystem, etc.) or (2) not validating them could result in - * internal memory errors such as overflowing a buffer controlled by the - * library. On the other hand, it doesn't attempt to validate parameters whose - * values are fully controlled by the application (such as pointers). - * - * When this flag is defined, the library additionally attempts to validate - * parameters that are fully controlled by the application, and should always - * be valid if the application code is fully correct and trusted. - * - * For example, when a function accepts as input a pointer to a buffer that may - * contain untrusted data, and its documentation mentions that this pointer - * must not be NULL: - * - The pointer is checked to be non-NULL only if this option is enabled. - * - The content of the buffer is always validated. - * - * When this flag is defined, if a library function receives a parameter that - * is invalid: - * 1. The function will invoke the macro MBEDTLS_PARAM_FAILED(). - * 2. If MBEDTLS_PARAM_FAILED() did not terminate the program, the function - * will immediately return. If the function returns an Mbed TLS error code, - * the error code in this case is MBEDTLS_ERR_xxx_BAD_INPUT_DATA. - * - * When defining this flag, you also need to arrange a definition for - * MBEDTLS_PARAM_FAILED(). You can do this by any of the following methods: - * - By default, the library defines MBEDTLS_PARAM_FAILED() to call a - * function mbedtls_param_failed(), but the library does not define this - * function. If you do not make any other arrangements, you must provide - * the function mbedtls_param_failed() in your application. - * See `platform_util.h` for its prototype. - * - If you enable the macro #MBEDTLS_CHECK_PARAMS_ASSERT, then the - * library defines MBEDTLS_PARAM_FAILED(\c cond) to be `assert(cond)`. - * You can still supply an alternative definition of - * MBEDTLS_PARAM_FAILED(), which may call `assert`. - * - If you define a macro MBEDTLS_PARAM_FAILED() before including `config.h` - * or you uncomment the definition of MBEDTLS_PARAM_FAILED() in `config.h`, - * the library will call the macro that you defined and will not supply - * its own version. Note that if MBEDTLS_PARAM_FAILED() calls `assert`, - * you need to enable #MBEDTLS_CHECK_PARAMS_ASSERT so that library source - * files include ``. - * - * Uncomment to enable validation of application-controlled parameters. - */ -//#define MBEDTLS_CHECK_PARAMS - -/** - * \def MBEDTLS_CHECK_PARAMS_ASSERT - * - * Allow MBEDTLS_PARAM_FAILED() to call `assert`, and make it default to - * `assert`. This macro is only used if #MBEDTLS_CHECK_PARAMS is defined. - * - * If this macro is not defined, then MBEDTLS_PARAM_FAILED() defaults to - * calling a function mbedtls_param_failed(). See the documentation of - * #MBEDTLS_CHECK_PARAMS for details. - * - * Uncomment to allow MBEDTLS_PARAM_FAILED() to call `assert`. - */ -//#define MBEDTLS_CHECK_PARAMS_ASSERT - -/* \} name SECTION: System support */ +/** \} name SECTION: System support */ /** * \name SECTION: mbed TLS feature support @@ -334,7 +275,7 @@ /** * \def MBEDTLS_TIMING_ALT * - * Uncomment to provide your own alternate implementation for mbedtls_timing_hardclock(), + * Uncomment to provide your own alternate implementation for * mbedtls_timing_get_timer(), mbedtls_set_alarm(), mbedtls_set/get_delay() * * Only works if you have MBEDTLS_TIMING_C enabled. @@ -363,16 +304,14 @@ * Uncomment a macro to enable alternate implementation of the corresponding * module. * - * \warning MD2, MD4, MD5, ARC4, DES and SHA-1 are considered weak and their + * \warning MD5, DES and SHA-1 are considered weak and their * use constitutes a security risk. If possible, we recommend * avoiding dependencies on them, and considering stronger message * digests and ciphers instead. * */ //#define MBEDTLS_AES_ALT -//#define MBEDTLS_ARC4_ALT //#define MBEDTLS_ARIA_ALT -//#define MBEDTLS_BLOWFISH_ALT //#define MBEDTLS_CAMELLIA_ALT //#define MBEDTLS_CCM_ALT //#define MBEDTLS_CHACHA20_ALT @@ -383,8 +322,6 @@ //#define MBEDTLS_ECJPAKE_ALT //#define MBEDTLS_GCM_ALT //#define MBEDTLS_NIST_KW_ALT -//#define MBEDTLS_MD2_ALT -//#define MBEDTLS_MD4_ALT //#define MBEDTLS_MD5_ALT //#define MBEDTLS_POLY1305_ALT //#define MBEDTLS_RIPEMD160_ALT @@ -392,10 +329,9 @@ //#define MBEDTLS_SHA1_ALT //#define MBEDTLS_SHA256_ALT //#define MBEDTLS_SHA512_ALT -//#define MBEDTLS_XTEA_ALT /* - * When replacing the elliptic curve module, pleace consider, that it is + * When replacing the elliptic curve module, please consider, that it is * implemented with two .c files: * - ecp.c * - ecp_curves.c @@ -406,7 +342,7 @@ //#define MBEDTLS_ECP_ALT /** - * \def MBEDTLS_MD2_PROCESS_ALT + * \def MBEDTLS_SHA256_PROCESS_ALT * * MBEDTLS__FUNCTION_NAME__ALT: Uncomment a macro to let mbed TLS use you * alternate core implementation of symmetric crypto or hash function. Keep in @@ -421,20 +357,14 @@ * of mbedtls_sha1_context, so your implementation of mbedtls_sha1_process must be compatible * with this definition. * - * \note Because of a signature change, the core AES encryption and decryption routines are - * currently named mbedtls_aes_internal_encrypt and mbedtls_aes_internal_decrypt, - * respectively. When setting up alternative implementations, these functions should - * be overridden, but the wrapper functions mbedtls_aes_decrypt and mbedtls_aes_encrypt - * must stay untouched. - * - * \note If you use the AES_xxx_ALT macros, then is is recommended to also set + * \note If you use the AES_xxx_ALT macros, then it is recommended to also set * MBEDTLS_AES_ROM_TABLES in order to help the linker garbage-collect the AES * tables. * * Uncomment a macro to enable alternate implementation of the corresponding * function. * - * \warning MD2, MD4, MD5, DES and SHA-1 are considered weak and their use + * \warning MD5, DES and SHA-1 are considered weak and their use * constitutes a security risk. If possible, we recommend avoiding * dependencies on them, and considering stronger message digests * and ciphers instead. @@ -445,13 +375,9 @@ * alternative implementations should use the RNG only for generating * the ephemeral key and nothing else. If this is not possible, then * MBEDTLS_ECDSA_DETERMINISTIC should be disabled and an alternative - * implementation should be provided for mbedtls_ecdsa_sign_det_ext() - * (and for mbedtls_ecdsa_sign_det() too if backward compatibility is - * desirable). + * implementation should be provided for mbedtls_ecdsa_sign_det_ext(). * */ -//#define MBEDTLS_MD2_PROCESS_ALT -//#define MBEDTLS_MD4_PROCESS_ALT //#define MBEDTLS_MD5_PROCESS_ALT //#define MBEDTLS_RIPEMD160_PROCESS_ALT //#define MBEDTLS_SHA1_PROCESS_ALT @@ -535,23 +461,6 @@ //#define MBEDTLS_ECP_RANDOMIZE_MXZ_ALT //#define MBEDTLS_ECP_NORMALIZE_MXZ_ALT -/** - * \def MBEDTLS_TEST_NULL_ENTROPY - * - * Enables testing and use of mbed TLS without any configured entropy sources. - * This permits use of the library on platforms before an entropy source has - * been integrated (see for example the MBEDTLS_ENTROPY_HARDWARE_ALT or the - * MBEDTLS_ENTROPY_NV_SEED switches). - * - * WARNING! This switch MUST be disabled in production builds, and is suitable - * only for development. - * Enabling the switch negates any security provided by the library. - * - * Requires MBEDTLS_ENTROPY_C, MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES - * - */ -//#define MBEDTLS_TEST_NULL_ENTROPY - /** * \def MBEDTLS_ENTROPY_HARDWARE_ALT * @@ -559,7 +468,8 @@ * hardware entropy collector. * * Your function must be called \c mbedtls_hardware_poll(), have the same - * prototype as declared in entropy_poll.h, and accept NULL as first argument. + * prototype as declared in library/entropy_poll.h, and accept NULL as first + * argument. * * Uncomment to use your own hardware entropy collector. */ @@ -616,6 +526,29 @@ */ //#define MBEDTLS_CAMELLIA_SMALL_MEMORY +/** + * \def MBEDTLS_CHECK_RETURN_WARNING + * + * If this macro is defined, emit a compile-time warning if application code + * calls a function without checking its return value, but the return value + * should generally be checked in portable applications. + * + * This is only supported on platforms where #MBEDTLS_CHECK_RETURN is + * implemented. Otherwise this option has no effect. + * + * Uncomment to get warnings on using fallible functions without checking + * their return value. + * + * \note This feature is a work in progress. + * Warnings will be added to more functions in the future. + * + * \note A few functions are considered critical, and ignoring the return + * value of these functions will trigger a warning even if this + * macro is not defined. To completely disable return value check + * warnings, define #MBEDTLS_CHECK_RETURN with an empty expansion. + */ +//#define MBEDTLS_CHECK_RETURN_WARNING + /** * \def MBEDTLS_CIPHER_MODE_CBC * @@ -658,8 +591,7 @@ * Warning: Only do so when you know what you are doing. This allows for * encryption or channels without any security! * - * Requires MBEDTLS_ENABLE_WEAK_CIPHERSUITES as well to enable - * the following ciphersuites: + * To enable the following ciphersuites: * MBEDTLS_TLS_ECDH_ECDSA_WITH_NULL_SHA * MBEDTLS_TLS_ECDH_RSA_WITH_NULL_SHA * MBEDTLS_TLS_ECDHE_ECDSA_WITH_NULL_SHA @@ -707,57 +639,6 @@ */ //#define MBEDTLS_CTR_DRBG_USE_128_BIT_KEY -/** - * \def MBEDTLS_ENABLE_WEAK_CIPHERSUITES - * - * Enable weak ciphersuites in SSL / TLS. - * Warning: Only do so when you know what you are doing. This allows for - * channels with virtually no security at all! - * - * This enables the following ciphersuites: - * MBEDTLS_TLS_RSA_WITH_DES_CBC_SHA - * MBEDTLS_TLS_DHE_RSA_WITH_DES_CBC_SHA - * - * Uncomment this macro to enable weak ciphersuites - * - * \warning DES is considered a weak cipher and its use constitutes a - * security risk. We recommend considering stronger ciphers instead. - */ -//#define MBEDTLS_ENABLE_WEAK_CIPHERSUITES - -/** - * \def MBEDTLS_REMOVE_ARC4_CIPHERSUITES - * - * Remove RC4 ciphersuites by default in SSL / TLS. - * This flag removes the ciphersuites based on RC4 from the default list as - * returned by mbedtls_ssl_list_ciphersuites(). However, it is still possible to - * enable (some of) them with mbedtls_ssl_conf_ciphersuites() by including them - * explicitly. - * - * Uncomment this macro to remove RC4 ciphersuites by default. - */ -#define MBEDTLS_REMOVE_ARC4_CIPHERSUITES - -/** - * \def MBEDTLS_REMOVE_3DES_CIPHERSUITES - * - * Remove 3DES ciphersuites by default in SSL / TLS. - * This flag removes the ciphersuites based on 3DES from the default list as - * returned by mbedtls_ssl_list_ciphersuites(). However, it is still possible - * to enable (some of) them with mbedtls_ssl_conf_ciphersuites() by including - * them explicitly. - * - * A man-in-the-browser attacker can recover authentication tokens sent through - * a TLS connection using a 3DES based cipher suite (see "On the Practical - * (In-)Security of 64-bit Block Ciphers" by Karthikeyan Bhargavan and Gaëtan - * Leurent, see https://sweet32.info/SWEET32_CCS16.pdf). If this attack falls - * in your threat model or you are unsure, then you should keep this option - * enabled to remove 3DES based cipher suites. - * - * Comment this macro to keep 3DES in the default ciphersuite list. - */ -#define MBEDTLS_REMOVE_3DES_CIPHERSUITES - /** * \def MBEDTLS_ECP_DP_SECP192R1_ENABLED * @@ -793,28 +674,6 @@ */ #define MBEDTLS_ECP_NIST_OPTIM -/** - * \def MBEDTLS_ECP_NO_INTERNAL_RNG - * - * When this option is disabled, mbedtls_ecp_mul() will make use of an - * internal RNG when called with a NULL \c f_rng argument, in order to protect - * against some side-channel attacks. - * - * This protection introduces a dependency of the ECP module on one of the - * DRBG modules. For very constrained implementations that don't require this - * protection (for example, because you're only doing signature verification, - * so not manipulating any secret, or because local/physical side-channel - * attacks are outside your threat model), it might be desirable to get rid of - * that dependency. - * - * \warning Enabling this option makes some uses of ECP vulnerable to some - * side-channel attacks. Only enable it if you know that's not a problem for - * your use case. - * - * Uncomment this macro to disable some counter-measures in ECP. - */ -//#define MBEDTLS_ECP_NO_INTERNAL_RNG - /** * \def MBEDTLS_ECP_RESTARTABLE * @@ -835,39 +694,10 @@ * * \note This option only works with the default software implementation of * elliptic curve functionality. It is incompatible with - * MBEDTLS_ECP_ALT, MBEDTLS_ECDH_XXX_ALT, MBEDTLS_ECDSA_XXX_ALT - * and MBEDTLS_ECDH_LEGACY_CONTEXT. + * MBEDTLS_ECP_ALT, MBEDTLS_ECDH_XXX_ALT, MBEDTLS_ECDSA_XXX_ALT. */ //#define MBEDTLS_ECP_RESTARTABLE -/** - * \def MBEDTLS_ECDH_LEGACY_CONTEXT - * - * Use a backward compatible ECDH context. - * - * Mbed TLS supports two formats for ECDH contexts (#mbedtls_ecdh_context - * defined in `ecdh.h`). For most applications, the choice of format makes - * no difference, since all library functions can work with either format, - * except that the new format is incompatible with MBEDTLS_ECP_RESTARTABLE. - - * The new format used when this option is disabled is smaller - * (56 bytes on a 32-bit platform). In future versions of the library, it - * will support alternative implementations of ECDH operations. - * The new format is incompatible with applications that access - * context fields directly and with restartable ECP operations. - * - * Define this macro if you enable MBEDTLS_ECP_RESTARTABLE or if you - * want to access ECDH context fields directly. Otherwise you should - * comment out this macro definition. - * - * This option has no effect if #MBEDTLS_ECDH_C is not enabled. - * - * \note This configuration option is experimental. Future versions of the - * library may modify the way the ECDH context layout is configured - * and may modify the layout of the new context type. - */ -//#define MBEDTLS_ECDH_LEGACY_CONTEXT - /** * \def MBEDTLS_ECDSA_DETERMINISTIC * @@ -899,8 +729,6 @@ * MBEDTLS_TLS_PSK_WITH_AES_128_CBC_SHA * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 * MBEDTLS_TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_PSK_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_PSK_WITH_RC4_128_SHA */ //#define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED @@ -923,8 +751,6 @@ * MBEDTLS_TLS_DHE_PSK_WITH_AES_128_CBC_SHA * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 * MBEDTLS_TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_DHE_PSK_WITH_RC4_128_SHA * * \warning Using DHE constitutes a security risk as it * is not possible to validate custom DH parameters. @@ -950,8 +776,6 @@ * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 * MBEDTLS_TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA * MBEDTLS_TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_ECDHE_PSK_WITH_RC4_128_SHA */ //#define MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED @@ -975,8 +799,6 @@ * MBEDTLS_TLS_RSA_PSK_WITH_AES_128_CBC_SHA * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256 * MBEDTLS_TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_RSA_PSK_WITH_RC4_128_SHA */ //#define MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED @@ -1002,9 +824,6 @@ * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256 * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 * MBEDTLS_TLS_RSA_WITH_CAMELLIA_128_CBC_SHA - * MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_RSA_WITH_RC4_128_SHA - * MBEDTLS_TLS_RSA_WITH_RC4_128_MD5 */ //#define MBEDTLS_KEY_EXCHANGE_RSA_ENABLED @@ -1030,7 +849,6 @@ * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 * MBEDTLS_TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA - * MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA * * \warning Using DHE constitutes a security risk as it * is not possible to validate custom DH parameters. @@ -1061,8 +879,6 @@ * MBEDTLS_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 * MBEDTLS_TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_ECDHE_RSA_WITH_RC4_128_SHA */ #define MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED @@ -1085,8 +901,6 @@ * MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 * MBEDTLS_TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA */ #define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED @@ -1099,8 +913,6 @@ * * This enables the following ciphersuites (if other requisites are * enabled as well): - * MBEDTLS_TLS_ECDH_ECDSA_WITH_RC4_128_SHA - * MBEDTLS_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA * MBEDTLS_TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 @@ -1123,8 +935,6 @@ * * This enables the following ciphersuites (if other requisites are * enabled as well): - * MBEDTLS_TLS_ECDH_RSA_WITH_RC4_128_SHA - * MBEDTLS_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA * MBEDTLS_TLS_ECDH_RSA_WITH_AES_256_CBC_SHA * MBEDTLS_TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 @@ -1205,8 +1015,7 @@ /** * \def MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES * - * Do not add default entropy sources. These are the platform specific, - * mbedtls_timing_hardclock and HAVEGE based poll functions. + * Do not add default entropy sources in mbedtls_entropy_init(). * * This is useful to have more control over the added entropy sources in an * application. @@ -1278,7 +1087,7 @@ * which is currently hard-coded to be int32_t. * * Note that this option is meant for internal use only and may be removed - * without notice. It is incompatible with MBEDTLS_USE_PSA_CRYPTO. + * without notice. */ //#define MBEDTLS_PSA_CRYPTO_KEY_ID_ENCODES_OWNER @@ -1321,7 +1130,7 @@ * * Enable support for PKCS#1 v1.5 encoding. * - * Requires: MBEDTLS_RSA_C + * Requires: MBEDTLS_MD_C, MBEDTLS_RSA_C * * This enables support for PKCS#1 v1.5 operations. */ @@ -1338,6 +1147,22 @@ */ //#define MBEDTLS_PKCS1_V21 +/** \def MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS + * + * Enable support for platform built-in keys. If you enable this feature, + * you must implement the function mbedtls_psa_platform_get_builtin_key(). + * See the documentation of that function for more information. + * + * Built-in keys are typically derived from a hardware unique key or + * stored in a secure element. + * + * Requires: MBEDTLS_PSA_CRYPTO_C. + * + * \warning This interface is experimental and may change or be removed + * without notice. + */ +//#define MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS + /** \def MBEDTLS_PSA_CRYPTO_CLIENT * * Enable support for PSA crypto client. @@ -1360,8 +1185,9 @@ * * Requires: MBEDTLS_PSA_CRYPTO_C * - * \warning This interface is experimental and may change or be removed - * without notice. + * \warning This interface is experimental. We intend to maintain backward + * compatibility with application code that relies on drivers, + * but the driver interfaces may change without notice. */ //#define MBEDTLS_PSA_CRYPTO_DRIVERS @@ -1454,7 +1280,7 @@ * Enable an implementation of SHA-256 that has lower ROM footprint but also * lower performance. * - * The default implementation is meant to be a reasonnable compromise between + * The default implementation is meant to be a reasonable compromise between * performance and size. This version optimizes more aggressively for size at * the expense of performance. Eg on Cortex-M4 it reduces the size of * mbedtls_sha256_process() from ~2KB to ~0.5KB for a performance hit of about @@ -1474,18 +1300,6 @@ */ //#define MBEDTLS_SHA512_SMALLER -/** - * \def MBEDTLS_SHA512_NO_SHA384 - * - * Disable the SHA-384 option of the SHA-512 module. Use this to save some - * code size on devices that don't use SHA-384. - * - * Requires: MBEDTLS_SHA512_C - * - * Uncomment to disable SHA-384 - */ -//#define MBEDTLS_SHA512_NO_SHA384 - /** * \def MBEDTLS_SSL_ALL_ALERT_MESSAGES * @@ -1500,20 +1314,6 @@ */ #define MBEDTLS_SSL_ALL_ALERT_MESSAGES -/** - * \def MBEDTLS_SSL_RECORD_CHECKING - * - * Enable the function mbedtls_ssl_check_record() which can be used to check - * the validity and authenticity of an incoming record, to verify that it has - * not been seen before. These checks are performed without modifying the - * externally visible state of the SSL context. - * - * See mbedtls_ssl_check_record() for more information. - * - * Uncomment to enable support for record checking. - */ -//#define MBEDTLS_SSL_RECORD_CHECKING - /** * \def MBEDTLS_SSL_DTLS_CONNECTION_ID * @@ -1524,8 +1324,9 @@ * in the underlying transport. * * Setting this option enables the SSL APIs `mbedtls_ssl_set_cid()`, - * `mbedtls_ssl_get_peer_cid()` and `mbedtls_ssl_conf_cid()`. - * See the corresponding documentation for more information. + * mbedtls_ssl_get_own_cid()`, `mbedtls_ssl_get_peer_cid()` and + * `mbedtls_ssl_conf_cid()`. See the corresponding documentation for + * more information. * * \warning The Connection ID extension is still in draft state. * We make no stability promises for the availability @@ -1606,9 +1407,7 @@ * * This only affects CBC ciphersuites, and is useless if none is defined. * - * Requires: MBEDTLS_SSL_PROTO_TLS1 or - * MBEDTLS_SSL_PROTO_TLS1_1 or - * MBEDTLS_SSL_PROTO_TLS1_2 + * Requires: MBEDTLS_SSL_PROTO_TLS1_2 * * Comment this macro to disable support for Encrypt-then-MAC */ @@ -1619,37 +1418,17 @@ * Enable support for RFC 7627: Session Hash and Extended Master Secret * Extension. * - * This was introduced as "the proper fix" to the Triple Handshake familiy of + * This was introduced as "the proper fix" to the Triple Handshake family of * attacks, but it is recommended to always use it (even if you disable * renegotiation), since it actually fixes a more fundamental issue in the * original SSL/TLS design, and has implications beyond Triple Handshake. * - * Requires: MBEDTLS_SSL_PROTO_TLS1 or - * MBEDTLS_SSL_PROTO_TLS1_1 or - * MBEDTLS_SSL_PROTO_TLS1_2 + * Requires: MBEDTLS_SSL_PROTO_TLS1_2 * * Comment this macro to disable support for Extended Master Secret. */ #define MBEDTLS_SSL_EXTENDED_MASTER_SECRET -/** - * \def MBEDTLS_SSL_FALLBACK_SCSV - * - * Enable support for RFC 7507: Fallback Signaling Cipher Suite Value (SCSV) - * for Preventing Protocol Downgrade Attacks. - * - * For servers, it is recommended to always enable this, unless you support - * only one version of TLS, or know for sure that none of your clients - * implements a fallback strategy. - * - * For clients, you only need this if you're using a fallback strategy, which - * is not recommended in the first place, unless you absolutely need it to - * interoperate with buggy (version-intolerant) servers. - * - * Comment this macro to disable support for FALLBACK_SCSV - */ -//#define MBEDTLS_SSL_FALLBACK_SCSV - /** * \def MBEDTLS_SSL_KEEP_PEER_CERTIFICATE * @@ -1665,38 +1444,15 @@ * \note This option has no influence on the protection against the * triple handshake attack. Even if it is disabled, Mbed TLS will * still ensure that certificates do not change during renegotiation, - * for exaple by keeping a hash of the peer's certificate. + * for example by keeping a hash of the peer's certificate. + * + * \note This option is required if MBEDTLS_SSL_PROTO_TLS1_3 is set. * * Comment this macro to disable storing the peer's certificate * after the handshake. */ //#define MBEDTLS_SSL_KEEP_PEER_CERTIFICATE -/** - * \def MBEDTLS_SSL_HW_RECORD_ACCEL - * - * Enable hooking functions in SSL module for hardware acceleration of - * individual records. - * - * \deprecated This option is deprecated and will be removed in a future - * version of Mbed TLS. - * - * Uncomment this macro to enable hooking functions. - */ -//#define MBEDTLS_SSL_HW_RECORD_ACCEL - -/** - * \def MBEDTLS_SSL_CBC_RECORD_SPLITTING - * - * Enable 1/n-1 record splitting for CBC mode in SSLv3 and TLS 1.0. - * - * This is a countermeasure to the BEAST attack, which also minimizes the risk - * of interoperability issues compared to sending 0-length records. - * - * Comment this macro to disable 1/n-1 record splitting. - */ -//#define MBEDTLS_SSL_CBC_RECORD_SPLITTING - /** * \def MBEDTLS_SSL_RENEGOTIATION * @@ -1719,29 +1475,6 @@ */ //#define MBEDTLS_SSL_RENEGOTIATION -/** - * \def MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO - * - * Enable support for receiving and parsing SSLv2 Client Hello messages for the - * SSL Server module (MBEDTLS_SSL_SRV_C). - * - * \deprecated This option is deprecated and will be removed in a future - * version of Mbed TLS. - * - * Uncomment this macro to enable support for SSLv2 Client Hello messages. - */ -//#define MBEDTLS_SSL_SRV_SUPPORT_SSLV2_CLIENT_HELLO - -/** - * \def MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE - * - * Pick the ciphersuite according to the client's preferences rather than ours - * in the SSL Server module (MBEDTLS_SSL_SRV_C). - * - * Uncomment this macro to respect client's ciphersuite order - */ -//#define MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE - /** * \def MBEDTLS_SSL_MAX_FRAGMENT_LENGTH * @@ -1752,85 +1485,70 @@ #define MBEDTLS_SSL_MAX_FRAGMENT_LENGTH /** - * \def MBEDTLS_SSL_PROTO_SSL3 - * - * Enable support for SSL 3.0. + * \def MBEDTLS_SSL_PROTO_TLS1_2 * - * Requires: MBEDTLS_MD5_C - * MBEDTLS_SHA1_C + * Enable support for TLS 1.2 (and DTLS 1.2 if DTLS is enabled). * - * \deprecated This option is deprecated and will be removed in a future - * version of Mbed TLS. + * Requires: MBEDTLS_SHA1_C or MBEDTLS_SHA256_C or MBEDTLS_SHA512_C + * (Depends on ciphersuites) * - * Comment this macro to disable support for SSL 3.0 + * Comment this macro to disable support for TLS 1.2 / DTLS 1.2 */ -//#define MBEDTLS_SSL_PROTO_SSL3 +#define MBEDTLS_SSL_PROTO_TLS1_2 /** - * \def MBEDTLS_SSL_PROTO_TLS1 - * - * Enable support for TLS 1.0. + * \def MBEDTLS_SSL_PROTO_TLS1_3 * - * Requires: MBEDTLS_MD5_C - * MBEDTLS_SHA1_C + * Enable support for TLS 1.3. * - * Comment this macro to disable support for TLS 1.0 - */ -//#define MBEDTLS_SSL_PROTO_TLS1 - -/** - * \def MBEDTLS_SSL_PROTO_TLS1_1 + * \note The support for TLS 1.3 is not comprehensive yet, in particular + * pre-shared keys are not supported. + * See docs/architecture/tls13-support.md for a description of the TLS + * 1.3 support that this option enables. * - * Enable support for TLS 1.1 (and DTLS 1.0 if DTLS is enabled). + * Requires: MBEDTLS_SSL_KEEP_PEER_CERTIFICATE + * Requires: MBEDTLS_PSA_CRYPTO_C * - * Requires: MBEDTLS_MD5_C - * MBEDTLS_SHA1_C + * Note: even though TLS 1.3 depends on PSA Crypto, if you want it to only use + * PSA for all crypto operations, you need to also enable + * MBEDTLS_USE_PSA_CRYPTO; otherwise X.509 operations, and functions that are + * common with TLS 1.2 (record protection, running handshake hash) will still + * use non-PSA crypto. * - * Comment this macro to disable support for TLS 1.1 / DTLS 1.0 + * Uncomment this macro to enable the support for TLS 1.3. */ -//#define MBEDTLS_SSL_PROTO_TLS1_1 +//#define MBEDTLS_SSL_PROTO_TLS1_3 /** - * \def MBEDTLS_SSL_PROTO_TLS1_2 - * - * Enable support for TLS 1.2 (and DTLS 1.2 if DTLS is enabled). + * \def MBEDTLS_SSL_TLS1_3_COMPATIBILITY_MODE * - * Requires: MBEDTLS_SHA1_C or MBEDTLS_SHA256_C or MBEDTLS_SHA512_C - * (Depends on ciphersuites) + * Enable TLS 1.3 middlebox compatibility mode. * - * Comment this macro to disable support for TLS 1.2 / DTLS 1.2 - */ -#define MBEDTLS_SSL_PROTO_TLS1_2 - -/** - * \def MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL + * As specified in Section D.4 of RFC 8446, TLS 1.3 offers a compatibility + * mode to make a TLS 1.3 connection more likely to pass through middle boxes + * expecting TLS 1.2 traffic. * - * This macro is used to selectively enable experimental parts - * of the code that contribute to the ongoing development of - * the prototype TLS 1.3 and DTLS 1.3 implementation, and provide - * no other purpose. + * Turning on the compatibility mode comes at the cost of a few added bytes + * on the wire, but it doesn't affect compatibility with TLS 1.3 implementations + * that don't use it. Therefore, unless transmission bandwidth is critical and + * you know that middlebox compatibility issues won't occur, it is therefore + * recommended to set this option. * - * \warning TLS 1.3 and DTLS 1.3 aren't yet supported in Mbed TLS, - * and no feature exposed through this macro is part of the - * public API. In particular, features under the control - * of this macro are experimental and don't come with any - * stability guarantees. + * Comment to disable compatibility mode for TLS 1.3. If + * MBEDTLS_SSL_PROTO_TLS1_3 is not enabled, this option does not have any + * effect on the build. * - * Uncomment this macro to enable experimental and partial - * functionality specific to TLS 1.3. */ -//#define MBEDTLS_SSL_PROTO_TLS1_3_EXPERIMENTAL +//#define MBEDTLS_SSL_TLS1_3_COMPATIBILITY_MODE /** * \def MBEDTLS_SSL_PROTO_DTLS * * Enable support for DTLS (all available versions). * - * Enable this and MBEDTLS_SSL_PROTO_TLS1_1 to enable DTLS 1.0, - * and/or this and MBEDTLS_SSL_PROTO_TLS1_2 to enable DTLS 1.2. + * Enable this and MBEDTLS_SSL_PROTO_TLS1_2 to enable DTLS 1.2. * - * Requires: MBEDTLS_SSL_PROTO_TLS1_1 - * or MBEDTLS_SSL_PROTO_TLS1_2 + * Requires: MBEDTLS_SSL_PROTO_TLS1_2 * * Comment this macro to disable support for DTLS */ @@ -1870,7 +1588,7 @@ * unless you know for sure amplification cannot be a problem in the * environment in which your server operates. * - * \warning Disabling this can ba a security risk! (see above) + * \warning Disabling this can be a security risk! (see above) * * Requires: MBEDTLS_SSL_PROTO_DTLS * @@ -1892,7 +1610,7 @@ * (see Section 5 of RFC 5764), are not handled by this feature. * Instead, after successful completion of a handshake negotiating * the use of DTLS-SRTP, the extended key exporter API - * mbedtls_ssl_conf_export_keys_ext_cb() should be used to implement + * mbedtls_ssl_conf_export_keys_cb() should be used to implement * the key exporter described in Section 4.2 of RFC 5764 and RFC 5705 * (this is implemented in the SSL example programs). * The resulting key should then be passed to an SRTP stack. @@ -1925,17 +1643,6 @@ */ //#define MBEDTLS_SSL_DTLS_CLIENT_PORT_REUSE -/** - * \def MBEDTLS_SSL_DTLS_BADMAC_LIMIT - * - * Enable support for a limit of records with bad MAC. - * - * See mbedtls_ssl_conf_dtls_badmac_limit(). - * - * Requires: MBEDTLS_SSL_PROTO_DTLS - */ -//#define MBEDTLS_SSL_DTLS_BADMAC_LIMIT - /** * \def MBEDTLS_SSL_SESSION_TICKETS * @@ -1950,16 +1657,6 @@ */ //#define MBEDTLS_SSL_SESSION_TICKETS -/** - * \def MBEDTLS_SSL_EXPORT_KEYS - * - * Enable support for exporting key block and master secret. - * This is required for certain users of TLS, e.g. EAP-TLS. - * - * Comment this macro to disable support for key export - */ -//#define MBEDTLS_SSL_EXPORT_KEYS - /** * \def MBEDTLS_SSL_SERVER_NAME_INDICATION * @@ -1971,39 +1668,6 @@ */ #define MBEDTLS_SSL_SERVER_NAME_INDICATION -/** - * \def MBEDTLS_SSL_TRUNCATED_HMAC - * - * Enable support for RFC 6066 truncated HMAC in SSL. - * - * Comment this macro to disable support for truncated HMAC in SSL - */ -//#define MBEDTLS_SSL_TRUNCATED_HMAC - -/** - * \def MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT - * - * Fallback to old (pre-2.7), non-conforming implementation of the truncated - * HMAC extension which also truncates the HMAC key. Note that this option is - * only meant for a transitory upgrade period and will be removed in a future - * version of the library. - * - * \warning The old implementation is non-compliant and has a security weakness - * (2^80 brute force attack on the HMAC key used for a single, - * uninterrupted connection). This should only be enabled temporarily - * when (1) the use of truncated HMAC is essential in order to save - * bandwidth, and (2) the peer is an Mbed TLS stack that doesn't use - * the fixed implementation yet (pre-2.7). - * - * \deprecated This option is deprecated and will be removed in a - * future version of Mbed TLS. - * - * Uncomment to fallback to old, non-compliant truncated HMAC implementation. - * - * Requires: MBEDTLS_SSL_TRUNCATED_HMAC - */ -//#define MBEDTLS_SSL_TRUNCATED_HMAC_COMPAT - /** * \def MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH * @@ -2103,17 +1767,14 @@ * will still continue to work as usual, so enabling this option should not * break backwards compatibility. * - * \warning The PSA Crypto API is in beta stage. While you're welcome to - * experiment using it, incompatible API changes are still possible, and some - * parts may not have reached the same quality as the rest of Mbed TLS yet. + * \note See docs/use-psa-crypto.md for a complete description of what this + * option currently does, and of parts that are not affected by it so far. * - * \warning This option enables new Mbed TLS APIs that are dependent on the - * PSA Crypto API, so can't come with the same stability guarantees as the - * rest of the Mbed TLS APIs. You're welcome to experiment with them, but for - * now, access to these APIs is opt-in (via enabling the present option), in - * order to clearly differentiate them from the stable Mbed TLS APIs. + * \warning If you enable this option, you need to call `psa_crypto_init()` + * before calling any function from the SSL/TLS, X.509 or PK modules. * * Requires: MBEDTLS_PSA_CRYPTO_C. + * Conflicts with: MBEDTLS_ECP_RESTARTABLE * * Uncomment this to enable internal use of PSA Crypto and new associated APIs. */ @@ -2125,12 +1786,19 @@ * This setting allows support for cryptographic mechanisms through the PSA * API to be configured separately from support through the mbedtls API. * - * Uncomment this to enable use of PSA Crypto configuration settings which - * can be found in include/psa/crypto_config.h. + * When this option is disabled, the PSA API exposes the cryptographic + * mechanisms that can be implemented on top of the `mbedtls_xxx` API + * configured with `MBEDTLS_XXX` symbols. + * + * When this option is enabled, the PSA API exposes the cryptographic + * mechanisms requested by the `PSA_WANT_XXX` symbols defined in + * include/psa/crypto_config.h. The corresponding `MBEDTLS_XXX` settings are + * automatically enabled if required (i.e. if no PSA driver provides the + * mechanism). You may still freely enable additional `MBEDTLS_XXX` symbols + * in mbedtls_config.h. * - * If you enable this option and write your own configuration file, you must - * include mbedtls/config_psa.h in your configuration file. The default - * provided mbedtls/config.h contains the necessary inclusion. + * If the symbol #MBEDTLS_PSA_CRYPTO_CONFIG_FILE is defined, it specifies + * an alternative header to include instead of include/psa/crypto_config.h. * * This feature is still experimental and is not ready for production since * it is not completed. @@ -2150,28 +1818,6 @@ */ //#define MBEDTLS_VERSION_FEATURES -/** - * \def MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3 - * - * If set, the X509 parser will not break-off when parsing an X509 certificate - * and encountering an extension in a v1 or v2 certificate. - * - * Uncomment to prevent an error. - */ -//#define MBEDTLS_X509_ALLOW_EXTENSIONS_NON_V3 - -/** - * \def MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION - * - * If set, the X509 parser will not break-off when parsing an X509 certificate - * and encountering an unknown critical extension. - * - * \warning Depending on your PKI use, enabling this can be a security risk! - * - * Uncomment to prevent an error. - */ -//#define MBEDTLS_X509_ALLOW_UNSUPPORTED_CRITICAL_EXTENSION - /** * \def MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK * @@ -2192,31 +1838,15 @@ //#define MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK /** - * \def MBEDTLS_X509_CHECK_KEY_USAGE + * \def MBEDTLS_X509_REMOVE_INFO * - * Enable verification of the keyUsage extension (CA and leaf certificates). + * Disable mbedtls_x509_*_info() and related APIs. * - * Disabling this avoids problems with mis-issued and/or misused - * (intermediate) CA and leaf certificates. - * - * \warning Depending on your PKI use, disabling this can be a security risk! - * - * Comment to skip keyUsage checking for both CA and leaf certificates. - */ -#define MBEDTLS_X509_CHECK_KEY_USAGE - -/** - * \def MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE - * - * Enable verification of the extendedKeyUsage extension (leaf certificates). - * - * Disabling this avoids problems with mis-issued and/or misused certificates. - * - * \warning Depending on your PKI use, disabling this can be a security risk! - * - * Comment to skip extendedKeyUsage checking for certificates. + * Uncomment to omit mbedtls_x509_*_info(), as well as mbedtls_debug_print_crt() + * and other functions/constants only used by these functions, thus reducing + * the code footprint by several KB. */ -#define MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE +//#define MBEDTLS_X509_REMOVE_INFO /** * \def MBEDTLS_X509_RSASSA_PSS_SUPPORT @@ -2227,32 +1857,7 @@ * Comment this macro to disallow using RSASSA-PSS in certificates. */ //#define MBEDTLS_X509_RSASSA_PSS_SUPPORT - -/** - * \def MBEDTLS_ZLIB_SUPPORT - * - * If set, the SSL/TLS module uses ZLIB to support compression and - * decompression of packet data. - * - * \warning TLS-level compression MAY REDUCE SECURITY! See for example the - * CRIME attack. Before enabling this option, you should examine with care if - * CRIME or similar exploits may be applicable to your use case. - * - * \note Currently compression can't be used with DTLS. - * - * \deprecated This feature is deprecated and will be removed - * in the next major revision of the library. - * - * Used in: library/ssl_tls.c - * library/ssl_cli.c - * library/ssl_srv.c - * - * This feature requires zlib library and headers to be present. - * - * Uncomment to enable use of ZLIB - */ -//#define MBEDTLS_ZLIB_SUPPORT -/* \} name SECTION: mbed TLS feature support */ +/** \} name SECTION: mbed TLS feature support */ /** * \name SECTION: mbed TLS modules @@ -2350,34 +1955,6 @@ */ #define MBEDTLS_AES_C -/** - * \def MBEDTLS_ARC4_C - * - * Enable the ARCFOUR stream cipher. - * - * Module: library/arc4.c - * Caller: library/cipher.c - * - * This module enables the following ciphersuites (if other requisites are - * enabled as well): - * MBEDTLS_TLS_ECDH_ECDSA_WITH_RC4_128_SHA - * MBEDTLS_TLS_ECDH_RSA_WITH_RC4_128_SHA - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_RC4_128_SHA - * MBEDTLS_TLS_ECDHE_RSA_WITH_RC4_128_SHA - * MBEDTLS_TLS_ECDHE_PSK_WITH_RC4_128_SHA - * MBEDTLS_TLS_DHE_PSK_WITH_RC4_128_SHA - * MBEDTLS_TLS_RSA_WITH_RC4_128_SHA - * MBEDTLS_TLS_RSA_WITH_RC4_128_MD5 - * MBEDTLS_TLS_RSA_PSK_WITH_RC4_128_SHA - * MBEDTLS_TLS_PSK_WITH_RC4_128_SHA - * - * \warning ARC4 is considered a weak cipher and its use constitutes a - * security risk. If possible, we recommend avoidng dependencies on - * it, and considering stronger ciphers instead. - * - */ -//#define MBEDTLS_ARC4_C - /** * \def MBEDTLS_ASN1_PARSE_C * @@ -2428,22 +2005,13 @@ * library/ecp.c * library/ecdsa.c * library/rsa.c - * library/rsa_internal.c + * library/rsa_alt_helpers.c * library/ssl_tls.c * * This module is required for RSA, DHM and ECC (ECDH, ECDSA) support. */ #define MBEDTLS_BIGNUM_C -/** - * \def MBEDTLS_BLOWFISH_C - * - * Enable the Blowfish block cipher. - * - * Module: library/blowfish.c - */ -//#define MBEDTLS_BLOWFISH_C - /** * \def MBEDTLS_CAMELLIA_C * @@ -2558,25 +2126,14 @@ * * Module: library/ccm.c * - * Requires: MBEDTLS_AES_C or MBEDTLS_CAMELLIA_C + * Requires: MBEDTLS_CIPHER_C, MBEDTLS_AES_C or MBEDTLS_CAMELLIA_C or + * MBEDTLS_ARIA_C * * This module enables the AES-CCM ciphersuites, if other requisites are * enabled as well. */ #define MBEDTLS_CCM_C -/** - * \def MBEDTLS_CERTS_C - * - * Enable the test certificates. - * - * Module: library/certs.c - * Caller: - * - * This module is used for testing (ssl_client/server). - */ -//#define MBEDTLS_CERTS_C - /** * \def MBEDTLS_CHACHA20_C * @@ -2603,7 +2160,17 @@ * Enable the generic cipher layer. * * Module: library/cipher.c - * Caller: library/ssl_tls.c + * Caller: library/ccm.c + * library/cmac.c + * library/gcm.c + * library/nist_kw.c + * library/pkcs12.c + * library/pkcs5.c + * library/psa_crypto_aead.c + * library/psa_crypto_mac.c + * library/ssl_ciphersuites.c + * library/ssl_msg.c + * library/ssl_ticket.c (unless MBEDTLS_USE_PSA_CRYPTO is enabled) * * Uncomment to enable generic cipher wrappers. */ @@ -2615,9 +2182,14 @@ * Enable the CMAC (Cipher-based Message Authentication Code) mode for block * ciphers. * + * \note When #MBEDTLS_CMAC_ALT is active, meaning that the underlying + * implementation of the CMAC algorithm is provided by an alternate + * implementation, that alternate implementation may opt to not support + * AES-192 or 3DES as underlying block ciphers for the CMAC operation. + * * Module: library/cmac.c * - * Requires: MBEDTLS_AES_C or MBEDTLS_DES_C + * Requires: MBEDTLS_CIPHER_C, MBEDTLS_AES_C or MBEDTLS_DES_C * */ //#define MBEDTLS_CMAC_C @@ -2648,9 +2220,10 @@ * Enable the debug functions. * * Module: library/debug.c - * Caller: library/ssl_cli.c - * library/ssl_srv.c + * Caller: library/ssl_msg.c * library/ssl_tls.c + * library/ssl_tls12_*.c + * library/ssl_tls13_*.c * * This module provides debugging functions. */ @@ -2665,19 +2238,6 @@ * Caller: library/pem.c * library/cipher.c * - * This module enables the following ciphersuites (if other requisites are - * enabled as well): - * MBEDTLS_TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA - * MBEDTLS_TLS_PSK_WITH_3DES_EDE_CBC_SHA - * * PEM_PARSE uses DES/3DES for decrypting encrypted keys. * * \warning DES is considered a weak cipher and its use constitutes a @@ -2691,8 +2251,9 @@ * Enable the Diffie-Hellman-Merkle module. * * Module: library/dhm.c - * Caller: library/ssl_cli.c - * library/ssl_srv.c + * Caller: library/ssl_tls.c + * library/ssl*_client.c + * library/ssl*_server.c * * This module is used by the following key exchanges: * DHE-RSA, DHE-PSK @@ -2712,8 +2273,10 @@ * Enable the elliptic curve Diffie-Hellman library. * * Module: library/ecdh.c - * Caller: library/ssl_cli.c - * library/ssl_srv.c + * Caller: library/psa_crypto.c + * library/ssl_tls.c + * library/ssl*_client.c + * library/ssl*_server.c * * This module is used by the following key exchanges: * ECDHE-ECDSA, ECDHE-RSA, DHE-PSK @@ -2744,9 +2307,9 @@ * * Enable the elliptic curve J-PAKE library. * - * \warning This is currently experimental. EC J-PAKE support is based on the - * Thread v1.0.0 specification; incompatible changes to the specification - * might still happen. For this reason, this is disabled by default. + * \note EC J-PAKE support is based on the Thread v1.0.0 specification. + * It has not been reviewed for compliance with newer standards such as + * Thread v1.1 or RFC 8236. * * Module: library/ecjpake.c * Caller: @@ -2805,36 +2368,14 @@ * * Module: library/gcm.c * - * Requires: MBEDTLS_AES_C or MBEDTLS_CAMELLIA_C or MBEDTLS_ARIA_C + * Requires: MBEDTLS_CIPHER_C, MBEDTLS_AES_C or MBEDTLS_CAMELLIA_C or + * MBEDTLS_ARIA_C * * This module enables the AES-GCM and CAMELLIA-GCM ciphersuites, if other * requisites are enabled as well. */ #define MBEDTLS_GCM_C -/** - * \def MBEDTLS_HAVEGE_C - * - * Enable the HAVEGE random generator. - * - * Warning: the HAVEGE random generator is not suitable for virtualized - * environments - * - * Warning: the HAVEGE random generator is dependent on timing and specific - * processor traits. It is therefore not advised to use HAVEGE as - * your applications primary random generator or primary entropy pool - * input. As a secondary input to your entropy pool, it IS able add - * the (limited) extra entropy it provides. - * - * Module: library/havege.c - * Caller: - * - * Requires: MBEDTLS_TIMING_C - * - * Uncomment to enable the HAVEGE random generator. - */ -//#define MBEDTLS_HAVEGE_C - /** * \def MBEDTLS_HKDF_C * @@ -2860,7 +2401,7 @@ * * Requires: MBEDTLS_MD_C * - * Uncomment to enable the HMAC_DRBG random number geerator. + * Uncomment to enable the HMAC_DRBG random number generator. */ //#define MBEDTLS_HMAC_DRBG_C @@ -2883,46 +2424,29 @@ * Enable the generic message digest layer. * * Module: library/md.c - * Caller: + * Caller: library/constant_time.c + * library/ecdsa.c + * library/ecjpake.c + * library/hkdf.c + * library/hmac_drbg.c + * library/pk.c + * library/pkcs5.c + * library/pkcs12.c + * library/psa_crypto_ecp.c + * library/psa_crypto_rsa.c + * library/rsa.c + * library/ssl_cookie.c + * library/ssl_msg.c + * library/ssl_tls.c + * library/x509.c + * library/x509_crt.c + * library/x509write_crt.c + * library/x509write_csr.c * * Uncomment to enable generic message digest wrappers. */ #define MBEDTLS_MD_C -/** - * \def MBEDTLS_MD2_C - * - * Enable the MD2 hash algorithm. - * - * Module: library/md2.c - * Caller: - * - * Uncomment to enable support for (rare) MD2-signed X.509 certs. - * - * \warning MD2 is considered a weak message digest and its use constitutes a - * security risk. If possible, we recommend avoiding dependencies on - * it, and considering stronger message digests instead. - * - */ -//#define MBEDTLS_MD2_C - -/** - * \def MBEDTLS_MD4_C - * - * Enable the MD4 hash algorithm. - * - * Module: library/md4.c - * Caller: - * - * Uncomment to enable support for (rare) MD4-signed X.509 certs. - * - * \warning MD4 is considered a weak message digest and its use constitutes a - * security risk. If possible, we recommend avoiding dependencies on - * it, and considering stronger message digests instead. - * - */ -//#define MBEDTLS_MD4_C - /** * \def MBEDTLS_MD5_C * @@ -2933,10 +2457,9 @@ * library/pem.c * library/ssl_tls.c * - * This module is required for SSL/TLS up to version 1.1, and for TLS 1.2 - * depending on the handshake parameters. Further, it is used for checking - * MD5-signed certificates, and for PBKDF1 when decrypting PEM-encoded - * encrypted keys. + * This module is required for TLS 1.2 depending on the handshake parameters. + * Further, it is used for checking MD5-signed certificates, and for PBKDF1 + * when decrypting PEM-encoded encrypted keys. * * \warning MD5 is considered a weak message digest and its use constitutes a * security risk. If possible, we recommend avoiding dependencies on @@ -3054,14 +2577,16 @@ /** * \def MBEDTLS_PK_C * - * Enable the generic public (asymetric) key layer. + * Enable the generic public (asymmetric) key layer. * * Module: library/pk.c - * Caller: library/ssl_tls.c - * library/ssl_cli.c - * library/ssl_srv.c + * Caller: library/psa_crypto_rsa.c + * library/ssl_tls.c + * library/ssl*_client.c + * library/ssl*_server.c + * library/x509.c * - * Requires: MBEDTLS_RSA_C or MBEDTLS_ECP_C + * Requires: MBEDTLS_MD_C, MBEDTLS_RSA_C or MBEDTLS_ECP_C * * Uncomment to enable generic public key wrappers. */ @@ -3070,7 +2595,7 @@ /** * \def MBEDTLS_PK_PARSE_C * - * Enable the generic public (asymetric) key parser. + * Enable the generic public (asymmetric) key parser. * * Module: library/pkparse.c * Caller: library/x509_crt.c @@ -3085,7 +2610,7 @@ /** * \def MBEDTLS_PK_WRITE_C * - * Enable the generic public (asymetric) key writer. + * Enable the generic public (asymmetric) key writer. * * Module: library/pkwrite.c * Caller: library/x509write.c @@ -3103,30 +2628,12 @@ * * Module: library/pkcs5.c * - * Requires: MBEDTLS_MD_C + * Requires: MBEDTLS_CIPHER_C, MBEDTLS_MD_C * * This module adds support for the PKCS#5 functions. */ #define MBEDTLS_PKCS5_C -/** - * \def MBEDTLS_PKCS11_C - * - * Enable wrapper for PKCS#11 smartcard support via the pkcs11-helper library. - * - * \deprecated This option is deprecated and will be removed in a future - * version of Mbed TLS. - * - * Module: library/pkcs11.c - * Caller: library/pk.c - * - * Requires: MBEDTLS_PK_C - * - * This module enables SSL/TLS PKCS #11 smartcard support. - * Requires the presence of the PKCS#11 helper library (libpkcs11-helper) - */ -//#define MBEDTLS_PKCS11_C - /** * \def MBEDTLS_PKCS12_C * @@ -3137,7 +2644,6 @@ * Caller: library/pkparse.c * * Requires: MBEDTLS_ASN1_PARSE_C, MBEDTLS_CIPHER_C, MBEDTLS_MD_C - * Can use: MBEDTLS_ARC4_C * * This module enables PKCS#12 functions. */ @@ -3178,27 +2684,24 @@ * * Enable the Platform Security Architecture cryptography API. * - * \warning The PSA Crypto API is still beta status. While you're welcome to - * experiment using it, incompatible API changes are still possible, and some - * parts may not have reached the same quality as the rest of Mbed TLS yet. - * * Module: library/psa_crypto.c * - * Requires: either MBEDTLS_CTR_DRBG_C and MBEDTLS_ENTROPY_C, + * Requires: MBEDTLS_CIPHER_C, + * either MBEDTLS_CTR_DRBG_C and MBEDTLS_ENTROPY_C, * or MBEDTLS_HMAC_DRBG_C and MBEDTLS_ENTROPY_C, * or MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG. * */ -//#define MBEDTLS_PSA_CRYPTO_C +#define MBEDTLS_PSA_CRYPTO_C /** * \def MBEDTLS_PSA_CRYPTO_SE_C * - * Enable secure element support in the Platform Security Architecture + * Enable dynamic secure element support in the Platform Security Architecture * cryptography API. * - * \warning This feature is not yet suitable for production. It is provided - * for API evaluation and testing purposes only. + * \deprecated This feature is deprecated. Please switch to the driver + * interface enabled by #MBEDTLS_PSA_CRYPTO_DRIVERS. * * Module: library/psa_crypto_se.c * @@ -3249,11 +2752,12 @@ * Enable the RSA public-key cryptosystem. * * Module: library/rsa.c - * library/rsa_internal.c - * Caller: library/ssl_cli.c - * library/ssl_srv.c + * library/rsa_alt_helpers.c + * Caller: library/pk.c + * library/psa_crypto.c * library/ssl_tls.c - * library/x509.c + * library/ssl*_client.c + * library/ssl*_server.c * * This module is used by the following key exchanges: * RSA, DHE-RSA, ECDHE-RSA, RSA-PSK @@ -3269,13 +2773,10 @@ * * Module: library/sha1.c * Caller: library/md.c - * library/ssl_cli.c - * library/ssl_srv.c - * library/ssl_tls.c - * library/x509write_crt.c + * library/psa_crypto_hash.c * - * This module is required for SSL/TLS up to version 1.1, for TLS 1.2 - * depending on the handshake parameters, and for SHA1-signed certificates. + * This module is required for TLS 1.2 depending on the handshake parameters, + * and for SHA1-signed certificates. * * \warning SHA-1 is considered a weak message digest and its use constitutes * a security risk. If possible, we recommend avoiding dependencies @@ -3284,37 +2785,177 @@ */ #define MBEDTLS_SHA1_C +/** + * \def MBEDTLS_SHA224_C + * + * Enable the SHA-224 cryptographic hash algorithm. + * + * Requires: MBEDTLS_SHA256_C. The library does not currently support enabling + * SHA-224 without SHA-256. + * + * Module: library/sha256.c + * Caller: library/md.c + * library/ssl_cookie.c + * + * This module adds support for SHA-224. + */ +#define MBEDTLS_SHA224_C + /** * \def MBEDTLS_SHA256_C * - * Enable the SHA-224 and SHA-256 cryptographic hash algorithms. + * Enable the SHA-256 cryptographic hash algorithm. + * + * Requires: MBEDTLS_SHA224_C. The library does not currently support enabling + * SHA-256 without SHA-224. * * Module: library/sha256.c * Caller: library/entropy.c * library/md.c - * library/ssl_cli.c - * library/ssl_srv.c * library/ssl_tls.c + * library/ssl*_client.c + * library/ssl*_server.c * - * This module adds support for SHA-224 and SHA-256. + * This module adds support for SHA-256. * This module is required for the SSL/TLS 1.2 PRF function. */ #define MBEDTLS_SHA256_C +/** + * \def MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT + * + * Enable acceleration of the SHA-256 and SHA-224 cryptographic hash algorithms + * with the ARMv8 cryptographic extensions if they are available at runtime. + * If not, the library will fall back to the C implementation. + * + * \note If MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT is defined when building + * for a non-Aarch64 build it will be silently ignored. + * + * \note The code uses Neon intrinsics, so \c CFLAGS must be set to a minimum + * of \c -march=armv8-a+crypto. + * + * \warning MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT cannot be defined at the + * same time as MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY. + * + * Requires: MBEDTLS_SHA256_C. + * + * Module: library/sha256.c + * + * Uncomment to have the library check for the A64 SHA-256 crypto extensions + * and use them if available. + */ +//#define MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT + +/** + * \def MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY + * + * Enable acceleration of the SHA-256 and SHA-224 cryptographic hash algorithms + * with the ARMv8 cryptographic extensions, which must be available at runtime + * or else an illegal instruction fault will occur. + * + * \note This allows builds with a smaller code size than with + * MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT + * + * \note The code uses Neon intrinsics, so \c CFLAGS must be set to a minimum + * of \c -march=armv8-a+crypto. + * + * \warning MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY cannot be defined at the same + * time as MBEDTLS_SHA256_USE_A64_CRYPTO_IF_PRESENT. + * + * Requires: MBEDTLS_SHA256_C. + * + * Module: library/sha256.c + * + * Uncomment to have the library use the A64 SHA-256 crypto extensions + * unconditionally. + */ +//#define MBEDTLS_SHA256_USE_A64_CRYPTO_ONLY + +/** + * \def MBEDTLS_SHA384_C + * + * Enable the SHA-384 cryptographic hash algorithm. + * + * Requires: MBEDTLS_SHA512_C + * + * Module: library/sha512.c + * Caller: library/md.c + * library/psa_crypto_hash.c + * library/ssl_tls.c + * library/ssl*_client.c + * library/ssl*_server.c + * + * Comment to disable SHA-384 + */ +//#define MBEDTLS_SHA384_C + /** * \def MBEDTLS_SHA512_C * - * Enable the SHA-384 and SHA-512 cryptographic hash algorithms. + * Enable SHA-512 cryptographic hash algorithms. * * Module: library/sha512.c * Caller: library/entropy.c * library/md.c - * library/ssl_cli.c - * library/ssl_srv.c + * library/ssl_tls.c + * library/ssl_cookie.c * - * This module adds support for SHA-384 and SHA-512. + * This module adds support for SHA-512. */ //#define MBEDTLS_SHA512_C +/** + * \def MBEDTLS_SHA512_USE_A64_CRYPTO_IF_PRESENT + * + * Enable acceleration of the SHA-512 and SHA-384 cryptographic hash algorithms + * with the ARMv8 cryptographic extensions if they are available at runtime. + * If not, the library will fall back to the C implementation. + * + * \note If MBEDTLS_SHA512_USE_A64_CRYPTO_IF_PRESENT is defined when building + * for a non-Aarch64 build it will be silently ignored. + * + * \note The code uses the SHA-512 Neon intrinsics, so requires GCC >= 8 or + * Clang >= 7, and \c CFLAGS must be set to a minimum of + * \c -march=armv8.2-a+sha3. An optimisation level of \c -O3 generates the + * fastest code. + * + * \warning MBEDTLS_SHA512_USE_A64_CRYPTO_IF_PRESENT cannot be defined at the + * same time as MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY. + * + * Requires: MBEDTLS_SHA512_C. + * + * Module: library/sha512.c + * + * Uncomment to have the library check for the A64 SHA-512 crypto extensions + * and use them if available. + */ +//#define MBEDTLS_SHA512_USE_A64_CRYPTO_IF_PRESENT + +/** + * \def MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY + * + * Enable acceleration of the SHA-512 and SHA-384 cryptographic hash algorithms + * with the ARMv8 cryptographic extensions, which must be available at runtime + * or else an illegal instruction fault will occur. + * + * \note This allows builds with a smaller code size than with + * MBEDTLS_SHA512_USE_A64_CRYPTO_IF_PRESENT + * + * \note The code uses the SHA-512 Neon intrinsics, so requires GCC >= 8 or + * Clang >= 7, and \c CFLAGS must be set to a minimum of + * \c -march=armv8.2-a+sha3. An optimisation level of \c -O3 generates the + * fastest code. + * + * \warning MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY cannot be defined at the same + * time as MBEDTLS_SHA512_USE_A64_CRYPTO_IF_PRESENT. + * + * Requires: MBEDTLS_SHA512_C. + * + * Module: library/sha512.c + * + * Uncomment to have the library use the A64 SHA-512 crypto extensions + * unconditionally. + */ +//#define MBEDTLS_SHA512_USE_A64_CRYPTO_ONLY /** * \def MBEDTLS_SSL_CACHE_C @@ -3346,7 +2987,7 @@ * Module: library/ssl_ticket.c * Caller: * - * Requires: MBEDTLS_CIPHER_C + * Requires: MBEDTLS_CIPHER_C || MBEDTLS_USE_PSA_CRYPTO */ //#define MBEDTLS_SSL_TICKET_C @@ -3355,7 +2996,7 @@ * * Enable the SSL/TLS client code. * - * Module: library/ssl_cli.c + * Module: library/ssl*_client.c * Caller: * * Requires: MBEDTLS_SSL_TLS_C @@ -3369,7 +3010,7 @@ * * Enable the SSL/TLS server code. * - * Module: library/ssl_srv.c + * Module: library/ssl*_server.c * Caller: * * Requires: MBEDTLS_SSL_TLS_C @@ -3384,8 +3025,8 @@ * Enable the generic SSL/TLS code. * * Module: library/ssl_tls.c - * Caller: library/ssl_cli.c - * library/ssl_srv.c + * Caller: library/ssl*_client.c + * library/ssl*_server.c * * Requires: MBEDTLS_CIPHER_C, MBEDTLS_MD_C * and at least one of the MBEDTLS_SSL_PROTO_XXX defines @@ -3428,14 +3069,15 @@ * your own implementation of the whole module by setting * \c MBEDTLS_TIMING_ALT in the current file. * + * \note The timing module will include time.h on suitable platforms + * regardless of the setting of MBEDTLS_HAVE_TIME, unless + * MBEDTLS_TIMING_ALT is used. See timing.c for more information. + * * \note See also our Knowledge Base article about porting to a new * environment: * https://tls.mbed.org/kb/how-to/how-do-i-port-mbed-tls-to-a-new-environment-OS * * Module: library/timing.c - * Caller: library/havege.c - * - * This module is used by the HAVEGE random number generator. */ //#define MBEDTLS_TIMING_C @@ -3473,9 +3115,9 @@ * Enable X.509 certificate parsing. * * Module: library/x509_crt.c - * Caller: library/ssl_cli.c - * library/ssl_srv.c - * library/ssl_tls.c + * Caller: library/ssl_tls.c + * library/ssl*_client.c + * library/ssl*_server.c * * Requires: MBEDTLS_X509_USE_C * @@ -3550,17 +3192,89 @@ */ #define MBEDTLS_X509_CSR_WRITE_C +/** \} name SECTION: mbed TLS modules */ + /** - * \def MBEDTLS_XTEA_C + * \name SECTION: General configuration options * - * Enable the XTEA block cipher. + * This section contains Mbed TLS build settings that are not associated + * with a particular module. * - * Module: library/xtea.c - * Caller: + * \{ */ -//#define MBEDTLS_XTEA_C -/* \} name SECTION: mbed TLS modules */ +/** + * \def MBEDTLS_CONFIG_FILE + * + * If defined, this is a header which will be included instead of + * `"mbedtls/mbedtls_config.h"`. + * This header file specifies the compile-time configuration of Mbed TLS. + * Unlike other configuration options, this one must be defined on the + * compiler command line: a definition in `mbedtls_config.h` would have + * no effect. + * + * This macro is expanded after an \#include directive. This is a popular but + * non-standard feature of the C language, so this feature is only available + * with compilers that perform macro expansion on an \#include line. + * + * The value of this symbol is typically a path in double quotes, either + * absolute or relative to a directory on the include search path. + */ +//#define MBEDTLS_CONFIG_FILE "mbedtls/mbedtls_config.h" + +/** + * \def MBEDTLS_USER_CONFIG_FILE + * + * If defined, this is a header which will be included after + * `"mbedtls/mbedtls_config.h"` or #MBEDTLS_CONFIG_FILE. + * This allows you to modify the default configuration, including the ability + * to undefine options that are enabled by default. + * + * This macro is expanded after an \#include directive. This is a popular but + * non-standard feature of the C language, so this feature is only available + * with compilers that perform macro expansion on an \#include line. + * + * The value of this symbol is typically a path in double quotes, either + * absolute or relative to a directory on the include search path. + */ +//#define MBEDTLS_USER_CONFIG_FILE "/dev/null" + +/** + * \def MBEDTLS_PSA_CRYPTO_CONFIG_FILE + * + * If defined, this is a header which will be included instead of + * `"psa/crypto_config.h"`. + * This header file specifies which cryptographic mechanisms are available + * through the PSA API when #MBEDTLS_PSA_CRYPTO_CONFIG is enabled, and + * is not used when #MBEDTLS_PSA_CRYPTO_CONFIG is disabled. + * + * This macro is expanded after an \#include directive. This is a popular but + * non-standard feature of the C language, so this feature is only available + * with compilers that perform macro expansion on an \#include line. + * + * The value of this symbol is typically a path in double quotes, either + * absolute or relative to a directory on the include search path. + */ +//#define MBEDTLS_PSA_CRYPTO_CONFIG_FILE "psa/crypto_config.h" + +/** + * \def MBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE + * + * If defined, this is a header which will be included after + * `"psa/crypto_config.h"` or #MBEDTLS_PSA_CRYPTO_CONFIG_FILE. + * This allows you to modify the default configuration, including the ability + * to undefine options that are enabled by default. + * + * This macro is expanded after an \#include directive. This is a popular but + * non-standard feature of the C language, so this feature is only available + * with compilers that perform macro expansion on an \#include line. + * + * The value of this symbol is typically a path in double quotes, either + * absolute or relative to a directory on the include search path. + */ +//#define MBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE "/dev/null" + +/** \} name SECTION: General configuration options */ /** * \name SECTION: Module configuration options @@ -3571,22 +3285,26 @@ * * Our advice is to enable options and change their values here * only if you have a good reason and know the consequences. - * - * Please check the respective header file for documentation on these - * parameters (to prevent duplicate documentation). * \{ */ +/* The Doxygen documentation here is used when a user comments out a + * setting and runs doxygen themselves. On the other hand, when we typeset + * the full documentation including disabled settings, the documentation + * in specific modules' header files is used if present. When editing this + * file, make sure that each option is documented in exactly one place, + * plus optionally a same-line Doxygen comment here if there is a Doxygen + * comment in the specific module. */ /* MPI / BIGNUM options */ //#define MBEDTLS_MPI_WINDOW_SIZE 6 /**< Maximum window size used. */ //#define MBEDTLS_MPI_MAX_SIZE 1024 /**< Maximum number of bytes for usable MPIs. */ /* CTR_DRBG options */ -//#define MBEDTLS_CTR_DRBG_ENTROPY_LEN 48 /**< Amount of entropy used per seed by default (48 with -// SHA-512, 32 with SHA-256) */ #define MBEDTLS_CTR_DRBG_RESEED_INTERVAL 10000 /**< Interval before reseed is -// performed by default */ #define MBEDTLS_CTR_DRBG_MAX_INPUT 256 /**< Maximum number of additional input -// bytes */ #define MBEDTLS_CTR_DRBG_MAX_REQUEST 1024 /**< Maximum number of requested bytes per call */ -//#define MBEDTLS_CTR_DRBG_MAX_SEED_INPUT 384 /**< Maximum size of (re)seed buffer */ +//#define MBEDTLS_CTR_DRBG_ENTROPY_LEN 48 /**< Amount of entropy used per seed by default (48 with SHA-512, 32 with +// SHA-256) */ #define MBEDTLS_CTR_DRBG_RESEED_INTERVAL 10000 /**< Interval before reseed is performed by default */ #define +// MBEDTLS_CTR_DRBG_MAX_INPUT 256 /**< Maximum number of additional input bytes */ #define +// MBEDTLS_CTR_DRBG_MAX_REQUEST 1024 /**< Maximum number of requested bytes per call */ #define +// MBEDTLS_CTR_DRBG_MAX_SEED_INPUT 384 /**< Maximum size of (re)seed buffer */ /* HMAC_DRBG options */ //#define MBEDTLS_HMAC_DRBG_RESEED_INTERVAL 10000 /**< Interval before reseed is performed by default */ @@ -3595,88 +3313,74 @@ //#define MBEDTLS_HMAC_DRBG_MAX_SEED_INPUT 384 /**< Maximum size of (re)seed buffer */ /* ECP options */ -//#define MBEDTLS_ECP_MAX_BITS 521 /**< Maximum bit size of groups */ -//#define MBEDTLS_ECP_WINDOW_SIZE 6 /**< Maximum window size used */ +//#define MBEDTLS_ECP_WINDOW_SIZE 4 /**< Maximum window size used */ //#define MBEDTLS_ECP_FIXED_POINT_OPTIM 1 /**< Enable fixed-point speed-up */ /* Entropy options */ //#define MBEDTLS_ENTROPY_MAX_SOURCES 20 /**< Maximum number of sources supported */ //#define MBEDTLS_ENTROPY_MAX_GATHER 128 /**< Maximum amount requested from entropy sources */ -//#define MBEDTLS_ENTROPY_MIN_HARDWARE 32 /**< Default minimum number of bytes required for the hardware -// entropy source mbedtls_hardware_poll() before entropy is released */ +//#define MBEDTLS_ENTROPY_MIN_HARDWARE 32 /**< Default minimum number of bytes required for the hardware entropy +// source mbedtls_hardware_poll() before entropy is released */ /* Memory buffer allocator options */ //#define MBEDTLS_MEMORY_ALIGN_MULTIPLE 4 /**< Align on multiples of this value */ /* Platform options */ -//#define MBEDTLS_PLATFORM_STD_MEM_HDR /**< Header to include if MBEDTLS_PLATFORM_NO_STD_FUNCTIONS is -// defined. Don't define if no header is needed. */ #define MBEDTLS_PLATFORM_STD_CALLOC calloc /**< Default -// allocator to use, can be undefined */ #define MBEDTLS_PLATFORM_STD_FREE free /**< Default free to use, can -// be undefined */ #define MBEDTLS_PLATFORM_STD_EXIT exit /**< Default exit to use, can be undefined */ -//#define MBEDTLS_PLATFORM_STD_TIME time /**< Default time to use, can be undefined. MBEDTLS_HAVE_TIME must -// be enabled */ #define MBEDTLS_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use, can be undefined */ -//#define MBEDTLS_PLATFORM_STD_PRINTF printf /**< Default printf to use, can be undefined */ +//#define MBEDTLS_PLATFORM_STD_MEM_HDR /**< Header to include if MBEDTLS_PLATFORM_NO_STD_FUNCTIONS is defined. Don't +// define if no header is needed. */ #define MBEDTLS_PLATFORM_STD_CALLOC calloc /**< Default allocator to use, can be +// undefined */ #define MBEDTLS_PLATFORM_STD_FREE free /**< Default free to use, can be undefined */ #define +// MBEDTLS_PLATFORM_STD_SETBUF setbuf /**< Default setbuf to use, can be undefined */ #define MBEDTLS_PLATFORM_STD_EXIT exit +///**< Default exit to use, can be undefined */ #define MBEDTLS_PLATFORM_STD_TIME time /**< Default time to use, can be +// undefined. MBEDTLS_HAVE_TIME must be enabled */ #define MBEDTLS_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use, +// can be undefined */ #define MBEDTLS_PLATFORM_STD_PRINTF printf /**< Default printf to use, can be undefined */ /* Note: your snprintf must correctly zero-terminate the buffer! */ //#define MBEDTLS_PLATFORM_STD_SNPRINTF snprintf /**< Default snprintf to use, can be undefined */ //#define MBEDTLS_PLATFORM_STD_EXIT_SUCCESS 0 /**< Default exit value to use, can be undefined */ //#define MBEDTLS_PLATFORM_STD_EXIT_FAILURE 1 /**< Default exit value to use, can be undefined */ -//#define MBEDTLS_PLATFORM_STD_NV_SEED_READ mbedtls_platform_std_nv_seed_read /**< Default nv_seed_read function to -// use, can be undefined */ #define MBEDTLS_PLATFORM_STD_NV_SEED_WRITE mbedtls_platform_std_nv_seed_write /**< Default -// nv_seed_write function to use, can be undefined */ #define MBEDTLS_PLATFORM_STD_NV_SEED_FILE "seedfile" /**< Seed -// file to read/write with default implementation */ +//#define MBEDTLS_PLATFORM_STD_NV_SEED_READ mbedtls_platform_std_nv_seed_read /**< Default nv_seed_read function to use, can be +// undefined */ #define MBEDTLS_PLATFORM_STD_NV_SEED_WRITE mbedtls_platform_std_nv_seed_write /**< Default nv_seed_write function +// to use, can be undefined */ #define MBEDTLS_PLATFORM_STD_NV_SEED_FILE "seedfile" /**< Seed file to read/write with default +// implementation */ /* To Use Function Macros MBEDTLS_PLATFORM_C must be enabled */ /* MBEDTLS_PLATFORM_XXX_MACRO and MBEDTLS_PLATFORM_XXX_ALT cannot both be defined */ //#define MBEDTLS_PLATFORM_CALLOC_MACRO calloc /**< Default allocator macro to use, can be undefined */ //#define MBEDTLS_PLATFORM_FREE_MACRO free /**< Default free macro to use, can be undefined */ //#define MBEDTLS_PLATFORM_EXIT_MACRO exit /**< Default exit macro to use, can be undefined */ -//#define MBEDTLS_PLATFORM_TIME_MACRO time /**< Default time macro to use, can be undefined. -// MBEDTLS_HAVE_TIME must be enabled */ #define MBEDTLS_PLATFORM_TIME_TYPE_MACRO time_t /**< Default time macro to -// use, can be undefined. MBEDTLS_HAVE_TIME must be enabled */ #define MBEDTLS_PLATFORM_FPRINTF_MACRO fprintf /**< -// Default fprintf macro to use, can be undefined */ #define MBEDTLS_PLATFORM_PRINTF_MACRO printf /**< Default -// printf macro to use, can be undefined */ +//#define MBEDTLS_PLATFORM_SETBUF_MACRO setbuf /**< Default setbuf macro to use, can be undefined */ +//#define MBEDTLS_PLATFORM_TIME_MACRO time /**< Default time macro to use, can be undefined. MBEDTLS_HAVE_TIME must be +// enabled */ #define MBEDTLS_PLATFORM_TIME_TYPE_MACRO time_t /**< Default time macro to use, can be undefined. +// MBEDTLS_HAVE_TIME must be enabled */ #define MBEDTLS_PLATFORM_FPRINTF_MACRO fprintf /**< Default fprintf macro to use, can +// be undefined */ #define MBEDTLS_PLATFORM_PRINTF_MACRO printf /**< Default printf macro to use, can be undefined */ /* Note: your snprintf must correctly zero-terminate the buffer! */ //#define MBEDTLS_PLATFORM_SNPRINTF_MACRO snprintf /**< Default snprintf macro to use, can be undefined */ //#define MBEDTLS_PLATFORM_VSNPRINTF_MACRO vsnprintf /**< Default vsnprintf macro to use, can be undefined */ -//#define MBEDTLS_PLATFORM_NV_SEED_READ_MACRO mbedtls_platform_std_nv_seed_read /**< Default nv_seed_read function to -// use, can be undefined */ #define MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO mbedtls_platform_std_nv_seed_write /**< -// Default nv_seed_write function to use, can be undefined */ - -/** - * \brief This macro is invoked by the library when an invalid parameter - * is detected that is only checked with #MBEDTLS_CHECK_PARAMS - * (see the documentation of that option for context). - * - * When you leave this undefined here, the library provides - * a default definition. If the macro #MBEDTLS_CHECK_PARAMS_ASSERT - * is defined, the default definition is `assert(cond)`, - * otherwise the default definition calls a function - * mbedtls_param_failed(). This function is declared in - * `platform_util.h` for the benefit of the library, but - * you need to define in your application. - * - * When you define this here, this replaces the default - * definition in platform_util.h (which no longer declares the - * function mbedtls_param_failed()) and it is your responsibility - * to make sure this macro expands to something suitable (in - * particular, that all the necessary declarations are visible - * from within the library - you can ensure that by providing - * them in this file next to the macro definition). - * If you define this macro to call `assert`, also define - * #MBEDTLS_CHECK_PARAMS_ASSERT so that library source files - * include ``. - * - * Note that you may define this macro to expand to nothing, in - * which case you don't have to worry about declarations or - * definitions. However, you will then be notified about invalid - * parameters only in non-void functions, and void function will - * just silently return early on invalid parameters, which - * partially negates the benefits of enabling - * #MBEDTLS_CHECK_PARAMS in the first place, so is discouraged. - * - * \param cond The expression that should evaluate to true, but doesn't. - */ -//#define MBEDTLS_PARAM_FAILED( cond ) assert( cond ) +//#define MBEDTLS_PLATFORM_NV_SEED_READ_MACRO mbedtls_platform_std_nv_seed_read /**< Default nv_seed_read function to use, can be +// undefined */ #define MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO mbedtls_platform_std_nv_seed_write /**< Default nv_seed_write function +// to use, can be undefined */ + +/** \def MBEDTLS_CHECK_RETURN + * + * This macro is used at the beginning of the declaration of a function + * to indicate that its return value should be checked. It should + * instruct the compiler to emit a warning or an error if the function + * is called without checking its return value. + * + * There is a default implementation for popular compilers in platform_util.h. + * You can override the default implementation by defining your own here. + * + * If the implementation here is empty, this will effectively disable the + * checking of functions' return values. + */ +//#define MBEDTLS_CHECK_RETURN __attribute__((__warn_unused_result__)) + +/** \def MBEDTLS_IGNORE_RETURN + * + * This macro requires one argument, which should be a C function call. + * If that function call would cause a #MBEDTLS_CHECK_RETURN warning, this + * warning is suppressed. + */ +//#define MBEDTLS_IGNORE_RETURN( result ) ((void) !(result)) /* PSA options */ /** @@ -3708,32 +3412,6 @@ /* SSL options */ -/** \def MBEDTLS_SSL_MAX_CONTENT_LEN - * - * Maximum length (in bytes) of incoming and outgoing plaintext fragments. - * - * This determines the size of both the incoming and outgoing TLS I/O buffers - * in such a way that both are capable of holding the specified amount of - * plaintext data, regardless of the protection mechanism used. - * - * To configure incoming and outgoing I/O buffers separately, use - * #MBEDTLS_SSL_IN_CONTENT_LEN and #MBEDTLS_SSL_OUT_CONTENT_LEN, - * which overwrite the value set by this option. - * - * \note When using a value less than the default of 16KB on the client, it is - * recommended to use the Maximum Fragment Length (MFL) extension to - * inform the server about this limitation. On the server, there - * is no supported, standardized way of informing the client about - * restriction on the maximum size of incoming messages, and unless - * the limitation has been communicated by other means, it is recommended - * to only change the outgoing buffer size #MBEDTLS_SSL_OUT_CONTENT_LEN - * while keeping the default value of 16KB for the incoming buffer. - * - * Uncomment to set the maximum plaintext size of both - * incoming and outgoing I/O buffers. - */ -#define MBEDTLS_SSL_MAX_CONTENT_LEN 8192 - /** \def MBEDTLS_SSL_IN_CONTENT_LEN * * Maximum length (in bytes) of incoming plaintext fragments. @@ -3742,9 +3420,6 @@ * that it is capable of holding the specified amount of plaintext data, * regardless of the protection mechanism used. * - * If this option is undefined, it inherits its value from - * #MBEDTLS_SSL_MAX_CONTENT_LEN. - * * \note When using a value less than the default of 16KB on the client, it is * recommended to use the Maximum Fragment Length (MFL) extension to * inform the server about this limitation. On the server, there @@ -3754,8 +3429,7 @@ * to only change the outgoing buffer size #MBEDTLS_SSL_OUT_CONTENT_LEN * while keeping the default value of 16KB for the incoming buffer. * - * Uncomment to set the maximum plaintext size of the incoming I/O buffer - * independently of the outgoing I/O buffer. + * Uncomment to set the maximum plaintext size of the incoming I/O buffer. */ //#define MBEDTLS_SSL_IN_CONTENT_LEN 16384 @@ -3773,27 +3447,10 @@ */ //#define MBEDTLS_SSL_CID_OUT_LEN_MAX 32 -/** \def MBEDTLS_SSL_CID_PADDING_GRANULARITY - * - * This option controls the use of record plaintext padding - * when using the Connection ID extension in DTLS 1.2. - * - * The padding will always be chosen so that the length of the - * padded plaintext is a multiple of the value of this option. - * - * Note: A value of \c 1 means that no padding will be used - * for outgoing records. - * - * Note: On systems lacking division instructions, - * a power of two should be preferred. - * - */ -//#define MBEDTLS_SSL_CID_PADDING_GRANULARITY 16 - -/** \def MBEDTLS_SSL_TLS1_3_PADDING_GRANULARITY +/** \def MBEDTLS_SSL_CID_TLS1_3_PADDING_GRANULARITY * * This option controls the use of record plaintext padding - * in TLS 1.3. + * in TLS 1.3 and when using the Connection ID extension in DTLS 1.2. * * The padding will always be chosen so that the length of the * padded plaintext is a multiple of the value of this option. @@ -3804,7 +3461,7 @@ * Note: On systems lacking division instructions, * a power of two should be preferred. */ -//#define MBEDTLS_SSL_TLS1_3_PADDING_GRANULARITY 1 +//#define MBEDTLS_SSL_CID_TLS1_3_PADDING_GRANULARITY 16 /** \def MBEDTLS_SSL_OUT_CONTENT_LEN * @@ -3814,9 +3471,6 @@ * that it is capable of holding the specified amount of plaintext data, * regardless of the protection mechanism used. * - * If this option undefined, it inherits its value from - * #MBEDTLS_SSL_MAX_CONTENT_LEN. - * * It is possible to save RAM by setting a smaller outward buffer, while keeping * the default inward 16384 byte buffer to conform to the TLS specification. * @@ -3825,8 +3479,7 @@ * The specific size requirement depends on the configured ciphers and any * certificate data which is sent during the handshake. * - * Uncomment to set the maximum plaintext size of the outgoing I/O buffer - * independently of the incoming I/O buffer. + * Uncomment to set the maximum plaintext size of the outgoing I/O buffer. */ //#define MBEDTLS_SSL_OUT_CONTENT_LEN 16384 @@ -3835,7 +3488,7 @@ * Maximum number of heap-allocated bytes for the purpose of * DTLS handshake message reassembly and future message buffering. * - * This should be at least 9/8 * MBEDTLSSL_IN_CONTENT_LEN + * This should be at least 9/8 * MBEDTLS_SSL_IN_CONTENT_LEN * to account for a reassembled handshake message of maximum size, * together with its reassembly bitmap. * @@ -3847,10 +3500,20 @@ */ //#define MBEDTLS_SSL_DTLS_MAX_BUFFERING 32768 -//#define MBEDTLS_SSL_DEFAULT_TICKET_LIFETIME 86400 /**< Lifetime of session tickets (if enabled) */ //#define MBEDTLS_PSK_MAX_LEN 32 /**< Max size of TLS pre-shared keys, in bytes (default 256 bits) */ -//#define MBEDTLS_SSL_COOKIE_TIMEOUT 60 /**< Default expiration delay of DTLS cookies, in seconds if HAVE_TIME, -// or in number of cookies issued */ +//#define MBEDTLS_SSL_COOKIE_TIMEOUT 60 /**< Default expiration delay of DTLS cookies, in seconds if HAVE_TIME, or in number +// of cookies issued */ + +/** \def MBEDTLS_TLS_EXT_CID + * + * At the time of writing, the CID extension has not been assigned its + * final value. Set this configuration option to make Mbed TLS use a + * different value. + * + * A future minor revision of Mbed TLS may change the default value of + * this option to match evolving standards and usage. + */ +//#define MBEDTLS_TLS_EXT_CID 254 /** * Complete list of ciphersuites to use, in order of preference. @@ -3864,44 +3527,12 @@ * * The value below is only an example, not the default. */ -//#define MBEDTLS_SSL_CIPHERSUITES -// MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 +//#define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,MBEDTLS_TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 /* X509 options */ //#define MBEDTLS_X509_MAX_INTERMEDIATE_CA 8 /**< Maximum number of intermediate CAs in a verification chain. */ -//#define MBEDTLS_X509_MAX_FILE_PATH_LEN 512 /**< Maximum length of a path/filename string in bytes including the -// null terminator character ('\0'). */ - -/** - * Allow SHA-1 in the default TLS configuration for certificate signing. - * Without this build-time option, SHA-1 support must be activated explicitly - * through mbedtls_ssl_conf_cert_profile. Turning on this option is not - * recommended because of it is possible to generate SHA-1 collisions, however - * this may be safe for legacy infrastructure where additional controls apply. - * - * \warning SHA-1 is considered a weak message digest and its use constitutes - * a security risk. If possible, we recommend avoiding dependencies - * on it, and considering stronger message digests instead. - * - */ -//#define MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_CERTIFICATES - -/** - * Allow SHA-1 in the default TLS configuration for TLS 1.2 handshake - * signature and ciphersuite selection. Without this build-time option, SHA-1 - * support must be activated explicitly through mbedtls_ssl_conf_sig_hashes. - * The use of SHA-1 in TLS <= 1.1 and in HMAC-SHA-1 is always allowed by - * default. At the time of writing, there is no practical attack on the use - * of SHA-1 in handshake signatures, hence this option is turned on by default - * to preserve compatibility with existing peers, but the general - * warning applies nonetheless: - * - * \warning SHA-1 is considered a weak message digest and its use constitutes - * a security risk. If possible, we recommend avoiding dependencies - * on it, and considering stronger message digests instead. - * - */ -//#define MBEDTLS_TLS_DEFAULT_ALLOW_SHA1_IN_KEY_EXCHANGE +//#define MBEDTLS_X509_MAX_FILE_PATH_LEN 512 /**< Maximum length of a path/filename string in bytes including the null +// terminator character ('\0'). */ /** * Uncomment the macro to let mbed TLS use your alternate implementation of @@ -3951,10 +3582,4 @@ */ //#define MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED -#if defined(MBEDTLS_PSA_CRYPTO_CONFIG) -#include "mbedtls/config_psa.h" -#endif - -#include "mbedtls/check_config.h" - -#endif /* MBEDTLS_CONFIG_H */ +/** \} name SECTION: Module configuration options */ diff --git a/config/openiotsdk/storage/CMakeLists.txt b/config/openiotsdk/storage/CMakeLists.txt new file mode 100644 index 00000000000000..a7f1e0b53f0e4a --- /dev/null +++ b/config/openiotsdk/storage/CMakeLists.txt @@ -0,0 +1,34 @@ +# +# Copyright (c) 2022 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +cmake_minimum_required(VERSION 3.21) + +# Declare Open IoT SDK app interface target +add_library(openiotsdk-storage + FlashBlockDevice.cpp +) + +target_include_directories(openiotsdk-storage + PUBLIC + . + ${CHIP_ROOT}/src/platform/openiotsdk +) + +target_link_libraries(openiotsdk-storage + PUBLIC + mcu-driver-hal + iotsdk-blockdevice +) diff --git a/config/openiotsdk/storage/FlashBlockDevice.cpp b/config/openiotsdk/storage/FlashBlockDevice.cpp new file mode 100644 index 00000000000000..e876dec9eaed19 --- /dev/null +++ b/config/openiotsdk/storage/FlashBlockDevice.cpp @@ -0,0 +1,287 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + * Utilities for interacting with the the Open IoT SDK key-value storage. + */ + +#include + +#include "FlashBlockDevice.h" +#include + +extern "C" { +#include +} + +#define FLASH_BASE_ADDRESS (SRAM_BASE_NS) /* 0x01000000 */ +#define FLASH_TOTAL_SIZE (SRAM_SIZE) /* 2 MB */ +#define FLASH_AREA_IMAGE_SECTOR_SIZE (0x1000) /* 4 KB */ +#define FLASH_PAGE_SIZE 256 +#define FLASH_END_ADDRESS (FLASH_BASE_ADDRESS + FLASH_TOTAL_SIZE) +#define FLASH_READ_SIZE 1 +#define FLASH_ERASE_VALUE 0xFFU + +namespace iotsdk { +namespace storage { + +FlashBlockDevice::FlashBlockDevice(uint32_t address, uint32_t size) : _base(address), _size(size), _is_initialized(false) {} + +FlashBlockDevice::~FlashBlockDevice() {} + +bd_status FlashBlockDevice::init() +{ + if (!_base) + { + _base = FLASH_BASE_ADDRESS; + } + + if (!_size) + { + _size = FLASH_TOTAL_SIZE - (_base - FLASH_BASE_ADDRESS); + } + + if (_size + _base > FLASH_TOTAL_SIZE + FLASH_BASE_ADDRESS) + { + return bd_status::INCORRECT_SIZE; + } + + if (_base < FLASH_BASE_ADDRESS) + { + return bd_status::INCORRECT_ADDRESS; + } + + _is_initialized = true; + return bd_status::OK; +} + +bd_status FlashBlockDevice::deinit() +{ + if (!_is_initialized) + { + return bd_status::OK; + } + + _is_initialized = false; + + return bd_status::OK; +} + +bd_status FlashBlockDevice::read(void * buffer, bd_addr_t virtual_address, bd_size_t size) +{ + if (!_is_initialized) + { + return bd_status::DEVICE_NOT_INITIALIZED; + } + + /* Check that the address and size are properly aligned and fit. */ + bd_status status = is_valid_read(virtual_address, size); + if (status != bd_status::OK) + { + return status; + } + + /* Convert virtual address to the physical address for the device. */ + const auto physical_address = static_cast(_base + virtual_address); + + /* Read data */ + memcpy(static_cast(buffer), (void *) physical_address, static_cast(size)); + + return bd_status::OK; +} + +bd_status FlashBlockDevice::program(const void * buffer, bd_addr_t virtual_address, bd_size_t size) +{ + if (!_is_initialized) + { + return bd_status::DEVICE_NOT_INITIALIZED; + } + + /* Check that the address and size are properly aligned and fit. */ + bd_status status = is_valid_program(virtual_address, size); + if (status != bd_status::OK) + { + return status; + } + + /* Convert virtual address to the physical address for the device. */ + auto physical_address = static_cast(_base + virtual_address); + auto remaining_size = static_cast(size); + const auto * buf = static_cast(buffer); + + while (remaining_size > 0) + { + /* Multiple pages can be programmed at once but cannot cross sector boundaries */ + const auto sector_size = FLASH_AREA_IMAGE_SECTOR_SIZE; + const auto sector_end = (physical_address / sector_size + 1) * sector_size; + const auto chunk = (physical_address + remaining_size > sector_end) ? (sector_end - physical_address) : remaining_size; + /* Write data */ + memcpy((void *) physical_address, buf, chunk); + physical_address += chunk; + remaining_size -= chunk; + buf += chunk; + } + + return bd_status::OK; +} + +bd_status FlashBlockDevice::erase(bd_addr_t virtual_address, bd_size_t size) +{ + if (!_is_initialized) + { + return bd_status::DEVICE_NOT_INITIALIZED; + } + + /* Check that the address and size are properly aligned and fit. */ + const bd_status status = is_valid_erase(virtual_address, size); + if (status != bd_status::OK) + { + return status; + } + + /* Convert virtual address to the physical address for the device. */ + auto physical_address = static_cast(_base + virtual_address); + const auto sector_size = FLASH_AREA_IMAGE_SECTOR_SIZE; + const auto erase_region = (physical_address + size) - sector_size; + + while (physical_address <= erase_region) + { + memset((void *) physical_address, FLASH_ERASE_VALUE, FLASH_AREA_IMAGE_SECTOR_SIZE); + physical_address += sector_size; + } + + return bd_status::OK; +} + +bd_size_t FlashBlockDevice::get_read_size() const +{ + return FLASH_READ_SIZE; +} + +bd_size_t FlashBlockDevice::get_program_size() const +{ + if (!_is_initialized) + { + return 0; + } + + return FLASH_PAGE_SIZE; +} + +bd_size_t FlashBlockDevice::get_erase_size() const +{ + return 0; +} + +bd_size_t FlashBlockDevice::get_erase_size(bd_addr_t addr) const +{ + if (!_is_initialized) + { + return 0; + } + + if (static_cast(_base) + addr > UINT32_MAX) + { + return 0; + } + + return FLASH_AREA_IMAGE_SECTOR_SIZE; +} + +int FlashBlockDevice::get_erase_value() const +{ + if (!_is_initialized) + { + return -1; + } + + return FLASH_ERASE_VALUE; +} + +bd_size_t FlashBlockDevice::size() const +{ + return _size; +} + +const char * FlashBlockDevice::get_type() const +{ + return "FLASH_BD"; +} + +bd_status FlashBlockDevice::is_valid_read(bd_addr_t addr, bd_size_t size) const +{ + if (static_cast(_base) + addr > UINT32_MAX) + { + return bd_status::INCORRECT_ADDRESS; + } + + if (size > UINT32_MAX) + { + return bd_status::INCORRECT_SIZE; + } + + return BlockDevice::is_valid_read(addr, size); +} + +bd_status FlashBlockDevice::is_valid_program(bd_addr_t addr, bd_size_t size) const +{ + if (static_cast(_base) + addr > UINT32_MAX) + { + return bd_status::INCORRECT_ADDRESS; + } + + if (size > UINT32_MAX) + { + return bd_status::INCORRECT_SIZE; + } + + return BlockDevice::is_valid_program(addr, size); +} + +bd_status FlashBlockDevice::is_valid_erase(bd_addr_t addr, bd_size_t size) const +{ + if (static_cast(_base) + addr > UINT32_MAX) + { + return bd_status::INCORRECT_ADDRESS; + } + + if (size > UINT32_MAX) + { + return bd_status::INCORRECT_SIZE; + } + + return BlockDevice::is_valid_erase(addr, size); +} + +} // namespace storage +} // namespace iotsdk + +namespace chip { +namespace DeviceLayer { +namespace Internal { + +static iotsdk::storage::FlashBlockDevice gBlockDevice(0, 0); + +iotsdk::storage::BlockDevice * GetBlockDevice() +{ + return &gBlockDevice; +} + +} // namespace Internal +} // namespace DeviceLayer +} // namespace chip diff --git a/config/openiotsdk/storage/FlashBlockDevice.h b/config/openiotsdk/storage/FlashBlockDevice.h new file mode 100644 index 00000000000000..95ba8375e7c9db --- /dev/null +++ b/config/openiotsdk/storage/FlashBlockDevice.h @@ -0,0 +1,185 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file + */ + +#ifndef IOTSDK_FLASH_BLOCKDEVICE_H +#define IOTSDK_FLASH_BLOCKDEVICE_H + +#include "iotsdk/BlockDevice.h" + +#include + +namespace iotsdk { +namespace storage { +/** BlockDevice using the flash memory for TF-M application + * + */ +class FlashBlockDevice final : public BlockDevice +{ +public: + /** Creates a FlashBlockDevice + * @param address Physical address where the block device start + * @param size The block device size + */ + FlashBlockDevice(uint32_t address, uint32_t size); + + ~FlashBlockDevice(); + + /** Initialize a block device + * + * This method must be called before attempting any further block device operations. + * + * @return bd_status::OK on success or an error status on failure + */ + bd_status init() override; + + /** Deinitialize a block device + * + * @return bd_status::OK on success or an error status on failure + */ + bd_status deinit() override; + + /** Read blocks from a block device + * + * If a failure occurs, it is not possible to determine how many bytes succeeded. + * + * @param buffer Buffer to write blocks to + * @param addr Address of block to begin reading from + * @param size Size to read in bytes, must be a multiple of the read block size + * @return bd_status::OK on success or an error status on failure + */ + bd_status read(void * buffer, bd_addr_t addr, bd_size_t size) override; + + /** Program blocks to a block device + * + * The blocks must have been erased prior to being programmed. + * + * If a failure occurs, it is not possible to determine how many bytes succeeded. + * + * @param buffer Buffer of data to write to blocks + * @param addr Address of block to begin writing to + * @param size Size to write in bytes, must be a multiple of the program block size + * @return bd_status::OK on success or an error status on failure + */ + bd_status program(const void * buffer, bd_addr_t addr, bd_size_t size) override; + + /** Erase blocks on a block device + * + * The state of an erased block is undefined until it has been programmed, + * unless get_erase_value returns a non-negative byte value. + * + * @param addr Address of block to begin erasing + * @param size Size to erase in bytes, must be a multiple of the erase block size + * @return bd_status::OK on success or an error status on failure + */ + bd_status erase(bd_addr_t addr, bd_size_t size) override; + + /** Get the size of a readable block + * + * @return Size of a readable block in bytes + */ + bd_size_t get_read_size() const override; + + /** Get the size of a programmable block + * + * @return Size of a programmable block in bytes + * @note Must be a multiple of the read size + */ + bd_size_t get_program_size() const override; + + /** Get the size of an erasable block for the whole device + * + * @return Size of an erasable block in bytes for the whole device + * @note Must be a multiple of the program size, or 0 if no common erase size exists + * across all regions or the underlying implementation does not provide this + * information in which case you need to call get_erase_size(bd_addr_t) instead + * @note For FlashBlockDevice, this always returns 0 because the underlying + * MCU-Driver-HAL flash API does not indicate whether all sectors have the same + * size + */ + bd_size_t get_erase_size() const override; + + /** Get the size of an erasable block given address + * + * @param addr Address within the erasable block + * @return Size of an erasable block in bytes + * @note Must be a multiple of the program size + */ + bd_size_t get_erase_size(bd_addr_t addr) const override; + + /** Get the value of storage when erased + * + * If get_erase_value returns a non-negative byte value, the underlying + * storage is set to that value when erased, and storage containing + * that value can be programmed without another erase. + * + * @return The value of storage when erased, or -1 if you can't + * rely on the value of the erased storage + */ + int get_erase_value() const override; + + /** Get the total size of the underlying device + * + * @return Size of the underlying device in bytes + */ + bd_size_t size() const override; + + /** Convenience function for checking block read validity + * + * @param addr Address of block to begin reading from + * @param size Size to read in bytes + * @return bd_status::OK if read is valid for underlying block device + */ + bd_status is_valid_read(bd_addr_t addr, bd_size_t size) const override; + + /** Convenience function for checking block program validity + * + * @param addr Address of block to begin writing to + * @param size Size to write in bytes + * @return bd_status::OK if program is valid for underlying block device + */ + bd_status is_valid_program(bd_addr_t addr, bd_size_t size) const override; + + /** Convenience function for checking block erase validity + * + * @param addr Address of block to begin erasing + * @param size Size to erase in bytes + * @return bd_status::OK if erase is valid for underlying block device + */ + bd_status is_valid_erase(bd_addr_t addr, bd_size_t size) const override; + + /** Get the BlockDevice class type. + * + * @return A string represent the BlockDevice class type. + */ + const char * get_type() const override; + +private: + // Device configuration + uint32_t _base; + uint32_t _size; + bool _is_initialized; +}; + +} // namespace storage +} // namespace iotsdk + +#endif /* IOTSDK_FLASH_BLOCKDEVICE_H */ diff --git a/config/openiotsdk/util.cmake b/config/openiotsdk/util.cmake index 23e0aabe662ee3..cfa34725f781fa 100644 --- a/config/openiotsdk/util.cmake +++ b/config/openiotsdk/util.cmake @@ -137,16 +137,3 @@ function(convert_list_of_flags_to_string_of_flags ptr_list_of_flags string_of_fl # Set the output variable in the parent scope set(${string_of_flags} ${locally_scoped_string_of_flags} PARENT_SCOPE) endfunction() - - -function (get_all_cmake_targets out_var current_dir) - get_property(targets DIRECTORY ${current_dir} PROPERTY BUILDSYSTEM_TARGETS) - get_property(subdirs DIRECTORY ${current_dir} PROPERTY SUBDIRECTORIES) - - foreach(subdir ${subdirs}) - get_all_cmake_targets(subdir_targets ${subdir}) - list(APPEND targets ${subdir_targets}) - endforeach() - - set(${out_var} ${targets} PARENT_SCOPE) -endfunction() \ No newline at end of file diff --git a/config/telink/chip-module/Kconfig b/config/telink/chip-module/Kconfig index aa58ad3c58a8cb..894986b2bf69ec 100644 --- a/config/telink/chip-module/Kconfig +++ b/config/telink/chip-module/Kconfig @@ -1,5 +1,5 @@ # -# Copyright (c) 2022 Project CHIP Authors +# Copyright (c) 2023 Project CHIP Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,6 +20,16 @@ rsource "../../zephyr/Kconfig" config CHIP_DEVICE_VENDOR_NAME default "Telink semiconductor" +config CHIP_APP_LOG_LEVEL + int "Logging level in application" + default LOG_DEFAULT_LEVEL + depends on LOG + help + Sets the logging level in the Matter application. Use this configuration + option only within the application. To set the logging level for the + Matter stack, use the MATTER_LOG_LEVEL configuration option. + + # See config/zephyr/Kconfig for full definition config CHIP_OTA_REQUESTOR bool @@ -130,3 +140,12 @@ endif #CHIP_FACTORY_DATA_BUILD config CHIP_FACTORY_RESET_ERASE_NVS bool default y + +config CHIP_LOG_SIZE_OPTIMIZATION + bool "Disable some detailed logs to decrease flash usage" + default y + help + Disables some log levels for specific Matter log modules that provide + information that is too detailed to be used in most cases. You can find + full configuration enabled by this option in the + platform/telink/CHIPPlatformConfig.h file. diff --git a/config/zephyr/Kconfig b/config/zephyr/Kconfig index 45b04b9a1e2216..54717d7e3b80ca 100644 --- a/config/zephyr/Kconfig +++ b/config/zephyr/Kconfig @@ -15,7 +15,7 @@ # menuconfig CHIP - bool "Connected Home over IP protocol stack" + bool "Matter protocol stack" default n select CPLUSPLUS imply LIB_CPLUSPLUS @@ -37,256 +37,275 @@ menuconfig CHIP imply NVS imply SETTINGS help - This option enables Connected Home over IP libraries. + Enables Matter libraries required for the Matter protocol stack to work. if CHIP # Device and firmware identifers config CHIP_DEVICE_VENDOR_ID - int "Device vendor ID" + int "Device Vendor ID" default 65521 # 0xFFF1 range 0 65535 help - Identifier of the device manufacturer, assigned by Connectivity Standards - Alliance. It is used in various CHIP areas, such as the Basic Information - cluster or OTA (Over-the-air update) image header. + Provides the 16-bit numeric identifier of the device manufacturer, + assigned by Connectivity Standards Alliance. The identifier is exposed as + an attribute of the Basic Informationcluster, and included in the header + of the generated Matter Over-the-air (OTA) update image. config CHIP_DEVICE_VENDOR_NAME - string "Human-readable vendor name" + string "Device vendor name" help - A human-readable vendor name which provides a simple string - containing identification of device's vendor for the Content APP. - This information should be included in the Matter Basic Cluster. + Provides a human-readable name of the device manufacturer. The name is + exposed as an attribute of the Basic Information cluster. config CHIP_DEVICE_PRODUCT_ID - int "Device product ID" + int "Product ID" default 32768 # 0x8000 range 0 65535 help - Identifier of the product, assigned by the device manufacturer. It is used - in various CHIP areas, such as the Basic Information cluster or OTA - (Over-the-air update) image header. + Provides the 16-bit numeric identifier of the product, assigned by the + device manufacturer. The identifier is exposed as an attribute of the + Basic Information cluster, and included in the header of the generated + Matter over-the-air (OTA) update image. config CHIP_DEVICE_PRODUCT_NAME - string "Human-readable product name" + string "Product name" default "not-specified" help - A human-readable product name which provides a simple string - containing identification of the product for the Content APP. + Provides a human-readable product name, such as the model number, assigned + by the device manufacturer. The name is exposed as an attribute of the + Basic Information cluster. config CHIP_DEVICE_HARDWARE_VERSION - int "Integer representation of hardware version" + int "Hardware version" default 0 help - A hardware version number specifies the version number - of the hardware of the device. The meaning of its value, - and the versioning scheme, are vendor defined. + Provides the 16-bit hardware version number, assigned by the device + manufacturer. The number is exposed as an attribute of the Basic + Information cluster. config CHIP_DEVICE_HARDWARE_VERSION_STRING - string "user-friendly string representation of hardware version" + string "Hardware version string" default "prerelease" help - A hardware version string parameter specifies the version - of the hardware of the device as a more user-friendly value - than that represented by the hardware version integer value. - The meaning of its value, and the versioning scheme, are - vendor defined. + Provides a human-readable representation of the hardware version number. + This must be an ASCII string of a length between 1 and 64 characters. The + hardware version string is exposed as an attribute of the Basic + Information cluster. config CHIP_DEVICE_SOFTWARE_VERSION - int "Device software version" + int "Software version" default 0 range 0 4294967295 help - A number identifying the software version. It is used in various CHIP - areas, such as the Basic Information cluster or OTA (Over-the-air update) - image header. Note that due to the rollback protection a device will only - accept a software update whose version is greater than the current one. + Provides the 32-bit software version number. The number is exposed as an + attribute of the Basic Information cluster, and included in the header of + the generated Matter Over-the-air (OTA) update image. The exact numbering + scheme is up to the device manufacturer. However, when using the Matter + OTA mechanism, only updates to higher versions than the current one are + accepted. config CHIP_DEVICE_SOFTWARE_VERSION_STRING - string "Device software version string" + string "Software version string" default "prerelease" help - A string between 1 and 64 characters that provides a user-friendly - description of the numeric software version specified in - CHIP_DEVICE_SOFTWARE_VERSION. It is used in various CHIP areas, such as - the Basic Information cluster or OTA (Over-the-air update) image header. + Provides a human-readable representation of the software version number. + This must be an ASCII string of a length between 1 and 64 characters. The + software version string is exposed as an attribute of the Basic + Information cluster, and included in the header of the generated Matter + over-the-air (OTA) update image. config CHIP_DEVICE_MANUFACTURING_DATE - string "Manufacturing date in ISO 8601" + string "Manufacturing date (ISO 8601 format)" default "2022-01-01" help - A manufacturing date specifies the date that the device was manufactured. - The format used for providing a manufacturing date is ISO 8601 e.g. YYYY-MM-DD. + Provides the device manufacturing date in the ISO 8601 format: YYYY-MM-DD. config CHIP_DEVICE_SERIAL_NUMBER - string "Serial number of device" + string "Device serial number" default "11223344556677889900" help - A serial number parameter defines an unique number of manufactured device. - Maximum length of serial number is 32 characters. + Provides a human-readable representation of the device serial number that + uniquely identifies the device. This must be an ASCII string of no more + than 32 characters. config CHIP_DEVICE_ROTATING_DEVICE_UID - string "A rotating device id unique id" + string "Rotating device ID unique ID (HEX format)" default "91a9c12a7c80700a31ddcfa7fce63e44" help - A device rotating id unique id which will be generated if - this config is not set in prj.conf file. + Provides a unique identifier of the device. This ID is used to derive the + rotating device identifier, which allows commissioners to discover the + device in a privacy-preserving way. The identifier must be a string of at + least 16 bytes encoded in HEX. config CHIP_DEVICE_TYPE - int "Device type" + int "Primary device type" default 65535 range 0 65535 help - Type of device that uses the CHIP Device Type Identifier. The default value means invalid device type. + Provides the primary device type implemented by the node. This must be one + of the device type identifiers defined in the Matter Device Library + specification. config CHIP_DEVICE_DISCRIMINATOR hex "Device pairing discriminator" default 0xF00 help - A 12-bit value matching the field of the same name in - the setup code. Discriminator is used during - a discovery process. + Provides a 12-bit identifier that is used to discover the device during + the commissioning. config CHIP_DEVICE_SPAKE2_PASSCODE - int "Spake2+ passcode" + int "SPAKE2+ passcode" default 20202021 range 1 99999998 help - A pairing passcode is a 27-bit unsigned integer which serves - as a proof of possession during commissioning. - Its value shall be restricted to the values 0x0000001 to 0x5F5E0FE - (00000001 to 99999998 in decimal), excluding the invalid Passcode values: - - 00000000, 11111111, 22222222, 33333333, 44444444, 55555555, + Provides a pairing passcode. This is a 27-bit unsigned integer that serves + as a proof of possession during the commissioning. The passcode must be + a value between 1 and 99999998, excluding the following invalid passcodes: + 00000000, 11111111, 22222222, 33333333, 44444444, 55555555, 66666666, 77777777, 88888888, 99999999, 12345678, 87654321. config CHIP_DEVICE_SPAKE2_IT - int "Spake2+ iteration count" + int "SPAKE2+ iteration count" default 1000 help - The Spake2 iteration count is associated with the ephemeral - PAKE passcode verifier to be used for the commissioning. - The iteration count is used as a crypto parameter to process - spake2 verifier. + Provides the SPAKE2+ iteration count, which is one of the input parameters + for the PBKDF operation, used to generate the SPAKE2+ verifier. config CHIP_DEVICE_SPAKE2_SALT - string "Spake2+ salt in string format" + string "SPAKE2+ salt (base64 format)" default "U1BBS0UyUCBLZXkgU2FsdA==" help - The spake2 salt is random data that is used as an additional input - to a one-way function that “hashes” data. - A new salt should be randomly generated for each password. - The minimum length of spake2 salt is 16 Bytes. - The maximum length of spake2 salt is 32 Bytes. + Provides the SPAKE2+ salt, which is one of the input parameters for the + PBKDF operation, used to generate the SPAKE2+ verifier. The salt must be + of a length between 16 and 32 bytes and it should be randomly generated + for each SPAKE2+ passcode. config CHIP_DEVICE_SPAKE2_TEST_VERIFIER - string "Testing spake2+ verifier" + string "SPAKE2+ verifier for testing purposes (base64 format)" default "uWFwqugDNGiEck/po7KHwwMwwqZgN10XuyBajPGuyzUEV/iree4lOrao5GuwnlQ65CJzbeUB49s31EH+NEkg0JVI5MGCQGMMT/SRPFNRODm3wH/MBiehuFc6FJ/NH6Rmzw==" help - The spake 2 verifier generated using default SPAKE2 salt, - iteration count and passcode. This value can be used for development - or testing purposes. - Generated with: - spake2p gen-verifier -o - -i 1000 -s "U1BBS0UyUCBLZXkgU2FsdA==" -p 20202021 + Provides the SPAKE2+ verifier that was generated using the configured + SPAKE2+ passcode, iteration count and salt. This configuration option can + be used for development or testing purposes. The default value was + generated using the following command: + ./scripts/tools/spake2p/spake2p.py gen-verifier -i 1000 -s U1BBS0UyUCBLZXkgU2FsdA== -p 20202021 config CHIP_DEVICE_ENABLE_KEY - string "Enable Key for triggering test actions on device" + string "Enable Key for triggering test actions (HEX format)" default "00112233445566778899AABBCCDDEEFF" help - The Enable Key is a 128-bit value that triggers test action - while invoking the TestEventTrigger Command. - Pattern: "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" - This value is used during Certification Tests, - and should not be present on production devices. + Provides the Enable Key, which is a 16-byte value encoded in HEX that + must be provided in the TestEventTrigger command to trigger a requested + test action. This value is used during certification tests, and should not + be present on devices in production environment. # Matter optional features and parameters config CHIP_ENABLE_PAIRING_AUTOSTART - bool "Enable pairing autostart" + bool "Open commissioning window on boot" default n help - Open pairing window automatically at application boot time. + Opens the commissioning window automatically at application boot time if + the node is not yet commissioned. config CHIP_OTA_REQUESTOR - bool "Enable OTA requestor" + bool "OTA Software Update Requestor" help - Enables OTA (Over-the-air) Requestor role that allows a device to perform + Enables over-the-air (OTA) Requestor role that allows the node to perform Device Firmware Upgrade by quering and downloading a new firmware image - from an external OTA Provider node. + from a peer OTA Provider node. config CHIP_ROTATING_DEVICE_ID - bool "Enable rotating device ID support" + bool "Generate rotating device ID" help - Enables rotating device identifier that provides a non-trackable identifier - which is unique per device and rotates at pre-defined moments. + Enables the rotating device identifier that provides a non-trackable + identifier. The identifier is unique per device and rotates at pre-defined + moments. config CHIP_COMMISSIONABLE_DEVICE_TYPE - bool "Enable the device type subtype in commissionable node discovery record" - depends on CHIP_ENABLE_DNSSD_SRP + bool "Include device type subtype in commissionable node discovery record" help - Enables including device type subtype in the commissionable node discovery record, - which allows filtering of the results to find the nodes that match the device type. + Includes the device type subtype in the commissionable node discovery + record. This allows a commissioner to find the node when looking for + a specific device type. config CHIP_EXTENDED_DISCOVERY - bool "Enable extended discovery" + bool "Extended discovery" help - Enables the device to advertise commissionable service when not in the - commissioning mode. + Enables advertising of the commissionable node service even if the node + does not have the commissioning window open. config CHIP_OPERATIONAL_TIME_SAVE_INTERVAL - int "Interval of saving node operation time to flash in hours unit" + int "Total operational time save interval (hours unit)" default 10 range 1 4294967295 help - Interval in hours with which the node operation time is saved to the flash - memory. Selected value is a trade off between performing frequent saves to know - precisely operation time in case of device reboot and maximizing flash memory - lifetime. + Provides an interval in hours with which the node operational time is + saved to the flash memory. The provided value is a trade-off between + performing frequent saves to know the precise operational time (in case of + device reboot) and maximizing the flash memory lifetime. config CHIP_CRYPTO_PSA bool "Use PSA crypto API for cryptographic operations" help - Use the backend for the Matter crypto layer that is based on PSA crypto - API instead of the default, based on legacy mbedTLS APIs. + Enables the implementation of the Matter cryptographic operations that is + based on the PSA crypto API (instead of the default implementation, which + is based on the legacy mbedTLS APIs). + +config CHIP_PERSISTENT_SUBSCRIPTIONS + bool "Persistent subscriptions" + help + Persists Matter subscriptions on the publisher node. This feature allows + a Matter node to faster get back to the previous operation after it went + offline, for example, due to a power outage. That is, the node can use the + persisted subscription information to quickly re-establish the previous + subscriptions instead of waiting for the subscriber node to realize that + the publisher is alive again. config CHIP_LIB_SHELL - bool "Enable CHIP shell library" + bool "Matter shell commands" default n imply SHELL help - Link the application with the library containing CHIP shell commands. + Enables linking the application with the library that contains Matter + shell commands. config CHIP_PROJECT_CONFIG - string "Project configuration file for CHIP" + string "Project configuration file for Matter" help - Project configuration file for CHIP. If specified, CHIP generic - configuration files will include the project configuration file which can - be used to override any CHIP default or platform-specific settings. + Provides a path to the project configuration file for Matter. The path can + be either absolute or relative to the application directory. If specified, + Matter's generic configuration files will include the project + configuration file that can be used to override any of Matter's default or + platform-specific settings. # Thread network features config CHIP_ENABLE_DNSSD_SRP - bool "Enable support for service registration" + bool "OpenThread Service Registration Protocol" default y if NET_L2_OPENTHREAD imply OPENTHREAD_ECDSA imply OPENTHREAD_SRP_CLIENT help - Enables DNS-SD SRP client support + Enables using the OpenThread SRP client for the Matter service + advertising. config CHIP_ENABLE_DNS_CLIENT - bool "Enable support for DNS client" - default y + bool "OpenThread DNS client" + default y if NET_L2_OPENTHREAD imply OPENTHREAD_DNS_CLIENT help - Enables DNS client support used for resolving and browsing services. + Enables using the OpenThread DNS client for the Matter service discovery. config CHIP_ENABLE_SLEEPY_END_DEVICE_SUPPORT - bool "Enable sleepy end device support" + bool "Thread Sleepy End Device support" default n depends on OPENTHREAD_MTD imply OPENTHREAD_MTD_SED help - Enables Thread Sleepy End Device support in Matter. + Enables the Thread Sleepy End Device (SED) support in Matter. if CHIP_ENABLE_SLEEPY_END_DEVICE_SUPPORT @@ -294,17 +313,17 @@ config CHIP_SED_IDLE_INTERVAL int "Sleepy End Device idle interval (ms)" default 1000 help - SED wake interval in milliseconds while the device is idle, meaning that - there is no active exchange to or from the device, and its commissioning - window is closed. + Provides the Sleepy End Device wake interval in milliseconds while the + device is idle (which means that there is no active exchange to or from + the device, and its commissioning window is closed). config CHIP_SED_ACTIVE_INTERVAL int "Sleepy End Device active interval (ms)" default 200 help - SED wake interval in milliseconds while the device is active, meaning that - there is an active exchange to or from the device, or its commissioning - window is open. + Provides the Sleepy End Device wake interval in milliseconds while the + device is active (which means that there is an active exchange to or from + the device, or its commissioning window is open). endif # CHIP_ENABLE_SLEEPY_END_DEVICE_SUPPORT @@ -312,33 +331,35 @@ config CHIP_THREAD_SSED bool "Enable Thread Synchronized Sleepy End Device support" depends on OPENTHREAD_CSL_RECEIVER && CHIP_ENABLE_SLEEPY_END_DEVICE_SUPPORT help - Enables Thread Synchronized Sleepy End Device support in Matter. + Enables the Thread Synchronized Sleepy End Device support in Matter. config CHIP_OPENTHREAD_CONFIG string "Custom OpenThread configuration file" help - This option can be used to replace Zephyr-supplied OpenThread - configuration file with a custom one. + Provides a path to an OpenThread configuration file. The path can be + either absolute or relative to the application directory. When this option + is specified, it replaces the OpenThread configuration file supplied by + Zephyr. # Platform additions and configuration config CHIP_CERTIFICATION_DECLARATION_STORAGE - bool "Enable storing Certification Declaration" + bool "Certification Declaration settings storage" depends on CHIP_FACTORY_DATA help - Enables storing Certification Declaration in Zephyr settings - instead of using hardcoded value from firmware. It also adds + Enables storing of the Certification Declaration in Zephyr settings + instead of using the hardcoded value from firmware. This option also adds support for including new Certification Declaration into a firmware - update image package sent via OTA Software Update. + update image package that is sent as part of the OTA software update. if CHIP_CERTIFICATION_DECLARATION_STORAGE config CHIP_CERTIFiCATION_DECLARATION_OTA_IMAGE_ID - int "Certification declaration OTA image id" + int "Certification declaration OTA image ID" default 205 #0xcd help - The image id of Certification Declaration image - for sending it via OTA Software Update purposes. + Provides the image ID of the Certification Declaration image for sending + it as part of the OTA software update. endif @@ -346,37 +367,38 @@ config CHIP_FACTORY_RESET_ERASE_NVS bool "Erase NVS flash pages on factory reset" depends on SETTINGS_NVS help - When factory reset is requested, erase flash pages occupied by non-volatile storage - instead of removing Matter-related settings only. This provides a more robust - factory reset mechanism and allows to regain the original storage performance if any - firmware issue has brought it to an unexpected state. For this reason, it is - advisable to set this option if all configuration, including device-specific - entries, is supposed to be cleared on a factory reset. + Erases flash pages occupied by non-volatile storage when a factory reset + is requested, instead of removing Matter-related settings only. Enabling + this option provides a more robust factory reset mechanism and allows to + regain the original storage performance if any firmware issue has brought + it to an unexpected state. For this reason, set this option if the entire + configuration is supposed to be cleared on a factory reset, including + device-specific entries. config CHIP_MALLOC_SYS_HEAP bool "Memory allocator based on Zephyr sys_heap" imply SYS_HEAP_RUNTIME_STATS help - Enable memory allocation functions, imitating with the default malloc, + Enables memory allocation functions that imitate the default malloc, calloc, realloc and free, based on sys_heap from Zephyr RTOS. if CHIP_MALLOC_SYS_HEAP config CHIP_MALLOC_SYS_HEAP_OVERRIDE - bool "Override default allocator with custom one based on Zephyr sys_heap" + bool "Override default allocator with memory allocator based on Zephyr sys_heap" default y help - Replace the default memory allocation functions, such as malloc, calloc, - realloc, free and their reentrant versions, with their counterparts based + Replaces the default memory allocation functions (such as malloc, calloc, + realloc, free, and their reentrant versions) with their counterparts based on sys_heap from Zephyr RTOS. config CHIP_MALLOC_SYS_HEAP_SIZE int "Heap size used by memory allocator based on Zephyr sys_heap" default 16384 # 16kB help - This value controls how much of the device RAM is reserved for the heap - used by the memory allocation functions based on sys_heap from Zephyr - RTOS. + Provides a value that controls how much of the device RAM is reserved for + the heap used by the memory allocation functions based on sys_heap from + Zephyr RTOS. endif @@ -387,28 +409,29 @@ source "${ZEPHYR_BASE}/subsys/logging/Kconfig.template.log_config" # Build system options config APP_LINK_WITH_CHIP - bool "Link 'app' with Connected Home over IP" + bool "Link application with Matter libraries" default y help - Add Connected Home over IP header files to the 'app' include path - and link the 'app' with Connected Home over IP libraries. + Adds Matter directories to the 'app' target include paths and links the + 'app' target with Matter libraries. config CHIP_PW_RPC - bool "Enable Pigweed RPC library" + bool "Pigweed RPC library" default n help - Link the application with the library containing Pigweed RPC functionalities. + Links the application with the libraries containing Pigweed RPC + functionalities. config CHIP_BUILD_TESTS - bool "Build CHIP unit tests" + bool "Build Matter unit tests" default n help - This option enables building CHIP unit tests. + Enables building Matter unit tests. config CHIP_OTA_IMAGE_BUILD bool "Generate OTA image" help - Enable building Matter OTA (Over-the-air update) image. + Enables building Matter over-the-air (OTA) update image. if CHIP_OTA_IMAGE_BUILD @@ -416,13 +439,13 @@ config CHIP_OTA_IMAGE_FILE_NAME string "OTA image file name" default "matter.ota" help - File name of the generated Matter OTA image. + Provides the file name of the generated Matter OTA image. config CHIP_OTA_IMAGE_EXTRA_ARGS string "OTA image creator extra arguments" help - This option allows one to pass optional arguments to the ota_image_tool.py - script, used for building OTA image. + Provides optional arguments to the ota_image_tool.py script, used for + building Matter OTA image. endif diff --git a/docs/VSCODE_DEVELOPMENT.md b/docs/VSCODE_DEVELOPMENT.md index 38cc9648f67c7f..5e7eeab92ee08c 100644 --- a/docs/VSCODE_DEVELOPMENT.md +++ b/docs/VSCODE_DEVELOPMENT.md @@ -29,9 +29,9 @@ Tested on: `git config --global core.autocrlf false` 1. Git clone the main Matter repository here: -1. Launch Visual Studio Code, and open the cloned folder from +1. Launch Visual Studio Code, and open the cloned folder from above 1. Install the - [Remote - Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) + [Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension for Visual Studio Code, this extension allows you to use docker containers as a development backend. 1. Once this is installed, you'll be prompted to reload Visual Studio Code, do diff --git a/docs/code_generation.md b/docs/code_generation.md index 57dc512a1f7055..0465d8795e116c 100644 --- a/docs/code_generation.md +++ b/docs/code_generation.md @@ -22,8 +22,8 @@ The selection of enabled clusters and files is done using [ZAP](https://github.com/project-chip/zap). You can download a recent release of zap from its [releases page](https://github.com/project-chip/zap/releases). It is recommended to download a release that is in sync with the currently in use -version by the SDK (see `integrations/docker/images/chip-build/Dockerfile` and -check the `ZAP_VERSION` setting). +version by the SDK (see `scripts/zap.json` and +`scripts/tools/zap/zap_execution.py` for the minimum supported version). Beyond basic zap file selection, there are also `.json` zap settings that define additional cluster info: source XML files, sdk-access methods and data types. @@ -36,9 +36,17 @@ There are only two such files currently in use: ### Installing zap and environment variables -Matter scripts may need to invoke `zap-cli` (for code generation) or `zap` (to -start the UI tool). For this, scrips need to know where to find the commands. In -the following order, the scripts process these environment variables: +ZAP is generally installed as a third-party tool via CIPD during the build +environment bootstrap (see `scripts/zap.json`), which makes `zap-cli` available +in `$PATH` when running in a build environment. + +**NOTE**: zap packages are currently NOT available for `arm64` (like when +compiling on Raspberry PI.). In these cases one should check out zap from source +and set `$ZAP_DEVELOPMENT_PATH` as described below. + +When matter scripts need to invoke `zap-cli` (for code generation) or `zap` (to +start the UI tool), they make use of the following environment variables to +figure out where the zap tool is located (in order of precedence): - if `$ZAP_DEVELOPMENT_PATH` is set, code assumes you are running zap from source. Use this if you develop zap. Zap has to be bootstrapped (generally @@ -48,7 +56,8 @@ the following order, the scripts process these environment variables: - if `$ZAP_INSTALL_PATH` is set, code assumes that `zap` or `zap-cli` is available in the given path. This is generally an unpacked release. -- otherwise, scripts will assume `zap`/`zap-cli` is in `$PATH` +- otherwise, scripts will assume `zap`/`zap-cli` is in `$PATH` (this is the + case when running in a bootstrapped environment) ### Using a UI to edit `.zap` files @@ -172,8 +181,24 @@ Additionally, individual code regeneration can be done using ```bash /scripts/tools/zap/generate.py \ - examples/bridge-app/bridge-common/bridge-app.zap \ - -o zzz_generated/bridge-app/zap-generated + examples/bridge-app/bridge-common/bridge-app.zap +``` + +The above will just generate a `.matter` file along side the `.zap` file, +as this is the only file that requires updates for applications. You can code +generate other things by passing in the `-t/--templates` argument to +generate.py. In those cases, you may also need to specify an output directory +via `-o/--output-dir`. + +#### Flow for updating an application zap file: + +``` +# use zap UI to edit the file (or edit zap file in any other way) +./scripts/tools/zap/run_zaptool.sh $PATH_TO_ZAP_FILE + +# re-generate .matter file. Note that for .matter file generation, output +# directory is NOT used +./scripts/tools/zap/generate.py $PATH_TO_ZAP_FILE ``` ### Compile-time code generation / pre-generated code @@ -286,3 +311,10 @@ replacement during running of `ninja check`. ```shell ZAP_GENERATE_GOLDEN_REGENERATE=1 ninja check ``` + +Alternatively, the golden image can also be re-generated by running the +stand-alone test in a bootstrapped environment: + +```shell +./scripts/tools/zap/test_generate.py --output out/gen --regenerate +``` diff --git a/docs/examples/openiotsdk_examples.md b/docs/examples/openiotsdk_examples.md index 36e12236c62172..6cdca9c5a8fdf1 100644 --- a/docs/examples/openiotsdk_examples.md +++ b/docs/examples/openiotsdk_examples.md @@ -140,6 +140,51 @@ Then add the GDB plugin to your development environment: arguments with `docker run` command. Remember add GDB plugin path to environment variable as FAST_MODEL_PLUGINS_PATH inside container. +## Configuration + +### Trusted Firmware-M + +To add [TF-M](https://tf-m-user-guide.trustedfirmware.org) support to Matter +example you need to set `TFM_SUPPORT` variable inside main application +`CMakeLists.txt` file. + +``` +set(TFM_SUPPORT YES) +``` + +This causes the Matter example to be built as non-secure application in +Non-secure Processing Environment (`NSPE`). The bootloader and the secure part +are also built from `TF-M` sources. All components are merged into a single +executable file at the end of the building process. + +You can also provide the own version of Matter example by setting +`TFM_NS_APP_VERSION` variable. + +``` +set(TFM_NS_APP_VERSION "0.0.1") +``` + +### Trusted Firmware-M Protected Storage + +There is an option to add +[TF-M Protected Storage Service](https://tf-m-user-guide.trustedfirmware.org/integration_guide/services/tfm_ps_integration_guide.html) +support for `key-value` storage component in Matter examples. You need to set +`CONFIG_CHIP_OPEN_IOT_SDK_USE_PSA_PS` variable inside main application +`CMakeLists.txt` fi + +``` +set(CONFIG_CHIP_OPEN_IOT_SDK_USE_PSA_PS YES) +``` + +This option causes `key-value` objects will be stored in a secure part of flash +memory and the Protected Storage Service takes care of their encryption and +authentication. + +**NOTE** + +The `TF-M Protected Storage` option requires enabling +[TF-M](#trusted-firmware-m) support. + ## Building You build using a vscode task or call the script directly from the command line. diff --git a/docs/guides/BUILDING.md b/docs/guides/BUILDING.md index ea0f235c04ec9f..fc6cac7de8f7a7 100644 --- a/docs/guides/BUILDING.md +++ b/docs/guides/BUILDING.md @@ -130,20 +130,9 @@ Finally, reboot your RPi. ## Installing ZAP -`zap-cli` is already installed in pre-built docker images for chip-build, such -as -[chip-build-vscode](https://hub.docker.com/r/connectedhomeip/chip-build-vscode). - -Zap generation and tooling relies on `zap-cli` being available on the current -system. You can install it from the zap project -[Releases](https://github.com/project-chip/zap/releases). - -You should install a compatible release version, generally checking against the -release set in -[integrations/docker/images/chip-build/Dockerfile](../../integrations/docker/images/chip-build/Dockerfile). - -On linux, installation from `zap-linux.zip` is recommended as it pulls fewer -dependencies than the `.deb` package. +`bootstrap.sh` will download a compatible zap version and set it up in `$PATH`. +If you want to install/use a different version, you may download one from the +zap project [Releases](https://github.com/project-chip/zap/releases) ### Which ZAP to use diff --git a/docs/guides/chip_tool_guide.md b/docs/guides/chip_tool_guide.md index 6ab37147b62099..220c850e90bb40 100644 --- a/docs/guides/chip_tool_guide.md +++ b/docs/guides/chip_tool_guide.md @@ -213,9 +213,10 @@ In this command: - __ is the user-defined ID of the node being commissioned. - __ is the Operational Dataset determined in the - step 3. + [step 4](#step-4-determine-network-pairing-credentials). - __ and __ are device-specific keys determined in - the step 4. + the + [step 5](#step-5-determine-matter-devices-discriminator-and-setup-pin-code). ##### Commissioning into Wi-Fi network over Bluetooth LE @@ -231,7 +232,8 @@ In this command: - __ is the user-defined ID of the node being commissioned. - __ and __ are credentials determined in the step 3. - __ and __ are device-specific keys determined in - the step 4. + the + [step 5](#step-5-determine-matter-devices-discriminator-and-setup-pin-code). If you prefer the hexadecimal format, use the `hex:` prefix. For example: @@ -263,7 +265,8 @@ $ ./chip-tool pairing onnetwork In this command: - __ is the user-defined ID of the node being commissioned. -- __ is device specific _setup PIN code_ determined in the step 4 +- __ is device specific _setup PIN code_ determined in the + [step 5](#step-5-determine-matter-devices-discriminator-and-setup-pin-code) and used to discover the device. ##### Commissioning with long discriminator @@ -279,7 +282,8 @@ In this command: - __ is the user-defined ID of the node being commissioned. - __ and __ are device specific keys determined in - the step 4. + the + [step 5](#step-5-determine-matter-devices-discriminator-and-setup-pin-code). ##### Commissioning with QR code payload or manual pairing code diff --git a/docs/guides/darwin.md b/docs/guides/darwin.md index 361eeebc18825c..131feaf7f3971d 100644 --- a/docs/guides/darwin.md +++ b/docs/guides/darwin.md @@ -15,7 +15,7 @@ Listed are the Current SHAs: - iOS/iPadOS/tvOS 16.1: [`33f6a910cd9a8a0cfdd7088e2f43efd2f7f566a7`](https://github.com/project-chip/connectedhomeip/commits/33f6a910cd9a8a0cfdd7088e2f43efd2f7f566a7) -- iOS/iPadOS/tvOS 16.2 Developer Preview: +- iOS/iPadOS/tvOS 16.2 and 16.3: [`c279578c5bc37f117335aa96cec6c5552f070cc0`](https://github.com/project-chip/connectedhomeip/commits/c279578c5bc37f117335aa96cec6c5552f070cc0) ## Supported Platforms for Matter Device Testing diff --git a/docs/guides/matter-repl.md b/docs/guides/matter-repl.md index bf05be63ddb9a5..5577881bca8f00 100644 --- a/docs/guides/matter-repl.md +++ b/docs/guides/matter-repl.md @@ -31,6 +31,35 @@ Please follow the instructions [here](./python_chip_controller_building.md#building-and-installing) to build the Python virtual environment. +### Building for `arm64` e.g. for Raspberry Pi + +Matter code relies on code generation for cluster-specific data types and +callbacks. A subset of code generation is done at compile time by `zap-cli`. ZAP +is generally installed as a third-party tool via CIPD during the build +environment bootstrap. However, zap packages are currently NOT available for +`arm64` (like when compiling on Raspberry PI.). In this case, you have 2 +choices. + +1. You could check out zap from source as described in + [Code Generation - Installing zap and environment variables](https://github.com/project-chip/connectedhomeip/blob/master/docs/code_generation.md#Installing-zap-and-environment-variables) + and proceed with the + [instructions](./python_chip_controller_building.md#building-and-installing) + to build the Python virtual environment. + +2. When compile-time code generation is not desirable, then pre-generated output + code can be used. To understand about code generation and pre-generating + matter code see. + [Code generation - Pre-generation](https://github.com/project-chip/connectedhomeip/blob/master/docs/code_generation.md#Pre-generation). + To build and install the Python CHIP controller with pre-generated files use + the -z argument that points to the directory of pre-generated code: + + ``` + scripts/build_python.sh -m platform -i separate -z "/some/pregen/dir" + ``` + + > Note: To get more details about available build configurations, run the + > following command: `scripts/build_python.sh --help` + ## Launching the REPL 1. Activate the Python virtual environment: @@ -154,13 +183,13 @@ launched into the playground: ## Guides -[REPL Basics](https://deepnote.com/viewer/github/project-chip/connectedhomeip/blob/master/docs/guides/repl/Matter%20-%20REPL%20Intro.ipynb) +[REPL Basics](https://deepnote.com/viewer/github/project-chip/connectedhomeip/blob/master/docs/guides/repl/Matter_REPL_Intro.ipynb) -[Using the IM](https://deepnote.com/viewer/github/project-chip/connectedhomeip/blob/master/docs/guides/repl/Matter%20-%20Basic%20Interactions.ipynb) +[Using the IM](https://deepnote.com/viewer/github/project-chip/connectedhomeip/blob/master/docs/guides/repl/Matter_Basic_Interactions.ipynb) -[Multi Fabric Commissioning](https://deepnote.com/viewer/github/project-chip/connectedhomeip/blob/master/docs/guides/repl/Matter%20-%20Multi%20Fabric%20Commissioning.ipynb) +[Multi Fabric Commissioning](https://deepnote.com/viewer/github/project-chip/connectedhomeip/blob/master/docs/guides/repl/Matter_Multi_Fabric_Commissioning.ipynb) -[Access Control](https://deepnote.com/viewer/github/project-chip/connectedhomeip/blob/master/docs/guides/repl/Matter%20-%20Access%20Control.ipynb) +[Access Control](https://deepnote.com/viewer/github/project-chip/connectedhomeip/blob/master/docs/guides/repl/Matter_Access_Control.ipynb) ## Testing diff --git a/docs/guides/openiotsdk_platform_overview.md b/docs/guides/openiotsdk_platform_overview.md index 2c4d04754dcc4a..211cd1af852179 100644 --- a/docs/guides/openiotsdk_platform_overview.md +++ b/docs/guides/openiotsdk_platform_overview.md @@ -93,3 +93,23 @@ This becomes the lower bound for timers. Drivers are provided by [Reference MCU-Driver-HAL driver implementation for Arm platforms](https://gitlab.arm.com/iot/open-iot-sdk/mcu-driver-hal/mcu-driver-reference-platforms-for-arm) which is provided by Open IoT SDK. + +## Trusted Firmware-M + +[Trusted Firmware-M](https://tf-m-user-guide.trustedfirmware.org) (`TF-M`) +implements the Secure Processing Environment (`SPE`) for `Armv8-M`, `Armv8.1-M` +architectures and dual-core platforms. It is the platform security architecture +reference implementation aligning with `PSA` Certified guidelines, enabling +chips, Real Time Operating Systems and devices to become `PSA` Certified. `TF-M` +relies on an isolation boundary between the Non-secure Processing Environment +(`NSPE`) and the Secure Processing Environment (`SPE`). + +`TF-M` consists of: + +- Secure Boot to authenticate `NSPE` and `SPE` images + +- `TF-M Core` for controlling the isolation, communication and execution + within `SPE` and with `NSPE` + +- Crypto, Internal Trusted Storage (`ITS`), Protected Storage (`PS`), Firmware + Update and Attestation secure services diff --git a/docs/guides/python_chip_controller_building.md b/docs/guides/python_chip_controller_building.md index 9bd6a4a095d612..7edbede54057ae 100644 --- a/docs/guides/python_chip_controller_building.md +++ b/docs/guides/python_chip_controller_building.md @@ -517,7 +517,7 @@ AudioOutput BarrierControl BasicInformation Binding -BridgedDeviceBasic +BridgedDeviceBasicInformation ColorControl ContentLaunch Descriptor diff --git a/docs/guides/repl/.ipynb_checkpoints/Matter - Basic Interactions-checkpoint.ipynb b/docs/guides/repl/.ipynb_checkpoints/Matter - Basic Interactions-checkpoint.ipynb index 48cac23fe3434b..12427060a4c542 100644 --- a/docs/guides/repl/.ipynb_checkpoints/Matter - Basic Interactions-checkpoint.ipynb +++ b/docs/guides/repl/.ipynb_checkpoints/Matter - Basic Interactions-checkpoint.ipynb @@ -1805,8 +1805,8 @@ "│ │ │ <class 'chip.clusters.Objects.NetworkCommissioning.Attributes.FeatureMap'>: 0,\n", "│ │ │ <class 'chip.clusters.Objects.NetworkCommissioning.Attributes.ClusterRevision'>: 1\n", "│ │ },\n", - "│ │ <class 'chip.clusters.Objects.BridgedDeviceBasic'>: {\n", - "│ │ │ <class 'chip.clusters.Objects.BridgedDeviceBasic.Attributes.ClusterRevision'>: 1\n", + "│ │ <class 'chip.clusters.Objects.BridgedDeviceBasicInformation'>: {\n", + "│ │ │ <class 'chip.clusters.Objects.BridgedDeviceBasicInformation.Attributes.ClusterRevision'>: 1\n", "│ │ },\n", "│ │ <class 'chip.clusters.Objects.Switch'>: {\n", "│ │ │ <class 'chip.clusters.Objects.Switch.Attributes.NumberOfPositions'>: 2,\n", @@ -2821,8 +2821,8 @@ "\u001b[2;32m│ │ │ \u001b[0m\u001b[1m<\u001b[0m\u001b[1;95mclass\u001b[0m\u001b[39m \u001b[0m\u001b[32m'chip.clusters.Objects.NetworkCommissioning.Attributes.FeatureMap'\u001b[0m\u001b[1m>\u001b[0m: \u001b[1;36m0\u001b[0m,\n", "\u001b[2;32m│ │ │ \u001b[0m\u001b[1m<\u001b[0m\u001b[1;95mclass\u001b[0m\u001b[39m \u001b[0m\u001b[32m'chip.clusters.Objects.NetworkCommissioning.Attributes.ClusterRevision'\u001b[0m\u001b[1m>\u001b[0m: \u001b[1;36m1\u001b[0m\n", "\u001b[2;32m│ │ \u001b[0m\u001b[1m}\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[1m<\u001b[0m\u001b[1;95mclass\u001b[0m\u001b[39m \u001b[0m\u001b[32m'chip.clusters.Objects.BridgedDeviceBasic'\u001b[0m\u001b[1m>\u001b[0m: \u001b[1m{\u001b[0m\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[1m<\u001b[0m\u001b[1;95mclass\u001b[0m\u001b[39m \u001b[0m\u001b[32m'chip.clusters.Objects.BridgedDeviceBasic.Attributes.ClusterRevision'\u001b[0m\u001b[1m>\u001b[0m: \u001b[1;36m1\u001b[0m\n", + "\u001b[2;32m│ │ \u001b[0m\u001b[1m<\u001b[0m\u001b[1;95mclass\u001b[0m\u001b[39m \u001b[0m\u001b[32m'chip.clusters.Objects.BridgedDeviceBasicInformation'\u001b[0m\u001b[1m>\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[1m<\u001b[0m\u001b[1;95mclass\u001b[0m\u001b[39m \u001b[0m\u001b[32m'chip.clusters.Objects.BridgedDeviceBasicInformation.Attributes.ClusterRevision'\u001b[0m\u001b[1m>\u001b[0m: \u001b[1;36m1\u001b[0m\n", "\u001b[2;32m│ │ \u001b[0m\u001b[1m}\u001b[0m,\n", "\u001b[2;32m│ │ \u001b[0m\u001b[1m<\u001b[0m\u001b[1;95mclass\u001b[0m\u001b[39m \u001b[0m\u001b[32m'chip.clusters.Objects.Switch'\u001b[0m\u001b[1m>\u001b[0m: \u001b[1m{\u001b[0m\n", "\u001b[2;32m│ │ │ \u001b[0m\u001b[1m<\u001b[0m\u001b[1;95mclass\u001b[0m\u001b[39m \u001b[0m\u001b[32m'chip.clusters.Objects.Switch.Attributes.NumberOfPositions'\u001b[0m\u001b[1m>\u001b[0m: \u001b[1;36m2\u001b[0m,\n", diff --git a/docs/guides/repl/Matter_Basic_Interactions.ipynb b/docs/guides/repl/Matter_Basic_Interactions.ipynb index 12d9224ef48613..f1ca29e36cc6ac 100644 --- a/docs/guides/repl/Matter_Basic_Interactions.ipynb +++ b/docs/guides/repl/Matter_Basic_Interactions.ipynb @@ -1798,8 +1798,8 @@ "│ │ │ <class 'chip.clusters.Objects.NetworkCommissioning.Attributes.FeatureMap'>: 0,\n", "│ │ │ <class 'chip.clusters.Objects.NetworkCommissioning.Attributes.ClusterRevision'>: 1\n", "│ │ },\n", - "│ │ <class 'chip.clusters.Objects.BridgedDeviceBasic'>: {\n", - "│ │ │ <class 'chip.clusters.Objects.BridgedDeviceBasic.Attributes.ClusterRevision'>: 1\n", + "│ │ <class 'chip.clusters.Objects.BridgedDeviceBasicInformation'>: {\n", + "│ │ │ <class 'chip.clusters.Objects.BridgedDeviceBasicInformation.Attributes.ClusterRevision'>: 1\n", "│ │ },\n", "│ │ <class 'chip.clusters.Objects.Switch'>: {\n", "│ │ │ <class 'chip.clusters.Objects.Switch.Attributes.NumberOfPositions'>: 2,\n", @@ -2814,8 +2814,8 @@ "\u001b[2;32m│ │ │ \u001b[0m\u001b[1m<\u001b[0m\u001b[1;95mclass\u001b[0m\u001b[39m \u001b[0m\u001b[32m'chip.clusters.Objects.NetworkCommissioning.Attributes.FeatureMap'\u001b[0m\u001b[1m>\u001b[0m: \u001b[1;36m0\u001b[0m,\n", "\u001b[2;32m│ │ │ \u001b[0m\u001b[1m<\u001b[0m\u001b[1;95mclass\u001b[0m\u001b[39m \u001b[0m\u001b[32m'chip.clusters.Objects.NetworkCommissioning.Attributes.ClusterRevision'\u001b[0m\u001b[1m>\u001b[0m: \u001b[1;36m1\u001b[0m\n", "\u001b[2;32m│ │ \u001b[0m\u001b[1m}\u001b[0m,\n", - "\u001b[2;32m│ │ \u001b[0m\u001b[1m<\u001b[0m\u001b[1;95mclass\u001b[0m\u001b[39m \u001b[0m\u001b[32m'chip.clusters.Objects.BridgedDeviceBasic'\u001b[0m\u001b[1m>\u001b[0m: \u001b[1m{\u001b[0m\n", - "\u001b[2;32m│ │ │ \u001b[0m\u001b[1m<\u001b[0m\u001b[1;95mclass\u001b[0m\u001b[39m \u001b[0m\u001b[32m'chip.clusters.Objects.BridgedDeviceBasic.Attributes.ClusterRevision'\u001b[0m\u001b[1m>\u001b[0m: \u001b[1;36m1\u001b[0m\n", + "\u001b[2;32m│ │ \u001b[0m\u001b[1m<\u001b[0m\u001b[1;95mclass\u001b[0m\u001b[39m \u001b[0m\u001b[32m'chip.clusters.Objects.BridgedDeviceBasicInformation'\u001b[0m\u001b[1m>\u001b[0m: \u001b[1m{\u001b[0m\n", + "\u001b[2;32m│ │ │ \u001b[0m\u001b[1m<\u001b[0m\u001b[1;95mclass\u001b[0m\u001b[39m \u001b[0m\u001b[32m'chip.clusters.Objects.BridgedDeviceBasicInformation.Attributes.ClusterRevision'\u001b[0m\u001b[1m>\u001b[0m: \u001b[1;36m1\u001b[0m\n", "\u001b[2;32m│ │ \u001b[0m\u001b[1m}\u001b[0m,\n", "\u001b[2;32m│ │ \u001b[0m\u001b[1m<\u001b[0m\u001b[1;95mclass\u001b[0m\u001b[39m \u001b[0m\u001b[32m'chip.clusters.Objects.Switch'\u001b[0m\u001b[1m>\u001b[0m: \u001b[1m{\u001b[0m\n", "\u001b[2;32m│ │ │ \u001b[0m\u001b[1m<\u001b[0m\u001b[1;95mclass\u001b[0m\u001b[39m \u001b[0m\u001b[32m'chip.clusters.Objects.Switch.Attributes.NumberOfPositions'\u001b[0m\u001b[1m>\u001b[0m: \u001b[1;36m2\u001b[0m,\n", diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter index 453c4a425aaca8..9ab98620f6513e 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter @@ -108,17 +108,21 @@ server cluster Groups = 4 { } server cluster Scenes = 5 { + bitmap SceneFeatures : BITMAP32 { + kSceneNames = 0x1; + } + bitmap ScenesCopyMode : BITMAP8 { kCopyAllScenes = 0x1; } struct ExtensionFieldSet { - cluster_id clusterId = 0; + cluster_id clusterID = 0; AttributeValuePair attributeValueList[] = 1; } struct AttributeValuePair { - optional attrib_id attributeId = 0; + optional attrib_id attributeID = 0; int8u attributeValue[] = 1; } @@ -131,52 +135,52 @@ server cluster Scenes = 5 { readonly attribute int16u clusterRevision = 65533; request struct AddSceneRequest { - group_id groupId = 0; - INT8U sceneId = 1; + group_id groupID = 0; + INT8U sceneID = 1; INT16U transitionTime = 2; CHAR_STRING sceneName = 3; ExtensionFieldSet extensionFieldSets[] = 4; } request struct ViewSceneRequest { - group_id groupId = 0; - INT8U sceneId = 1; + group_id groupID = 0; + INT8U sceneID = 1; } request struct RemoveSceneRequest { - group_id groupId = 0; - INT8U sceneId = 1; + group_id groupID = 0; + INT8U sceneID = 1; } request struct RemoveAllScenesRequest { - group_id groupId = 0; + group_id groupID = 0; } request struct StoreSceneRequest { - group_id groupId = 0; - INT8U sceneId = 1; + group_id groupID = 0; + INT8U sceneID = 1; } request struct RecallSceneRequest { - group_id groupId = 0; - INT8U sceneId = 1; + group_id groupID = 0; + INT8U sceneID = 1; optional nullable INT16U transitionTime = 2; } request struct GetSceneMembershipRequest { - group_id groupId = 0; + group_id groupID = 0; } response struct AddSceneResponse = 0 { ENUM8 status = 0; - group_id groupId = 1; - INT8U sceneId = 2; + group_id groupID = 1; + INT8U sceneID = 2; } response struct ViewSceneResponse = 1 { ENUM8 status = 0; - group_id groupId = 1; - INT8U sceneId = 2; + group_id groupID = 1; + INT8U sceneID = 2; optional INT16U transitionTime = 3; optional CHAR_STRING sceneName = 4; optional ExtensionFieldSet extensionFieldSets[] = 5; @@ -184,25 +188,25 @@ server cluster Scenes = 5 { response struct RemoveSceneResponse = 2 { ENUM8 status = 0; - group_id groupId = 1; - INT8U sceneId = 2; + group_id groupID = 1; + INT8U sceneID = 2; } response struct RemoveAllScenesResponse = 3 { ENUM8 status = 0; - group_id groupId = 1; + group_id groupID = 1; } response struct StoreSceneResponse = 4 { ENUM8 status = 0; - group_id groupId = 1; - INT8U sceneId = 2; + group_id groupID = 1; + INT8U sceneID = 2; } response struct GetSceneMembershipResponse = 6 { ENUM8 status = 0; nullable INT8U capacity = 1; - group_id groupId = 2; + group_id groupID = 2; optional INT8U sceneList[] = 3; } @@ -215,7 +219,7 @@ server cluster Scenes = 5 { fabric command GetSceneMembership(GetSceneMembershipRequest): GetSceneMembershipResponse = 6; } -server cluster OnOff = 6 { +client cluster OnOff = 6 { enum OnOffDelayedAllOffEffectVariant : ENUM8 { kFadeToOffIn0p8Seconds = 0; kNoFade = 1; @@ -245,8 +249,47 @@ server cluster OnOff = 6 { kLighting = 0x1; } - bitmap SceneFeatures : BITMAP32 { - kSceneNames = 0x1; + readonly attribute boolean onOff = 0; + readonly attribute boolean globalSceneControl = 16384; + attribute int16u onTime = 16385; + attribute int16u offWaitTime = 16386; + attribute access(write: manage) nullable OnOffStartUpOnOff startUpOnOff = 16387; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + command Off(): DefaultSuccess = 0; + command On(): DefaultSuccess = 1; + command Toggle(): DefaultSuccess = 2; +} + +server cluster OnOff = 6 { + enum OnOffDelayedAllOffEffectVariant : ENUM8 { + kFadeToOffIn0p8Seconds = 0; + kNoFade = 1; + k50PercentDimDownIn0p8SecondsThenFadeToOffIn12Seconds = 2; + } + + enum OnOffDyingLightEffectVariant : ENUM8 { + k20PercenterDimUpIn0p5SecondsThenFadeToOffIn1Second = 0; + } + + enum OnOffEffectIdentifier : ENUM8 { + kDelayedAllOff = 0; + kDyingLight = 1; + } + + enum OnOffStartUpOnOff : ENUM8 { + kOff = 0; + kOn = 1; + kTogglePreviousOnOff = 2; + } + + bitmap OnOffControl : BITMAP8 { + kAcceptOnlyWhenOn = 0x1; + } + + bitmap OnOffFeature : BITMAP32 { + kLighting = 0x1; } readonly attribute boolean onOff = 0; @@ -798,7 +841,7 @@ server cluster PowerSourceConfiguration = 46 { server cluster PowerSource = 47 { enum BatChargeFault : ENUM8 { - kUnspecfied = 0; + kUnspecified = 0; kAmbientTooHot = 1; kAmbientTooCold = 2; kBatteryTooHot = 3; @@ -838,7 +881,7 @@ server cluster PowerSource = 47 { } enum PowerSourceStatus : ENUM8 { - kUnspecfied = 0; + kUnspecified = 0; kActive = 1; kStandby = 2; kUnavailable = 3; @@ -1123,7 +1166,7 @@ server cluster GeneralDiagnostics = 51 { kSoftwareReset = 6; } - enum HardwareFault : ENUM8 { + enum HardwareFaultEnum : ENUM8 { kUnspecified = 0; kRadio = 1; kSensor = 2; @@ -1137,7 +1180,7 @@ server cluster GeneralDiagnostics = 51 { kTamperDetected = 10; } - enum InterfaceType : ENUM8 { + enum InterfaceTypeEnum : ENUM8 { kUnspecified = 0; kWiFi = 1; kEthernet = 2; @@ -1145,14 +1188,14 @@ server cluster GeneralDiagnostics = 51 { kThread = 4; } - enum NetworkFaultType : ENUM8 { + enum NetworkFaultEnum : ENUM8 { kUnspecified = 0; kHardwareFailure = 1; kNetworkJammed = 2; kConnectionFailed = 3; } - enum RadioFault : ENUM8 { + enum RadioFaultEnum : ENUM8 { kUnspecified = 0; kWiFiFault = 1; kCellularFault = 2; @@ -1170,22 +1213,22 @@ server cluster GeneralDiagnostics = 51 { octet_string<8> hardwareAddress = 4; octet_string IPv4Addresses[] = 5; octet_string IPv6Addresses[] = 6; - InterfaceType type = 7; + InterfaceTypeEnum type = 7; } critical event HardwareFaultChange = 0 { - HardwareFault current[] = 0; - HardwareFault previous[] = 1; + HardwareFaultEnum current[] = 0; + HardwareFaultEnum previous[] = 1; } critical event RadioFaultChange = 1 { - RadioFault current[] = 0; - RadioFault previous[] = 1; + RadioFaultEnum current[] = 0; + RadioFaultEnum previous[] = 1; } critical event NetworkFaultChange = 2 { - NetworkFaultType current[] = 0; - NetworkFaultType previous[] = 1; + NetworkFaultEnum current[] = 0; + NetworkFaultEnum previous[] = 1; } critical event BootReason = 3 { @@ -1197,9 +1240,9 @@ server cluster GeneralDiagnostics = 51 { readonly attribute int64u upTime = 2; readonly attribute int32u totalOperationalHours = 3; readonly attribute BootReasonEnum bootReason = 4; - readonly attribute HardwareFault activeHardwareFaults[] = 5; - readonly attribute RadioFault activeRadioFaults[] = 6; - readonly attribute NetworkFaultType activeNetworkFaults[] = 7; + readonly attribute HardwareFaultEnum activeHardwareFaults[] = 5; + readonly attribute RadioFaultEnum activeRadioFaults[] = 6; + readonly attribute NetworkFaultEnum activeNetworkFaults[] = 7; readonly attribute boolean testEventTriggersEnabled = 8; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; @@ -1433,6 +1476,11 @@ server cluster WiFiNetworkDiagnostics = 54 { kAx = 5; } + bitmap WiFiNetworkDiagnosticsFeature : BITMAP32 { + kPacketCounts = 0x1; + kErrorCounts = 0x2; + } + info event Disconnection = 0 { INT16U reasonCode = 0; } @@ -1466,7 +1514,7 @@ server cluster WiFiNetworkDiagnostics = 54 { } server cluster EthernetNetworkDiagnostics = 55 { - enum PHYRate : ENUM8 { + enum PHYRateEnum : ENUM8 { kRate10M = 0; kRate100M = 1; kRate1G = 2; @@ -1479,7 +1527,12 @@ server cluster EthernetNetworkDiagnostics = 55 { kRate400G = 9; } - readonly attribute nullable PHYRate PHYRate = 0; + bitmap EthernetNetworkDiagnosticsFeature : BITMAP32 { + kPacketCounts = 0x1; + kErrorCounts = 0x2; + } + + readonly attribute nullable PHYRateEnum PHYRate = 0; readonly attribute nullable boolean fullDuplex = 1; readonly attribute int64u packetRxCount = 2; readonly attribute int64u packetTxCount = 3; @@ -1541,7 +1594,7 @@ server cluster Switch = 59 { } server cluster AdministratorCommissioning = 60 { - enum CommissioningWindowStatus : ENUM8 { + enum CommissioningWindowStatusEnum : ENUM8 { kWindowNotOpen = 0; kEnhancedWindowOpen = 1; kBasicWindowOpen = 2; @@ -1553,7 +1606,7 @@ server cluster AdministratorCommissioning = 60 { kWindowNotOpen = 4; } - readonly attribute CommissioningWindowStatus windowStatus = 0; + readonly attribute CommissioningWindowStatusEnum windowStatus = 0; readonly attribute nullable fabric_idx adminFabricIndex = 1; readonly attribute nullable int16u adminVendorId = 2; readonly attribute bitmap32 featureMap = 65532; @@ -1577,8 +1630,13 @@ server cluster AdministratorCommissioning = 60 { } server cluster OperationalCredentials = 62 { - enum OperationalCertStatus : ENUM8 { - kSuccess = 0; + enum CertificateChainTypeEnum : ENUM8 { + kDACCertificate = 1; + kPAICertificate = 2; + } + + enum NodeOperationalCertStatusEnum : ENUM8 { + kOk = 0; kInvalidPublicKey = 1; kInvalidNodeOpId = 2; kInvalidNOC = 3; @@ -1596,17 +1654,17 @@ server cluster OperationalCredentials = 62 { fabric_idx fabricIndex = 254; } - fabric_scoped struct FabricDescriptor { + fabric_scoped struct FabricDescriptorStruct { octet_string<65> rootPublicKey = 1; - vendor_id vendorId = 2; - fabric_id fabricId = 3; - node_id nodeId = 4; + vendor_id vendorID = 2; + fabric_id fabricID = 3; + node_id nodeID = 4; char_string<32> label = 5; fabric_idx fabricIndex = 254; } readonly attribute access(read: administer) NOCStruct NOCs[] = 0; - readonly attribute FabricDescriptor fabrics[] = 1; + readonly attribute FabricDescriptorStruct fabrics[] = 1; readonly attribute int8u supportedFabrics = 2; readonly attribute int8u commissionedFabrics = 3; readonly attribute OCTET_STRING trustedRootCertificates[] = 4; @@ -1619,7 +1677,7 @@ server cluster OperationalCredentials = 62 { } request struct CertificateChainRequestRequest { - INT8U certificateType = 0; + CertificateChainTypeEnum certificateType = 0; } request struct CSRRequestRequest { @@ -1649,12 +1707,12 @@ server cluster OperationalCredentials = 62 { } request struct AddTrustedRootCertificateRequest { - OCTET_STRING rootCertificate = 0; + OCTET_STRING rootCACertificate = 0; } response struct AttestationResponse = 1 { OCTET_STRING attestationElements = 0; - OCTET_STRING signature = 1; + OCTET_STRING attestationSignature = 1; } response struct CertificateChainResponse = 3 { @@ -1667,7 +1725,7 @@ server cluster OperationalCredentials = 62 { } response struct NOCResponse = 8 { - OperationalCertStatus statusCode = 0; + NodeOperationalCertStatusEnum statusCode = 0; optional fabric_idx fabricIndex = 1; optional CHAR_STRING debugText = 2; } @@ -1808,7 +1866,7 @@ server cluster ModeSelect = 80 { } server cluster DoorLock = 257 { - enum DlAlarmCode : ENUM8 { + enum AlarmCodeEnum : ENUM8 { kLockJammed = 0; kLockFactoryReset = 1; kLockRadioPowerCycled = 3; @@ -1819,13 +1877,13 @@ server cluster DoorLock = 257 { kForcedUser = 8; } - enum DlCredentialRule : ENUM8 { + enum CredentialRuleEnum : ENUM8 { kSingle = 0; - kDouble = 1; + kDual = 1; kTri = 2; } - enum DlCredentialType : ENUM8 { + enum CredentialTypeEnum : ENUM8 { kProgrammingPIN = 0; kPin = 1; kRfid = 2; @@ -1834,40 +1892,12 @@ server cluster DoorLock = 257 { kFace = 5; } - enum DlDataOperationType : ENUM8 { + enum DataOperationTypeEnum : ENUM8 { kAdd = 0; kClear = 1; kModify = 2; } - enum DlDoorState : ENUM8 { - kDoorOpen = 0; - kDoorClosed = 1; - kDoorJammed = 2; - kDoorForcedOpen = 3; - kDoorUnspecifiedError = 4; - kDoorAjar = 5; - } - - enum DlLockDataType : ENUM8 { - kUnspecified = 0; - kProgrammingCode = 1; - kUserIndex = 2; - kWeekDaySchedule = 3; - kYearDaySchedule = 4; - kHolidaySchedule = 5; - kPin = 6; - kRfid = 7; - kFingerprint = 8; - } - - enum DlLockOperationType : ENUM8 { - kLock = 0; - kUnlock = 1; - kNonAccessUserEvent = 2; - kForcedUserEvent = 3; - } - enum DlLockState : ENUM8 { kNotFullyLocked = 0; kLocked = 1; @@ -1888,35 +1918,6 @@ server cluster DoorLock = 257 { kDoorFurniture = 10; } - enum DlOperatingMode : ENUM8 { - kNormal = 0; - kVacation = 1; - kPrivacy = 2; - kNoRemoteLockUnlock = 3; - kPassage = 4; - } - - enum DlOperationError : ENUM8 { - kUnspecified = 0; - kInvalidCredential = 1; - kDisabledUserDenied = 2; - kRestricted = 3; - kInsufficientBattery = 4; - } - - enum DlOperationSource : ENUM8 { - kUnspecified = 0; - kManual = 1; - kProprietaryRemote = 2; - kKeypad = 3; - kAuto = 4; - kButton = 5; - kSchedule = 6; - kRemote = 7; - kRfid = 8; - kBiometric = 9; - } - enum DlStatus : ENUM8 { kSuccess = 0; kFailure = 1; @@ -1927,25 +1928,6 @@ server cluster DoorLock = 257 { kNotFound = 139; } - enum DlUserStatus : ENUM8 { - kAvailable = 0; - kOccupiedEnabled = 1; - kOccupiedDisabled = 3; - } - - enum DlUserType : ENUM8 { - kUnrestrictedUser = 0; - kYearDayScheduleUser = 1; - kWeekDayScheduleUser = 2; - kProgrammingUser = 3; - kNonAccessUser = 4; - kForcedUser = 5; - kDisposableUser = 6; - kExpiringUser = 7; - kScheduleRestrictedUser = 8; - kRemoteOnlyUser = 9; - } - enum DoorLockOperationEventCode : ENUM8 { kUnknownOrMfgSpecific = 0; kLock = 1; @@ -1997,19 +1979,83 @@ server cluster DoorLock = 257 { kNotSupported = 255; } - bitmap DlCredentialRuleMask : BITMAP8 { - kSingle = 0x1; - kDual = 0x2; - kTri = 0x4; + enum DoorStateEnum : ENUM8 { + kDoorOpen = 0; + kDoorClosed = 1; + kDoorJammed = 2; + kDoorForcedOpen = 3; + kDoorUnspecifiedError = 4; + kDoorAjar = 5; } - bitmap DlCredentialRulesSupport : BITMAP8 { - kSingle = 0x1; - kDual = 0x2; - kTri = 0x4; + enum LockDataTypeEnum : ENUM8 { + kUnspecified = 0; + kProgrammingCode = 1; + kUserIndex = 2; + kWeekDaySchedule = 3; + kYearDaySchedule = 4; + kHolidaySchedule = 5; + kPin = 6; + kRfid = 7; + kFingerprint = 8; + } + + enum LockOperationTypeEnum : ENUM8 { + kLock = 0; + kUnlock = 1; + kNonAccessUserEvent = 2; + kForcedUserEvent = 3; + } + + enum OperatingModeEnum : ENUM8 { + kNormal = 0; + kVacation = 1; + kPrivacy = 2; + kNoRemoteLockUnlock = 3; + kPassage = 4; + } + + enum OperationErrorEnum : ENUM8 { + kUnspecified = 0; + kInvalidCredential = 1; + kDisabledUserDenied = 2; + kRestricted = 3; + kInsufficientBattery = 4; + } + + enum OperationSourceEnum : ENUM8 { + kUnspecified = 0; + kManual = 1; + kProprietaryRemote = 2; + kKeypad = 3; + kAuto = 4; + kButton = 5; + kSchedule = 6; + kRemote = 7; + kRfid = 8; + kBiometric = 9; + } + + enum UserStatusEnum : ENUM8 { + kAvailable = 0; + kOccupiedEnabled = 1; + kOccupiedDisabled = 3; + } + + enum UserTypeEnum : ENUM8 { + kUnrestrictedUser = 0; + kYearDayScheduleUser = 1; + kWeekDayScheduleUser = 2; + kProgrammingUser = 3; + kNonAccessUser = 4; + kForcedUser = 5; + kDisposableUser = 6; + kExpiringUser = 7; + kScheduleRestrictedUser = 8; + kRemoteOnlyUser = 9; } - bitmap DlDaysMaskMap : BITMAP8 { + bitmap DaysMaskMap : BITMAP8 { kSunday = 0x1; kMonday = 0x2; kTuesday = 0x4; @@ -2019,6 +2065,18 @@ server cluster DoorLock = 257 { kSaturday = 0x40; } + bitmap DlCredentialRuleMask : BITMAP8 { + kSingle = 0x1; + kDual = 0x2; + kTri = 0x4; + } + + bitmap DlCredentialRulesSupport : BITMAP8 { + kSingle = 0x1; + kDual = 0x2; + kTri = 0x4; + } + bitmap DlDefaultConfigurationRegister : BITMAP16 { kEnableLocalProgrammingEnabled = 0x1; kKeypadInterfaceDefaultAccessEnabled = 0x2; @@ -2123,56 +2181,56 @@ server cluster DoorLock = 257 { } bitmap DoorLockFeature : BITMAP32 { - kPINCredentials = 0x1; - kRFIDCredentials = 0x2; + kPinCredential = 0x1; + kRfidCredential = 0x2; kFingerCredentials = 0x4; kLogging = 0x8; - kWeekDaySchedules = 0x10; + kWeekDayAccessSchedules = 0x10; kDoorPositionSensor = 0x20; kFaceCredentials = 0x40; - kCredentialsOTA = 0x80; - kUsersManagement = 0x100; - kNotifications = 0x200; - kYearDaySchedules = 0x400; + kCredentialsOverTheAirAccess = 0x80; + kUser = 0x100; + kNotification = 0x200; + kYearDayAccessSchedules = 0x400; kHolidaySchedules = 0x800; } - struct DlCredential { - DlCredentialType credentialType = 0; + struct CredentialStruct { + CredentialTypeEnum credentialType = 0; int16u credentialIndex = 1; } critical event DoorLockAlarm = 0 { - DlAlarmCode alarmCode = 0; + AlarmCodeEnum alarmCode = 0; } critical event DoorStateChange = 1 { - DlDoorState doorState = 0; + DoorStateEnum doorState = 0; } critical event LockOperation = 2 { - DlLockOperationType lockOperationType = 0; - DlOperationSource operationSource = 1; + LockOperationTypeEnum lockOperationType = 0; + OperationSourceEnum operationSource = 1; nullable INT16U userIndex = 2; nullable fabric_idx fabricIndex = 3; nullable NODE_ID sourceNode = 4; - optional nullable DlCredential credentials[] = 5; + optional nullable CredentialStruct credentials[] = 5; } critical event LockOperationError = 3 { - DlLockOperationType lockOperationType = 0; - DlOperationSource operationSource = 1; - DlOperationError operationError = 2; + LockOperationTypeEnum lockOperationType = 0; + OperationSourceEnum operationSource = 1; + OperationErrorEnum operationError = 2; nullable INT16U userIndex = 3; nullable fabric_idx fabricIndex = 4; nullable NODE_ID sourceNode = 5; - optional nullable DlCredential credentials[] = 6; + optional nullable CredentialStruct credentials[] = 6; } info event LockUserChange = 4 { - DlLockDataType lockDataType = 0; - DlDataOperationType dataOperationType = 1; - DlOperationSource operationSource = 2; + LockDataTypeEnum lockDataType = 0; + DataOperationTypeEnum dataOperationType = 1; + OperationSourceEnum operationSource = 2; nullable INT16U userIndex = 3; nullable fabric_idx fabricIndex = 4; nullable NODE_ID sourceNode = 5; @@ -2182,7 +2240,7 @@ server cluster DoorLock = 257 { readonly attribute nullable DlLockState lockState = 0; readonly attribute DlLockType lockType = 1; readonly attribute boolean actuatorEnabled = 2; - readonly attribute nullable DlDoorState doorState = 3; + readonly attribute nullable DoorStateEnum doorState = 3; attribute access(write: manage) int32u doorOpenEvents = 4; attribute access(write: manage) int32u doorClosedEvents = 5; attribute access(write: manage) int16u openPeriod = 6; @@ -2201,7 +2259,7 @@ server cluster DoorLock = 257 { attribute access(write: manage) char_string<3> language = 33; attribute access(write: manage) int32u autoRelockTime = 35; attribute access(write: manage) int8u soundVolume = 36; - attribute access(write: manage) DlOperatingMode operatingMode = 37; + attribute access(write: manage) OperatingModeEnum operatingMode = 37; readonly attribute DlSupportedOperatingModes supportedOperatingModes = 38; readonly attribute DlDefaultConfigurationRegister defaultConfigurationRegister = 39; attribute access(write: manage) boolean enableOneTouchLocking = 41; @@ -2214,22 +2272,22 @@ server cluster DoorLock = 257 { readonly attribute int16u clusterRevision = 65533; request struct LockDoorRequest { - optional OCTET_STRING pinCode = 0; + optional OCTET_STRING PINCode = 0; } request struct UnlockDoorRequest { - optional OCTET_STRING pinCode = 0; + optional OCTET_STRING PINCode = 0; } request struct UnlockWithTimeoutRequest { INT16U timeout = 0; - optional OCTET_STRING pinCode = 1; + optional OCTET_STRING PINCode = 1; } request struct SetWeekDayScheduleRequest { INT8U weekDayIndex = 0; INT16U userIndex = 1; - DlDaysMaskMap daysMask = 2; + DaysMaskMap daysMask = 2; INT8U startHour = 3; INT8U startMinute = 4; INT8U endHour = 5; @@ -2259,13 +2317,13 @@ server cluster DoorLock = 257 { } request struct SetUserRequest { - DlDataOperationType operationType = 0; + DataOperationTypeEnum operationType = 0; INT16U userIndex = 1; nullable CHAR_STRING userName = 2; - nullable INT32U userUniqueId = 3; - nullable DlUserStatus userStatus = 4; - nullable DlUserType userType = 5; - nullable DlCredentialRule credentialRule = 6; + nullable INT32U userUniqueID = 3; + nullable UserStatusEnum userStatus = 4; + nullable UserTypeEnum userType = 5; + nullable CredentialRuleEnum credentialRule = 6; } request struct GetUserRequest { @@ -2277,30 +2335,30 @@ server cluster DoorLock = 257 { } request struct SetCredentialRequest { - DlDataOperationType operationType = 0; - DlCredential credential = 1; + DataOperationTypeEnum operationType = 0; + CredentialStruct credential = 1; LONG_OCTET_STRING credentialData = 2; nullable INT16U userIndex = 3; - nullable DlUserStatus userStatus = 4; - nullable DlUserType userType = 5; + nullable UserStatusEnum userStatus = 4; + nullable UserTypeEnum userType = 5; } request struct GetCredentialStatusRequest { - DlCredential credential = 0; + CredentialStruct credential = 0; } request struct ClearCredentialRequest { - nullable DlCredential credential = 0; + nullable CredentialStruct credential = 0; } response struct GetUserResponse = 28 { INT16U userIndex = 0; nullable CHAR_STRING userName = 1; - nullable INT32U userUniqueId = 2; - nullable DlUserStatus userStatus = 3; - nullable DlUserType userType = 4; - nullable DlCredentialRule credentialRule = 5; - nullable DlCredential credentials[] = 6; + nullable INT32U userUniqueID = 2; + nullable UserStatusEnum userStatus = 3; + nullable UserTypeEnum userType = 4; + nullable CredentialRuleEnum credentialRule = 5; + nullable CredentialStruct credentials[] = 6; nullable fabric_idx creatorFabricIndex = 7; nullable fabric_idx lastModifiedFabricIndex = 8; nullable INT16U nextUserIndex = 9; @@ -2511,6 +2569,16 @@ server cluster PumpConfigurationAndControl = 512 { kLocal = 3; } + bitmap PumpFeature : BITMAP32 { + kConstantPressure = 0x1; + kCompensatedPressure = 0x2; + kConstantFlow = 0x4; + kConstantSpeed = 0x8; + kConstantTemperature = 0x10; + kAutomatic = 0x20; + kLocal = 0x40; + } + bitmap PumpStatus : BITMAP16 { kDeviceFault = 0x1; kSupplyfault = 0x2; @@ -2603,9 +2671,9 @@ server cluster PumpConfigurationAndControl = 512 { server cluster Thermostat = 513 { enum SetpointAdjustMode : ENUM8 { - kHeatSetpoint = 0; - kCoolSetpoint = 1; - kHeatAndCoolSetpoints = 2; + kHeat = 0; + kCool = 1; + kBoth = 2; } enum ThermostatControlSequence : ENUM8 { @@ -2628,9 +2696,11 @@ server cluster Thermostat = 513 { kAuto = 1; kCool = 3; kHeat = 4; - kEmergencyHeating = 5; + kEmergencyHeat = 5; kPrecooling = 6; kFanOnly = 7; + kDry = 8; + kSleep = 9; } bitmap DayOfWeek : BITMAP8 { @@ -2641,21 +2711,21 @@ server cluster Thermostat = 513 { kThursday = 0x10; kFriday = 0x20; kSaturday = 0x40; - kAwayOrVacation = 0x80; + kAway = 0x80; } bitmap ModeForSequence : BITMAP8 { - kHeatSetpointFieldPresent = 0x1; - kCoolSetpointFieldPresent = 0x2; + kHeatSetpointPresent = 0x1; + kCoolSetpointPresent = 0x2; } bitmap ThermostatFeature : BITMAP32 { kHeating = 0x1; kCooling = 0x2; kOccupancy = 0x4; - kSchedule = 0x8; + kScheduleConfiguration = 0x8; kSetback = 0x10; - kAutomode = 0x20; + kAutoMode = 0x20; } struct ThermostatScheduleTransition { @@ -2960,7 +3030,7 @@ server cluster ColorControl = 768 { } request struct MoveToColorTemperatureRequest { - INT16U colorTemperature = 0; + INT16U colorTemperatureMireds = 0; INT16U transitionTime = 1; BITMAP8 optionsMask = 2; BITMAP8 optionsOverride = 3; @@ -3052,6 +3122,28 @@ server cluster ColorControl = 768 { command StepColorTemperature(StepColorTemperatureRequest): DefaultSuccess = 76; } +server cluster BallastConfiguration = 769 { + readonly attribute int8u physicalMinLevel = 0; + readonly attribute int8u physicalMaxLevel = 1; + readonly attribute bitmap8 ballastStatus = 2; + attribute int8u minLevel = 16; + attribute int8u maxLevel = 17; + attribute nullable int8u intrinsicBallastFactor = 20; + attribute nullable int8u ballastFactorAdjustment = 21; + readonly attribute int8u lampQuantity = 32; + attribute char_string<16> lampType = 48; + attribute char_string<16> lampManufacturer = 49; + attribute nullable int24u lampRatedHours = 50; + attribute nullable int24u lampBurnHours = 51; + attribute bitmap8 lampAlarmMode = 52; + attribute nullable int24u lampBurnHoursTripPoint = 53; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + server cluster IlluminanceMeasurement = 1024 { enum LightSensorType : ENUM8 { kPhotodiode = 0; @@ -3136,15 +3228,15 @@ server cluster Channel = 1284 { kLineupInfo = 0x2; } - struct ChannelInfo { + struct ChannelInfoStruct { int16u majorNumber = 0; int16u minorNumber = 1; - optional char_string<32> name = 2; - optional char_string<32> callSign = 3; - optional char_string<32> affiliateCallSign = 4; + optional char_string name = 2; + optional char_string callSign = 3; + optional char_string affiliateCallSign = 4; } - readonly attribute ChannelInfo channelList[] = 0; + readonly attribute ChannelInfoStruct channelList[] = 0; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; } @@ -3156,12 +3248,12 @@ server cluster TargetNavigator = 1285 { kNotAllowed = 2; } - struct TargetInfo { + struct TargetInfoStruct { int8u identifier = 0; char_string<32> name = 1; } - readonly attribute TargetInfo targetList[] = 0; + readonly attribute TargetInfoStruct targetList[] = 0; readonly attribute int8u currentTarget = 1; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -3231,14 +3323,14 @@ server cluster MediaInput = 1287 { kNameUpdates = 0x1; } - struct InputInfo { + struct InputInfoStruct { int8u index = 0; InputTypeEnum inputType = 1; char_string<32> name = 2; char_string<32> description = 3; } - readonly attribute InputInfo inputList[] = 0; + readonly attribute InputInfoStruct inputList[] = 0; readonly attribute int8u currentInput = 1; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -3407,6 +3499,7 @@ server cluster ContentLauncher = 1290 { kSport = 10; kSportsTeam = 11; kType = 12; + kVideo = 13; } bitmap ContentLauncherFeature : BITMAP32 { @@ -3419,37 +3512,37 @@ server cluster ContentLauncher = 1290 { kHls = 0x2; } - struct ContentSearch { - Parameter parameterList[] = 0; + struct ContentSearchStruct { + ParameterStruct parameterList[] = 0; } - struct Parameter { + struct ParameterStruct { ParameterEnum type = 0; char_string value = 1; - optional AdditionalInfo externalIDList[] = 2; + optional AdditionalInfoStruct externalIDList[] = 2; } - struct AdditionalInfo { + struct AdditionalInfoStruct { char_string name = 0; char_string value = 1; } - struct BrandingInformation { + struct BrandingInformationStruct { char_string providerName = 0; - optional StyleInformation background = 1; - optional StyleInformation logo = 2; - optional StyleInformation progressBar = 3; - optional StyleInformation splash = 4; - optional StyleInformation waterMark = 5; + optional StyleInformationStruct background = 1; + optional StyleInformationStruct logo = 2; + optional StyleInformationStruct progressBar = 3; + optional StyleInformationStruct splash = 4; + optional StyleInformationStruct waterMark = 5; } - struct StyleInformation { - optional char_string imageUrl = 0; + struct StyleInformationStruct { + optional char_string imageURL = 0; optional char_string color = 1; - optional Dimension size = 2; + optional DimensionStruct size = 2; } - struct Dimension { + struct DimensionStruct { double width = 0; double height = 1; MetricTypeEnum metric = 2; @@ -3475,13 +3568,13 @@ server cluster AudioOutput = 1291 { kNameUpdates = 0x1; } - struct OutputInfo { + struct OutputInfoStruct { int8u index = 0; OutputTypeEnum outputType = 1; char_string<32> name = 2; } - readonly attribute OutputInfo outputList[] = 0; + readonly attribute OutputInfoStruct outputList[] = 0; readonly attribute int8u currentOutput = 1; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -3498,9 +3591,9 @@ server cluster ApplicationLauncher = 1292 { kApplicationPlatform = 0x1; } - struct Application { - int16u catalogVendorId = 0; - char_string applicationId = 1; + struct ApplicationStruct { + int16u catalogVendorID = 0; + char_string applicationID = 1; } readonly attribute INT16U catalogList[] = 0; @@ -3962,7 +4055,7 @@ endpoint 0 { callback attribute extension; callback attribute subjectsPerAccessControlEntry default = 4; callback attribute targetsPerAccessControlEntry default = 3; - callback attribute accessControlEntriesPerFabric default = 3; + callback attribute accessControlEntriesPerFabric default = 4; ram attribute featureMap; callback attribute clusterRevision default = 1; } @@ -4266,6 +4359,7 @@ endpoint 0 { } endpoint 1 { device type onofflight = 256, version 1; + binding cluster OnOff; server cluster Identify { ram attribute identifyTime; @@ -4508,8 +4602,8 @@ endpoint 1 { ram attribute lifetimeEnergyConsumed; ram attribute operationMode; ram attribute controlMode; - ram attribute featureMap; - ram attribute clusterRevision default = 3; + ram attribute featureMap default = 0x1F; + ram attribute clusterRevision default = 4; } server cluster Thermostat { @@ -4615,6 +4709,28 @@ endpoint 1 { ram attribute clusterRevision default = 5; } + server cluster BallastConfiguration { + ram attribute physicalMinLevel default = 0x01; + ram attribute physicalMaxLevel default = 0xFE; + ram attribute ballastStatus; + ram attribute minLevel default = 0x01; + ram attribute maxLevel default = 0xFE; + ram attribute intrinsicBallastFactor; + ram attribute ballastFactorAdjustment default = 0xFF; + ram attribute lampQuantity; + ram attribute lampType; + ram attribute lampManufacturer; + ram attribute lampRatedHours default = 0xFFFFFF; + ram attribute lampBurnHours; + ram attribute lampAlarmMode; + ram attribute lampBurnHoursTripPoint default = 0xFFFFFF; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; + ram attribute featureMap; + ram attribute clusterRevision default = 4; + } + server cluster IlluminanceMeasurement { ram attribute measuredValue; ram attribute minMeasuredValue default = 0x01; diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap index de039d9d9a8c82..d5703ab2ecefdc 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap @@ -1098,7 +1098,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "4", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -5121,7 +5121,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "PHYRate", + "type": "PHYRateEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -5395,7 +5395,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -5447,7 +5447,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -5459,7 +5459,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "CommissioningWindowStatus", + "type": "CommissioningWindowStatusEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -6221,7 +6221,7 @@ "code": 3, "mfgCode": null, "side": "server", - "type": "DlDoorState", + "type": "DoorStateEnum", "included": 0, "storageOption": "RAM", "singleton": 0, @@ -6301,7 +6301,7 @@ "code": 37, "mfgCode": null, "side": "server", - "type": "DlOperatingMode", + "type": "OperatingModeEnum", "included": 0, "storageOption": "RAM", "singleton": 0, @@ -7989,7 +7989,7 @@ "enabled": 0, "attributes": [ { - "name": "occupancy", + "name": "Occupancy", "code": 0, "mfgCode": null, "side": "server", @@ -8005,7 +8005,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type", + "name": "OccupancySensorType", "code": 1, "mfgCode": null, "side": "server", @@ -8021,7 +8021,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type bitmap", + "name": "OccupancySensorTypeBitmap", "code": 2, "mfgCode": null, "side": "server", @@ -9366,7 +9366,7 @@ "mfgCode": null, "define": "ON_OFF_CLUSTER", "side": "client", - "enabled": 0, + "enabled": 1, "commands": [ { "name": "Off", @@ -13031,7 +13031,7 @@ "code": 3, "mfgCode": null, "side": "server", - "type": "DlDoorState", + "type": "DoorStateEnum", "included": 1, "storageOption": "RAM", "singleton": 0, @@ -13351,7 +13351,7 @@ "code": 37, "mfgCode": null, "side": "server", - "type": "DlOperatingMode", + "type": "OperatingModeEnum", "included": 1, "storageOption": "RAM", "singleton": 0, @@ -14724,7 +14724,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": "0x1F", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -14740,7 +14740,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "4", "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -16688,6 +16688,362 @@ } ] }, + { + "name": "Ballast Configuration", + "code": 769, + "mfgCode": null, + "define": "BALLAST_CONFIGURATION_CLUSTER", + "side": "client", + "enabled": 0, + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "client", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Ballast Configuration", + "code": 769, + "mfgCode": null, + "define": "BALLAST_CONFIGURATION_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "PhysicalMinLevel", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PhysicalMaxLevel", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xFE", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "BallastStatus", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "bitmap8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "MinLevel", + "code": 16, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "MaxLevel", + "code": 17, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xFE", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "IntrinsicBallastFactor", + "code": 20, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "BallastFactorAdjustment", + "code": 21, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xFF", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LampQuantity", + "code": 32, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LampType", + "code": 48, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LampManufacturer", + "code": 49, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LampRatedHours", + "code": 50, + "mfgCode": null, + "side": "server", + "type": "int24u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xFFFFFF", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LampBurnHours", + "code": 51, + "mfgCode": null, + "side": "server", + "type": "int24u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x000000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LampAlarmMode", + "code": 52, + "mfgCode": null, + "side": "server", + "type": "bitmap8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LampBurnHoursTripPoint", + "code": 53, + "mfgCode": null, + "side": "server", + "type": "int24u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xFFFFFF", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, { "name": "Illuminance Measurement", "code": 1024, @@ -17431,7 +17787,7 @@ "enabled": 1, "attributes": [ { - "name": "occupancy", + "name": "Occupancy", "code": 0, "mfgCode": null, "side": "server", @@ -17447,7 +17803,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type", + "name": "OccupancySensorType", "code": 1, "mfgCode": null, "side": "server", @@ -17463,7 +17819,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type bitmap", + "name": "OccupancySensorTypeBitmap", "code": 2, "mfgCode": null, "side": "server", @@ -17717,7 +18073,7 @@ "code": 1, "mfgCode": null, "side": "server", - "type": "LineupInfo", + "type": "LineupInfoStruct", "included": 0, "storageOption": "External", "singleton": 0, @@ -17733,7 +18089,7 @@ "code": 2, "mfgCode": null, "side": "server", - "type": "ChannelInfo", + "type": "ChannelInfoStruct", "included": 0, "storageOption": "External", "singleton": 0, @@ -17955,7 +18311,7 @@ "outgoing": 1 }, { - "name": "StopPlayback", + "name": "Stop", "code": 2, "mfgCode": null, "source": "client", @@ -18099,7 +18455,7 @@ "code": 3, "mfgCode": null, "side": "server", - "type": "PlaybackPosition", + "type": "PlaybackPositionStruct", "included": 0, "storageOption": "External", "singleton": 0, @@ -18825,7 +19181,7 @@ "code": 1, "mfgCode": null, "side": "server", - "type": "ApplicationEP", + "type": "ApplicationEPStruct", "included": 0, "storageOption": "External", "singleton": 0, @@ -22985,7 +23341,7 @@ "code": 3, "mfgCode": null, "side": "server", - "type": "DlDoorState", + "type": "DoorStateEnum", "included": 0, "storageOption": "RAM", "singleton": 0, @@ -23065,7 +23421,7 @@ "code": 37, "mfgCode": null, "side": "server", - "type": "DlOperatingMode", + "type": "OperatingModeEnum", "included": 0, "storageOption": "RAM", "singleton": 0, @@ -24489,7 +24845,7 @@ "enabled": 1, "attributes": [ { - "name": "occupancy", + "name": "Occupancy", "code": 0, "mfgCode": null, "side": "server", @@ -24505,7 +24861,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type", + "name": "OccupancySensorType", "code": 1, "mfgCode": null, "side": "server", @@ -24521,7 +24877,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type bitmap", + "name": "OccupancySensorTypeBitmap", "code": 2, "mfgCode": null, "side": "server", diff --git a/examples/all-clusters-app/ameba/main/DeviceCallbacks.cpp b/examples/all-clusters-app/ameba/main/DeviceCallbacks.cpp index 4817cfb5f99e03..fab4ba499df2ce 100644 --- a/examples/all-clusters-app/ameba/main/DeviceCallbacks.cpp +++ b/examples/all-clusters-app/ameba/main/DeviceCallbacks.cpp @@ -25,7 +25,7 @@ #include "DeviceCallbacks.h" #include "CHIPDeviceManager.h" -#include +#include #include #include #include @@ -143,7 +143,7 @@ void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event void DeviceCallbacks::OnOnOffPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { - VerifyOrExit(attributeId == ZCL_ON_OFF_ATTRIBUTE_ID, + VerifyOrExit(attributeId == app::Clusters::OnOff::Attributes::OnOff::Id, ChipLogError(DeviceLayer, TAG, "Unhandled Attribute ID: '0x%04x", attributeId)); VerifyOrExit(endpointId == 1 || endpointId == 2, ChipLogError(DeviceLayer, TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); @@ -165,7 +165,7 @@ void IdentifyTimerHandler(Layer * systemLayer, void * appState, CHIP_ERROR error void DeviceCallbacks::OnIdentifyPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { - VerifyOrExit(attributeId == ZCL_IDENTIFY_TIME_ATTRIBUTE_ID, + VerifyOrExit(attributeId == app::Clusters::Identify::Attributes::IdentifyTime::Id, ChipLogError(DeviceLayer, "[%s] Unhandled Attribute ID: '0x%04x", TAG, attributeId)); VerifyOrExit(endpointId == 1, ChipLogError(DeviceLayer, "[%s] Unexpected EndPoint ID: `0x%02x'", TAG, endpointId)); diff --git a/examples/all-clusters-app/ameba/main/include/ColorControlCommands.h b/examples/all-clusters-app/ameba/main/include/ColorControlCommands.h index f4514470b3e630..00e36e434160b6 100644 --- a/examples/all-clusters-app/ameba/main/include/ColorControlCommands.h +++ b/examples/all-clusters-app/ameba/main/include/ColorControlCommands.h @@ -453,10 +453,10 @@ void ProcessColorControlUnicastBindingCommand(BindingCommandData * data, const E break; case Clusters::ColorControl::Commands::MoveToColorTemperature::Id: - moveToColorTemperatureCommand.colorTemperature = static_cast(data->args[0]); - moveToColorTemperatureCommand.transitionTime = static_cast(data->args[1]); - moveToColorTemperatureCommand.optionsMask = static_cast(data->args[2]); - moveToColorTemperatureCommand.optionsOverride = static_cast(data->args[3]); + moveToColorTemperatureCommand.colorTemperatureMireds = static_cast(data->args[0]); + moveToColorTemperatureCommand.transitionTime = static_cast(data->args[1]); + moveToColorTemperatureCommand.optionsMask = static_cast(data->args[2]); + moveToColorTemperatureCommand.optionsOverride = static_cast(data->args[3]); Controller::InvokeCommandRequest(peer_device->GetExchangeManager(), peer_device->GetSecureSession().Value(), binding.remote, moveToColorTemperatureCommand, onSuccess, onFailure); break; @@ -658,10 +658,10 @@ void ProcessColorControlGroupBindingCommand(BindingCommandData * data, const Emb break; case Clusters::ColorControl::Commands::MoveToColorTemperature::Id: - moveToColorTemperatureCommand.colorTemperature = static_cast(data->args[0]); - moveToColorTemperatureCommand.transitionTime = static_cast(data->args[1]); - moveToColorTemperatureCommand.optionsMask = static_cast(data->args[2]); - moveToColorTemperatureCommand.optionsOverride = static_cast(data->args[3]); + moveToColorTemperatureCommand.colorTemperatureMireds = static_cast(data->args[0]); + moveToColorTemperatureCommand.transitionTime = static_cast(data->args[1]); + moveToColorTemperatureCommand.optionsMask = static_cast(data->args[2]); + moveToColorTemperatureCommand.optionsOverride = static_cast(data->args[3]); Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, moveToColorTemperatureCommand); break; diff --git a/examples/all-clusters-app/ameba/main/include/ThermostatCommands.h b/examples/all-clusters-app/ameba/main/include/ThermostatCommands.h index c1444bf332c0ab..31ff5098869680 100644 --- a/examples/all-clusters-app/ameba/main/include/ThermostatCommands.h +++ b/examples/all-clusters-app/ameba/main/include/ThermostatCommands.h @@ -154,7 +154,7 @@ void ProcessThermostatUnicastBindingCommand(BindingCommandData * data, const Emb switch (data->commandId) { case Clusters::Thermostat::Commands::SetpointRaiseLower::Id: - setpointRaiseLowerCommand.mode = static_cast(data->args[0]); + setpointRaiseLowerCommand.mode = static_cast(data->args[0]); setpointRaiseLowerCommand.amount = static_cast(data->args[1]); Controller::InvokeCommandRequest(peer_device->GetExchangeManager(), peer_device->GetSecureSession().Value(), binding.remote, setpointRaiseLowerCommand, onSuccess, onFailure); @@ -171,7 +171,7 @@ void ProcessThermostatGroupBindingCommand(BindingCommandData * data, const Ember switch (data->commandId) { case Clusters::Thermostat::Commands::SetpointRaiseLower::Id: - setpointRaiseLowerCommand.mode = static_cast(data->args[0]); + setpointRaiseLowerCommand.mode = static_cast(data->args[0]); setpointRaiseLowerCommand.amount = static_cast(data->args[1]); Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, setpointRaiseLowerCommand); break; diff --git a/examples/all-clusters-app/cc13x2x7_26x2x7/main/ClusterManager.cpp b/examples/all-clusters-app/cc13x2x7_26x2x7/main/ClusterManager.cpp index 1a07e18c72c3de..17922c679e2135 100644 --- a/examples/all-clusters-app/cc13x2x7_26x2x7/main/ClusterManager.cpp +++ b/examples/all-clusters-app/cc13x2x7_26x2x7/main/ClusterManager.cpp @@ -18,9 +18,8 @@ */ #include "ClusterManager.h" #include "Globals.h" -#include -#include #include +#include #include #include #include @@ -83,7 +82,9 @@ Identify gIdentify1 = { void ClusterManager::OnOnOffPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { - VerifyOrExit(attributeId == ZCL_ON_OFF_ATTRIBUTE_ID, PLAT_LOG("Unhandled Attribute ID: '0x%04x", attributeId)); + using namespace app::Clusters::OnOff::Attributes; + + VerifyOrExit(attributeId == OnOff::Id, PLAT_LOG("Unhandled Attribute ID: '0x%04x", attributeId)); VerifyOrExit(endpointId == ENDPOINT_ID_1 || endpointId == ENDPOINT_ID_2, PLAT_LOG("Unexpected EndPoint ID: `0x%02x'", endpointId)); @@ -97,11 +98,13 @@ void ClusterManager::OnOnOffPostAttributeChangeCallback(EndpointId endpointId, A void ClusterManager::OnLevelControlAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { + using namespace app::Clusters::LevelControl::Attributes; + bool onOffState = mEndpointOnOffState[endpointId - 1]; uint8_t brightness = onOffState ? *value : 0; VerifyOrExit(brightness > 0, PLAT_LOG("Brightness set to 0, ignoring")); - VerifyOrExit(attributeId == ZCL_CURRENT_LEVEL_ATTRIBUTE_ID, PLAT_LOG("Unhandled Attribute ID: '0x%04x", attributeId)); + VerifyOrExit(attributeId == CurrentLevel::Id, PLAT_LOG("Unhandled Attribute ID: '0x%04x", attributeId)); VerifyOrExit(endpointId == ENDPOINT_ID_1 || endpointId == ENDPOINT_ID_2, PLAT_LOG("Unexpected EndPoint ID: `0x%02x'", endpointId)); @@ -118,8 +121,9 @@ void ClusterManager::OnLevelControlAttributeChangeCallback(EndpointId endpointId void ClusterManager::OnColorControlAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { - VerifyOrExit(attributeId == ZCL_COLOR_CONTROL_CURRENT_HUE_ATTRIBUTE_ID || - attributeId == ZCL_COLOR_CONTROL_CURRENT_SATURATION_ATTRIBUTE_ID, + using namespace app::Clusters::ColorControl::Attributes; + + VerifyOrExit(attributeId == CurrentHue::Id || attributeId == CurrentSaturation::Id, PLAT_LOG("Unhandled AttributeId ID: '0x%04x", attributeId)); VerifyOrExit(endpointId == ENDPOINT_ID_1 || endpointId == ENDPOINT_ID_2, PLAT_LOG("Unexpected EndPoint ID: `0x%02x'", endpointId)); @@ -127,17 +131,17 @@ void ClusterManager::OnColorControlAttributeChangeCallback(EndpointId endpointId if (endpointId == ENDPOINT_ID_1) { uint8_t hue, saturation; - if (attributeId == ZCL_COLOR_CONTROL_CURRENT_HUE_ATTRIBUTE_ID) + if (attributeId == CurrentHue::Id) { hue = *value; /* Read Current Saturation value when Attribute change callback for HUE Attribute */ - app::Clusters::ColorControl::Attributes::CurrentSaturation::Get(endpointId, &saturation); + CurrentSaturation::Get(endpointId, &saturation); } else { saturation = *value; /* Read Current Hue value when Attribute change callback for SATURATION Attribute */ - app::Clusters::ColorControl::Attributes::CurrentHue::Get(endpointId, &hue); + CurrentHue::Get(endpointId, &hue); } PLAT_LOG("Color Control triggered: Hue: %d Saturation: %d", hue, saturation); } diff --git a/examples/all-clusters-app/cc13x2x7_26x2x7/main/ZclCallbacks.cpp b/examples/all-clusters-app/cc13x2x7_26x2x7/main/ZclCallbacks.cpp index 4d14d56f8f0d6f..5a78ce84982c40 100644 --- a/examples/all-clusters-app/cc13x2x7_26x2x7/main/ZclCallbacks.cpp +++ b/examples/all-clusters-app/cc13x2x7_26x2x7/main/ZclCallbacks.cpp @@ -27,7 +27,6 @@ #include "ClusterManager.h" -#include #include #include #include diff --git a/examples/all-clusters-app/esp32/CMakeLists.txt b/examples/all-clusters-app/esp32/CMakeLists.txt index 0a8752ca6bcc27..e1eb655da1c9e9 100644 --- a/examples/all-clusters-app/esp32/CMakeLists.txt +++ b/examples/all-clusters-app/esp32/CMakeLists.txt @@ -27,7 +27,6 @@ include(${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common/cm set(EXTRA_COMPONENT_DIRS "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/config/esp32/components" "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common/QRCode" - "${IDF_PATH}/examples/common_components/led_strip" ) if(${IDF_TARGET} STREQUAL "esp32") list(APPEND EXTRA_COMPONENT_DIRS "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common/m5stack-tft/repo/components/tft" diff --git a/examples/all-clusters-app/esp32/main/AppTask.cpp b/examples/all-clusters-app/esp32/main/AppTask.cpp index 51ee806898cd10..836e4d8b2b7f02 100644 --- a/examples/all-clusters-app/esp32/main/AppTask.cpp +++ b/examples/all-clusters-app/esp32/main/AppTask.cpp @@ -23,11 +23,20 @@ #include "LEDWidget.h" #include "ScreenManager.h" #include "driver/gpio.h" +#include "esp_idf_version.h" #include "esp_log.h" -#include "esp_spi_flash.h" #include "freertos/FreeRTOS.h" #include +#include + +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) +#include "esp_spi_flash.h" +#else +#include "esp_chip_info.h" +#include "esp_flash.h" +#endif +#define FACTORY_RESET_CANCEL_WINDOW_TIMEOUT 3000 #define APP_TASK_NAME "APP" #define APP_EVENT_QUEUE_SIZE 10 #define APP_TASK_STACK_SIZE (3072) @@ -35,6 +44,7 @@ static const char * TAG = "app-task"; namespace { +TimerHandle_t sFunctionTimer; // FreeRTOS app sw timer QueueHandle_t sAppEventQueue; TaskHandle_t sAppTaskHandle; @@ -58,18 +68,143 @@ CHIP_ERROR AppTask::StartAppTask() return (xReturned == pdPASS) ? CHIP_NO_ERROR : APP_ERROR_CREATE_TASK_FAILED; } +void AppTask::TimerEventHandler(TimerHandle_t xTimer) +{ + AppEvent event; + event.mType = AppEvent::kEventType_Timer; + event.mTimerEvent.mContext = (void *) xTimer; + event.mHandler = FunctionTimerEventHandler; + sAppTask.PostEvent(&event); +} + +void AppTask::FunctionTimerEventHandler(AppEvent * aEvent) +{ + if (aEvent->mType != AppEvent::kEventType_Timer) + { + return; + } + // If we reached here, the button was held past FACTORY_RESET_TRIGGER_TIMEOUT, + // initiate factory reset + if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_StartBleAdv) + { + // ESP_LOGI(TAG, "Factory Reset Triggered. Release button within %ums to cancel.", FACTORY_RESET_CANCEL_WINDOW_TIMEOUT); + // Start timer for FACTORY_RESET_CANCEL_WINDOW_TIMEOUT to allow user to + // cancel, if required. + sAppTask.StartTimer(FACTORY_RESET_CANCEL_WINDOW_TIMEOUT); + sAppTask.mFunction = kFunction_FactoryReset; + // Turn off all LEDs before starting blink to make sure blink is + // co-ordinated. + // sStatusLED.Set(false); + // sLockLED.Set(false); + // sStatusLED.Blink(500); + // sLockLED.Blink(500); + } + else if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_FactoryReset) + { + // Actually trigger Factory Reset + sAppTask.mFunction = kFunction_NoneSelected; + chip::Server::GetInstance().ScheduleFactoryReset(); + } +} + +void AppTask::CancelTimer() +{ + if (xTimerStop(sFunctionTimer, 0) == pdFAIL) + { + ESP_LOGI(TAG, "app timer stop() failed"); + return; + } + mFunctionTimerActive = false; +} +void AppTask::StartTimer(uint32_t aTimeoutInMs) +{ + if (xTimerIsTimerActive(sFunctionTimer)) + { + ESP_LOGI(TAG, "app timer already started!"); + CancelTimer(); + } + // timer is not active, change its period to required value (== restart). + // FreeRTOS- Block for a maximum of 100 ticks if the change period command + // cannot immediately be sent to the timer command queue. + if (xTimerChangePeriod(sFunctionTimer, aTimeoutInMs / portTICK_PERIOD_MS, 100) != pdPASS) + { + ESP_LOGI(TAG, "app timer start() failed"); + return; + } + mFunctionTimerActive = true; +} +void AppTask::ActionInitiated(BoltLockManager::Action_t aAction, int32_t aActor) +{ + // If the action has been initiated by the lock, update the bolt lock trait + // and start flashing the LEDs rapidly to indicate action initiation. + if (aAction == BoltLockManager::LOCK_ACTION) + { + ESP_LOGI(TAG, "Lock Action has been initiated"); + } + else if (aAction == BoltLockManager::UNLOCK_ACTION) + { + ESP_LOGI(TAG, "Unlock Action has been initiated"); + } + if (aActor == AppEvent::kEventType_Button) + { + sAppTask.mSyncClusterToButtonAction = true; + } + // sLockLED.Blink(50, 50); +} +void AppTask::ActionCompleted(BoltLockManager::Action_t aAction) +{ + // if the action has been completed by the lock, update the bolt lock trait. + // Turn on the lock LED if in a LOCKED state OR + // Turn off the lock LED if in an UNLOCKED state. + if (aAction == BoltLockManager::LOCK_ACTION) + { + ESP_LOGI(TAG, "Lock Action has been completed"); + // sLockLED.Set(true); + } + else if (aAction == BoltLockManager::UNLOCK_ACTION) + { + ESP_LOGI(TAG, "Unlock Action has been completed"); + // sLockLED.Set(false); + } +} + +CHIP_ERROR AppTask::LockInit() +{ + ReturnErrorOnFailure(BoltLockMgr().InitLockState()); + BoltLockMgr().SetCallbacks(ActionInitiated, ActionCompleted); + return CHIP_NO_ERROR; +} + CHIP_ERROR AppTask::Init() { /* Print chip information */ esp_chip_info_t chip_info; esp_chip_info(&chip_info); + uint32_t flash_size = 0; + +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) + flash_size = spi_flash_get_chip_size(); +#else + if (esp_flash_get_size(NULL, &flash_size) != ESP_OK) + { + ESP_LOGW(TAG, "Failed to get flash size"); + } +#endif ESP_LOGI(TAG, "This is ESP32 chip with %d CPU cores, WiFi%s%s, ", chip_info.cores, (chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "", (chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : ""); ESP_LOGI(TAG, "silicon revision %d, ", chip_info.revision); - ESP_LOGI(TAG, "%dMB %s flash\n", spi_flash_get_chip_size() / (1024 * 1024), + ESP_LOGI(TAG, "%" PRIu32 " MB %s flash\n", flash_size / (1024 * 1024), (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external"); - CHIP_ERROR err = CHIP_NO_ERROR; + // Create FreeRTOS sw timer for Function Selection + sFunctionTimer = xTimerCreate("FnTmr", // Just a text name, not used by the RTOS kernel + 1, // == default timer period (mS) + false, // no timer reload (==one-shot) + (void *) this, // init timer id = app task obj context + TimerEventHandler // timer callback handler + ); + VerifyOrReturnError(sFunctionTimer != NULL, CHIP_ERROR_NO_MEMORY, ESP_LOGE(TAG, "Failed to create function selection timer")); + statusLED1.Init(STATUS_LED_GPIO_NUM); // Our second LED doesn't map to any physical LEDs so far, just to virtual // "LED"s on devices with screens. @@ -85,7 +220,7 @@ CHIP_ERROR AppTask::Init() InitDeviceDisplay(); #endif - return err; + return CHIP_NO_ERROR; } void AppTask::AppTaskMain(void * pvParameter) diff --git a/examples/all-clusters-app/esp32/main/CMakeLists.txt b/examples/all-clusters-app/esp32/main/CMakeLists.txt index a4003980dedde0..bf2c65dd1570f6 100644 --- a/examples/all-clusters-app/esp32/main/CMakeLists.txt +++ b/examples/all-clusters-app/esp32/main/CMakeLists.txt @@ -20,21 +20,19 @@ set(PRIV_INCLUDE_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/all-clusters-app" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/all-clusters-app/all-clusters-common/include" "${CMAKE_CURRENT_LIST_DIR}/include" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/lock-app/linux/include" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/providers" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/third_party/nlfaultinjection/repo/include" ) set(SRC_DIRS_LIST "${CMAKE_CURRENT_LIST_DIR}" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/all-clusters-app/zap-generated" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated/attributes" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/lock-app/linux/src" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/providers" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/ota" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/common" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/shell_extension" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/lock" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting" @@ -94,10 +92,6 @@ set(SRC_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/all-clusters-app/all-clusters-common/src" ) -set(EXCLUDE_SRCS_LIST - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/lock-app/linux/src/LockAppCommandDelegate.cpp" -) - if (CONFIG_ENABLE_PW_RPC) # Append additional directories for RPC build set(PRIV_INCLUDE_DIRS_LIST "${PRIV_INCLUDE_DIRS_LIST}" @@ -115,7 +109,7 @@ set(SRC_DIRS_LIST "${SRC_DIRS_LIST}" ) endif (CONFIG_ENABLE_PW_RPC) -if(("${CONFIG_DEVICE_TYPE_ESP32_DEVKITC}" STREQUAL "y") OR ("${CONFIG_DEVICE_TYPE_ESP32_C3_DEVKITM}" STREQUAL "y")) +if(("${CONFIG_DEVICE_TYPE_ESP32_DEVKITC}" STREQUAL "y") OR ("${CONFIG_DEVICE_TYPE_ESP32_C3_DEVKITM}" STREQUAL "y") OR ("${CONFIG_DEVICE_TYPE_ESP32_C2_DEVKITM}" STREQUAL "y")) list(APPEND PRIV_INCLUDE_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/screen-framework/include") set(PRIV_REQUIRES_LIST chip QRCode bt) diff --git a/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp b/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp index 82917c28ef26b5..cb9a532961198d 100644 --- a/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp @@ -27,8 +27,8 @@ #include "Globals.h" #include "LEDWidget.h" #include "WiFiWidget.h" -#include -#include +#include +#include #include #include #include @@ -93,8 +93,7 @@ void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Clus uint8_t type, uint16_t size, uint8_t * value) { ESP_LOGI(TAG, - "PostAttributeChangeCallback - Cluster ID: '0x%04x', EndPoint ID: " - "'0x%02x', Attribute ID: '0x%04x'", + "PostAttributeChangeCallback - Cluster ID: '0x%04" PRIx32 "', EndPoint ID: '0x%02x' , Attribute ID: '0x%04" PRIx32 "'", clusterId, endpointId, attributeId); switch (clusterId) @@ -115,7 +114,7 @@ void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Clus OnIdentifyPostAttributeChangeCallback(endpointId, attributeId, size, value); break; default: - ESP_LOGI(TAG, "Unhandled cluster ID: %d", clusterId); + ESP_LOGI(TAG, "Unhandled cluster ID: %" PRIu32, clusterId); break; } @@ -124,7 +123,9 @@ void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Clus void AppDeviceCallbacks::OnOnOffPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { - VerifyOrExit(attributeId == ZCL_ON_OFF_ATTRIBUTE_ID, ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04x", attributeId)); + using namespace app::Clusters::OnOff::Attributes; + + VerifyOrExit(attributeId == OnOff::Id, ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04" PRIx32 "'", attributeId)); VerifyOrExit(endpointId == 1 || endpointId == 2, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); // At this point we can assume that value points to a bool value. @@ -137,10 +138,12 @@ void AppDeviceCallbacks::OnOnOffPostAttributeChangeCallback(EndpointId endpointI void AppDeviceCallbacks::OnLevelControlAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { + using namespace app::Clusters::LevelControl::Attributes; + bool onOffState = mEndpointOnOffState[endpointId - 1]; uint8_t brightness = onOffState ? *value : 0; - VerifyOrExit(attributeId == ZCL_CURRENT_LEVEL_ATTRIBUTE_ID, ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04x", attributeId)); + VerifyOrExit(attributeId == CurrentLevel::Id, ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04" PRIx32 "'", attributeId)); VerifyOrExit(endpointId == 1 || endpointId == 2, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); // At this point we can assume that value points to a bool value. @@ -155,24 +158,23 @@ void AppDeviceCallbacks::OnLevelControlAttributeChangeCallback(EndpointId endpoi #if CONFIG_DEVICE_TYPE_ESP32_C3_DEVKITM void AppDeviceCallbacks::OnColorControlAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { - VerifyOrExit(attributeId == ZCL_COLOR_CONTROL_CURRENT_HUE_ATTRIBUTE_ID || - attributeId == ZCL_COLOR_CONTROL_CURRENT_SATURATION_ATTRIBUTE_ID, - ESP_LOGI(TAG, "Unhandled AttributeId ID: '0x%04x", attributeId)); + using namespace app::Clusters::ColorControl::Attributes; + + VerifyOrExit(attributeId == CurrentHue::Id || attributeId == CurrentSaturation::Id, + ESP_LOGI(TAG, "Unhandled AttributeId ID: '0x%04" PRIx32 "'", attributeId)); VerifyOrExit(endpointId == 1 || endpointId == 2, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); if (endpointId == 1) { uint8_t hue, saturation; - if (attributeId == ZCL_COLOR_CONTROL_CURRENT_HUE_ATTRIBUTE_ID) + if (attributeId == CurrentHue::Id) { hue = *value; - emberAfReadServerAttribute(endpointId, Clusters::ColorControl::Id, ZCL_COLOR_CONTROL_CURRENT_SATURATION_ATTRIBUTE_ID, - &saturation, sizeof(uint8_t)); + CurrentSaturation::Get(endpointId, &saturation); } else { saturation = *value; - emberAfReadServerAttribute(endpointId, Clusters::ColorControl::Id, ZCL_COLOR_CONTROL_CURRENT_HUE_ATTRIBUTE_ID, &hue, - sizeof(uint8_t)); + CurrentHue::Get(endpointId, &hue); } statusLED1.SetColor(hue, saturation); } diff --git a/examples/all-clusters-app/esp32/main/DeviceWithDisplay.cpp b/examples/all-clusters-app/esp32/main/DeviceWithDisplay.cpp index 967431efa8fc5f..a9fce33410c7b7 100644 --- a/examples/all-clusters-app/esp32/main/DeviceWithDisplay.cpp +++ b/examples/all-clusters-app/esp32/main/DeviceWithDisplay.cpp @@ -17,6 +17,7 @@ */ #include "DeviceWithDisplay.h" +#include #include #include #include @@ -321,16 +322,15 @@ class EditAttributeListModel : public TouchesMatterStackModel if (name == "OnOff" && cluster == "OnOff") { - value = (value == "On") ? "Off" : "On"; - uint8_t attributeValue = (value == "On") ? 1 : 0; - emberAfWriteServerAttribute(endpointIndex + 1, app::Clusters::OnOff::Id, ZCL_ON_OFF_ATTRIBUTE_ID, - (uint8_t *) &attributeValue, ZCL_BOOLEAN_ATTRIBUTE_TYPE); + value = (value == "On") ? "Off" : "On"; + bool attributeValue = (value == "On"); + app::Clusters::OnOff::Attributes::OnOff::Set(endpointIndex + 1, attributeValue); } if (name == "Occupancy" && cluster == "Occupancy Sensor") { - value = (value == "Yes") ? "No" : "Yes"; - uint8_t attributeValue = (value == "Yes") ? 1 : 0; + value = (value == "Yes") ? "No" : "Yes"; + bool attributeValue = (value == "Yes"); ESP_LOGI(TAG, "Occupancy changed to : %s", value.c_str()); // update the current occupancy here for hardcoded endpoint 1 app::Clusters::OccupancySensing::Attributes::Occupancy::Set(1, attributeValue); diff --git a/examples/all-clusters-app/esp32/main/Kconfig.projbuild b/examples/all-clusters-app/esp32/main/Kconfig.projbuild index 43fcf6c47219ea..4f9e071eb8a5dd 100644 --- a/examples/all-clusters-app/esp32/main/Kconfig.projbuild +++ b/examples/all-clusters-app/esp32/main/Kconfig.projbuild @@ -24,6 +24,7 @@ menu "Demo" prompt "Device Type" default DEVICE_TYPE_ESP32_DEVKITC if IDF_TARGET_ESP32 default DEVICE_TYPE_ESP32_C3_DEVKITM if IDF_TARGET_ESP32C3 + default DEVICE_TYPE_ESP32_C2_DEVKITM if IDF_TARGET_ESP32C2 help Specifies the type of ESP32 device. @@ -46,6 +47,9 @@ menu "Demo" bool "ESP32-Ethernet-Kit_A_V1.0" select ENABLE_ETHERNET_TELEMETRY depends on IDF_TARGET_ESP32 + config DEVICE_TYPE_ESP32_C2_DEVKITM + bool "ESP32C2-DevKitM" + depends on IDF_TARGET_ESP32C2 endchoice choice @@ -77,7 +81,7 @@ menu "Demo" int range 0 5 default 0 if DEVICE_TYPE_ESP32_DEVKITC - default 0 if DEVICE_TYPE_ESP32_C3_DEVKITM + default 0 if DEVICE_TYPE_ESP32_C3_DEVKITM || DEVICE_TYPE_ESP32_C2_DEVKITM default 3 if DEVICE_TYPE_M5STACK default 4 if DEVICE_TYPE_ESP32_WROVER_KIT @@ -102,7 +106,7 @@ menu "Demo" range 0 40 default 2 if DEVICE_TYPE_ESP32_DEVKITC #Use LED1 (blue LED) as status LED on DevKitC default 2 if DEVICE_TYPE_ESP32_ETHERNET_KIT - default 8 if DEVICE_TYPE_ESP32_C3_DEVKITM + default 8 if DEVICE_TYPE_ESP32_C3_DEVKITM || DEVICE_TYPE_ESP32_C2_DEVKITM default 26 if DEVICE_TYPE_ESP32_WROVER_KIT default 40 if DEVICE_TYPE_M5STACK help diff --git a/examples/all-clusters-app/esp32/main/idf_component.yml b/examples/all-clusters-app/esp32/main/idf_component.yml new file mode 100644 index 00000000000000..1c539b8eb57668 --- /dev/null +++ b/examples/all-clusters-app/esp32/main/idf_component.yml @@ -0,0 +1,2 @@ +dependencies: + espressif/led_strip: "^1.0.0-alpha" diff --git a/examples/all-clusters-app/esp32/main/include/AppTask.h b/examples/all-clusters-app/esp32/main/include/AppTask.h index 3dd8b0bf121a5c..779e7e990c12a7 100644 --- a/examples/all-clusters-app/esp32/main/include/AppTask.h +++ b/examples/all-clusters-app/esp32/main/include/AppTask.h @@ -18,7 +18,8 @@ */ #pragma once -#include "AppEvent.h" +#include +#include #include // Application-defined error codes in the CHIP_ERROR space. @@ -28,6 +29,7 @@ #define APP_ERROR_CREATE_TIMER_FAILED CHIP_APPLICATION_ERROR(0x04) #define APP_ERROR_START_TIMER_FAILED CHIP_APPLICATION_ERROR(0x05) #define APP_ERROR_STOP_TIMER_FAILED CHIP_APPLICATION_ERROR(0x06) +#define APP_ERROR_ALLOCATION_FAILED CHIP_APPLICATION_ERROR(0x07) class AppTask { @@ -37,10 +39,34 @@ class AppTask void PostEvent(const AppEvent * event); void ButtonEventHandler(uint8_t btnIdx, uint8_t btnAction); static void ButtonPressedAction(AppEvent * aEvent); + CHIP_ERROR LockInit(); private: CHIP_ERROR Init(); + + static void ActionInitiated(BoltLockManager::Action_t aAction, int32_t aActor); + static void ActionCompleted(BoltLockManager::Action_t aAction); + + void StartTimer(uint32_t aTimeoutMs); + void CancelTimer(void); + + static void FunctionTimerEventHandler(AppEvent * aEvent); + static void TimerEventHandler(TimerHandle_t xTimer); + void DispatchEvent(AppEvent * event); + + enum Function_t + { + kFunction_NoneSelected = 0, + kFunction_SoftwareUpdate = 0, + kFunction_StartBleAdv = 1, + kFunction_FactoryReset = 2, + kFunction_Invalid + } Function; + Function_t mFunction; + bool mFunctionTimerActive; + bool mSyncClusterToButtonAction; + static AppTask sAppTask; friend AppTask & GetAppTask(void); }; diff --git a/examples/all-clusters-app/esp32/main/include/DeviceWithDisplay.h b/examples/all-clusters-app/esp32/main/include/DeviceWithDisplay.h index 7a283fe7546ef5..3dc7b57f2af3fb 100644 --- a/examples/all-clusters-app/esp32/main/include/DeviceWithDisplay.h +++ b/examples/all-clusters-app/esp32/main/include/DeviceWithDisplay.h @@ -34,8 +34,6 @@ #include #include -#include -#include #include #include #include diff --git a/examples/all-clusters-app/esp32/main/main.cpp b/examples/all-clusters-app/esp32/main/main.cpp index 1447638bcce0b1..507fb3349a960d 100644 --- a/examples/all-clusters-app/esp32/main/main.cpp +++ b/examples/all-clusters-app/esp32/main/main.cpp @@ -115,6 +115,13 @@ static void InitServer(intptr_t context) emberAfEndpointEnableDisable(kNetworkCommissioningEndpointSecondary, false); InitBindingHandlers(); + + CHIP_ERROR err = GetAppTask().LockInit(); + if (err != CHIP_NO_ERROR) + { + ESP_LOGE(TAG, "Failed to initialize app task lock, err:%" CHIP_ERROR_FORMAT, err.Format()); + } + #if CONFIG_DEVICE_TYPE_M5STACK SetupPretendDevices(); #endif @@ -155,7 +162,7 @@ extern "C" void app_main() DeviceCallbacksDelegate::Instance().SetAppDelegate(&sAppDeviceCallbacksDelegate); if (error != CHIP_NO_ERROR) { - ESP_LOGE(TAG, "device.Init() failed: %s", ErrorStr(error)); + ESP_LOGE(TAG, "device.Init() failed: %" CHIP_ERROR_FORMAT, error.Format()); return; } @@ -173,7 +180,7 @@ extern "C" void app_main() error = GetAppTask().StartAppTask(); if (error != CHIP_NO_ERROR) { - ESP_LOGE(TAG, "GetAppTask().StartAppTask() failed : %s", ErrorStr(error)); + ESP_LOGE(TAG, "GetAppTask().StartAppTask() failed : %" CHIP_ERROR_FORMAT, error.Format()); } chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast(nullptr)); diff --git a/examples/all-clusters-app/esp32/sdkconfig.defaults b/examples/all-clusters-app/esp32/sdkconfig.defaults index 5fe66f692b842d..42d30f4d170b8d 100644 --- a/examples/all-clusters-app/esp32/sdkconfig.defaults +++ b/examples/all-clusters-app/esp32/sdkconfig.defaults @@ -59,3 +59,7 @@ CONFIG_ESPTOOLPY_FLASHSIZE="4MB" # Disable softap support by default CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n + +# This example uses the older version of RMT driver to work with both +# idf-v4.4.3 and idf-v5.0, so supressing the warnings by setting below option +CONFIG_RMT_SUPPRESS_DEPRECATE_WARN=y diff --git a/examples/all-clusters-app/esp32/sdkconfig.defaults.esp32c2 b/examples/all-clusters-app/esp32/sdkconfig.defaults.esp32c2 new file mode 100644 index 00000000000000..6cb90db4f55b9d --- /dev/null +++ b/examples/all-clusters-app/esp32/sdkconfig.defaults.esp32c2 @@ -0,0 +1,19 @@ +# Disable chip shell +CONFIG_ENABLE_CHIP_SHELL=n + +# CONFIG_ESP32_WIFI_IRAM_OPT is not set +# CONFIG_ESP32_WIFI_RX_IRAM_OPT is not set +CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y +CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH=y + +CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE=y + +CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=16 +CONFIG_LWIP_TCP_RECVMBOX_SIZE=8 + +CONFIG_BT_NIMBLE_ROLE_CENTRAL=n +CONFIG_BT_NIMBLE_ROLE_OBSERVER=n + +CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=4 +CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=8 +CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=16 diff --git a/examples/all-clusters-app/infineon/psoc6/src/AppTask.cpp b/examples/all-clusters-app/infineon/psoc6/src/AppTask.cpp index 4c871b546bacd5..49a95ec1d15821 100644 --- a/examples/all-clusters-app/infineon/psoc6/src/AppTask.cpp +++ b/examples/all-clusters-app/infineon/psoc6/src/AppTask.cpp @@ -23,8 +23,6 @@ #include "AppEvent.h" #include "ButtonHandler.h" #include "LEDWidget.h" -#include -#include #include #include #include @@ -408,8 +406,7 @@ void AppTask::OnOffUpdateClusterState(intptr_t context) uint8_t onoff = sLightLED.Get(); // write the new on/off value - EmberAfStatus status = - emberAfWriteServerAttribute(2, app::Clusters::OnOff::Id, ZCL_ON_OFF_ATTRIBUTE_ID, &onoff, ZCL_BOOLEAN_ATTRIBUTE_TYPE); + EmberAfStatus status = app::Clusters::OnOff::Attributes::OnOff::Set(2, onoff); if (status != EMBER_ZCL_STATUS_SUCCESS) { diff --git a/examples/all-clusters-app/infineon/psoc6/src/ClusterManager.cpp b/examples/all-clusters-app/infineon/psoc6/src/ClusterManager.cpp index a3ae6a44190c75..6659131ea8b9ab 100644 --- a/examples/all-clusters-app/infineon/psoc6/src/ClusterManager.cpp +++ b/examples/all-clusters-app/infineon/psoc6/src/ClusterManager.cpp @@ -24,8 +24,8 @@ #include "ClusterManager.h" #include "AppConfig.h" #include "LEDWidget.h" -#include #include +#include #include #include #include @@ -49,7 +49,7 @@ ClusterManager ClusterManager::sCluster; void ClusterManager::OnOnOffPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { - VerifyOrExit(attributeId == ZCL_ON_OFF_ATTRIBUTE_ID, + VerifyOrExit(attributeId == OnOff::Attributes::OnOff::Id, P6_LOG("Unhandled Attribute ID: '" ChipLogFormatMEI "'", ChipLogValueMEI(attributeId))); VerifyOrExit(endpointId == ENDPOINT_FIRST_IDX || endpointId == ENDPOINT_SECOND_IDX, P6_LOG("Unexpected EndPoint ID: `0x%02x'", endpointId)); @@ -69,7 +69,7 @@ void ClusterManager::OnLevelControlAttributeChangeCallback(EndpointId endpointId bool onOffState = mEndpointOnOffState[endpointId - 1]; uint8_t brightness = onOffState ? *value : 0; - VerifyOrExit(attributeId == ZCL_CURRENT_LEVEL_ATTRIBUTE_ID, + VerifyOrExit(attributeId == LevelControl::Attributes::CurrentLevel::Id, P6_LOG("Unhandled Attribute ID: '" ChipLogFormatMEI "'", ChipLogValueMEI(attributeId))); VerifyOrExit(endpointId == ENDPOINT_FIRST_IDX || endpointId == ENDPOINT_SECOND_IDX, P6_LOG("Unexpected EndPoint ID: `0x%02x'", endpointId)); @@ -90,7 +90,7 @@ void ClusterManager::OnColorControlAttributeChangeCallback(EndpointId endpointId if (endpointId == 1) { uint8_t hue, saturation; - /* If the Current Attribute is ZCL_COLOR_CONTROL_CURRENT_HUE_ATTRIBUTE_ID, read the saturation value and + /* If the Current Attribute is CurrentHue, read the saturation value and * set the color on Cluster LED using both Saturation and Hue. */ if (attributeId == ColorControl::Attributes::CurrentHue::Id) @@ -101,7 +101,7 @@ void ClusterManager::OnColorControlAttributeChangeCallback(EndpointId endpointId } else { - /* If the Current Attribute is ZCL_COLOR_CONTROL_CURRENT_SATURATION_ATTRIBUTE_ID, read the Hue value and + /* If the Current Attribute is CurrentSaturation, read the Hue value and * set the color on Cluster LED using both Saturation and Hue. */ saturation = *value; diff --git a/examples/all-clusters-app/infineon/psoc6/src/ZclCallbacks.cpp b/examples/all-clusters-app/infineon/psoc6/src/ZclCallbacks.cpp index f3fd7cf6689a70..9a439771026736 100644 --- a/examples/all-clusters-app/infineon/psoc6/src/ZclCallbacks.cpp +++ b/examples/all-clusters-app/infineon/psoc6/src/ZclCallbacks.cpp @@ -26,7 +26,6 @@ #include "ClusterManager.h" -#include #include #include #include diff --git a/examples/all-clusters-app/linux/AllClustersCommandDelegate.cpp b/examples/all-clusters-app/linux/AllClustersCommandDelegate.cpp index d7bebc065904f4..2c2f5385c57ba4 100644 --- a/examples/all-clusters-app/linux/AllClustersCommandDelegate.cpp +++ b/examples/all-clusters-app/linux/AllClustersCommandDelegate.cpp @@ -19,7 +19,6 @@ #include "AllClustersCommandDelegate.h" #include -#include #include #include #include @@ -183,13 +182,13 @@ void AllClustersAppCommandHandler::OnGeneralFaultEventHandler(uint32_t eventId) #if CHIP_CONFIG_TEST // On Linux Simulation, set following hardware faults statically. - ReturnOnFailure(previous.add(EMBER_ZCL_HARDWARE_FAULT_RADIO)); - ReturnOnFailure(previous.add(EMBER_ZCL_HARDWARE_FAULT_POWER_SOURCE)); + ReturnOnFailure(previous.add(EMBER_ZCL_HARDWARE_FAULT_ENUM_RADIO)); + ReturnOnFailure(previous.add(EMBER_ZCL_HARDWARE_FAULT_ENUM_POWER_SOURCE)); - ReturnOnFailure(current.add(EMBER_ZCL_HARDWARE_FAULT_RADIO)); - ReturnOnFailure(current.add(EMBER_ZCL_HARDWARE_FAULT_SENSOR)); - ReturnOnFailure(current.add(EMBER_ZCL_HARDWARE_FAULT_POWER_SOURCE)); - ReturnOnFailure(current.add(EMBER_ZCL_HARDWARE_FAULT_USER_INTERFACE_FAULT)); + ReturnOnFailure(current.add(EMBER_ZCL_HARDWARE_FAULT_ENUM_RADIO)); + ReturnOnFailure(current.add(EMBER_ZCL_HARDWARE_FAULT_ENUM_SENSOR)); + ReturnOnFailure(current.add(EMBER_ZCL_HARDWARE_FAULT_ENUM_POWER_SOURCE)); + ReturnOnFailure(current.add(EMBER_ZCL_HARDWARE_FAULT_ENUM_USER_INTERFACE_FAULT)); #endif Clusters::GeneralDiagnosticsServer::Instance().OnHardwareFaultsDetect(previous, current); } @@ -200,13 +199,13 @@ void AllClustersAppCommandHandler::OnGeneralFaultEventHandler(uint32_t eventId) #if CHIP_CONFIG_TEST // On Linux Simulation, set following radio faults statically. - ReturnOnFailure(previous.add(EMBER_ZCL_RADIO_FAULT_WI_FI_FAULT)); - ReturnOnFailure(previous.add(EMBER_ZCL_RADIO_FAULT_THREAD_FAULT)); + ReturnOnFailure(previous.add(EMBER_ZCL_RADIO_FAULT_ENUM_WI_FI_FAULT)); + ReturnOnFailure(previous.add(EMBER_ZCL_RADIO_FAULT_ENUM_THREAD_FAULT)); - ReturnOnFailure(current.add(EMBER_ZCL_RADIO_FAULT_WI_FI_FAULT)); - ReturnOnFailure(current.add(EMBER_ZCL_RADIO_FAULT_CELLULAR_FAULT)); - ReturnOnFailure(current.add(EMBER_ZCL_RADIO_FAULT_THREAD_FAULT)); - ReturnOnFailure(current.add(EMBER_ZCL_RADIO_FAULT_NFC_FAULT)); + ReturnOnFailure(current.add(EMBER_ZCL_RADIO_FAULT_ENUM_WI_FI_FAULT)); + ReturnOnFailure(current.add(EMBER_ZCL_RADIO_FAULT_ENUM_CELLULAR_FAULT)); + ReturnOnFailure(current.add(EMBER_ZCL_RADIO_FAULT_ENUM_THREAD_FAULT)); + ReturnOnFailure(current.add(EMBER_ZCL_RADIO_FAULT_ENUM_NFC_FAULT)); #endif Clusters::GeneralDiagnosticsServer::Instance().OnRadioFaultsDetect(previous, current); } @@ -217,12 +216,12 @@ void AllClustersAppCommandHandler::OnGeneralFaultEventHandler(uint32_t eventId) #if CHIP_CONFIG_TEST // On Linux Simulation, set following radio faults statically. - ReturnOnFailure(previous.add(EMBER_ZCL_NETWORK_FAULT_TYPE_HARDWARE_FAILURE)); - ReturnOnFailure(previous.add(EMBER_ZCL_NETWORK_FAULT_TYPE_NETWORK_JAMMED)); + ReturnOnFailure(previous.add(EMBER_ZCL_NETWORK_FAULT_ENUM_HARDWARE_FAILURE)); + ReturnOnFailure(previous.add(EMBER_ZCL_NETWORK_FAULT_ENUM_NETWORK_JAMMED)); - ReturnOnFailure(current.add(EMBER_ZCL_NETWORK_FAULT_TYPE_HARDWARE_FAILURE)); - ReturnOnFailure(current.add(EMBER_ZCL_NETWORK_FAULT_TYPE_NETWORK_JAMMED)); - ReturnOnFailure(current.add(EMBER_ZCL_NETWORK_FAULT_TYPE_CONNECTION_FAILED)); + ReturnOnFailure(current.add(EMBER_ZCL_NETWORK_FAULT_ENUM_HARDWARE_FAILURE)); + ReturnOnFailure(current.add(EMBER_ZCL_NETWORK_FAULT_ENUM_NETWORK_JAMMED)); + ReturnOnFailure(current.add(EMBER_ZCL_NETWORK_FAULT_ENUM_CONNECTION_FAILED)); #endif Clusters::GeneralDiagnosticsServer::Instance().OnNetworkFaultsDetect(previous, current); } diff --git a/examples/all-clusters-app/linux/README.md b/examples/all-clusters-app/linux/README.md index 8479fd480736fa..a84fd757703681 100644 --- a/examples/all-clusters-app/linux/README.md +++ b/examples/all-clusters-app/linux/README.md @@ -2,7 +2,8 @@ ## Compiling all-clusters-app for testing on Linux and Mac -To compile all-clusters-app on Intel Mac, run: +To compile all-clusters-app on Intel Mac, using the bootstrap-provided clang, +run: ``` $ ./scripts/run_in_build_env.sh "./scripts/build/build_examples.py --target darwin-x64-all-clusters-no-ble-asan-clang build" @@ -10,10 +11,16 @@ $ ./scripts/run_in_build_env.sh "./scripts/build/build_examples.py --target darw at the top level of the Matter tree. -To compile on an Arm Mac, run: +To compile all-clusters-app on Intel Mac, using the system clang, run: ``` -$ ./scripts/run_in_build_env.sh "./scripts/build/build_examples.py --target darwin-arm64-all-clusters-no-ble-asan-clang build" +$ ./scripts/run_in_build_env.sh "./scripts/build/build_examples.py --target darwin-x64-all-clusters-no-ble-asan build" +``` + +To compile on an Arm Mac, which can only be done using the system clang, run: + +``` +$ ./scripts/run_in_build_env.sh "./scripts/build/build_examples.py --target darwin-arm64-all-clusters-no-ble-asan build" ``` Similarly, to compile on Linux x86-64 run: diff --git a/examples/all-clusters-app/linux/main-common.cpp b/examples/all-clusters-app/linux/main-common.cpp index d106ee7c77c116..059ebf0af7f6e8 100644 --- a/examples/all-clusters-app/linux/main-common.cpp +++ b/examples/all-clusters-app/linux/main-common.cpp @@ -21,7 +21,6 @@ #include "WindowCoveringManager.h" #include "include/tv-callbacks.h" #include -#include #include #include #include diff --git a/examples/all-clusters-app/nrfconnect/main/AppTask.cpp b/examples/all-clusters-app/nrfconnect/main/AppTask.cpp index ea8dcfddc8f535..1d5a001dd1e9b1 100644 --- a/examples/all-clusters-app/nrfconnect/main/AppTask.cpp +++ b/examples/all-clusters-app/nrfconnect/main/AppTask.cpp @@ -26,8 +26,6 @@ #include #include -#include -#include #include #include #include @@ -332,16 +330,6 @@ void AppTask::FunctionTimerEventHandler(const AppEvent & event) } } -#ifdef CONFIG_MCUMGR_SMP_BT -void AppTask::RequestSMPAdvertisingStart(void) -{ - AppEvent event; - event.Type = AppEventType::StartSMPAdvertising; - event.Handler = [](const AppEvent &) { GetDFUOverSMP().StartBLEAdvertising(); }; - PostEvent(event); -} -#endif - void AppTask::FunctionHandler(const AppEvent & event) { if (event.ButtonEvent.PinNo != FUNCTION_BUTTON) diff --git a/examples/all-clusters-app/nrfconnect/main/ZclDoorLockCallbacks.cpp b/examples/all-clusters-app/nrfconnect/main/ZclDoorLockCallbacks.cpp index 0ab2703cb268b2..068b990444b4f5 100644 --- a/examples/all-clusters-app/nrfconnect/main/ZclDoorLockCallbacks.cpp +++ b/examples/all-clusters-app/nrfconnect/main/ZclDoorLockCallbacks.cpp @@ -30,15 +30,16 @@ LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL); // Provided some empty callbacks and replaced feature map // to simulate DoorLock endpoint for All-Clusters-App example -// without using kUsersManagement|kAccessSchedules|kRFIDCredentials|kPINCredentials +// without using kUser|kAccessSchedules|kRfidCredential|kPinCredential -bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const Optional & pinCode, DlOperationError & err) +bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const Optional & pinCode, + OperationErrorEnum & err) { return true; } bool emberAfPluginDoorLockOnDoorUnlockCommand(chip::EndpointId endpointId, const Optional & pinCode, - DlOperationError & err) + OperationErrorEnum & err) { return true; } @@ -48,7 +49,7 @@ void emberAfDoorLockClusterInitCallback(EndpointId endpoint) DoorLockServer::Instance().InitServer(endpoint); // Set FeatureMap to 0, default is: - // (kUsersManagement|kAccessSchedules|kRFIDCredentials|kPINCredentials) 0x113 + // (kUser|kAccessSchedules|kRfidCredential|kPinCredential) 0x113 EmberAfStatus status = DoorLock::Attributes::FeatureMap::Set(endpoint, 0); if (status != EMBER_ZCL_STATUS_SUCCESS) { diff --git a/examples/all-clusters-app/nrfconnect/main/include/AppEvent.h b/examples/all-clusters-app/nrfconnect/main/include/AppEvent.h index ccefe5d52bbdac..0a61ed41b083c3 100644 --- a/examples/all-clusters-app/nrfconnect/main/include/AppEvent.h +++ b/examples/all-clusters-app/nrfconnect/main/include/AppEvent.h @@ -33,7 +33,6 @@ enum class AppEventType : uint8_t UpdateLedState, IdentifyStart, IdentifyStop, - StartSMPAdvertising }; enum class FunctionEvent : uint8_t diff --git a/examples/all-clusters-app/nrfconnect/main/include/AppTask.h b/examples/all-clusters-app/nrfconnect/main/include/AppTask.h index 72e87e480f9fc1..a369eeefe55c6b 100644 --- a/examples/all-clusters-app/nrfconnect/main/include/AppTask.h +++ b/examples/all-clusters-app/nrfconnect/main/include/AppTask.h @@ -66,10 +66,6 @@ class AppTask static void FunctionTimerTimeoutCallback(k_timer * timer); static void UpdateStatusLED(); -#ifdef CONFIG_MCUMGR_SMP_BT - static void RequestSMPAdvertisingStart(void); -#endif - FunctionEvent mFunction = FunctionEvent::NoneSelected; bool mFunctionTimerActive = false; diff --git a/examples/all-clusters-app/nxp/mw320/main.cpp b/examples/all-clusters-app/nxp/mw320/main.cpp index a7f6478b1af9f7..23675050c73052 100644 --- a/examples/all-clusters-app/nxp/mw320/main.cpp +++ b/examples/all-clusters-app/nxp/mw320/main.cpp @@ -29,7 +29,8 @@ #include //#include //==> rm from TE7.5 -#include +#include +#include #include #include #include @@ -1143,13 +1144,15 @@ void task_test_main(void * param) is_on = !is_on; value = (uint16_t) is_on; // sync-up the switch attribute: - PRINTF("--> update ZCL_CURRENT_POSITION_ATTRIBUTE_ID [%d] \r\n", value); - emAfWriteAttribute(1, Clusters::Switch::Id, ZCL_CURRENT_POSITION_ATTRIBUTE_ID, (uint8_t *) &value, sizeof(value), true, - false); + PRINTF("--> update CurrentPosition [%d] \r\n", value); + Clusters::Switch::Attributes::CurrentPosition::Set(1, value); #ifdef SUPPORT_MANUAL_CTRL +#error \ + "This code thinks it's setting the OnOff attribute, but it's actually setting the NumberOfPositions attribute! And passing the wrong size for either case. Figure out what it's trying to do." // sync-up the Light attribute (for test event, OO.M.ManuallyControlled) - PRINTF("--> update [Clusters::Switch::Id]: ZCL_ON_OFF_ATTRIBUTE_ID [%d] \r\n", value); - emAfWriteAttribute(1, Clusters::Switch::Id, ZCL_ON_OFF_ATTRIBUTE_ID, (uint8_t *) &value, sizeof(value), true, false); + PRINTF("--> update [Clusters::Switch::Id]: OnOff::Id [%d] \r\n", value); + emAfWriteAttribute(1, Clusters::Switch::Id, Clusters::OnOff::Attributes::OnOff::Id, (uint8_t *) &value, sizeof(value), + true, false); #endif // SUPPORT_MANUAL_CTRL need2sync_sw_attr = false; @@ -1499,8 +1502,9 @@ bool lowPowerClusterSleep() static void OnOnOffPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { - VerifyOrExit(attributeId == ZCL_ON_OFF_ATTRIBUTE_ID, - ChipLogError(DeviceLayer, "Unhandled Attribute ID: '0x%04lx", attributeId)); + using namespace Clusters::OnOff::Attributes; + + VerifyOrExit(attributeId == OnOff::Id, ChipLogError(DeviceLayer, "Unhandled Attribute ID: '0x%04lx", attributeId)); VerifyOrExit(endpointId == 1 || endpointId == 2, ChipLogError(DeviceLayer, "Unexpected EndPoint ID: `0x%02x'", endpointId)); // At this point we can assume that value points to a bool value. @@ -1512,11 +1516,12 @@ static void OnOnOffPostAttributeChangeCallback(EndpointId endpointId, AttributeI static void OnSwitchAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { + using namespace Clusters::Switch::Attributes; + // auto * pimEngine = chip::app::InteractionModelEngine::GetInstance(); // bool do_sendrpt = false; - VerifyOrExit(attributeId == ZCL_CURRENT_POSITION_ATTRIBUTE_ID, - ChipLogError(DeviceLayer, "Unhandled Attribute ID: '0x%04lx", attributeId)); + VerifyOrExit(attributeId == CurrentPosition::Id, ChipLogError(DeviceLayer, "Unhandled Attribute ID: '0x%04lx", attributeId)); // Send the switch status report now /* for (uint32_t i = 0 ; iGetNumActiveReadHandlers() ; i++) { @@ -1549,20 +1554,23 @@ Identify_Time_t id_time[MAX_ENDPOINT_COUNT]; void IdentifyTimerHandler(System::Layer * systemLayer, void * appState) { + using namespace Clusters::Identify::Attributes; + Identify_Time_t * pidt = (Identify_Time_t *) appState; PRINTF(" -> %s(%u, %u) \r\n", __FUNCTION__, pidt->ep, pidt->identifyTimerCount); if (pidt->identifyTimerCount) { pidt->identifyTimerCount--; - emAfWriteAttribute(pidt->ep, Clusters::Identify::Id, ZCL_IDENTIFY_TIME_ATTRIBUTE_ID, (uint8_t *) &pidt->identifyTimerCount, - sizeof(identifyTimerCount), true, false); + IdentifyTime::Set(pidt->ep, pidt->identifyTimerCount); DeviceLayer::SystemLayer().StartTimer(System::Clock::Seconds16(1), IdentifyTimerHandler, pidt); } } static void OnIdentifyPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { - VerifyOrExit(attributeId == ZCL_IDENTIFY_TIME_ATTRIBUTE_ID, + using namespace Clusters::Identify::Attributes; + + VerifyOrExit(attributeId == IdentifyTime::Id, ChipLogError(DeviceLayer, "[%s] Unhandled Attribute ID: '0x%04lx", TAG, attributeId)); VerifyOrExit((endpointId < MAX_ENDPOINT_COUNT), ChipLogError(DeviceLayer, "[%s] EndPoint > max: [%u, %u]", TAG, endpointId, MAX_ENDPOINT_COUNT)); diff --git a/examples/all-clusters-app/telink/CMakeLists.txt b/examples/all-clusters-app/telink/CMakeLists.txt index 9b981dfc1766f9..afe18d1cb7c95d 100644 --- a/examples/all-clusters-app/telink/CMakeLists.txt +++ b/examples/all-clusters-app/telink/CMakeLists.txt @@ -55,7 +55,8 @@ target_sources(app PRIVATE ${ALL_CLUSTERS_COMMON_DIR}/src/binding-handler.cpp ${TELINK_COMMON}/util/src/LEDWidget.cpp ${TELINK_COMMON}/util/src/ButtonManager.cpp - ${TELINK_COMMON}/util/src/ThreadUtil.cpp) + ${TELINK_COMMON}/util/src/ThreadUtil.cpp + ${TELINK_COMMON}/util/src/PWMDevice.cpp) chip_configure_data_model(app INCLUDE_SERVER diff --git a/examples/all-clusters-app/telink/Readme.md b/examples/all-clusters-app/telink/Readme.md index f436507f9684b6..719656cbcb8484 100644 --- a/examples/all-clusters-app/telink/Readme.md +++ b/examples/all-clusters-app/telink/Readme.md @@ -66,14 +66,31 @@ The following buttons are available on **tlsr9518adk80d** board: ### LEDs -**Red** LED indicates current state of Thread network. It ables to be in +#### Indicate current state of Thread network + +**Red** LED indicates current state of Thread network. It is able to be in following states: | State | Description | | :-------------------------- | :--------------------------------------------------------------------------- | | Blinks with short pulses | Device is not commissioned to Thread, Thread is disabled | -| Blinls with frequent pulses | Device is commissioned, Thread enabled. Device trying to JOIN thread network | -| Blinks with whde pulses | Device commissioned and joined to thread network as CHILD | +| Blinks with frequent pulses | Device is commissioned, Thread enabled. Device trying to JOIN thread network | +| Blinks with wide pulses | Device commissioned and joined to thread network as CHILD | + +#### Indicate identify of device + +**Green** LED used to identify the device. The LED starts blinking when the +Identify command of the Identify cluster is received. The command's argument can +be used to specify the the effect. It is able to be in following effects: + +| Effect | Description | +| :------------------------------ | :------------------------------------------------------------------- | +| Blinks (200 ms on/200 ms off) | Blink (EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK) | +| Breathe (during 1000 ms) | Breathe (EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE) | +| Blinks (50 ms on/950 ms off) | Okay (EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY) | +| Blinks (1000 ms on/1000 ms off) | Channel Change (EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE) | +| Blinks (950 ms on/50 ms off) | Finish (EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_FINISH_EFFECT) | +| LED off | Stop (EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT) | ### CHIP tool commands diff --git a/examples/all-clusters-app/telink/include/AppConfig.h b/examples/all-clusters-app/telink/include/AppConfig.h index 27d2cc072c03fc..8eb990230520e6 100644 --- a/examples/all-clusters-app/telink/include/AppConfig.h +++ b/examples/all-clusters-app/telink/include/AppConfig.h @@ -29,6 +29,6 @@ #define BUTTON_PIN_2 0 // LEDs config -// System led config -#define SYSTEM_STATE_LED_PORT DEVICE_DT_GET(DT_NODELABEL(gpiob)) -#define SYSTEM_STATE_LED_PIN 7 +#define LEDS_PORT DEVICE_DT_GET(DT_NODELABEL(gpiob)) +#define SYSTEM_STATE_LED 7 +#define LIGHTING_PWM_SPEC_IDENTIFY_GREEN PWM_DT_SPEC_GET(DT_ALIAS(pwm_led3)) diff --git a/examples/all-clusters-app/telink/include/AppEvent.h b/examples/all-clusters-app/telink/include/AppEvent.h index 54250995e06ca8..b6e45d7d1526c8 100644 --- a/examples/all-clusters-app/telink/include/AppEvent.h +++ b/examples/all-clusters-app/telink/include/AppEvent.h @@ -32,6 +32,8 @@ struct AppEvent kEventType_Button = 0, kEventType_Timer, kEventType_UpdateLedState, + kEventType_IdentifyStart, + kEventType_IdentifyStop, }; uint16_t Type; diff --git a/examples/all-clusters-app/telink/include/AppTask.h b/examples/all-clusters-app/telink/include/AppTask.h index 7787968458b867..69e5d61669752b 100644 --- a/examples/all-clusters-app/telink/include/AppTask.h +++ b/examples/all-clusters-app/telink/include/AppTask.h @@ -20,6 +20,7 @@ #include "AppEvent.h" #include "LEDWidget.h" +#include "PWMDevice.h" #include @@ -28,22 +29,25 @@ #include struct k_timer; +struct Identify; class AppTask { public: - CHIP_ERROR StartApp(); + CHIP_ERROR StartApp(void); void PostEvent(AppEvent * event); + static void IdentifyEffectHandler(EmberAfIdentifyEffectIdentifier aEffect); private: friend AppTask & GetAppTask(void); + CHIP_ERROR Init(void); - CHIP_ERROR Init(); + static void ActionIdentifyStateUpdateHandler(k_timer * timer); void DispatchEvent(AppEvent * event); - static void UpdateStatusLED(); + static void UpdateStatusLED(void); static void LEDStateUpdateHandler(LEDWidget * ledWidget); static void FactoryResetButtonEventHandler(void); static void StartThreadButtonEventHandler(void); @@ -58,12 +62,14 @@ class AppTask static void StartThreadHandler(AppEvent * aEvent); static void StartBleAdvHandler(AppEvent * aEvent); static void UpdateLedStateEventHandler(AppEvent * aEvent); + static void UpdateIdentifyStateEventHandler(AppEvent * aEvent); static void InitButtons(void); static void ThreadProvisioningHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg); static AppTask sAppTask; + PWMDevice mPwmIdentifyLed; }; inline AppTask & GetAppTask(void) diff --git a/examples/all-clusters-app/telink/prj.conf b/examples/all-clusters-app/telink/prj.conf index 6c7821f2c87ec7..be2598cb6ade52 100644 --- a/examples/all-clusters-app/telink/prj.conf +++ b/examples/all-clusters-app/telink/prj.conf @@ -21,6 +21,9 @@ # enable GPIO CONFIG_GPIO=y +# enable PWM +CONFIG_PWM=y + # OpenThread configs CONFIG_OPENTHREAD_MTD=y CONFIG_OPENTHREAD_FTD=n diff --git a/examples/all-clusters-app/telink/src/AppTask.cpp b/examples/all-clusters-app/telink/src/AppTask.cpp index 9f831beecfaf9b..41abf953c3300b 100644 --- a/examples/all-clusters-app/telink/src/AppTask.cpp +++ b/examples/all-clusters-app/telink/src/AppTask.cpp @@ -29,8 +29,6 @@ #include "ThreadUtil.h" -#include -#include #include #include @@ -43,14 +41,48 @@ #include #include +#if CONFIG_CHIP_LIB_SHELL +#include +#include -LOG_MODULE_DECLARE(app); +static int cmd_telink_reboot(const struct shell * shell, size_t argc, char ** argv) +{ + ARG_UNUSED(argc); + ARG_UNUSED(argv); + + shell_print(shell, "Performing board reboot..."); + sys_reboot(); +} + +SHELL_STATIC_SUBCMD_SET_CREATE(sub_telink, SHELL_CMD(reboot, NULL, "Reboot board command", cmd_telink_reboot), + SHELL_SUBCMD_SET_END); +SHELL_CMD_REGISTER(telink, &sub_telink, "Telink commands", NULL); +#endif // CONFIG_CHIP_LIB_SHELL + +LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL); + +using namespace ::chip; +using namespace ::chip::app; +using namespace ::chip::Credentials; +using namespace ::chip::DeviceLayer; namespace { -constexpr int kFactoryResetTriggerTimeout = 2000; -constexpr int kAppEventQueueSize = 10; -constexpr uint8_t kButtonPushEvent = 1; -constexpr uint8_t kButtonReleaseEvent = 0; +constexpr int kFactoryResetTriggerTimeout = 2000; +constexpr int kAppEventQueueSize = 10; +constexpr uint8_t kButtonPushEvent = 1; +constexpr uint8_t kButtonReleaseEvent = 0; +constexpr EndpointId kEndpointId = 1; +constexpr uint8_t kDefaultMinLevel = 0; +constexpr uint8_t kDefaultMaxLevel = 254; +constexpr uint32_t kIdentifyBlinkRateMs = 200; +constexpr uint32_t kIdentifyOkayOnRateMs = 50; +constexpr uint32_t kIdentifyOkayOffRateMs = 950; +constexpr uint32_t kIdentifyFinishOnRateMs = 950; +constexpr uint32_t kIdentifyFinishOffRateMs = 50; +constexpr uint32_t kIdentifyChannelChangeRateMs = 1000; +constexpr uint32_t kIdentifyBreatheRateMs = 1000; + +const struct pwm_dt_spec sPwmIdentifySpecGreenLed = LIGHTING_PWM_SPEC_IDENTIFY_GREEN; K_MSGQ_DEFINE(sAppEventQueue, sizeof(AppEvent), kAppEventQueueSize, alignof(AppEvent)); k_timer sFactoryResetTimer; @@ -71,29 +103,11 @@ chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; void OnIdentifyTriggerEffect(Identify * identify) { - switch (identify->mCurrentEffectIdentifier) - { - case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK: - ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK"); - break; - case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE: - ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE"); - break; - case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY: - ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY"); - break; - case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE: - ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE"); - break; - default: - ChipLogProgress(Zcl, "No identifier effect"); - break; - } - return; + AppTask::IdentifyEffectHandler(identify->mCurrentEffectIdentifier); } Identify sIdentify = { - chip::EndpointId{ 1 }, + kEndpointId, [](Identify *) { ChipLogProgress(Zcl, "OnIdentifyStart"); }, [](Identify *) { ChipLogProgress(Zcl, "OnIdentifyStop"); }, EMBER_ZCL_IDENTIFY_IDENTIFY_TYPE_VISIBLE_LED, @@ -102,11 +116,6 @@ Identify sIdentify = { } // namespace -using namespace ::chip; -using namespace ::chip::Credentials; -using namespace ::chip::DeviceLayer; -using namespace ::chip::DeviceLayer::Internal; - AppTask AppTask::sAppTask; class AppFabricTableDelegate : public FabricTable::Delegate @@ -122,16 +131,14 @@ class AppFabricTableDelegate : public FabricTable::Delegate constexpr EndpointId kNetworkCommissioningEndpointSecondary = 0xFFFE; -CHIP_ERROR AppTask::Init() +CHIP_ERROR AppTask::Init(void) { - CHIP_ERROR ret; - LOG_INF("SW Version: %u, %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION, CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING); // Initialize status LED - LEDWidget::InitGpio(SYSTEM_STATE_LED_PORT); + LEDWidget::InitGpio(LEDS_PORT); LEDWidget::SetStateUpdateCallback(LEDStateUpdateHandler); - sStatusLED.Init(SYSTEM_STATE_LED_PIN); + sStatusLED.Init(SYSTEM_STATE_LED); UpdateStatusLED(); @@ -146,6 +153,16 @@ CHIP_ERROR AppTask::Init() (void) initParams.InitializeStaticResourcesBeforeServerInit(); chip::Server::GetInstance().Init(initParams); + // Initialize PWM Identify led + CHIP_ERROR err = sAppTask.mPwmIdentifyLed.Init(&sPwmIdentifySpecGreenLed, kDefaultMinLevel, kDefaultMaxLevel, kDefaultMaxLevel); + if (err != CHIP_NO_ERROR) + { + LOG_ERR("Green IDENTIFY PWM Device Init fail"); + return err; + } + + sAppTask.mPwmIdentifyLed.SetCallbacks(nullptr, nullptr, ActionIdentifyStateUpdateHandler); + // Initialize device attestation config SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); @@ -164,11 +181,11 @@ CHIP_ERROR AppTask::Init() ConfigurationMgr().LogDeviceConfig(); // Configure Bindings - ret = InitBindingHandlers(); - if (ret != CHIP_NO_ERROR) + err = InitBindingHandlers(); + if (err != CHIP_NO_ERROR) { LOG_ERR("InitBindingHandlers fail"); - return ret; + return err; } PrintOnboardingCodes(chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)); @@ -178,24 +195,24 @@ CHIP_ERROR AppTask::Init() // between the main and the CHIP threads. PlatformMgr().AddEventHandler(ChipEventHandler, 0); - ret = ConnectivityMgr().SetBLEDeviceName("TelinkApp"); - if (ret != CHIP_NO_ERROR) + err = ConnectivityMgr().SetBLEDeviceName("TelinkApp"); + if (err != CHIP_NO_ERROR) { LOG_ERR("SetBLEDeviceName fail"); - return ret; + return err; } - ret = chip::Server::GetInstance().GetFabricTable().AddFabricDelegate(new AppFabricTableDelegate); - if (ret != CHIP_NO_ERROR) + err = chip::Server::GetInstance().GetFabricTable().AddFabricDelegate(new AppFabricTableDelegate); + if (err != CHIP_NO_ERROR) { LOG_ERR("AppFabricTableDelegate fail"); - return ret; + return err; } return CHIP_NO_ERROR; } -CHIP_ERROR AppTask::StartApp() +CHIP_ERROR AppTask::StartApp(void) { CHIP_ERROR err = Init(); @@ -219,6 +236,56 @@ CHIP_ERROR AppTask::StartApp() } } +void AppTask::IdentifyEffectHandler(EmberAfIdentifyEffectIdentifier aEffect) +{ + AppEvent event; + event.Type = AppEvent::kEventType_IdentifyStart; + + switch (aEffect) + { + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK: + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK"); + event.Handler = [](AppEvent *) { + sAppTask.mPwmIdentifyLed.InitiateBlinkAction(kIdentifyBlinkRateMs, kIdentifyBlinkRateMs); + }; + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE: + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE"); + event.Handler = [](AppEvent *) { + sAppTask.mPwmIdentifyLed.InitiateBreatheAction(PWMDevice::kBreatheType_Both, kIdentifyBreatheRateMs); + }; + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY: + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY"); + event.Handler = [](AppEvent *) { + sAppTask.mPwmIdentifyLed.InitiateBlinkAction(kIdentifyOkayOnRateMs, kIdentifyOkayOffRateMs); + }; + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE: + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE"); + event.Handler = [](AppEvent *) { + sAppTask.mPwmIdentifyLed.InitiateBlinkAction(kIdentifyChannelChangeRateMs, kIdentifyChannelChangeRateMs); + }; + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_FINISH_EFFECT: + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_FINISH_EFFECT"); + event.Handler = [](AppEvent *) { + sAppTask.mPwmIdentifyLed.InitiateBlinkAction(kIdentifyFinishOnRateMs, kIdentifyFinishOffRateMs); + }; + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT: + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT"); + event.Handler = [](AppEvent *) { sAppTask.mPwmIdentifyLed.StopAction(); }; + event.Type = AppEvent::kEventType_IdentifyStop; + break; + default: + ChipLogProgress(Zcl, "No identifier effect"); + return; + } + + sAppTask.PostEvent(&event); +} + void AppTask::FactoryResetButtonEventHandler(void) { AppEvent event; @@ -259,7 +326,7 @@ void AppTask::StartThreadHandler(AppEvent * aEvent) if (!chip::DeviceLayer::ConnectivityMgr().IsThreadProvisioned()) { // Switch context from BLE to Thread - BLEManagerImpl sInstance; + Internal::BLEManagerImpl sInstance; sInstance.SwitchToIeee802154(); StartDefaultThreadNetwork(); } @@ -319,7 +386,7 @@ void AppTask::LEDStateUpdateHandler(LEDWidget * ledWidget) sAppTask.PostEvent(&event); } -void AppTask::UpdateStatusLED() +void AppTask::UpdateStatusLED(void) { if (sIsThreadProvisioned && sIsThreadEnabled) { @@ -365,10 +432,21 @@ void AppTask::ChipEventHandler(const ChipDeviceEvent * event, intptr_t /* arg */ } } +void AppTask::ActionIdentifyStateUpdateHandler(k_timer * timer) +{ + AppEvent event; + event.Type = AppEvent::kEventType_UpdateLedState; + event.Handler = UpdateIdentifyStateEventHandler; + sAppTask.PostEvent(&event); +} + +void AppTask::UpdateIdentifyStateEventHandler(AppEvent * aEvent) +{ + sAppTask.mPwmIdentifyLed.UpdateAction(); +} + void AppTask::PostEvent(AppEvent * aEvent) { - if (!aEvent) - return; if (k_msgq_put(&sAppEventQueue, aEvent, K_NO_WAIT) != 0) { LOG_INF("PostEvent fail"); @@ -377,8 +455,6 @@ void AppTask::PostEvent(AppEvent * aEvent) void AppTask::DispatchEvent(AppEvent * aEvent) { - if (!aEvent) - return; if (aEvent->Handler) { aEvent->Handler(aEvent); diff --git a/examples/all-clusters-app/telink/src/ZclDoorLockCallbacks.cpp b/examples/all-clusters-app/telink/src/ZclDoorLockCallbacks.cpp index edaa86e44d5125..068b990444b4f5 100644 --- a/examples/all-clusters-app/telink/src/ZclDoorLockCallbacks.cpp +++ b/examples/all-clusters-app/telink/src/ZclDoorLockCallbacks.cpp @@ -26,19 +26,20 @@ using namespace ::chip; using namespace ::chip::app::Clusters; using namespace ::chip::app::Clusters::DoorLock; -LOG_MODULE_DECLARE(app, CONFIG_MATTER_LOG_LEVEL); +LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL); // Provided some empty callbacks and replaced feature map // to simulate DoorLock endpoint for All-Clusters-App example -// without using kUsersManagement|kAccessSchedules|kRFIDCredentials|kPINCredentials +// without using kUser|kAccessSchedules|kRfidCredential|kPinCredential -bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const Optional & pinCode, DlOperationError & err) +bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const Optional & pinCode, + OperationErrorEnum & err) { return true; } bool emberAfPluginDoorLockOnDoorUnlockCommand(chip::EndpointId endpointId, const Optional & pinCode, - DlOperationError & err) + OperationErrorEnum & err) { return true; } @@ -48,7 +49,7 @@ void emberAfDoorLockClusterInitCallback(EndpointId endpoint) DoorLockServer::Instance().InitServer(endpoint); // Set FeatureMap to 0, default is: - // (kUsersManagement|kAccessSchedules|kRFIDCredentials|kPINCredentials) 0x113 + // (kUser|kAccessSchedules|kRfidCredential|kPinCredential) 0x113 EmberAfStatus status = DoorLock::Attributes::FeatureMap::Set(endpoint, 0); if (status != EMBER_ZCL_STATUS_SUCCESS) { diff --git a/examples/all-clusters-app/telink/src/main.cpp b/examples/all-clusters-app/telink/src/main.cpp index dd1480f6677e45..4061e239ee8fbc 100644 --- a/examples/all-clusters-app/telink/src/main.cpp +++ b/examples/all-clusters-app/telink/src/main.cpp @@ -23,7 +23,7 @@ #include -LOG_MODULE_REGISTER(app); +LOG_MODULE_REGISTER(app, CONFIG_CHIP_APP_LOG_LEVEL); using namespace ::chip; using namespace ::chip::Inet; diff --git a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter index 41265fd93aa923..f95448b7c206f4 100644 --- a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter +++ b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter @@ -6,6 +6,11 @@ struct LabelStruct { char_string<16> value = 1; } +struct ApplicationStruct { + int16u catalogVendorID = 0; + char_string applicationID = 1; +} + server cluster Identify = 3 { enum IdentifyEffectIdentifier : ENUM8 { kBlink = 0; @@ -102,17 +107,21 @@ server cluster Groups = 4 { } server cluster Scenes = 5 { + bitmap SceneFeatures : BITMAP32 { + kSceneNames = 0x1; + } + bitmap ScenesCopyMode : BITMAP8 { kCopyAllScenes = 0x1; } struct ExtensionFieldSet { - cluster_id clusterId = 0; + cluster_id clusterID = 0; AttributeValuePair attributeValueList[] = 1; } struct AttributeValuePair { - optional attrib_id attributeId = 0; + optional attrib_id attributeID = 0; int8u attributeValue[] = 1; } @@ -125,52 +134,52 @@ server cluster Scenes = 5 { readonly attribute int16u clusterRevision = 65533; request struct AddSceneRequest { - group_id groupId = 0; - INT8U sceneId = 1; + group_id groupID = 0; + INT8U sceneID = 1; INT16U transitionTime = 2; CHAR_STRING sceneName = 3; ExtensionFieldSet extensionFieldSets[] = 4; } request struct ViewSceneRequest { - group_id groupId = 0; - INT8U sceneId = 1; + group_id groupID = 0; + INT8U sceneID = 1; } request struct RemoveSceneRequest { - group_id groupId = 0; - INT8U sceneId = 1; + group_id groupID = 0; + INT8U sceneID = 1; } request struct RemoveAllScenesRequest { - group_id groupId = 0; + group_id groupID = 0; } request struct StoreSceneRequest { - group_id groupId = 0; - INT8U sceneId = 1; + group_id groupID = 0; + INT8U sceneID = 1; } request struct RecallSceneRequest { - group_id groupId = 0; - INT8U sceneId = 1; + group_id groupID = 0; + INT8U sceneID = 1; optional nullable INT16U transitionTime = 2; } request struct GetSceneMembershipRequest { - group_id groupId = 0; + group_id groupID = 0; } response struct AddSceneResponse = 0 { ENUM8 status = 0; - group_id groupId = 1; - INT8U sceneId = 2; + group_id groupID = 1; + INT8U sceneID = 2; } response struct ViewSceneResponse = 1 { ENUM8 status = 0; - group_id groupId = 1; - INT8U sceneId = 2; + group_id groupID = 1; + INT8U sceneID = 2; optional INT16U transitionTime = 3; optional CHAR_STRING sceneName = 4; optional ExtensionFieldSet extensionFieldSets[] = 5; @@ -178,25 +187,25 @@ server cluster Scenes = 5 { response struct RemoveSceneResponse = 2 { ENUM8 status = 0; - group_id groupId = 1; - INT8U sceneId = 2; + group_id groupID = 1; + INT8U sceneID = 2; } response struct RemoveAllScenesResponse = 3 { ENUM8 status = 0; - group_id groupId = 1; + group_id groupID = 1; } response struct StoreSceneResponse = 4 { ENUM8 status = 0; - group_id groupId = 1; - INT8U sceneId = 2; + group_id groupID = 1; + INT8U sceneID = 2; } response struct GetSceneMembershipResponse = 6 { ENUM8 status = 0; nullable INT8U capacity = 1; - group_id groupId = 2; + group_id groupID = 2; optional INT8U sceneList[] = 3; } @@ -239,10 +248,6 @@ server cluster OnOff = 6 { kLighting = 0x1; } - bitmap SceneFeatures : BITMAP32 { - kSceneNames = 0x1; - } - readonly attribute boolean onOff = 0; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -730,7 +735,7 @@ server cluster PowerSourceConfiguration = 46 { server cluster PowerSource = 47 { enum BatChargeFault : ENUM8 { - kUnspecfied = 0; + kUnspecified = 0; kAmbientTooHot = 1; kAmbientTooCold = 2; kBatteryTooHot = 3; @@ -770,7 +775,7 @@ server cluster PowerSource = 47 { } enum PowerSourceStatus : ENUM8 { - kUnspecfied = 0; + kUnspecified = 0; kActive = 1; kStandby = 2; kUnavailable = 3; @@ -1052,7 +1057,7 @@ server cluster GeneralDiagnostics = 51 { kSoftwareReset = 6; } - enum HardwareFault : ENUM8 { + enum HardwareFaultEnum : ENUM8 { kUnspecified = 0; kRadio = 1; kSensor = 2; @@ -1066,7 +1071,7 @@ server cluster GeneralDiagnostics = 51 { kTamperDetected = 10; } - enum InterfaceType : ENUM8 { + enum InterfaceTypeEnum : ENUM8 { kUnspecified = 0; kWiFi = 1; kEthernet = 2; @@ -1074,14 +1079,14 @@ server cluster GeneralDiagnostics = 51 { kThread = 4; } - enum NetworkFaultType : ENUM8 { + enum NetworkFaultEnum : ENUM8 { kUnspecified = 0; kHardwareFailure = 1; kNetworkJammed = 2; kConnectionFailed = 3; } - enum RadioFault : ENUM8 { + enum RadioFaultEnum : ENUM8 { kUnspecified = 0; kWiFiFault = 1; kCellularFault = 2; @@ -1099,22 +1104,22 @@ server cluster GeneralDiagnostics = 51 { octet_string<8> hardwareAddress = 4; octet_string IPv4Addresses[] = 5; octet_string IPv6Addresses[] = 6; - InterfaceType type = 7; + InterfaceTypeEnum type = 7; } critical event HardwareFaultChange = 0 { - HardwareFault current[] = 0; - HardwareFault previous[] = 1; + HardwareFaultEnum current[] = 0; + HardwareFaultEnum previous[] = 1; } critical event RadioFaultChange = 1 { - RadioFault current[] = 0; - RadioFault previous[] = 1; + RadioFaultEnum current[] = 0; + RadioFaultEnum previous[] = 1; } critical event NetworkFaultChange = 2 { - NetworkFaultType current[] = 0; - NetworkFaultType previous[] = 1; + NetworkFaultEnum current[] = 0; + NetworkFaultEnum previous[] = 1; } critical event BootReason = 3 { @@ -1294,6 +1299,11 @@ server cluster WiFiNetworkDiagnostics = 54 { kAx = 5; } + bitmap WiFiNetworkDiagnosticsFeature : BITMAP32 { + kPacketCounts = 0x1; + kErrorCounts = 0x2; + } + info event Disconnection = 0 { INT16U reasonCode = 0; } @@ -1317,7 +1327,7 @@ server cluster WiFiNetworkDiagnostics = 54 { } server cluster EthernetNetworkDiagnostics = 55 { - enum PHYRate : ENUM8 { + enum PHYRateEnum : ENUM8 { kRate10M = 0; kRate100M = 1; kRate1G = 2; @@ -1330,7 +1340,12 @@ server cluster EthernetNetworkDiagnostics = 55 { kRate400G = 9; } - readonly attribute nullable PHYRate PHYRate = 0; + bitmap EthernetNetworkDiagnosticsFeature : BITMAP32 { + kPacketCounts = 0x1; + kErrorCounts = 0x2; + } + + readonly attribute nullable PHYRateEnum PHYRate = 0; readonly attribute nullable boolean fullDuplex = 1; readonly attribute int64u packetRxCount = 2; readonly attribute int64u packetTxCount = 3; @@ -1391,7 +1406,7 @@ server cluster Switch = 59 { } server cluster AdministratorCommissioning = 60 { - enum CommissioningWindowStatus : ENUM8 { + enum CommissioningWindowStatusEnum : ENUM8 { kWindowNotOpen = 0; kEnhancedWindowOpen = 1; kBasicWindowOpen = 2; @@ -1403,7 +1418,7 @@ server cluster AdministratorCommissioning = 60 { kWindowNotOpen = 4; } - readonly attribute CommissioningWindowStatus windowStatus = 0; + readonly attribute CommissioningWindowStatusEnum windowStatus = 0; readonly attribute nullable fabric_idx adminFabricIndex = 1; readonly attribute nullable int16u adminVendorId = 2; readonly attribute bitmap32 featureMap = 65532; @@ -1422,8 +1437,13 @@ server cluster AdministratorCommissioning = 60 { } server cluster OperationalCredentials = 62 { - enum OperationalCertStatus : ENUM8 { - kSuccess = 0; + enum CertificateChainTypeEnum : ENUM8 { + kDACCertificate = 1; + kPAICertificate = 2; + } + + enum NodeOperationalCertStatusEnum : ENUM8 { + kOk = 0; kInvalidPublicKey = 1; kInvalidNodeOpId = 2; kInvalidNOC = 3; @@ -1441,17 +1461,17 @@ server cluster OperationalCredentials = 62 { fabric_idx fabricIndex = 254; } - fabric_scoped struct FabricDescriptor { + fabric_scoped struct FabricDescriptorStruct { octet_string<65> rootPublicKey = 1; - vendor_id vendorId = 2; - fabric_id fabricId = 3; - node_id nodeId = 4; + vendor_id vendorID = 2; + fabric_id fabricID = 3; + node_id nodeID = 4; char_string<32> label = 5; fabric_idx fabricIndex = 254; } readonly attribute access(read: administer) NOCStruct NOCs[] = 0; - readonly attribute FabricDescriptor fabrics[] = 1; + readonly attribute FabricDescriptorStruct fabrics[] = 1; readonly attribute int8u supportedFabrics = 2; readonly attribute int8u commissionedFabrics = 3; readonly attribute OCTET_STRING trustedRootCertificates[] = 4; @@ -1464,7 +1484,7 @@ server cluster OperationalCredentials = 62 { } request struct CertificateChainRequestRequest { - INT8U certificateType = 0; + CertificateChainTypeEnum certificateType = 0; } request struct CSRRequestRequest { @@ -1494,12 +1514,12 @@ server cluster OperationalCredentials = 62 { } request struct AddTrustedRootCertificateRequest { - OCTET_STRING rootCertificate = 0; + OCTET_STRING rootCACertificate = 0; } response struct AttestationResponse = 1 { OCTET_STRING attestationElements = 0; - OCTET_STRING signature = 1; + OCTET_STRING attestationSignature = 1; } response struct CertificateChainResponse = 3 { @@ -1512,7 +1532,7 @@ server cluster OperationalCredentials = 62 { } response struct NOCResponse = 8 { - OperationalCertStatus statusCode = 0; + NodeOperationalCertStatusEnum statusCode = 0; optional fabric_idx fabricIndex = 1; optional CHAR_STRING debugText = 2; } @@ -1650,7 +1670,7 @@ server cluster ModeSelect = 80 { } server cluster DoorLock = 257 { - enum DlAlarmCode : ENUM8 { + enum AlarmCodeEnum : ENUM8 { kLockJammed = 0; kLockFactoryReset = 1; kLockRadioPowerCycled = 3; @@ -1661,13 +1681,13 @@ server cluster DoorLock = 257 { kForcedUser = 8; } - enum DlCredentialRule : ENUM8 { + enum CredentialRuleEnum : ENUM8 { kSingle = 0; - kDouble = 1; + kDual = 1; kTri = 2; } - enum DlCredentialType : ENUM8 { + enum CredentialTypeEnum : ENUM8 { kProgrammingPIN = 0; kPin = 1; kRfid = 2; @@ -1676,40 +1696,12 @@ server cluster DoorLock = 257 { kFace = 5; } - enum DlDataOperationType : ENUM8 { + enum DataOperationTypeEnum : ENUM8 { kAdd = 0; kClear = 1; kModify = 2; } - enum DlDoorState : ENUM8 { - kDoorOpen = 0; - kDoorClosed = 1; - kDoorJammed = 2; - kDoorForcedOpen = 3; - kDoorUnspecifiedError = 4; - kDoorAjar = 5; - } - - enum DlLockDataType : ENUM8 { - kUnspecified = 0; - kProgrammingCode = 1; - kUserIndex = 2; - kWeekDaySchedule = 3; - kYearDaySchedule = 4; - kHolidaySchedule = 5; - kPin = 6; - kRfid = 7; - kFingerprint = 8; - } - - enum DlLockOperationType : ENUM8 { - kLock = 0; - kUnlock = 1; - kNonAccessUserEvent = 2; - kForcedUserEvent = 3; - } - enum DlLockState : ENUM8 { kNotFullyLocked = 0; kLocked = 1; @@ -1730,35 +1722,6 @@ server cluster DoorLock = 257 { kDoorFurniture = 10; } - enum DlOperatingMode : ENUM8 { - kNormal = 0; - kVacation = 1; - kPrivacy = 2; - kNoRemoteLockUnlock = 3; - kPassage = 4; - } - - enum DlOperationError : ENUM8 { - kUnspecified = 0; - kInvalidCredential = 1; - kDisabledUserDenied = 2; - kRestricted = 3; - kInsufficientBattery = 4; - } - - enum DlOperationSource : ENUM8 { - kUnspecified = 0; - kManual = 1; - kProprietaryRemote = 2; - kKeypad = 3; - kAuto = 4; - kButton = 5; - kSchedule = 6; - kRemote = 7; - kRfid = 8; - kBiometric = 9; - } - enum DlStatus : ENUM8 { kSuccess = 0; kFailure = 1; @@ -1769,25 +1732,6 @@ server cluster DoorLock = 257 { kNotFound = 139; } - enum DlUserStatus : ENUM8 { - kAvailable = 0; - kOccupiedEnabled = 1; - kOccupiedDisabled = 3; - } - - enum DlUserType : ENUM8 { - kUnrestrictedUser = 0; - kYearDayScheduleUser = 1; - kWeekDayScheduleUser = 2; - kProgrammingUser = 3; - kNonAccessUser = 4; - kForcedUser = 5; - kDisposableUser = 6; - kExpiringUser = 7; - kScheduleRestrictedUser = 8; - kRemoteOnlyUser = 9; - } - enum DoorLockOperationEventCode : ENUM8 { kUnknownOrMfgSpecific = 0; kLock = 1; @@ -1839,19 +1783,83 @@ server cluster DoorLock = 257 { kNotSupported = 255; } - bitmap DlCredentialRuleMask : BITMAP8 { - kSingle = 0x1; - kDual = 0x2; - kTri = 0x4; + enum DoorStateEnum : ENUM8 { + kDoorOpen = 0; + kDoorClosed = 1; + kDoorJammed = 2; + kDoorForcedOpen = 3; + kDoorUnspecifiedError = 4; + kDoorAjar = 5; } - bitmap DlCredentialRulesSupport : BITMAP8 { - kSingle = 0x1; - kDual = 0x2; - kTri = 0x4; + enum LockDataTypeEnum : ENUM8 { + kUnspecified = 0; + kProgrammingCode = 1; + kUserIndex = 2; + kWeekDaySchedule = 3; + kYearDaySchedule = 4; + kHolidaySchedule = 5; + kPin = 6; + kRfid = 7; + kFingerprint = 8; + } + + enum LockOperationTypeEnum : ENUM8 { + kLock = 0; + kUnlock = 1; + kNonAccessUserEvent = 2; + kForcedUserEvent = 3; + } + + enum OperatingModeEnum : ENUM8 { + kNormal = 0; + kVacation = 1; + kPrivacy = 2; + kNoRemoteLockUnlock = 3; + kPassage = 4; + } + + enum OperationErrorEnum : ENUM8 { + kUnspecified = 0; + kInvalidCredential = 1; + kDisabledUserDenied = 2; + kRestricted = 3; + kInsufficientBattery = 4; + } + + enum OperationSourceEnum : ENUM8 { + kUnspecified = 0; + kManual = 1; + kProprietaryRemote = 2; + kKeypad = 3; + kAuto = 4; + kButton = 5; + kSchedule = 6; + kRemote = 7; + kRfid = 8; + kBiometric = 9; + } + + enum UserStatusEnum : ENUM8 { + kAvailable = 0; + kOccupiedEnabled = 1; + kOccupiedDisabled = 3; + } + + enum UserTypeEnum : ENUM8 { + kUnrestrictedUser = 0; + kYearDayScheduleUser = 1; + kWeekDayScheduleUser = 2; + kProgrammingUser = 3; + kNonAccessUser = 4; + kForcedUser = 5; + kDisposableUser = 6; + kExpiringUser = 7; + kScheduleRestrictedUser = 8; + kRemoteOnlyUser = 9; } - bitmap DlDaysMaskMap : BITMAP8 { + bitmap DaysMaskMap : BITMAP8 { kSunday = 0x1; kMonday = 0x2; kTuesday = 0x4; @@ -1861,6 +1869,18 @@ server cluster DoorLock = 257 { kSaturday = 0x40; } + bitmap DlCredentialRuleMask : BITMAP8 { + kSingle = 0x1; + kDual = 0x2; + kTri = 0x4; + } + + bitmap DlCredentialRulesSupport : BITMAP8 { + kSingle = 0x1; + kDual = 0x2; + kTri = 0x4; + } + bitmap DlDefaultConfigurationRegister : BITMAP16 { kEnableLocalProgrammingEnabled = 0x1; kKeypadInterfaceDefaultAccessEnabled = 0x2; @@ -1965,56 +1985,56 @@ server cluster DoorLock = 257 { } bitmap DoorLockFeature : BITMAP32 { - kPINCredentials = 0x1; - kRFIDCredentials = 0x2; + kPinCredential = 0x1; + kRfidCredential = 0x2; kFingerCredentials = 0x4; kLogging = 0x8; - kWeekDaySchedules = 0x10; + kWeekDayAccessSchedules = 0x10; kDoorPositionSensor = 0x20; kFaceCredentials = 0x40; - kCredentialsOTA = 0x80; - kUsersManagement = 0x100; - kNotifications = 0x200; - kYearDaySchedules = 0x400; + kCredentialsOverTheAirAccess = 0x80; + kUser = 0x100; + kNotification = 0x200; + kYearDayAccessSchedules = 0x400; kHolidaySchedules = 0x800; } - struct DlCredential { - DlCredentialType credentialType = 0; + struct CredentialStruct { + CredentialTypeEnum credentialType = 0; int16u credentialIndex = 1; } critical event DoorLockAlarm = 0 { - DlAlarmCode alarmCode = 0; + AlarmCodeEnum alarmCode = 0; } critical event DoorStateChange = 1 { - DlDoorState doorState = 0; + DoorStateEnum doorState = 0; } critical event LockOperation = 2 { - DlLockOperationType lockOperationType = 0; - DlOperationSource operationSource = 1; + LockOperationTypeEnum lockOperationType = 0; + OperationSourceEnum operationSource = 1; nullable INT16U userIndex = 2; nullable fabric_idx fabricIndex = 3; nullable NODE_ID sourceNode = 4; - optional nullable DlCredential credentials[] = 5; + optional nullable CredentialStruct credentials[] = 5; } critical event LockOperationError = 3 { - DlLockOperationType lockOperationType = 0; - DlOperationSource operationSource = 1; - DlOperationError operationError = 2; + LockOperationTypeEnum lockOperationType = 0; + OperationSourceEnum operationSource = 1; + OperationErrorEnum operationError = 2; nullable INT16U userIndex = 3; nullable fabric_idx fabricIndex = 4; nullable NODE_ID sourceNode = 5; - optional nullable DlCredential credentials[] = 6; + optional nullable CredentialStruct credentials[] = 6; } info event LockUserChange = 4 { - DlLockDataType lockDataType = 0; - DlDataOperationType dataOperationType = 1; - DlOperationSource operationSource = 2; + LockDataTypeEnum lockDataType = 0; + DataOperationTypeEnum dataOperationType = 1; + OperationSourceEnum operationSource = 2; nullable INT16U userIndex = 3; nullable fabric_idx fabricIndex = 4; nullable NODE_ID sourceNode = 5; @@ -2025,17 +2045,17 @@ server cluster DoorLock = 257 { readonly attribute DlLockType lockType = 1; readonly attribute boolean actuatorEnabled = 2; attribute access(write: manage) int32u autoRelockTime = 35; - attribute access(write: manage) DlOperatingMode operatingMode = 37; + attribute access(write: manage) OperatingModeEnum operatingMode = 37; readonly attribute DlSupportedOperatingModes supportedOperatingModes = 38; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; request struct LockDoorRequest { - optional OCTET_STRING pinCode = 0; + optional OCTET_STRING PINCode = 0; } request struct UnlockDoorRequest { - optional OCTET_STRING pinCode = 0; + optional OCTET_STRING PINCode = 0; } timed command LockDoor(LockDoorRequest): DefaultSuccess = 0; @@ -2164,6 +2184,16 @@ server cluster PumpConfigurationAndControl = 512 { kLocal = 3; } + bitmap PumpFeature : BITMAP32 { + kConstantPressure = 0x1; + kCompensatedPressure = 0x2; + kConstantFlow = 0x4; + kConstantSpeed = 0x8; + kConstantTemperature = 0x10; + kAutomatic = 0x20; + kLocal = 0x40; + } + bitmap PumpStatus : BITMAP16 { kDeviceFault = 0x1; kSupplyfault = 0x2; @@ -2230,6 +2260,8 @@ server cluster PumpConfigurationAndControl = 512 { readonly attribute nullable int16s maxPressure = 0; readonly attribute nullable int16u maxSpeed = 1; readonly attribute nullable int16u maxFlow = 2; + readonly attribute nullable int16s minConstPressure = 3; + readonly attribute nullable int16s maxConstPressure = 4; readonly attribute PumpOperationMode effectiveOperationMode = 17; readonly attribute PumpControlMode effectiveControlMode = 18; readonly attribute nullable int16s capacity = 19; @@ -2240,9 +2272,9 @@ server cluster PumpConfigurationAndControl = 512 { server cluster Thermostat = 513 { enum SetpointAdjustMode : ENUM8 { - kHeatSetpoint = 0; - kCoolSetpoint = 1; - kHeatAndCoolSetpoints = 2; + kHeat = 0; + kCool = 1; + kBoth = 2; } enum ThermostatControlSequence : ENUM8 { @@ -2265,9 +2297,11 @@ server cluster Thermostat = 513 { kAuto = 1; kCool = 3; kHeat = 4; - kEmergencyHeating = 5; + kEmergencyHeat = 5; kPrecooling = 6; kFanOnly = 7; + kDry = 8; + kSleep = 9; } bitmap DayOfWeek : BITMAP8 { @@ -2278,21 +2312,21 @@ server cluster Thermostat = 513 { kThursday = 0x10; kFriday = 0x20; kSaturday = 0x40; - kAwayOrVacation = 0x80; + kAway = 0x80; } bitmap ModeForSequence : BITMAP8 { - kHeatSetpointFieldPresent = 0x1; - kCoolSetpointFieldPresent = 0x2; + kHeatSetpointPresent = 0x1; + kCoolSetpointPresent = 0x2; } bitmap ThermostatFeature : BITMAP32 { kHeating = 0x1; kCooling = 0x2; kOccupancy = 0x4; - kSchedule = 0x8; + kScheduleConfiguration = 0x8; kSetback = 0x10; - kAutomode = 0x20; + kAutoMode = 0x20; } struct ThermostatScheduleTransition { @@ -2453,6 +2487,19 @@ server cluster ColorControl = 768 { readonly attribute int16u clusterRevision = 65533; } +server cluster BallastConfiguration = 769 { + readonly attribute int8u physicalMinLevel = 0; + readonly attribute int8u physicalMaxLevel = 1; + attribute int8u minLevel = 16; + attribute int8u maxLevel = 17; + readonly attribute int8u lampQuantity = 32; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + server cluster IlluminanceMeasurement = 1024 { enum LightSensorType : ENUM8 { kPhotodiode = 0; @@ -2554,12 +2601,12 @@ server cluster TargetNavigator = 1285 { kNotAllowed = 2; } - struct TargetInfo { + struct TargetInfoStruct { int8u identifier = 0; char_string<32> name = 1; } - readonly attribute TargetInfo targetList[] = 0; + readonly attribute TargetInfoStruct targetList[] = 0; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -2609,7 +2656,7 @@ server cluster MediaPlayback = 1286 { command Play(): PlaybackResponse = 0; command Pause(): PlaybackResponse = 1; - command StopPlayback(): PlaybackResponse = 2; + command Stop(): PlaybackResponse = 2; } server cluster MediaInput = 1287 { @@ -2632,14 +2679,14 @@ server cluster MediaInput = 1287 { kNameUpdates = 0x1; } - struct InputInfo { + struct InputInfoStruct { int8u index = 0; InputTypeEnum inputType = 1; char_string<32> name = 2; char_string<32> description = 3; } - readonly attribute InputInfo inputList[] = 0; + readonly attribute InputInfoStruct inputList[] = 0; readonly attribute int8u currentInput = 1; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -2802,6 +2849,7 @@ server cluster ContentLauncher = 1290 { kSport = 10; kSportsTeam = 11; kType = 12; + kVideo = 13; } bitmap ContentLauncherFeature : BITMAP32 { @@ -2814,37 +2862,37 @@ server cluster ContentLauncher = 1290 { kHls = 0x2; } - struct ContentSearch { - Parameter parameterList[] = 0; + struct ContentSearchStruct { + ParameterStruct parameterList[] = 0; } - struct Parameter { + struct ParameterStruct { ParameterEnum type = 0; char_string value = 1; - optional AdditionalInfo externalIDList[] = 2; + optional AdditionalInfoStruct externalIDList[] = 2; } - struct AdditionalInfo { + struct AdditionalInfoStruct { char_string name = 0; char_string value = 1; } - struct BrandingInformation { + struct BrandingInformationStruct { char_string providerName = 0; - optional StyleInformation background = 1; - optional StyleInformation logo = 2; - optional StyleInformation progressBar = 3; - optional StyleInformation splash = 4; - optional StyleInformation waterMark = 5; + optional StyleInformationStruct background = 1; + optional StyleInformationStruct logo = 2; + optional StyleInformationStruct progressBar = 3; + optional StyleInformationStruct splash = 4; + optional StyleInformationStruct waterMark = 5; } - struct StyleInformation { - optional char_string imageUrl = 0; + struct StyleInformationStruct { + optional char_string imageURL = 0; optional char_string color = 1; - optional Dimension size = 2; + optional DimensionStruct size = 2; } - struct Dimension { + struct DimensionStruct { double width = 0; double height = 1; MetricTypeEnum metric = 2; @@ -2868,13 +2916,13 @@ server cluster AudioOutput = 1291 { kNameUpdates = 0x1; } - struct OutputInfo { + struct OutputInfoStruct { int8u index = 0; OutputTypeEnum outputType = 1; char_string<32> name = 2; } - readonly attribute OutputInfo outputList[] = 0; + readonly attribute OutputInfoStruct outputList[] = 0; readonly attribute int8u currentOutput = 1; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -2897,30 +2945,25 @@ server cluster ApplicationLauncher = 1292 { kApplicationPlatform = 0x1; } - struct Application { - int16u catalogVendorId = 0; - char_string applicationId = 1; - } - readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; request struct LaunchAppRequest { - Application application = 0; + optional ApplicationStruct application = 0; optional OCTET_STRING data = 1; } request struct StopAppRequest { - Application application = 0; + optional ApplicationStruct application = 0; } request struct HideAppRequest { - Application application = 0; + optional ApplicationStruct application = 0; } response struct LauncherResponse = 3 { ApplicationLauncherStatusEnum status = 0; - OCTET_STRING data = 1; + optional OCTET_STRING data = 1; } command LaunchApp(LaunchAppRequest): LauncherResponse = 0; @@ -2936,13 +2979,8 @@ server cluster ApplicationBasic = 1293 { kActiveVisibleNotFocus = 3; } - struct ApplicationBasicApplication { - int16u catalogVendorId = 0; - char_string applicationId = 1; - } - readonly attribute char_string<32> applicationName = 2; - readonly attribute ApplicationBasicApplication application = 4; + readonly attribute ApplicationStruct application = 4; readonly attribute ApplicationStatusEnum status = 5; readonly attribute char_string<32> applicationVersion = 6; readonly attribute vendor_id allowedVendorList[] = 7; @@ -3320,7 +3358,7 @@ endpoint 0 { callback attribute acl; callback attribute subjectsPerAccessControlEntry default = 4; callback attribute targetsPerAccessControlEntry default = 3; - callback attribute accessControlEntriesPerFabric default = 3; + callback attribute accessControlEntriesPerFabric default = 4; ram attribute featureMap; callback attribute clusterRevision default = 1; } @@ -3659,12 +3697,14 @@ endpoint 1 { ram attribute maxPressure; ram attribute maxSpeed; ram attribute maxFlow; + ram attribute minConstPressure; + ram attribute maxConstPressure; ram attribute effectiveOperationMode; ram attribute effectiveControlMode; ram attribute capacity; ram attribute operationMode; - ram attribute featureMap; - ram attribute clusterRevision default = 3; + ram attribute featureMap default = 1; + ram attribute clusterRevision default = 4; } server cluster Thermostat { @@ -3702,6 +3742,19 @@ endpoint 1 { ram attribute clusterRevision default = 5; } + server cluster BallastConfiguration { + ram attribute physicalMinLevel default = 0x01; + ram attribute physicalMaxLevel default = 0xFE; + ram attribute minLevel default = 0x01; + ram attribute maxLevel default = 0xFE; + ram attribute lampQuantity; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; + ram attribute featureMap; + ram attribute clusterRevision default = 4; + } + server cluster IlluminanceMeasurement { ram attribute measuredValue; ram attribute minMeasuredValue default = 0x01; diff --git a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.zap b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.zap index 01fd43c5185c66..dbdda93fb5af79 100644 --- a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.zap +++ b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.zap @@ -1098,7 +1098,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "4", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -5121,7 +5121,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "PHYRate", + "type": "PHYRateEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -5395,7 +5395,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -5447,7 +5447,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -5459,7 +5459,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "CommissioningWindowStatus", + "type": "CommissioningWindowStatusEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -6221,7 +6221,7 @@ "code": 3, "mfgCode": null, "side": "server", - "type": "DlDoorState", + "type": "DoorStateEnum", "included": 0, "storageOption": "RAM", "singleton": 0, @@ -6301,7 +6301,7 @@ "code": 37, "mfgCode": null, "side": "server", - "type": "DlOperatingMode", + "type": "OperatingModeEnum", "included": 0, "storageOption": "RAM", "singleton": 0, @@ -7989,7 +7989,7 @@ "enabled": 0, "attributes": [ { - "name": "occupancy", + "name": "Occupancy", "code": 0, "mfgCode": null, "side": "server", @@ -8005,7 +8005,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type", + "name": "OccupancySensorType", "code": 1, "mfgCode": null, "side": "server", @@ -8021,7 +8021,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type bitmap", + "name": "OccupancySensorTypeBitmap", "code": 2, "mfgCode": null, "side": "server", @@ -12651,7 +12651,7 @@ "code": 3, "mfgCode": null, "side": "server", - "type": "DlDoorState", + "type": "DoorStateEnum", "included": 0, "storageOption": "RAM", "singleton": 0, @@ -12971,7 +12971,7 @@ "code": 37, "mfgCode": null, "side": "server", - "type": "DlOperatingMode", + "type": "OperatingModeEnum", "included": 1, "storageOption": "RAM", "singleton": 0, @@ -13956,11 +13956,11 @@ "mfgCode": null, "side": "server", "type": "int16s", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -13972,11 +13972,11 @@ "mfgCode": null, "side": "server", "type": "int16s", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -14280,7 +14280,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": "1", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -14296,7 +14296,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "4", "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -16180,6 +16180,362 @@ } ] }, + { + "name": "Ballast Configuration", + "code": 769, + "mfgCode": null, + "define": "BALLAST_CONFIGURATION_CLUSTER", + "side": "client", + "enabled": 0, + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "client", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Ballast Configuration", + "code": 769, + "mfgCode": null, + "define": "BALLAST_CONFIGURATION_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "PhysicalMinLevel", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PhysicalMaxLevel", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xFE", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "BallastStatus", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "bitmap8", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "MinLevel", + "code": 16, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "MaxLevel", + "code": 17, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xFE", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "IntrinsicBallastFactor", + "code": 20, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "BallastFactorAdjustment", + "code": 21, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xFF", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LampQuantity", + "code": 32, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LampType", + "code": 48, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LampManufacturer", + "code": 49, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LampRatedHours", + "code": 50, + "mfgCode": null, + "side": "server", + "type": "int24u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xFFFFFF", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LampBurnHours", + "code": 51, + "mfgCode": null, + "side": "server", + "type": "int24u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x000000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LampAlarmMode", + "code": 52, + "mfgCode": null, + "side": "server", + "type": "bitmap8", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LampBurnHoursTripPoint", + "code": 53, + "mfgCode": null, + "side": "server", + "type": "int24u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xFFFFFF", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, { "name": "Illuminance Measurement", "code": 1024, @@ -16923,7 +17279,7 @@ "enabled": 1, "attributes": [ { - "name": "occupancy", + "name": "Occupancy", "code": 0, "mfgCode": null, "side": "server", @@ -16939,7 +17295,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type", + "name": "OccupancySensorType", "code": 1, "mfgCode": null, "side": "server", @@ -16955,7 +17311,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type bitmap", + "name": "OccupancySensorTypeBitmap", "code": 2, "mfgCode": null, "side": "server", @@ -17217,7 +17573,7 @@ "code": 1, "mfgCode": null, "side": "server", - "type": "LineupInfo", + "type": "LineupInfoStruct", "included": 0, "storageOption": "External", "singleton": 0, @@ -17233,7 +17589,7 @@ "code": 2, "mfgCode": null, "side": "server", - "type": "ChannelInfo", + "type": "ChannelInfoStruct", "included": 0, "storageOption": "External", "singleton": 0, @@ -17455,7 +17811,7 @@ "outgoing": 1 }, { - "name": "StopPlayback", + "name": "Stop", "code": 2, "mfgCode": null, "source": "client", @@ -17609,7 +17965,7 @@ "code": 3, "mfgCode": null, "side": "server", - "type": "PlaybackPosition", + "type": "PlaybackPositionStruct", "included": 0, "storageOption": "External", "singleton": 0, @@ -18361,7 +18717,7 @@ "code": 1, "mfgCode": null, "side": "server", - "type": "ApplicationEP", + "type": "ApplicationEPStruct", "included": 0, "storageOption": "External", "singleton": 0, @@ -18509,7 +18865,7 @@ "code": 4, "mfgCode": null, "side": "server", - "type": "ApplicationBasicApplication", + "type": "ApplicationStruct", "included": 1, "storageOption": "External", "singleton": 0, @@ -22547,7 +22903,7 @@ "code": 3, "mfgCode": null, "side": "server", - "type": "DlDoorState", + "type": "DoorStateEnum", "included": 0, "storageOption": "RAM", "singleton": 0, @@ -22627,7 +22983,7 @@ "code": 37, "mfgCode": null, "side": "server", - "type": "DlOperatingMode", + "type": "OperatingModeEnum", "included": 0, "storageOption": "RAM", "singleton": 0, @@ -24051,7 +24407,7 @@ "enabled": 1, "attributes": [ { - "name": "occupancy", + "name": "Occupancy", "code": 0, "mfgCode": null, "side": "server", @@ -24067,7 +24423,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type", + "name": "OccupancySensorType", "code": 1, "mfgCode": null, "side": "server", @@ -24083,7 +24439,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type bitmap", + "name": "OccupancySensorTypeBitmap", "code": 2, "mfgCode": null, "side": "server", diff --git a/examples/all-clusters-minimal-app/ameba/main/DeviceCallbacks.cpp b/examples/all-clusters-minimal-app/ameba/main/DeviceCallbacks.cpp index f4a7ab2d076c2f..e53adc0c793f25 100644 --- a/examples/all-clusters-minimal-app/ameba/main/DeviceCallbacks.cpp +++ b/examples/all-clusters-minimal-app/ameba/main/DeviceCallbacks.cpp @@ -25,7 +25,7 @@ #include "DeviceCallbacks.h" #include "CHIPDeviceManager.h" -#include +#include #include #include #include @@ -116,7 +116,7 @@ void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event void DeviceCallbacks::OnOnOffPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { - VerifyOrExit(attributeId == ZCL_ON_OFF_ATTRIBUTE_ID, + VerifyOrExit(attributeId == app::Clusters::OnOff::Attributes::OnOff::Id, ChipLogError(DeviceLayer, TAG, "Unhandled Attribute ID: '0x%04x", attributeId)); VerifyOrExit(endpointId == 1 || endpointId == 2, ChipLogError(DeviceLayer, TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); @@ -138,7 +138,7 @@ void IdentifyTimerHandler(Layer * systemLayer, void * appState, CHIP_ERROR error void DeviceCallbacks::OnIdentifyPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { - VerifyOrExit(attributeId == ZCL_IDENTIFY_TIME_ATTRIBUTE_ID, + VerifyOrExit(attributeId == app::Clusters::Identify::Attributes::IdentifyTime::Id, ChipLogError(DeviceLayer, "[%s] Unhandled Attribute ID: '0x%04x", TAG, attributeId)); VerifyOrExit(endpointId == 1, ChipLogError(DeviceLayer, "[%s] Unexpected EndPoint ID: `0x%02x'", TAG, endpointId)); diff --git a/examples/all-clusters-minimal-app/cc13x2x7_26x2x7/main/ClusterManager.cpp b/examples/all-clusters-minimal-app/cc13x2x7_26x2x7/main/ClusterManager.cpp index 1a07e18c72c3de..b55ffa374e9788 100644 --- a/examples/all-clusters-minimal-app/cc13x2x7_26x2x7/main/ClusterManager.cpp +++ b/examples/all-clusters-minimal-app/cc13x2x7_26x2x7/main/ClusterManager.cpp @@ -18,9 +18,8 @@ */ #include "ClusterManager.h" #include "Globals.h" -#include -#include #include +#include #include #include #include @@ -83,7 +82,8 @@ Identify gIdentify1 = { void ClusterManager::OnOnOffPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { - VerifyOrExit(attributeId == ZCL_ON_OFF_ATTRIBUTE_ID, PLAT_LOG("Unhandled Attribute ID: '0x%04x", attributeId)); + VerifyOrExit(attributeId == app::Clusters::OnOff::Attributes::OnOff::Id, + PLAT_LOG("Unhandled Attribute ID: '0x%04x", attributeId)); VerifyOrExit(endpointId == ENDPOINT_ID_1 || endpointId == ENDPOINT_ID_2, PLAT_LOG("Unexpected EndPoint ID: `0x%02x'", endpointId)); @@ -101,7 +101,8 @@ void ClusterManager::OnLevelControlAttributeChangeCallback(EndpointId endpointId uint8_t brightness = onOffState ? *value : 0; VerifyOrExit(brightness > 0, PLAT_LOG("Brightness set to 0, ignoring")); - VerifyOrExit(attributeId == ZCL_CURRENT_LEVEL_ATTRIBUTE_ID, PLAT_LOG("Unhandled Attribute ID: '0x%04x", attributeId)); + VerifyOrExit(attributeId == app::Clusters::LevelControl::Attributes::CurrentLevel::Id, + PLAT_LOG("Unhandled Attribute ID: '0x%04x", attributeId)); VerifyOrExit(endpointId == ENDPOINT_ID_1 || endpointId == ENDPOINT_ID_2, PLAT_LOG("Unexpected EndPoint ID: `0x%02x'", endpointId)); @@ -118,8 +119,9 @@ void ClusterManager::OnLevelControlAttributeChangeCallback(EndpointId endpointId void ClusterManager::OnColorControlAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { - VerifyOrExit(attributeId == ZCL_COLOR_CONTROL_CURRENT_HUE_ATTRIBUTE_ID || - attributeId == ZCL_COLOR_CONTROL_CURRENT_SATURATION_ATTRIBUTE_ID, + using namespace app::Clusters::ColorControl::Attributes; + + VerifyOrExit(attributeId == CurrentHue::Id || attributeId == CurrentSaturation::Id, PLAT_LOG("Unhandled AttributeId ID: '0x%04x", attributeId)); VerifyOrExit(endpointId == ENDPOINT_ID_1 || endpointId == ENDPOINT_ID_2, PLAT_LOG("Unexpected EndPoint ID: `0x%02x'", endpointId)); @@ -127,17 +129,17 @@ void ClusterManager::OnColorControlAttributeChangeCallback(EndpointId endpointId if (endpointId == ENDPOINT_ID_1) { uint8_t hue, saturation; - if (attributeId == ZCL_COLOR_CONTROL_CURRENT_HUE_ATTRIBUTE_ID) + if (attributeId == CurrentHue::Id) { hue = *value; /* Read Current Saturation value when Attribute change callback for HUE Attribute */ - app::Clusters::ColorControl::Attributes::CurrentSaturation::Get(endpointId, &saturation); + CurrentSaturation::Get(endpointId, &saturation); } else { saturation = *value; /* Read Current Hue value when Attribute change callback for SATURATION Attribute */ - app::Clusters::ColorControl::Attributes::CurrentHue::Get(endpointId, &hue); + CurrentHue::Get(endpointId, &hue); } PLAT_LOG("Color Control triggered: Hue: %d Saturation: %d", hue, saturation); } diff --git a/examples/all-clusters-minimal-app/cc13x2x7_26x2x7/main/ZclCallbacks.cpp b/examples/all-clusters-minimal-app/cc13x2x7_26x2x7/main/ZclCallbacks.cpp index 4d14d56f8f0d6f..5a78ce84982c40 100644 --- a/examples/all-clusters-minimal-app/cc13x2x7_26x2x7/main/ZclCallbacks.cpp +++ b/examples/all-clusters-minimal-app/cc13x2x7_26x2x7/main/ZclCallbacks.cpp @@ -27,7 +27,6 @@ #include "ClusterManager.h" -#include #include #include #include diff --git a/examples/all-clusters-minimal-app/esp32/CMakeLists.txt b/examples/all-clusters-minimal-app/esp32/CMakeLists.txt index c53fd3c05c92af..0d6aa7b68931f6 100644 --- a/examples/all-clusters-minimal-app/esp32/CMakeLists.txt +++ b/examples/all-clusters-minimal-app/esp32/CMakeLists.txt @@ -27,7 +27,6 @@ include(${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common/cm set(EXTRA_COMPONENT_DIRS "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/config/esp32/components" "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common/QRCode" - "${IDF_PATH}/examples/common_components/led_strip" ) if(${IDF_TARGET} STREQUAL "esp32") list(APPEND EXTRA_COMPONENT_DIRS "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common/m5stack-tft/repo/components/tft" diff --git a/examples/all-clusters-minimal-app/esp32/main/AppTask.cpp b/examples/all-clusters-minimal-app/esp32/main/AppTask.cpp index 6db8c63b3c14ec..82a8f9757b590d 100644 --- a/examples/all-clusters-minimal-app/esp32/main/AppTask.cpp +++ b/examples/all-clusters-minimal-app/esp32/main/AppTask.cpp @@ -23,11 +23,18 @@ #include "LEDWidget.h" #include "ScreenManager.h" #include "driver/gpio.h" +#include "esp_idf_version.h" #include "esp_log.h" -#include "esp_spi_flash.h" #include "freertos/FreeRTOS.h" #include +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) +#include "esp_spi_flash.h" +#else +#include "esp_chip_info.h" +#include "esp_flash.h" +#endif + #define APP_TASK_NAME "APP" #define APP_EVENT_QUEUE_SIZE 10 #define APP_TASK_STACK_SIZE (3072) @@ -63,10 +70,20 @@ CHIP_ERROR AppTask::Init() /* Print chip information */ esp_chip_info_t chip_info; esp_chip_info(&chip_info); + uint32_t flash_size = 0; + +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) + flash_size = spi_flash_get_chip_size(); +#else + if (esp_flash_get_size(NULL, &flash_size) != ESP_OK) + { + ESP_LOGW(TAG, "Failed to get flash size"); + } +#endif ESP_LOGI(TAG, "This is ESP32 chip with %d CPU cores, WiFi%s%s, ", chip_info.cores, (chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "", (chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : ""); ESP_LOGI(TAG, "silicon revision %d, ", chip_info.revision); - ESP_LOGI(TAG, "%dMB %s flash\n", spi_flash_get_chip_size() / (1024 * 1024), + ESP_LOGI(TAG, "%" PRIu32 " MB %s flash\n", flash_size / (1024 * 1024), (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external"); CHIP_ERROR err = CHIP_NO_ERROR; diff --git a/examples/all-clusters-minimal-app/esp32/main/CMakeLists.txt b/examples/all-clusters-minimal-app/esp32/main/CMakeLists.txt index 4994beed15155e..65132df36e2983 100644 --- a/examples/all-clusters-minimal-app/esp32/main/CMakeLists.txt +++ b/examples/all-clusters-minimal-app/esp32/main/CMakeLists.txt @@ -26,7 +26,6 @@ set(PRIV_INCLUDE_DIRS_LIST ) set(SRC_DIRS_LIST "${CMAKE_CURRENT_LIST_DIR}" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/all-clusters-minimal-app/zap-generated" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated/attributes" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/ota" @@ -107,7 +106,7 @@ set(SRC_DIRS_LIST "${SRC_DIRS_LIST}" ) endif (CONFIG_ENABLE_PW_RPC) -if(("${CONFIG_DEVICE_TYPE_ESP32_DEVKITC}" STREQUAL "y") OR ("${CONFIG_DEVICE_TYPE_ESP32_C3_DEVKITM}" STREQUAL "y")) +if(("${CONFIG_DEVICE_TYPE_ESP32_DEVKITC}" STREQUAL "y") OR ("${CONFIG_DEVICE_TYPE_ESP32_C3_DEVKITM}" STREQUAL "y") OR ("${CONFIG_DEVICE_TYPE_ESP32_C2_DEVKITM}" STREQUAL "y")) list(APPEND PRIV_INCLUDE_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/screen-framework/include") set(PRIV_REQUIRES_LIST chip QRCode bt) diff --git a/examples/all-clusters-minimal-app/esp32/main/DeviceCallbacks.cpp b/examples/all-clusters-minimal-app/esp32/main/DeviceCallbacks.cpp index 82917c28ef26b5..9acee43d2c2790 100644 --- a/examples/all-clusters-minimal-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/all-clusters-minimal-app/esp32/main/DeviceCallbacks.cpp @@ -27,8 +27,7 @@ #include "Globals.h" #include "LEDWidget.h" #include "WiFiWidget.h" -#include -#include +#include #include #include #include @@ -93,8 +92,7 @@ void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Clus uint8_t type, uint16_t size, uint8_t * value) { ESP_LOGI(TAG, - "PostAttributeChangeCallback - Cluster ID: '0x%04x', EndPoint ID: " - "'0x%02x', Attribute ID: '0x%04x'", + "PostAttributeChangeCallback - Cluster ID: '0x%04" PRIx32 "', EndPoint ID: '0x%02x' , Attribute ID: '0x%04" PRIx32 "'", clusterId, endpointId, attributeId); switch (clusterId) @@ -115,7 +113,7 @@ void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Clus OnIdentifyPostAttributeChangeCallback(endpointId, attributeId, size, value); break; default: - ESP_LOGI(TAG, "Unhandled cluster ID: %d", clusterId); + ESP_LOGI(TAG, "Unhandled cluster ID: %" PRIu32, clusterId); break; } @@ -124,7 +122,8 @@ void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Clus void AppDeviceCallbacks::OnOnOffPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { - VerifyOrExit(attributeId == ZCL_ON_OFF_ATTRIBUTE_ID, ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04x", attributeId)); + VerifyOrExit(attributeId == Clusters::OnOff::Attributes::OnOff::Id, + ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04" PRIx32 "'", attributeId)); VerifyOrExit(endpointId == 1 || endpointId == 2, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); // At this point we can assume that value points to a bool value. @@ -140,7 +139,8 @@ void AppDeviceCallbacks::OnLevelControlAttributeChangeCallback(EndpointId endpoi bool onOffState = mEndpointOnOffState[endpointId - 1]; uint8_t brightness = onOffState ? *value : 0; - VerifyOrExit(attributeId == ZCL_CURRENT_LEVEL_ATTRIBUTE_ID, ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04x", attributeId)); + VerifyOrExit(attributeId == Clusters::LevelControl::Attributes::CurrentLevel::Id, + ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04" PRIx32 "'", attributeId)); VerifyOrExit(endpointId == 1 || endpointId == 2, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); // At this point we can assume that value points to a bool value. @@ -155,24 +155,23 @@ void AppDeviceCallbacks::OnLevelControlAttributeChangeCallback(EndpointId endpoi #if CONFIG_DEVICE_TYPE_ESP32_C3_DEVKITM void AppDeviceCallbacks::OnColorControlAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { - VerifyOrExit(attributeId == ZCL_COLOR_CONTROL_CURRENT_HUE_ATTRIBUTE_ID || - attributeId == ZCL_COLOR_CONTROL_CURRENT_SATURATION_ATTRIBUTE_ID, - ESP_LOGI(TAG, "Unhandled AttributeId ID: '0x%04x", attributeId)); + using namespace Clusters::ColorControl::Attributes; + + VerifyOrExit(attributeId == CurrentHue::Id || attributeId == CurrentSaturation::Id, + ESP_LOGI(TAG, "Unhandled AttributeId ID: '0x%04" PRIx32 "'", attributeId)); VerifyOrExit(endpointId == 1 || endpointId == 2, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); if (endpointId == 1) { uint8_t hue, saturation; - if (attributeId == ZCL_COLOR_CONTROL_CURRENT_HUE_ATTRIBUTE_ID) + if (attributeId == CurrentHue::Id) { hue = *value; - emberAfReadServerAttribute(endpointId, Clusters::ColorControl::Id, ZCL_COLOR_CONTROL_CURRENT_SATURATION_ATTRIBUTE_ID, - &saturation, sizeof(uint8_t)); + CurrentSaturation::Get(endpointId, &saturation); } else { saturation = *value; - emberAfReadServerAttribute(endpointId, Clusters::ColorControl::Id, ZCL_COLOR_CONTROL_CURRENT_HUE_ATTRIBUTE_ID, &hue, - sizeof(uint8_t)); + CurrentHue::Get(endpointId, &hue); } statusLED1.SetColor(hue, saturation); } diff --git a/examples/all-clusters-minimal-app/esp32/main/DeviceWithDisplay.cpp b/examples/all-clusters-minimal-app/esp32/main/DeviceWithDisplay.cpp index 9146fe465e12e9..e3061455e96c8f 100644 --- a/examples/all-clusters-minimal-app/esp32/main/DeviceWithDisplay.cpp +++ b/examples/all-clusters-minimal-app/esp32/main/DeviceWithDisplay.cpp @@ -17,6 +17,7 @@ */ #include "DeviceWithDisplay.h" +#include #include #include @@ -231,16 +232,15 @@ class EditAttributeListModel : public TouchesMatterStackModel if (name == "OnOff" && cluster == "OnOff") { - value = (value == "On") ? "Off" : "On"; - uint8_t attributeValue = (value == "On") ? 1 : 0; - emberAfWriteServerAttribute(endpointIndex + 1, app::Clusters::OnOff::Id, ZCL_ON_OFF_ATTRIBUTE_ID, - (uint8_t *) &attributeValue, ZCL_BOOLEAN_ATTRIBUTE_TYPE); + value = (value == "On") ? "Off" : "On"; + bool attributeValue = (value == "On"); + app::Clusters::OnOff::Attributes::OnOff::Set(endpointIndex + 1, attributeValue); } if (name == "Occupancy" && cluster == "Occupancy Sensor") { - value = (value == "Yes") ? "No" : "Yes"; - uint8_t attributeValue = (value == "Yes") ? 1 : 0; + value = (value == "Yes") ? "No" : "Yes"; + bool attributeValue = (value == "Yes"); ESP_LOGI(TAG, "Occupancy changed to : %s", value.c_str()); // update the current occupancy here for hardcoded endpoint 1 app::Clusters::OccupancySensing::Attributes::Occupancy::Set(1, attributeValue); diff --git a/examples/all-clusters-minimal-app/esp32/main/Kconfig.projbuild b/examples/all-clusters-minimal-app/esp32/main/Kconfig.projbuild index dbf11ecaab5a57..9b5bff48d90a1e 100644 --- a/examples/all-clusters-minimal-app/esp32/main/Kconfig.projbuild +++ b/examples/all-clusters-minimal-app/esp32/main/Kconfig.projbuild @@ -24,6 +24,7 @@ menu "Demo" prompt "Device Type" default DEVICE_TYPE_ESP32_DEVKITC if IDF_TARGET_ESP32 default DEVICE_TYPE_ESP32_C3_DEVKITM if IDF_TARGET_ESP32C3 + default DEVICE_TYPE_ESP32_C2_DEVKITM if IDF_TARGET_ESP32C2 help Specifies the type of ESP32 device. @@ -42,6 +43,9 @@ menu "Demo" config DEVICE_TYPE_ESP32_C3_DEVKITM bool "ESP32C3-DevKitM" depends on IDF_TARGET_ESP32C3 + config DEVICE_TYPE_ESP32_C2_DEVKITM + bool "ESP32C2-DevKitM" + depends on IDF_TARGET_ESP32C2 endchoice choice @@ -73,7 +77,7 @@ menu "Demo" int range 0 5 default 0 if DEVICE_TYPE_ESP32_DEVKITC - default 0 if DEVICE_TYPE_ESP32_C3_DEVKITM + default 0 if DEVICE_TYPE_ESP32_C3_DEVKITM || DEVICE_TYPE_ESP32_C2_DEVKITM default 3 if DEVICE_TYPE_M5STACK default 4 if DEVICE_TYPE_ESP32_WROVER_KIT @@ -97,7 +101,7 @@ menu "Demo" int range 0 40 default 2 if DEVICE_TYPE_ESP32_DEVKITC #Use LED1 (blue LED) as status LED on DevKitC - default 8 if DEVICE_TYPE_ESP32_C3_DEVKITM + default 8 if DEVICE_TYPE_ESP32_C3_DEVKITM || DEVICE_TYPE_ESP32_C2_DEVKITM default 26 if DEVICE_TYPE_ESP32_WROVER_KIT default 40 if DEVICE_TYPE_M5STACK help diff --git a/examples/all-clusters-minimal-app/esp32/main/idf_component.yml b/examples/all-clusters-minimal-app/esp32/main/idf_component.yml new file mode 100644 index 00000000000000..1c539b8eb57668 --- /dev/null +++ b/examples/all-clusters-minimal-app/esp32/main/idf_component.yml @@ -0,0 +1,2 @@ +dependencies: + espressif/led_strip: "^1.0.0-alpha" diff --git a/examples/all-clusters-minimal-app/esp32/main/include/DeviceWithDisplay.h b/examples/all-clusters-minimal-app/esp32/main/include/DeviceWithDisplay.h index 7a283fe7546ef5..3dc7b57f2af3fb 100644 --- a/examples/all-clusters-minimal-app/esp32/main/include/DeviceWithDisplay.h +++ b/examples/all-clusters-minimal-app/esp32/main/include/DeviceWithDisplay.h @@ -34,8 +34,6 @@ #include #include -#include -#include #include #include #include diff --git a/examples/all-clusters-minimal-app/esp32/main/main.cpp b/examples/all-clusters-minimal-app/esp32/main/main.cpp index a5de104f33bb9f..69bb15ee91d326 100644 --- a/examples/all-clusters-minimal-app/esp32/main/main.cpp +++ b/examples/all-clusters-minimal-app/esp32/main/main.cpp @@ -156,7 +156,7 @@ extern "C" void app_main() DeviceCallbacksDelegate::Instance().SetAppDelegate(&sAppDeviceCallbacksDelegate); if (error != CHIP_NO_ERROR) { - ESP_LOGE(TAG, "device.Init() failed: %s", ErrorStr(error)); + ESP_LOGE(TAG, "device.Init() failed: %" CHIP_ERROR_FORMAT, error.Format()); return; } @@ -174,7 +174,7 @@ extern "C" void app_main() error = GetAppTask().StartAppTask(); if (error != CHIP_NO_ERROR) { - ESP_LOGE(TAG, "GetAppTask().StartAppTask() failed : %s", ErrorStr(error)); + ESP_LOGE(TAG, "GetAppTask().StartAppTask() failed : %" CHIP_ERROR_FORMAT, error.Format()); } chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast(nullptr)); diff --git a/examples/all-clusters-minimal-app/esp32/sdkconfig.defaults b/examples/all-clusters-minimal-app/esp32/sdkconfig.defaults index 5fe66f692b842d..42d30f4d170b8d 100644 --- a/examples/all-clusters-minimal-app/esp32/sdkconfig.defaults +++ b/examples/all-clusters-minimal-app/esp32/sdkconfig.defaults @@ -59,3 +59,7 @@ CONFIG_ESPTOOLPY_FLASHSIZE="4MB" # Disable softap support by default CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n + +# This example uses the older version of RMT driver to work with both +# idf-v4.4.3 and idf-v5.0, so supressing the warnings by setting below option +CONFIG_RMT_SUPPRESS_DEPRECATE_WARN=y diff --git a/examples/all-clusters-minimal-app/esp32/sdkconfig.defaults.esp32c2 b/examples/all-clusters-minimal-app/esp32/sdkconfig.defaults.esp32c2 new file mode 100644 index 00000000000000..6cb90db4f55b9d --- /dev/null +++ b/examples/all-clusters-minimal-app/esp32/sdkconfig.defaults.esp32c2 @@ -0,0 +1,19 @@ +# Disable chip shell +CONFIG_ENABLE_CHIP_SHELL=n + +# CONFIG_ESP32_WIFI_IRAM_OPT is not set +# CONFIG_ESP32_WIFI_RX_IRAM_OPT is not set +CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y +CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH=y + +CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE=y + +CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=16 +CONFIG_LWIP_TCP_RECVMBOX_SIZE=8 + +CONFIG_BT_NIMBLE_ROLE_CENTRAL=n +CONFIG_BT_NIMBLE_ROLE_OBSERVER=n + +CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=4 +CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=8 +CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=16 diff --git a/examples/all-clusters-minimal-app/infineon/psoc6/src/AppTask.cpp b/examples/all-clusters-minimal-app/infineon/psoc6/src/AppTask.cpp index 35af6870006185..efbbb4af9ec705 100644 --- a/examples/all-clusters-minimal-app/infineon/psoc6/src/AppTask.cpp +++ b/examples/all-clusters-minimal-app/infineon/psoc6/src/AppTask.cpp @@ -23,8 +23,6 @@ #include "AppEvent.h" #include "ButtonHandler.h" #include "LEDWidget.h" -#include -#include #include #include #include @@ -408,8 +406,7 @@ void AppTask::OnOffUpdateClusterState(intptr_t context) uint8_t onoff = sLightLED.Get(); // write the new on/off value - EmberAfStatus status = - emberAfWriteServerAttribute(2, app::Clusters::OnOff::Id, ZCL_ON_OFF_ATTRIBUTE_ID, &onoff, ZCL_BOOLEAN_ATTRIBUTE_TYPE); + EmberAfStatus status = app::Clusters::OnOff::Attributes::OnOff::Set(2, onoff); if (status != EMBER_ZCL_STATUS_SUCCESS) { diff --git a/examples/all-clusters-minimal-app/infineon/psoc6/src/ClusterManager.cpp b/examples/all-clusters-minimal-app/infineon/psoc6/src/ClusterManager.cpp index a3ae6a44190c75..38d009a53f8fc7 100644 --- a/examples/all-clusters-minimal-app/infineon/psoc6/src/ClusterManager.cpp +++ b/examples/all-clusters-minimal-app/infineon/psoc6/src/ClusterManager.cpp @@ -24,8 +24,8 @@ #include "ClusterManager.h" #include "AppConfig.h" #include "LEDWidget.h" -#include #include +#include #include #include #include @@ -49,7 +49,7 @@ ClusterManager ClusterManager::sCluster; void ClusterManager::OnOnOffPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { - VerifyOrExit(attributeId == ZCL_ON_OFF_ATTRIBUTE_ID, + VerifyOrExit(attributeId == OnOff::Attributes::OnOff::Id, P6_LOG("Unhandled Attribute ID: '" ChipLogFormatMEI "'", ChipLogValueMEI(attributeId))); VerifyOrExit(endpointId == ENDPOINT_FIRST_IDX || endpointId == ENDPOINT_SECOND_IDX, P6_LOG("Unexpected EndPoint ID: `0x%02x'", endpointId)); @@ -69,7 +69,7 @@ void ClusterManager::OnLevelControlAttributeChangeCallback(EndpointId endpointId bool onOffState = mEndpointOnOffState[endpointId - 1]; uint8_t brightness = onOffState ? *value : 0; - VerifyOrExit(attributeId == ZCL_CURRENT_LEVEL_ATTRIBUTE_ID, + VerifyOrExit(attributeId == LevelControl::Attributes::CurrentLevel::Id, P6_LOG("Unhandled Attribute ID: '" ChipLogFormatMEI "'", ChipLogValueMEI(attributeId))); VerifyOrExit(endpointId == ENDPOINT_FIRST_IDX || endpointId == ENDPOINT_SECOND_IDX, P6_LOG("Unexpected EndPoint ID: `0x%02x'", endpointId)); @@ -82,31 +82,32 @@ void ClusterManager::OnLevelControlAttributeChangeCallback(EndpointId endpointId void ClusterManager::OnColorControlAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { - VerifyOrExit(attributeId == ColorControl::Attributes::CurrentHue::Id || - attributeId == ColorControl::Attributes::CurrentSaturation::Id, + using namespace ColorControl::Attributes; + + VerifyOrExit(attributeId == CurrentHue::Id || attributeId == CurrentSaturation::Id, P6_LOG("Unhandled Attribute ID: '" ChipLogFormatMEI "'", ChipLogValueMEI(attributeId))); VerifyOrExit(endpointId == ENDPOINT_FIRST_IDX || endpointId == ENDPOINT_SECOND_IDX, P6_LOG("Unexpected EndPoint ID: `0x%02x'", endpointId)); if (endpointId == 1) { uint8_t hue, saturation; - /* If the Current Attribute is ZCL_COLOR_CONTROL_CURRENT_HUE_ATTRIBUTE_ID, read the saturation value and + /* If the Current Attribute is CurrentHue, read the saturation value and * set the color on Cluster LED using both Saturation and Hue. */ - if (attributeId == ColorControl::Attributes::CurrentHue::Id) + if (attributeId == CurrentHue::Id) { hue = *value; /* Read Current Saturation value when Attribute change callback for HUE Attribute */ - ColorControl::Attributes::CurrentSaturation::Get(endpointId, &saturation); + CurrentSaturation::Get(endpointId, &saturation); } else { - /* If the Current Attribute is ZCL_COLOR_CONTROL_CURRENT_SATURATION_ATTRIBUTE_ID, read the Hue value and + /* If the Current Attribute is CurrentSaturation, read the Hue value and * set the color on Cluster LED using both Saturation and Hue. */ saturation = *value; /* Read Current Hue value when Attribute change callback for SATURATION Attribute */ - ColorControl::Attributes::CurrentHue::Get(endpointId, &hue); + CurrentHue::Get(endpointId, &hue); } /* Set RGB Color on Cluster Indication LED */ sClusterLED.SetColor(hue, saturation); diff --git a/examples/all-clusters-minimal-app/infineon/psoc6/src/ZclCallbacks.cpp b/examples/all-clusters-minimal-app/infineon/psoc6/src/ZclCallbacks.cpp index f3fd7cf6689a70..9a439771026736 100644 --- a/examples/all-clusters-minimal-app/infineon/psoc6/src/ZclCallbacks.cpp +++ b/examples/all-clusters-minimal-app/infineon/psoc6/src/ZclCallbacks.cpp @@ -26,7 +26,6 @@ #include "ClusterManager.h" -#include #include #include #include diff --git a/examples/all-clusters-minimal-app/linux/main-common.cpp b/examples/all-clusters-minimal-app/linux/main-common.cpp index 7829f3a6c1894a..0b431136ed0d1d 100644 --- a/examples/all-clusters-minimal-app/linux/main-common.cpp +++ b/examples/all-clusters-minimal-app/linux/main-common.cpp @@ -18,7 +18,6 @@ #include "include/tv-callbacks.h" #include -#include #include #include #include diff --git a/examples/all-clusters-minimal-app/nrfconnect/main/AppTask.cpp b/examples/all-clusters-minimal-app/nrfconnect/main/AppTask.cpp index 5d3c2b0d2bba8c..b0e23d9c4c54e4 100644 --- a/examples/all-clusters-minimal-app/nrfconnect/main/AppTask.cpp +++ b/examples/all-clusters-minimal-app/nrfconnect/main/AppTask.cpp @@ -24,8 +24,6 @@ #include #include -#include -#include #include #include @@ -209,16 +207,6 @@ void AppTask::ButtonEventHandler(uint32_t buttonState, uint32_t hasChanged) } } -#ifdef CONFIG_MCUMGR_SMP_BT -void AppTask::RequestSMPAdvertisingStart(void) -{ - AppEvent event; - event.Type = AppEventType::StartSMPAdvertising; - event.Handler = [](const AppEvent &) { GetDFUOverSMP().StartBLEAdvertising(); }; - PostEvent(event); -} -#endif - void AppTask::FunctionTimerTimeoutCallback(k_timer * timer) { if (!timer) diff --git a/examples/all-clusters-minimal-app/nrfconnect/main/include/AppEvent.h b/examples/all-clusters-minimal-app/nrfconnect/main/include/AppEvent.h index 4589d636a4decf..057a32ad41ed05 100644 --- a/examples/all-clusters-minimal-app/nrfconnect/main/include/AppEvent.h +++ b/examples/all-clusters-minimal-app/nrfconnect/main/include/AppEvent.h @@ -33,7 +33,6 @@ enum class AppEventType : uint8_t UpdateLedState, IdentifyStart, IdentifyStop, - StartSMPAdvertising }; enum class FunctionEvent : uint8_t diff --git a/examples/all-clusters-minimal-app/nrfconnect/main/include/AppTask.h b/examples/all-clusters-minimal-app/nrfconnect/main/include/AppTask.h index 94a3de35f04038..1a6922e9286f0d 100644 --- a/examples/all-clusters-minimal-app/nrfconnect/main/include/AppTask.h +++ b/examples/all-clusters-minimal-app/nrfconnect/main/include/AppTask.h @@ -62,10 +62,6 @@ class AppTask static void FunctionTimerTimeoutCallback(k_timer * timer); static void UpdateStatusLED(); -#ifdef CONFIG_MCUMGR_SMP_BT - static void RequestSMPAdvertisingStart(void); -#endif - FunctionEvent mFunction = FunctionEvent::NoneSelected; bool mFunctionTimerActive = false; diff --git a/examples/all-clusters-minimal-app/telink/src/AppTask.cpp b/examples/all-clusters-minimal-app/telink/src/AppTask.cpp index 4d0f29cb87efea..1577259b94feba 100644 --- a/examples/all-clusters-minimal-app/telink/src/AppTask.cpp +++ b/examples/all-clusters-minimal-app/telink/src/AppTask.cpp @@ -27,8 +27,6 @@ #include "ThreadUtil.h" -#include -#include #include #include @@ -41,7 +39,25 @@ #include #include -LOG_MODULE_DECLARE(app); +#if CONFIG_CHIP_LIB_SHELL +#include +#include + +static int cmd_telink_reboot(const struct shell * shell, size_t argc, char ** argv) +{ + ARG_UNUSED(argc); + ARG_UNUSED(argv); + + shell_print(shell, "Performing board reboot..."); + sys_reboot(); +} + +SHELL_STATIC_SUBCMD_SET_CREATE(sub_telink, SHELL_CMD(reboot, NULL, "Reboot board command", cmd_telink_reboot), + SHELL_SUBCMD_SET_END); +SHELL_CMD_REGISTER(telink, &sub_telink, "Telink commands", NULL); +#endif // CONFIG_CHIP_LIB_SHELL + +LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL); namespace { constexpr int kFactoryResetTriggerTimeout = 2000; diff --git a/examples/all-clusters-minimal-app/telink/src/main.cpp b/examples/all-clusters-minimal-app/telink/src/main.cpp index dd1480f6677e45..4061e239ee8fbc 100644 --- a/examples/all-clusters-minimal-app/telink/src/main.cpp +++ b/examples/all-clusters-minimal-app/telink/src/main.cpp @@ -23,7 +23,7 @@ #include -LOG_MODULE_REGISTER(app); +LOG_MODULE_REGISTER(app, CONFIG_CHIP_APP_LOG_LEVEL); using namespace ::chip; using namespace ::chip::Inet; diff --git a/examples/bridge-app/bridge-common/bridge-app.matter b/examples/bridge-app/bridge-common/bridge-app.matter index 9a5e0494d24228..d163a578653bf5 100644 --- a/examples/bridge-app/bridge-common/bridge-app.matter +++ b/examples/bridge-app/bridge-common/bridge-app.matter @@ -75,10 +75,6 @@ server cluster OnOff = 6 { kLighting = 0x1; } - bitmap SceneFeatures : BITMAP32 { - kSceneNames = 0x1; - } - readonly attribute boolean onOff = 0; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -801,7 +797,7 @@ server cluster GeneralDiagnostics = 51 { kSoftwareReset = 6; } - enum HardwareFault : ENUM8 { + enum HardwareFaultEnum : ENUM8 { kUnspecified = 0; kRadio = 1; kSensor = 2; @@ -815,7 +811,7 @@ server cluster GeneralDiagnostics = 51 { kTamperDetected = 10; } - enum InterfaceType : ENUM8 { + enum InterfaceTypeEnum : ENUM8 { kUnspecified = 0; kWiFi = 1; kEthernet = 2; @@ -823,14 +819,14 @@ server cluster GeneralDiagnostics = 51 { kThread = 4; } - enum NetworkFaultType : ENUM8 { + enum NetworkFaultEnum : ENUM8 { kUnspecified = 0; kHardwareFailure = 1; kNetworkJammed = 2; kConnectionFailed = 3; } - enum RadioFault : ENUM8 { + enum RadioFaultEnum : ENUM8 { kUnspecified = 0; kWiFiFault = 1; kCellularFault = 2; @@ -848,22 +844,22 @@ server cluster GeneralDiagnostics = 51 { octet_string<8> hardwareAddress = 4; octet_string IPv4Addresses[] = 5; octet_string IPv6Addresses[] = 6; - InterfaceType type = 7; + InterfaceTypeEnum type = 7; } critical event HardwareFaultChange = 0 { - HardwareFault current[] = 0; - HardwareFault previous[] = 1; + HardwareFaultEnum current[] = 0; + HardwareFaultEnum previous[] = 1; } critical event RadioFaultChange = 1 { - RadioFault current[] = 0; - RadioFault previous[] = 1; + RadioFaultEnum current[] = 0; + RadioFaultEnum previous[] = 1; } critical event NetworkFaultChange = 2 { - NetworkFaultType current[] = 0; - NetworkFaultType previous[] = 1; + NetworkFaultEnum current[] = 0; + NetworkFaultEnum previous[] = 1; } critical event BootReason = 3 { @@ -875,9 +871,9 @@ server cluster GeneralDiagnostics = 51 { readonly attribute int64u upTime = 2; readonly attribute int32u totalOperationalHours = 3; readonly attribute BootReasonEnum bootReason = 4; - readonly attribute HardwareFault activeHardwareFaults[] = 5; - readonly attribute RadioFault activeRadioFaults[] = 6; - readonly attribute NetworkFaultType activeNetworkFaults[] = 7; + readonly attribute HardwareFaultEnum activeHardwareFaults[] = 5; + readonly attribute RadioFaultEnum activeRadioFaults[] = 6; + readonly attribute NetworkFaultEnum activeNetworkFaults[] = 7; readonly attribute boolean testEventTriggersEnabled = 8; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; @@ -1107,6 +1103,11 @@ server cluster WiFiNetworkDiagnostics = 54 { kAx = 5; } + bitmap WiFiNetworkDiagnosticsFeature : BITMAP32 { + kPacketCounts = 0x1; + kErrorCounts = 0x2; + } + info event Disconnection = 0 { INT16U reasonCode = 0; } @@ -1138,7 +1139,7 @@ server cluster WiFiNetworkDiagnostics = 54 { } server cluster EthernetNetworkDiagnostics = 55 { - enum PHYRate : ENUM8 { + enum PHYRateEnum : ENUM8 { kRate10M = 0; kRate100M = 1; kRate1G = 2; @@ -1151,7 +1152,12 @@ server cluster EthernetNetworkDiagnostics = 55 { kRate400G = 9; } - readonly attribute nullable PHYRate PHYRate = 0; + bitmap EthernetNetworkDiagnosticsFeature : BITMAP32 { + kPacketCounts = 0x1; + kErrorCounts = 0x2; + } + + readonly attribute nullable PHYRateEnum PHYRate = 0; readonly attribute nullable boolean fullDuplex = 1; readonly attribute int64u packetRxCount = 2; readonly attribute int64u packetTxCount = 3; @@ -1213,7 +1219,7 @@ server cluster Switch = 59 { } server cluster AdministratorCommissioning = 60 { - enum CommissioningWindowStatus : ENUM8 { + enum CommissioningWindowStatusEnum : ENUM8 { kWindowNotOpen = 0; kEnhancedWindowOpen = 1; kBasicWindowOpen = 2; @@ -1225,7 +1231,7 @@ server cluster AdministratorCommissioning = 60 { kWindowNotOpen = 4; } - readonly attribute CommissioningWindowStatus windowStatus = 0; + readonly attribute CommissioningWindowStatusEnum windowStatus = 0; readonly attribute nullable fabric_idx adminFabricIndex = 1; readonly attribute nullable int16u adminVendorId = 2; readonly attribute command_id generatedCommandList[] = 65528; @@ -1252,8 +1258,13 @@ server cluster AdministratorCommissioning = 60 { } server cluster OperationalCredentials = 62 { - enum OperationalCertStatus : ENUM8 { - kSuccess = 0; + enum CertificateChainTypeEnum : ENUM8 { + kDACCertificate = 1; + kPAICertificate = 2; + } + + enum NodeOperationalCertStatusEnum : ENUM8 { + kOk = 0; kInvalidPublicKey = 1; kInvalidNodeOpId = 2; kInvalidNOC = 3; @@ -1271,17 +1282,17 @@ server cluster OperationalCredentials = 62 { fabric_idx fabricIndex = 254; } - fabric_scoped struct FabricDescriptor { + fabric_scoped struct FabricDescriptorStruct { octet_string<65> rootPublicKey = 1; - vendor_id vendorId = 2; - fabric_id fabricId = 3; - node_id nodeId = 4; + vendor_id vendorID = 2; + fabric_id fabricID = 3; + node_id nodeID = 4; char_string<32> label = 5; fabric_idx fabricIndex = 254; } readonly attribute access(read: administer) NOCStruct NOCs[] = 0; - readonly attribute FabricDescriptor fabrics[] = 1; + readonly attribute FabricDescriptorStruct fabrics[] = 1; readonly attribute int8u supportedFabrics = 2; readonly attribute int8u commissionedFabrics = 3; readonly attribute OCTET_STRING trustedRootCertificates[] = 4; @@ -1297,7 +1308,7 @@ server cluster OperationalCredentials = 62 { } request struct CertificateChainRequestRequest { - INT8U certificateType = 0; + CertificateChainTypeEnum certificateType = 0; } request struct CSRRequestRequest { @@ -1327,12 +1338,12 @@ server cluster OperationalCredentials = 62 { } request struct AddTrustedRootCertificateRequest { - OCTET_STRING rootCertificate = 0; + OCTET_STRING rootCACertificate = 0; } response struct AttestationResponse = 1 { OCTET_STRING attestationElements = 0; - OCTET_STRING signature = 1; + OCTET_STRING attestationSignature = 1; } response struct CertificateChainResponse = 3 { @@ -1345,7 +1356,7 @@ server cluster OperationalCredentials = 62 { } response struct NOCResponse = 8 { - OperationalCertStatus statusCode = 0; + NodeOperationalCertStatusEnum statusCode = 0; optional fabric_idx fabricIndex = 1; optional CHAR_STRING debugText = 2; } @@ -1473,7 +1484,7 @@ endpoint 0 { callback attribute extension; callback attribute subjectsPerAccessControlEntry default = 4; callback attribute targetsPerAccessControlEntry default = 3; - callback attribute accessControlEntriesPerFabric default = 3; + callback attribute accessControlEntriesPerFabric default = 4; callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute attributeList; diff --git a/examples/bridge-app/bridge-common/bridge-app.zap b/examples/bridge-app/bridge-common/bridge-app.zap index 28c59bdbd6369e..63842b374dc5a8 100644 --- a/examples/bridge-app/bridge-common/bridge-app.zap +++ b/examples/bridge-app/bridge-common/bridge-app.zap @@ -358,7 +358,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "4", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -3855,7 +3855,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "PHYRate", + "type": "PHYRateEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -4029,7 +4029,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4097,7 +4097,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4109,7 +4109,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "CommissioningWindowStatus", + "type": "CommissioningWindowStatusEnum", "included": 1, "storageOption": "External", "singleton": 0, diff --git a/examples/bridge-app/esp32/main/CMakeLists.txt b/examples/bridge-app/esp32/main/CMakeLists.txt index 62b57d8d3fb2e7..f79d86d2ac9e40 100644 --- a/examples/bridge-app/esp32/main/CMakeLists.txt +++ b/examples/bridge-app/esp32/main/CMakeLists.txt @@ -20,7 +20,6 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/providers" SRC_DIRS "${CMAKE_CURRENT_LIST_DIR}" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/bridge-app/zap-generated" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated/attributes" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server" @@ -51,7 +50,7 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general-commissioning-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/common" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/providers" - PRIV_REQUIRES chip QRCode bt) + PRIV_REQUIRES chip QRCode bt nvs_flash) get_filename_component(CHIP_ROOT ${CMAKE_SOURCE_DIR}/third_party/connectedhomeip REALPATH) diff --git a/examples/bridge-app/esp32/main/DeviceCallbacks.cpp b/examples/bridge-app/esp32/main/DeviceCallbacks.cpp index b7e5a2bffc99fa..fa51be072f38ee 100644 --- a/examples/bridge-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/bridge-app/esp32/main/DeviceCallbacks.cpp @@ -39,8 +39,9 @@ using namespace ::chip::System; void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, ClusterId clusterId, AttributeId attributeId, uint8_t type, uint16_t size, uint8_t * value) { - ESP_LOGI(TAG, "PostAttributeChangeCallback - Cluster ID: '0x%04x', EndPoint ID: '0x%02x', Attribute ID: '0x%04x'", clusterId, - endpointId, attributeId); + ESP_LOGI(TAG, + "PostAttributeChangeCallback - Cluster ID: '0x%04" PRIx32 "', EndPoint ID: '0x%02x', Attribute ID: '0x%04" PRIx32 "'", + clusterId, endpointId, attributeId); ESP_LOGI(TAG, "Current free heap: %d\n", heap_caps_get_free_size(MALLOC_CAP_8BIT)); } diff --git a/examples/bridge-app/esp32/main/main.cpp b/examples/bridge-app/esp32/main/main.cpp index dd06b095a17cf7..5a90a98b9f4055 100644 --- a/examples/bridge-app/esp32/main/main.cpp +++ b/examples/bridge-app/esp32/main/main.cpp @@ -20,7 +20,7 @@ #include "esp_log.h" #include "nvs_flash.h" #include -#include +#include #include #include #include @@ -32,7 +32,6 @@ #include #include #include -#include #include #include @@ -100,26 +99,26 @@ static Device gLight4("Light 4", "Den"); /* BRIDGED DEVICE ENDPOINT: contains the following clusters: - On/Off - Descriptor - - Bridged Device Basic + - Bridged Device Basic Information */ // Declare On/Off cluster attributes DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(onOffAttrs) -DECLARE_DYNAMIC_ATTRIBUTE(ZCL_ON_OFF_ATTRIBUTE_ID, BOOLEAN, 1, 0), /* on/off */ +DECLARE_DYNAMIC_ATTRIBUTE(OnOff::Attributes::OnOff::Id, BOOLEAN, 1, 0), /* on/off */ DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); // Declare Descriptor cluster attributes DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(descriptorAttrs) -DECLARE_DYNAMIC_ATTRIBUTE(ZCL_DEVICE_LIST_ATTRIBUTE_ID, ARRAY, kDescriptorAttributeArraySize, 0), /* device list */ - DECLARE_DYNAMIC_ATTRIBUTE(ZCL_SERVER_LIST_ATTRIBUTE_ID, ARRAY, kDescriptorAttributeArraySize, 0), /* server list */ - DECLARE_DYNAMIC_ATTRIBUTE(ZCL_CLIENT_LIST_ATTRIBUTE_ID, ARRAY, kDescriptorAttributeArraySize, 0), /* client list */ - DECLARE_DYNAMIC_ATTRIBUTE(ZCL_PARTS_LIST_ATTRIBUTE_ID, ARRAY, kDescriptorAttributeArraySize, 0), /* parts list */ +DECLARE_DYNAMIC_ATTRIBUTE(Descriptor::Attributes::DeviceTypeList::Id, ARRAY, kDescriptorAttributeArraySize, 0), /* device list */ + DECLARE_DYNAMIC_ATTRIBUTE(Descriptor::Attributes::ServerList::Id, ARRAY, kDescriptorAttributeArraySize, 0), /* server list */ + DECLARE_DYNAMIC_ATTRIBUTE(Descriptor::Attributes::ClientList::Id, ARRAY, kDescriptorAttributeArraySize, 0), /* client list */ + DECLARE_DYNAMIC_ATTRIBUTE(Descriptor::Attributes::PartsList::Id, ARRAY, kDescriptorAttributeArraySize, 0), /* parts list */ DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); -// Declare Bridged Device Basic information cluster attributes +// Declare Bridged Device Basic Information cluster attributes DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(bridgedDeviceBasicAttrs) -DECLARE_DYNAMIC_ATTRIBUTE(ZCL_NODE_LABEL_ATTRIBUTE_ID, CHAR_STRING, kNodeLabelSize, 0), /* NodeLabel */ - DECLARE_DYNAMIC_ATTRIBUTE(ZCL_REACHABLE_ATTRIBUTE_ID, BOOLEAN, 1, 0), /* Reachable */ +DECLARE_DYNAMIC_ATTRIBUTE(BridgedDeviceBasicInformation::Attributes::NodeLabel::Id, CHAR_STRING, kNodeLabelSize, 0), /* NodeLabel */ + DECLARE_DYNAMIC_ATTRIBUTE(BridgedDeviceBasicInformation::Attributes::Reachable::Id, BOOLEAN, 1, 0), /* Reachable */ DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); // Declare Cluster List for Bridged Light endpoint @@ -138,7 +137,8 @@ constexpr CommandId onOffIncomingCommands[] = { DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(bridgedLightClusters) DECLARE_DYNAMIC_CLUSTER(OnOff::Id, onOffAttrs, onOffIncomingCommands, nullptr), DECLARE_DYNAMIC_CLUSTER(Descriptor::Id, descriptorAttrs, nullptr, nullptr), - DECLARE_DYNAMIC_CLUSTER(BridgedDeviceBasic::Id, bridgedDeviceBasicAttrs, nullptr, nullptr) DECLARE_DYNAMIC_CLUSTER_LIST_END; + DECLARE_DYNAMIC_CLUSTER(BridgedDeviceBasicInformation::Id, bridgedDeviceBasicAttrs, nullptr, + nullptr) DECLARE_DYNAMIC_CLUSTER_LIST_END; // Declare Bridged Light endpoint DECLARE_DYNAMIC_ENDPOINT(bridgedLightEndpoint, bridgedLightClusters); @@ -152,7 +152,7 @@ DataVersion gLight4DataVersions[ArraySize(bridgedLightClusters)]; */ #define ZCL_DESCRIPTOR_CLUSTER_REVISION (1u) -#define ZCL_BRIDGED_DEVICE_BASIC_CLUSTER_REVISION (1u) +#define ZCL_BRIDGED_DEVICE_BASIC_INFORMATION_CLUSTER_REVISION (1u) #define ZCL_FIXED_LABEL_CLUSTER_REVISION (1u) #define ZCL_ON_OFF_CLUSTER_REVISION (4u) @@ -215,20 +215,22 @@ CHIP_ERROR RemoveDeviceEndpoint(Device * dev) EmberAfStatus HandleReadBridgedDeviceBasicAttribute(Device * dev, chip::AttributeId attributeId, uint8_t * buffer, uint16_t maxReadLength) { - ChipLogProgress(DeviceLayer, "HandleReadBridgedDeviceBasicAttribute: attrId=%d, maxReadLength=%d", attributeId, maxReadLength); + using namespace BridgedDeviceBasicInformation::Attributes; + ChipLogProgress(DeviceLayer, "HandleReadBridgedDeviceBasicAttribute: attrId=%" PRIu32 ", maxReadLength=%u", attributeId, + maxReadLength); - if ((attributeId == ZCL_REACHABLE_ATTRIBUTE_ID) && (maxReadLength == 1)) + if ((attributeId == Reachable::Id) && (maxReadLength == 1)) { *buffer = dev->IsReachable() ? 1 : 0; } - else if ((attributeId == ZCL_NODE_LABEL_ATTRIBUTE_ID) && (maxReadLength == 32)) + else if ((attributeId == NodeLabel::Id) && (maxReadLength == 32)) { MutableByteSpan zclNameSpan(buffer, maxReadLength); MakeZclCharString(zclNameSpan, dev->GetName()); } - else if ((attributeId == ZCL_CLUSTER_REVISION_SERVER_ATTRIBUTE_ID) && (maxReadLength == 2)) + else if ((attributeId == ClusterRevision::Id) && (maxReadLength == 2)) { - *buffer = (uint16_t) ZCL_BRIDGED_DEVICE_BASIC_CLUSTER_REVISION; + *buffer = (uint16_t) ZCL_BRIDGED_DEVICE_BASIC_INFORMATION_CLUSTER_REVISION; } else { @@ -240,13 +242,13 @@ EmberAfStatus HandleReadBridgedDeviceBasicAttribute(Device * dev, chip::Attribut EmberAfStatus HandleReadOnOffAttribute(Device * dev, chip::AttributeId attributeId, uint8_t * buffer, uint16_t maxReadLength) { - ChipLogProgress(DeviceLayer, "HandleReadOnOffAttribute: attrId=%d, maxReadLength=%d", attributeId, maxReadLength); + ChipLogProgress(DeviceLayer, "HandleReadOnOffAttribute: attrId=%" PRIu32 ", maxReadLength=%u", attributeId, maxReadLength); - if ((attributeId == ZCL_ON_OFF_ATTRIBUTE_ID) && (maxReadLength == 1)) + if ((attributeId == OnOff::Attributes::OnOff::Id) && (maxReadLength == 1)) { *buffer = dev->IsOn() ? 1 : 0; } - else if ((attributeId == ZCL_CLUSTER_REVISION_SERVER_ATTRIBUTE_ID) && (maxReadLength == 2)) + else if ((attributeId == OnOff::Attributes::ClusterRevision::Id) && (maxReadLength == 2)) { *buffer = (uint16_t) ZCL_ON_OFF_CLUSTER_REVISION; } @@ -260,9 +262,9 @@ EmberAfStatus HandleReadOnOffAttribute(Device * dev, chip::AttributeId attribute EmberAfStatus HandleWriteOnOffAttribute(Device * dev, chip::AttributeId attributeId, uint8_t * buffer) { - ChipLogProgress(DeviceLayer, "HandleWriteOnOffAttribute: attrId=%d", attributeId); + ChipLogProgress(DeviceLayer, "HandleWriteOnOffAttribute: attrId=%" PRIu32, attributeId); - ReturnErrorCodeIf((attributeId != ZCL_ON_OFF_ATTRIBUTE_ID) || (!dev->IsReachable()), EMBER_ZCL_STATUS_FAILURE); + ReturnErrorCodeIf((attributeId != OnOff::Attributes::OnOff::Id) || (!dev->IsReachable()), EMBER_ZCL_STATUS_FAILURE); dev->SetOnOff(*buffer == 1); return EMBER_ZCL_STATUS_SUCCESS; } @@ -277,7 +279,7 @@ EmberAfStatus emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterI { Device * dev = gDevices[endpointIndex]; - if (clusterId == BridgedDeviceBasic::Id) + if (clusterId == BridgedDeviceBasicInformation::Id) { return HandleReadBridgedDeviceBasicAttribute(dev, attributeMetadata->attributeId, buffer, maxReadLength); } @@ -327,7 +329,7 @@ void HandleDeviceStatusChanged(Device * dev, Device::Changed_t itemChangedMask) { if (itemChangedMask & Device::kChanged_Reachable) { - ScheduleReportingCallback(dev, BridgedDeviceBasic::Id, BridgedDeviceBasic::Attributes::Reachable::Id); + ScheduleReportingCallback(dev, BridgedDeviceBasicInformation::Id, BridgedDeviceBasicInformation::Attributes::Reachable::Id); } if (itemChangedMask & Device::kChanged_State) @@ -337,7 +339,7 @@ void HandleDeviceStatusChanged(Device * dev, Device::Changed_t itemChangedMask) if (itemChangedMask & Device::kChanged_Name) { - ScheduleReportingCallback(dev, BridgedDeviceBasic::Id, BridgedDeviceBasic::Attributes::NodeLabel::Id); + ScheduleReportingCallback(dev, BridgedDeviceBasicInformation::Id, BridgedDeviceBasicInformation::Attributes::NodeLabel::Id); } } @@ -427,7 +429,7 @@ extern "C" void app_main() chip_err = deviceMgr.Init(&AppCallback); if (chip_err != CHIP_NO_ERROR) { - ESP_LOGE(TAG, "device.Init() failed: %s", ErrorStr(chip_err)); + ESP_LOGE(TAG, "device.Init() failed: %" CHIP_ERROR_FORMAT, chip_err.Format()); return; } diff --git a/examples/bridge-app/linux/README.md b/examples/bridge-app/linux/README.md index 83ac848871af20..f9e8c9708b64a0 100644 --- a/examples/bridge-app/linux/README.md +++ b/examples/bridge-app/linux/README.md @@ -87,7 +87,7 @@ clusters as well as the root descriptor cluster. The example demonstrates the use of dynamic endpoints and the concept of adding and removing endpoints at runtime. First, the example declares a `bridgedLightEndpoint` data structure for a Light endpoint with `OnOff`, -`Descriptor`, `BridgedDeviceBasic`, and `FixedLabel` clusters. +`Descriptor`, `BridgedDeviceBasicInformation`, and `FixedLabel` clusters. Using this declared endpoint structure, three endpoints for three bridged lights are dynamically added at endpoint ID's `2`, `3`, and `4`, representing @@ -99,10 +99,10 @@ A fourth light, `Light 4`, is then added occupying endpoint ID `5`. Finally, `Light 2` is re-added, and will occupy endpoint ID `6`. -All endpoints populate the `Bridged Device Basic` and `Fixed Label` clusters. In -the `Bridged Device Basic` cluster, the `reachable` attribute is simulated. In -the `Fixed Label` cluster, the `LabelList` attribute is simulated with the -value/label pair `"room"`/`[light name]`. +All endpoints populate the `Bridged Device Basic Information` and `Fixed Label` +clusters. In the `Bridged Device Basic Information` cluster, the `reachable` +attribute is simulated. In the `Fixed Label` cluster, the `LabelList` attribute +is simulated with the value/label pair `"room"`/`[light name]`. ## Building diff --git a/examples/bridge-app/linux/main.cpp b/examples/bridge-app/linux/main.cpp index c7ef75c26d9928..622c1cac4fd709 100644 --- a/examples/bridge-app/linux/main.cpp +++ b/examples/bridge-app/linux/main.cpp @@ -22,7 +22,7 @@ #include -#include +#include #include #include #include @@ -149,26 +149,26 @@ const int16_t initialMeasuredValue = 100; // LIGHT ENDPOINT: contains the following clusters: // - On/Off // - Descriptor -// - Bridged Device Basic +// - Bridged Device Basic Information // Declare On/Off cluster attributes DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(onOffAttrs) -DECLARE_DYNAMIC_ATTRIBUTE(ZCL_ON_OFF_ATTRIBUTE_ID, BOOLEAN, 1, 0), /* on/off */ +DECLARE_DYNAMIC_ATTRIBUTE(OnOff::Attributes::OnOff::Id, BOOLEAN, 1, 0), /* on/off */ DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); // Declare Descriptor cluster attributes DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(descriptorAttrs) -DECLARE_DYNAMIC_ATTRIBUTE(ZCL_DEVICE_LIST_ATTRIBUTE_ID, ARRAY, kDescriptorAttributeArraySize, 0), /* device list */ - DECLARE_DYNAMIC_ATTRIBUTE(ZCL_SERVER_LIST_ATTRIBUTE_ID, ARRAY, kDescriptorAttributeArraySize, 0), /* server list */ - DECLARE_DYNAMIC_ATTRIBUTE(ZCL_CLIENT_LIST_ATTRIBUTE_ID, ARRAY, kDescriptorAttributeArraySize, 0), /* client list */ - DECLARE_DYNAMIC_ATTRIBUTE(ZCL_PARTS_LIST_ATTRIBUTE_ID, ARRAY, kDescriptorAttributeArraySize, 0), /* parts list */ +DECLARE_DYNAMIC_ATTRIBUTE(Descriptor::Attributes::DeviceTypeList::Id, ARRAY, kDescriptorAttributeArraySize, 0), /* device list */ + DECLARE_DYNAMIC_ATTRIBUTE(Descriptor::Attributes::ServerList::Id, ARRAY, kDescriptorAttributeArraySize, 0), /* server list */ + DECLARE_DYNAMIC_ATTRIBUTE(Descriptor::Attributes::ClientList::Id, ARRAY, kDescriptorAttributeArraySize, 0), /* client list */ + DECLARE_DYNAMIC_ATTRIBUTE(Descriptor::Attributes::PartsList::Id, ARRAY, kDescriptorAttributeArraySize, 0), /* parts list */ DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); -// Declare Bridged Device Basic information cluster attributes +// Declare Bridged Device Basic Information cluster attributes DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(bridgedDeviceBasicAttrs) -DECLARE_DYNAMIC_ATTRIBUTE(ZCL_NODE_LABEL_ATTRIBUTE_ID, CHAR_STRING, kNodeLabelSize, 0), /* NodeLabel */ - DECLARE_DYNAMIC_ATTRIBUTE(ZCL_REACHABLE_ATTRIBUTE_ID, BOOLEAN, 1, 0), /* Reachable */ - DECLARE_DYNAMIC_ATTRIBUTE(ZCL_FEATURE_MAP_SERVER_ATTRIBUTE_ID, BITMAP32, 4, 0), /* feature map */ +DECLARE_DYNAMIC_ATTRIBUTE(BridgedDeviceBasicInformation::Attributes::NodeLabel::Id, CHAR_STRING, kNodeLabelSize, 0), /* NodeLabel */ + DECLARE_DYNAMIC_ATTRIBUTE(BridgedDeviceBasicInformation::Attributes::Reachable::Id, BOOLEAN, 1, 0), /* Reachable */ + DECLARE_DYNAMIC_ATTRIBUTE(BridgedDeviceBasicInformation::Attributes::FeatureMap::Id, BITMAP32, 4, 0), /* feature map */ DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); // Declare Cluster List for Bridged Light endpoint @@ -187,7 +187,8 @@ constexpr CommandId onOffIncomingCommands[] = { DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(bridgedLightClusters) DECLARE_DYNAMIC_CLUSTER(OnOff::Id, onOffAttrs, onOffIncomingCommands, nullptr), DECLARE_DYNAMIC_CLUSTER(Descriptor::Id, descriptorAttrs, nullptr, nullptr), - DECLARE_DYNAMIC_CLUSTER(BridgedDeviceBasic::Id, bridgedDeviceBasicAttrs, nullptr, nullptr) DECLARE_DYNAMIC_CLUSTER_LIST_END; + DECLARE_DYNAMIC_CLUSTER(BridgedDeviceBasicInformation::Id, bridgedDeviceBasicAttrs, nullptr, + nullptr) DECLARE_DYNAMIC_CLUSTER_LIST_END; // Declare Bridged Light endpoint DECLARE_DYNAMIC_ENDPOINT(bridgedLightEndpoint, bridgedLightClusters); @@ -229,26 +230,26 @@ Action action3(0x1003, "Turn Off Room 1", Actions::ActionTypeEnum::kAutomation, // POWER SOURCE ENDPOINT: contains the following clusters: // - Power Source // - Descriptor -// - Bridged Device Basic +// - Bridged Device Basic Information DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(powerSourceAttrs) -DECLARE_DYNAMIC_ATTRIBUTE(ZCL_POWER_SOURCE_BAT_CHARGE_LEVEL_ATTRIBUTE_ID, ENUM8, 1, 0), - DECLARE_DYNAMIC_ATTRIBUTE(ZCL_POWER_SOURCE_ORDER_ATTRIBUTE_ID, INT8U, 1, 0), - DECLARE_DYNAMIC_ATTRIBUTE(ZCL_POWER_SOURCE_STATUS_ATTRIBUTE_ID, ENUM8, 1, 0), - DECLARE_DYNAMIC_ATTRIBUTE(ZCL_POWER_SOURCE_DESCRIPTION_ATTRIBUTE_ID, CHAR_STRING, 32, 0), DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); +DECLARE_DYNAMIC_ATTRIBUTE(PowerSource::Attributes::BatChargeLevel::Id, ENUM8, 1, 0), + DECLARE_DYNAMIC_ATTRIBUTE(PowerSource::Attributes::Order::Id, INT8U, 1, 0), + DECLARE_DYNAMIC_ATTRIBUTE(PowerSource::Attributes::Status::Id, ENUM8, 1, 0), + DECLARE_DYNAMIC_ATTRIBUTE(PowerSource::Attributes::Description::Id, CHAR_STRING, 32, 0), DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(bridgedPowerSourceClusters) DECLARE_DYNAMIC_CLUSTER(Descriptor::Id, descriptorAttrs, nullptr, nullptr), - DECLARE_DYNAMIC_CLUSTER(BridgedDeviceBasic::Id, bridgedDeviceBasicAttrs, nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER(BridgedDeviceBasicInformation::Id, bridgedDeviceBasicAttrs, nullptr, nullptr), DECLARE_DYNAMIC_CLUSTER(PowerSource::Id, powerSourceAttrs, nullptr, nullptr), DECLARE_DYNAMIC_CLUSTER_LIST_END; DECLARE_DYNAMIC_ENDPOINT(bridgedPowerSourceEndpoint, bridgedPowerSourceClusters); DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(tempSensorAttrs) -DECLARE_DYNAMIC_ATTRIBUTE(ZCL_TEMP_MEASURED_VALUE_ATTRIBUTE_ID, INT16S, 2, 0), /* Measured Value */ - DECLARE_DYNAMIC_ATTRIBUTE(ZCL_TEMP_MIN_MEASURED_VALUE_ATTRIBUTE_ID, INT16S, 2, 0), /* Min Measured Value */ - DECLARE_DYNAMIC_ATTRIBUTE(ZCL_TEMP_MAX_MEASURED_VALUE_ATTRIBUTE_ID, INT16S, 2, 0), /* Max Measured Value */ - DECLARE_DYNAMIC_ATTRIBUTE(ZCL_FEATURE_MAP_SERVER_ATTRIBUTE_ID, BITMAP32, 4, 0), /* FeatureMap */ +DECLARE_DYNAMIC_ATTRIBUTE(TemperatureMeasurement::Attributes::MeasuredValue::Id, INT16S, 2, 0), /* Measured Value */ + DECLARE_DYNAMIC_ATTRIBUTE(TemperatureMeasurement::Attributes::MinMeasuredValue::Id, INT16S, 2, 0), /* Min Measured Value */ + DECLARE_DYNAMIC_ATTRIBUTE(TemperatureMeasurement::Attributes::MaxMeasuredValue::Id, INT16S, 2, 0), /* Max Measured Value */ + DECLARE_DYNAMIC_ATTRIBUTE(TemperatureMeasurement::Attributes::FeatureMap::Id, BITMAP32, 4, 0), /* FeatureMap */ DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); // --------------------------------------------------------------------------- @@ -256,11 +257,12 @@ DECLARE_DYNAMIC_ATTRIBUTE(ZCL_TEMP_MEASURED_VALUE_ATTRIBUTE_ID, INT16S, 2, 0), // TEMPERATURE SENSOR ENDPOINT: contains the following clusters: // - Temperature measurement // - Descriptor -// - Bridged Device Basic +// - Bridged Device Basic Information DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(bridgedTempSensorClusters) DECLARE_DYNAMIC_CLUSTER(TemperatureMeasurement::Id, tempSensorAttrs, nullptr, nullptr), DECLARE_DYNAMIC_CLUSTER(Descriptor::Id, descriptorAttrs, nullptr, nullptr), - DECLARE_DYNAMIC_CLUSTER(BridgedDeviceBasic::Id, bridgedDeviceBasicAttrs, nullptr, nullptr), DECLARE_DYNAMIC_CLUSTER_LIST_END; + DECLARE_DYNAMIC_CLUSTER(BridgedDeviceBasicInformation::Id, bridgedDeviceBasicAttrs, nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER_LIST_END; // Declare Bridged Light endpoint DECLARE_DYNAMIC_ENDPOINT(bridgedTempSensorEndpoint, bridgedTempSensorClusters); @@ -271,12 +273,13 @@ DataVersion gTempSensor2DataVersions[ArraySize(bridgedTempSensorClusters)]; // // COMPOSED DEVICE ENDPOINT: contains the following clusters: // - Descriptor -// - Bridged Device Basic +// - Bridged Device Basic Information // Composed Device Configuration DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(bridgedComposedDeviceClusters) DECLARE_DYNAMIC_CLUSTER(Descriptor::Id, descriptorAttrs, nullptr, nullptr), - DECLARE_DYNAMIC_CLUSTER(BridgedDeviceBasic::Id, bridgedDeviceBasicAttrs, nullptr, nullptr), DECLARE_DYNAMIC_CLUSTER_LIST_END; + DECLARE_DYNAMIC_CLUSTER(BridgedDeviceBasicInformation::Id, bridgedDeviceBasicAttrs, nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER_LIST_END; DECLARE_DYNAMIC_ENDPOINT(bridgedComposedDeviceEndpoint, bridgedComposedDeviceClusters); DataVersion gComposedDeviceDataVersions[ArraySize(bridgedComposedDeviceClusters)]; @@ -290,8 +293,8 @@ DataVersion gComposedPowerSourceDataVersions[ArraySize(bridgedPowerSourceCluster // ================================================================================= #define ZCL_DESCRIPTOR_CLUSTER_REVISION (1u) -#define ZCL_BRIDGED_DEVICE_BASIC_CLUSTER_REVISION (1u) -#define ZCL_BRIDGED_DEVICE_BASIC_FEATURE_MAP (0u) +#define ZCL_BRIDGED_DEVICE_BASIC_INFORMATION_CLUSTER_REVISION (1u) +#define ZCL_BRIDGED_DEVICE_BASIC_INFORMATION_FEATURE_MAP (0u) #define ZCL_FIXED_LABEL_CLUSTER_REVISION (1u) #define ZCL_ON_OFF_CLUSTER_REVISION (4u) #define ZCL_TEMPERATURE_SENSOR_CLUSTER_REVISION (1u) @@ -427,12 +430,12 @@ void HandleDeviceStatusChanged(Device * dev, Device::Changed_t itemChangedMask) { if (itemChangedMask & Device::kChanged_Reachable) { - ScheduleReportingCallback(dev, BridgedDeviceBasic::Id, BridgedDeviceBasic::Attributes::Reachable::Id); + ScheduleReportingCallback(dev, BridgedDeviceBasicInformation::Id, BridgedDeviceBasicInformation::Attributes::Reachable::Id); } if (itemChangedMask & Device::kChanged_Name) { - ScheduleReportingCallback(dev, BridgedDeviceBasic::Id, BridgedDeviceBasic::Attributes::NodeLabel::Id); + ScheduleReportingCallback(dev, BridgedDeviceBasicInformation::Id, BridgedDeviceBasicInformation::Attributes::NodeLabel::Id); } } @@ -485,24 +488,26 @@ void HandleDeviceTempSensorStatusChanged(DeviceTempSensor * dev, DeviceTempSenso EmberAfStatus HandleReadBridgedDeviceBasicAttribute(Device * dev, chip::AttributeId attributeId, uint8_t * buffer, uint16_t maxReadLength) { + using namespace BridgedDeviceBasicInformation::Attributes; + ChipLogProgress(DeviceLayer, "HandleReadBridgedDeviceBasicAttribute: attrId=%d, maxReadLength=%d", attributeId, maxReadLength); - if ((attributeId == ZCL_REACHABLE_ATTRIBUTE_ID) && (maxReadLength == 1)) + if ((attributeId == Reachable::Id) && (maxReadLength == 1)) { *buffer = dev->IsReachable() ? 1 : 0; } - else if ((attributeId == ZCL_NODE_LABEL_ATTRIBUTE_ID) && (maxReadLength == 32)) + else if ((attributeId == NodeLabel::Id) && (maxReadLength == 32)) { MutableByteSpan zclNameSpan(buffer, maxReadLength); MakeZclCharString(zclNameSpan, dev->GetName()); } - else if ((attributeId == ZCL_CLUSTER_REVISION_SERVER_ATTRIBUTE_ID) && (maxReadLength == 2)) + else if ((attributeId == ClusterRevision::Id) && (maxReadLength == 2)) { - *buffer = (uint16_t) ZCL_BRIDGED_DEVICE_BASIC_CLUSTER_REVISION; + *buffer = (uint16_t) ZCL_BRIDGED_DEVICE_BASIC_INFORMATION_CLUSTER_REVISION; } - else if ((attributeId == ZCL_FEATURE_MAP_SERVER_ATTRIBUTE_ID) && (maxReadLength == 4)) + else if ((attributeId == FeatureMap::Id) && (maxReadLength == 4)) { - *buffer = (uint32_t) ZCL_BRIDGED_DEVICE_BASIC_FEATURE_MAP; + *buffer = (uint32_t) ZCL_BRIDGED_DEVICE_BASIC_INFORMATION_FEATURE_MAP; } else { @@ -516,11 +521,11 @@ EmberAfStatus HandleReadOnOffAttribute(DeviceOnOff * dev, chip::AttributeId attr { ChipLogProgress(DeviceLayer, "HandleReadOnOffAttribute: attrId=%d, maxReadLength=%d", attributeId, maxReadLength); - if ((attributeId == ZCL_ON_OFF_ATTRIBUTE_ID) && (maxReadLength == 1)) + if ((attributeId == OnOff::Attributes::OnOff::Id) && (maxReadLength == 1)) { *buffer = dev->IsOn() ? 1 : 0; } - else if ((attributeId == ZCL_CLUSTER_REVISION_SERVER_ATTRIBUTE_ID) && (maxReadLength == 2)) + else if ((attributeId == OnOff::Attributes::ClusterRevision::Id) && (maxReadLength == 2)) { *buffer = (uint16_t) ZCL_ON_OFF_CLUSTER_REVISION; } @@ -536,7 +541,7 @@ EmberAfStatus HandleWriteOnOffAttribute(DeviceOnOff * dev, chip::AttributeId att { ChipLogProgress(DeviceLayer, "HandleWriteOnOffAttribute: attrId=%d", attributeId); - if ((attributeId == ZCL_ON_OFF_ATTRIBUTE_ID) && (dev->IsReachable())) + if ((attributeId == OnOff::Attributes::OnOff::Id) && (dev->IsReachable())) { if (*buffer) { @@ -597,27 +602,29 @@ EmberAfStatus HandleReadPowerSourceAttribute(DevicePowerSource * dev, chip::Attr EmberAfStatus HandleReadTempMeasurementAttribute(DeviceTempSensor * dev, chip::AttributeId attributeId, uint8_t * buffer, uint16_t maxReadLength) { - if ((attributeId == ZCL_TEMP_MEASURED_VALUE_ATTRIBUTE_ID) && (maxReadLength == 2)) + using namespace TemperatureMeasurement::Attributes; + + if ((attributeId == MeasuredValue::Id) && (maxReadLength == 2)) { int16_t measuredValue = dev->GetMeasuredValue(); memcpy(buffer, &measuredValue, sizeof(measuredValue)); } - else if ((attributeId == ZCL_TEMP_MIN_MEASURED_VALUE_ATTRIBUTE_ID) && (maxReadLength == 2)) + else if ((attributeId == MinMeasuredValue::Id) && (maxReadLength == 2)) { int16_t minValue = dev->mMin; memcpy(buffer, &minValue, sizeof(minValue)); } - else if ((attributeId == ZCL_TEMP_MAX_MEASURED_VALUE_ATTRIBUTE_ID) && (maxReadLength == 2)) + else if ((attributeId == MaxMeasuredValue::Id) && (maxReadLength == 2)) { int16_t maxValue = dev->mMax; memcpy(buffer, &maxValue, sizeof(maxValue)); } - else if ((attributeId == ZCL_FEATURE_MAP_SERVER_ATTRIBUTE_ID) && (maxReadLength == 4)) + else if ((attributeId == FeatureMap::Id) && (maxReadLength == 4)) { uint32_t featureMap = ZCL_TEMPERATURE_SENSOR_FEATURE_MAP; memcpy(buffer, &featureMap, sizeof(featureMap)); } - else if ((attributeId == ZCL_CLUSTER_REVISION_SERVER_ATTRIBUTE_ID) && (maxReadLength == 2)) + else if ((attributeId == ClusterRevision::Id) && (maxReadLength == 2)) { uint16_t clusterRevision = ZCL_TEMPERATURE_SENSOR_CLUSTER_REVISION; memcpy(buffer, &clusterRevision, sizeof(clusterRevision)); @@ -642,7 +649,7 @@ EmberAfStatus emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterI { Device * dev = gDevices[endpointIndex]; - if (clusterId == BridgedDeviceBasic::Id) + if (clusterId == BridgedDeviceBasicInformation::Id) { ret = HandleReadBridgedDeviceBasicAttribute(dev, attributeMetadata->attributeId, buffer, maxReadLength); } diff --git a/examples/build_overrides/ot_efr32.gni b/examples/build_overrides/ot_efr32.gni index d1d64c693b735f..76a68a839eab64 100644 --- a/examples/build_overrides/ot_efr32.gni +++ b/examples/build_overrides/ot_efr32.gni @@ -13,6 +13,5 @@ # limitations under the License. declare_args() { - openthread_efr32_root = - "//third_party/connectedhomeip/third_party/openthread/ot-efr32" + openthread_efr32_root = "//third_party/connectedhomeip/third_party/silabs/gecko_sdk/protocol/openthread/platform-abstraction/efr32" } diff --git a/examples/chef/ameba/main/DeviceCallbacks.cpp b/examples/chef/ameba/main/DeviceCallbacks.cpp index 8e6b1192b96dd8..0ef956fe939e11 100644 --- a/examples/chef/ameba/main/DeviceCallbacks.cpp +++ b/examples/chef/ameba/main/DeviceCallbacks.cpp @@ -25,7 +25,7 @@ #include "DeviceCallbacks.h" #include "CHIPDeviceManager.h" -#include +#include #include #include #include @@ -139,7 +139,7 @@ void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event void DeviceCallbacks::OnOnOffPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { - VerifyOrExit(attributeId == ZCL_ON_OFF_ATTRIBUTE_ID, + VerifyOrExit(attributeId == app::Clusters::OnOff::Attributes::OnOff::Id, ChipLogError(DeviceLayer, TAG, "Unhandled Attribute ID: '0x%04x", attributeId)); VerifyOrExit(endpointId == 1 || endpointId == 2, ChipLogError(DeviceLayer, TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); @@ -161,7 +161,7 @@ void IdentifyTimerHandler(Layer * systemLayer, void * appState, CHIP_ERROR error void DeviceCallbacks::OnIdentifyPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { - VerifyOrExit(attributeId == ZCL_IDENTIFY_TIME_ATTRIBUTE_ID, + VerifyOrExit(attributeId == app::Clusters::Identify::Attributes::IdentifyTime::Id, ChipLogError(DeviceLayer, "[%s] Unhandled Attribute ID: '0x%04x", TAG, attributeId)); VerifyOrExit(endpointId == 1, ChipLogError(DeviceLayer, "[%s] Unexpected EndPoint ID: `0x%02x'", TAG, endpointId)); diff --git a/examples/chef/common/stubs.cpp b/examples/chef/common/stubs.cpp index f170d306ff9ff3..5d7c2802d857f0 100644 --- a/examples/chef/common/stubs.cpp +++ b/examples/chef/common/stubs.cpp @@ -1,25 +1,22 @@ -#include -#include #include #include -#include // Include door lock callbacks only when the server is enabled #ifdef EMBER_AF_PLUGIN_DOOR_LOCK_SERVER #include bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const chip::Optional & pinCode, - chip::app::Clusters::DoorLock::DlOperationError & err) + chip::app::Clusters::DoorLock::OperationErrorEnum & err) { - err = DlOperationError::kUnspecified; + err = OperationErrorEnum::kUnspecified; // TBD: LockManager, check pinCode, ... return DoorLockServer::Instance().SetLockState(endpointId, DlLockState::kLocked); } bool emberAfPluginDoorLockOnDoorUnlockCommand(chip::EndpointId endpointId, const chip::Optional & pinCode, - chip::app::Clusters::DoorLock::DlOperationError & err) + chip::app::Clusters::DoorLock::OperationErrorEnum & err) { - err = DlOperationError::kUnspecified; + err = OperationErrorEnum::kUnspecified; // TBD: LockManager, check pinCode, ... return DoorLockServer::Instance().SetLockState(endpointId, DlLockState::kUnlocked); } diff --git a/examples/chef/devices/noip_rootnode_dimmablelight_bCwGYSDpoe.matter b/examples/chef/devices/noip_rootnode_dimmablelight_bCwGYSDpoe.matter index 1cc0aa78347c7e..55066d37b26292 100644 --- a/examples/chef/devices/noip_rootnode_dimmablelight_bCwGYSDpoe.matter +++ b/examples/chef/devices/noip_rootnode_dimmablelight_bCwGYSDpoe.matter @@ -132,10 +132,6 @@ server cluster OnOff = 6 { kLighting = 0x1; } - bitmap SceneFeatures : BITMAP32 { - kSceneNames = 0x1; - } - readonly attribute boolean onOff = 0; readonly attribute boolean globalSceneControl = 16384; attribute int16u onTime = 16385; @@ -656,7 +652,7 @@ server cluster GeneralDiagnostics = 51 { kSoftwareReset = 6; } - enum HardwareFault : ENUM8 { + enum HardwareFaultEnum : ENUM8 { kUnspecified = 0; kRadio = 1; kSensor = 2; @@ -670,7 +666,7 @@ server cluster GeneralDiagnostics = 51 { kTamperDetected = 10; } - enum InterfaceType : ENUM8 { + enum InterfaceTypeEnum : ENUM8 { kUnspecified = 0; kWiFi = 1; kEthernet = 2; @@ -678,14 +674,14 @@ server cluster GeneralDiagnostics = 51 { kThread = 4; } - enum NetworkFaultType : ENUM8 { + enum NetworkFaultEnum : ENUM8 { kUnspecified = 0; kHardwareFailure = 1; kNetworkJammed = 2; kConnectionFailed = 3; } - enum RadioFault : ENUM8 { + enum RadioFaultEnum : ENUM8 { kUnspecified = 0; kWiFiFault = 1; kCellularFault = 2; @@ -703,22 +699,22 @@ server cluster GeneralDiagnostics = 51 { octet_string<8> hardwareAddress = 4; octet_string IPv4Addresses[] = 5; octet_string IPv6Addresses[] = 6; - InterfaceType type = 7; + InterfaceTypeEnum type = 7; } critical event HardwareFaultChange = 0 { - HardwareFault current[] = 0; - HardwareFault previous[] = 1; + HardwareFaultEnum current[] = 0; + HardwareFaultEnum previous[] = 1; } critical event RadioFaultChange = 1 { - RadioFault current[] = 0; - RadioFault previous[] = 1; + RadioFaultEnum current[] = 0; + RadioFaultEnum previous[] = 1; } critical event NetworkFaultChange = 2 { - NetworkFaultType current[] = 0; - NetworkFaultType previous[] = 1; + NetworkFaultEnum current[] = 0; + NetworkFaultEnum previous[] = 1; } critical event BootReason = 3 { @@ -730,9 +726,9 @@ server cluster GeneralDiagnostics = 51 { readonly attribute int64u upTime = 2; readonly attribute int32u totalOperationalHours = 3; readonly attribute BootReasonEnum bootReason = 4; - readonly attribute HardwareFault activeHardwareFaults[] = 5; - readonly attribute RadioFault activeRadioFaults[] = 6; - readonly attribute NetworkFaultType activeNetworkFaults[] = 7; + readonly attribute HardwareFaultEnum activeHardwareFaults[] = 5; + readonly attribute RadioFaultEnum activeRadioFaults[] = 6; + readonly attribute NetworkFaultEnum activeNetworkFaults[] = 7; readonly attribute boolean testEventTriggersEnabled = 8; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -963,6 +959,11 @@ server cluster WiFiNetworkDiagnostics = 54 { kAx = 5; } + bitmap WiFiNetworkDiagnosticsFeature : BITMAP32 { + kPacketCounts = 0x1; + kErrorCounts = 0x2; + } + info event Disconnection = 0 { INT16U reasonCode = 0; } @@ -996,7 +997,7 @@ server cluster WiFiNetworkDiagnostics = 54 { } server cluster EthernetNetworkDiagnostics = 55 { - enum PHYRate : ENUM8 { + enum PHYRateEnum : ENUM8 { kRate10M = 0; kRate100M = 1; kRate1G = 2; @@ -1009,7 +1010,12 @@ server cluster EthernetNetworkDiagnostics = 55 { kRate400G = 9; } - readonly attribute nullable PHYRate PHYRate = 0; + bitmap EthernetNetworkDiagnosticsFeature : BITMAP32 { + kPacketCounts = 0x1; + kErrorCounts = 0x2; + } + + readonly attribute nullable PHYRateEnum PHYRate = 0; readonly attribute nullable boolean fullDuplex = 1; readonly attribute int64u packetRxCount = 2; readonly attribute int64u packetTxCount = 3; @@ -1068,7 +1074,7 @@ server cluster Switch = 59 { } server cluster AdministratorCommissioning = 60 { - enum CommissioningWindowStatus : ENUM8 { + enum CommissioningWindowStatusEnum : ENUM8 { kWindowNotOpen = 0; kEnhancedWindowOpen = 1; kBasicWindowOpen = 2; @@ -1080,7 +1086,7 @@ server cluster AdministratorCommissioning = 60 { kWindowNotOpen = 4; } - readonly attribute CommissioningWindowStatus windowStatus = 0; + readonly attribute CommissioningWindowStatusEnum windowStatus = 0; readonly attribute nullable fabric_idx adminFabricIndex = 1; readonly attribute nullable int16u adminVendorId = 2; readonly attribute bitmap32 featureMap = 65532; @@ -1104,8 +1110,13 @@ server cluster AdministratorCommissioning = 60 { } server cluster OperationalCredentials = 62 { - enum OperationalCertStatus : ENUM8 { - kSuccess = 0; + enum CertificateChainTypeEnum : ENUM8 { + kDACCertificate = 1; + kPAICertificate = 2; + } + + enum NodeOperationalCertStatusEnum : ENUM8 { + kOk = 0; kInvalidPublicKey = 1; kInvalidNodeOpId = 2; kInvalidNOC = 3; @@ -1123,17 +1134,17 @@ server cluster OperationalCredentials = 62 { fabric_idx fabricIndex = 254; } - fabric_scoped struct FabricDescriptor { + fabric_scoped struct FabricDescriptorStruct { octet_string<65> rootPublicKey = 1; - vendor_id vendorId = 2; - fabric_id fabricId = 3; - node_id nodeId = 4; + vendor_id vendorID = 2; + fabric_id fabricID = 3; + node_id nodeID = 4; char_string<32> label = 5; fabric_idx fabricIndex = 254; } readonly attribute access(read: administer) NOCStruct NOCs[] = 0; - readonly attribute FabricDescriptor fabrics[] = 1; + readonly attribute FabricDescriptorStruct fabrics[] = 1; readonly attribute int8u supportedFabrics = 2; readonly attribute int8u commissionedFabrics = 3; readonly attribute OCTET_STRING trustedRootCertificates[] = 4; @@ -1146,7 +1157,7 @@ server cluster OperationalCredentials = 62 { } request struct CertificateChainRequestRequest { - INT8U certificateType = 0; + CertificateChainTypeEnum certificateType = 0; } request struct CSRRequestRequest { @@ -1176,12 +1187,12 @@ server cluster OperationalCredentials = 62 { } request struct AddTrustedRootCertificateRequest { - OCTET_STRING rootCertificate = 0; + OCTET_STRING rootCACertificate = 0; } response struct AttestationResponse = 1 { OCTET_STRING attestationElements = 0; - OCTET_STRING signature = 1; + OCTET_STRING attestationSignature = 1; } response struct CertificateChainResponse = 3 { @@ -1194,7 +1205,7 @@ server cluster OperationalCredentials = 62 { } response struct NOCResponse = 8 { - OperationalCertStatus statusCode = 0; + NodeOperationalCertStatusEnum statusCode = 0; optional fabric_idx fabricIndex = 1; optional CHAR_STRING debugText = 2; } diff --git a/examples/chef/devices/noip_rootnode_dimmablelight_bCwGYSDpoe.zap b/examples/chef/devices/noip_rootnode_dimmablelight_bCwGYSDpoe.zap index 642aed58da4ab1..db21fdca32ba5b 100644 --- a/examples/chef/devices/noip_rootnode_dimmablelight_bCwGYSDpoe.zap +++ b/examples/chef/devices/noip_rootnode_dimmablelight_bCwGYSDpoe.zap @@ -4265,7 +4265,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "PHYRate", + "type": "PHYRateEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -4489,7 +4489,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4541,7 +4541,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4553,7 +4553,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "CommissioningWindowStatus", + "type": "CommissioningWindowStatusEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -6997,7 +6997,7 @@ "enabled": 0, "attributes": [ { - "name": "occupancy", + "name": "Occupancy", "code": 0, "mfgCode": null, "side": "server", @@ -7013,7 +7013,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type", + "name": "OccupancySensorType", "code": 1, "mfgCode": null, "side": "server", @@ -7029,7 +7029,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type bitmap", + "name": "OccupancySensorTypeBitmap", "code": 2, "mfgCode": null, "side": "server", @@ -7045,7 +7045,7 @@ "reportableChange": 0 }, { - "name": "PIR occupied to unoccupied delay", + "name": "PIROccupiedToUnoccupiedDelay", "code": 16, "mfgCode": null, "side": "server", @@ -7061,7 +7061,7 @@ "reportableChange": 0 }, { - "name": "PIR unoccupied to occupied delay", + "name": "PIRUnoccupiedToOccupiedDelay", "code": 17, "mfgCode": null, "side": "server", @@ -7077,7 +7077,7 @@ "reportableChange": 0 }, { - "name": "PIR unoccupied to occupied threshold", + "name": "PIRUnoccupiedToOccupiedThreshold", "code": 18, "mfgCode": null, "side": "server", @@ -7093,7 +7093,7 @@ "reportableChange": 0 }, { - "name": "ultrasonic occupied to unoccupied delay", + "name": "UltrasonicOccupiedToUnoccupiedDelay", "code": 32, "mfgCode": null, "side": "server", @@ -7109,7 +7109,7 @@ "reportableChange": 0 }, { - "name": "ultrasonic unoccupied to occupied delay", + "name": "UltrasonicUnoccupiedToOccupiedDelay", "code": 33, "mfgCode": null, "side": "server", @@ -7125,7 +7125,7 @@ "reportableChange": 0 }, { - "name": "ultrasonic unoccupied to occupied threshold", + "name": "UltrasonicUnoccupiedToOccupiedThreshold", "code": 34, "mfgCode": null, "side": "server", @@ -7141,7 +7141,7 @@ "reportableChange": 0 }, { - "name": "physical contact occupied to unoccupied delay", + "name": "PhysicalContactOccupiedToUnoccupiedDelay", "code": 48, "mfgCode": null, "side": "server", @@ -7157,7 +7157,7 @@ "reportableChange": 0 }, { - "name": "physical contact unoccupied to occupied delay", + "name": "PhysicalContactUnoccupiedToOccupiedDelay", "code": 49, "mfgCode": null, "side": "server", @@ -7173,7 +7173,7 @@ "reportableChange": 0 }, { - "name": "physical contact unoccupied to occupied threshold", + "name": "PhysicalContactUnoccupiedToOccupiedThreshold", "code": 50, "mfgCode": null, "side": "server", diff --git a/examples/chef/devices/rootnode_colortemperaturelight_hbUnzYVeyn.matter b/examples/chef/devices/rootnode_colortemperaturelight_hbUnzYVeyn.matter index 1895d3f6b39d6f..37ddc92e299bcd 100644 --- a/examples/chef/devices/rootnode_colortemperaturelight_hbUnzYVeyn.matter +++ b/examples/chef/devices/rootnode_colortemperaturelight_hbUnzYVeyn.matter @@ -138,10 +138,6 @@ server cluster OnOff = 6 { kLighting = 0x1; } - bitmap SceneFeatures : BITMAP32 { - kSceneNames = 0x1; - } - readonly nosubscribe attribute boolean onOff = 0; readonly attribute boolean globalSceneControl = 16384; attribute int16u onTime = 16385; @@ -768,7 +764,7 @@ server cluster GeneralDiagnostics = 51 { kSoftwareReset = 6; } - enum HardwareFault : ENUM8 { + enum HardwareFaultEnum : ENUM8 { kUnspecified = 0; kRadio = 1; kSensor = 2; @@ -782,7 +778,7 @@ server cluster GeneralDiagnostics = 51 { kTamperDetected = 10; } - enum InterfaceType : ENUM8 { + enum InterfaceTypeEnum : ENUM8 { kUnspecified = 0; kWiFi = 1; kEthernet = 2; @@ -790,14 +786,14 @@ server cluster GeneralDiagnostics = 51 { kThread = 4; } - enum NetworkFaultType : ENUM8 { + enum NetworkFaultEnum : ENUM8 { kUnspecified = 0; kHardwareFailure = 1; kNetworkJammed = 2; kConnectionFailed = 3; } - enum RadioFault : ENUM8 { + enum RadioFaultEnum : ENUM8 { kUnspecified = 0; kWiFiFault = 1; kCellularFault = 2; @@ -815,22 +811,22 @@ server cluster GeneralDiagnostics = 51 { octet_string<8> hardwareAddress = 4; octet_string IPv4Addresses[] = 5; octet_string IPv6Addresses[] = 6; - InterfaceType type = 7; + InterfaceTypeEnum type = 7; } critical event HardwareFaultChange = 0 { - HardwareFault current[] = 0; - HardwareFault previous[] = 1; + HardwareFaultEnum current[] = 0; + HardwareFaultEnum previous[] = 1; } critical event RadioFaultChange = 1 { - RadioFault current[] = 0; - RadioFault previous[] = 1; + RadioFaultEnum current[] = 0; + RadioFaultEnum previous[] = 1; } critical event NetworkFaultChange = 2 { - NetworkFaultType current[] = 0; - NetworkFaultType previous[] = 1; + NetworkFaultEnum current[] = 0; + NetworkFaultEnum previous[] = 1; } critical event BootReason = 3 { @@ -842,9 +838,9 @@ server cluster GeneralDiagnostics = 51 { readonly attribute int64u upTime = 2; readonly attribute int32u totalOperationalHours = 3; readonly attribute BootReasonEnum bootReason = 4; - readonly attribute HardwareFault activeHardwareFaults[] = 5; - readonly attribute RadioFault activeRadioFaults[] = 6; - readonly attribute NetworkFaultType activeNetworkFaults[] = 7; + readonly attribute HardwareFaultEnum activeHardwareFaults[] = 5; + readonly attribute RadioFaultEnum activeRadioFaults[] = 6; + readonly attribute NetworkFaultEnum activeNetworkFaults[] = 7; readonly attribute boolean testEventTriggersEnabled = 8; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -887,7 +883,7 @@ server cluster SoftwareDiagnostics = 52 { } server cluster AdministratorCommissioning = 60 { - enum CommissioningWindowStatus : ENUM8 { + enum CommissioningWindowStatusEnum : ENUM8 { kWindowNotOpen = 0; kEnhancedWindowOpen = 1; kBasicWindowOpen = 2; @@ -899,7 +895,7 @@ server cluster AdministratorCommissioning = 60 { kWindowNotOpen = 4; } - readonly attribute CommissioningWindowStatus windowStatus = 0; + readonly attribute CommissioningWindowStatusEnum windowStatus = 0; readonly attribute nullable fabric_idx adminFabricIndex = 1; readonly attribute nullable int16u adminVendorId = 2; readonly attribute bitmap32 featureMap = 65532; @@ -923,8 +919,13 @@ server cluster AdministratorCommissioning = 60 { } server cluster OperationalCredentials = 62 { - enum OperationalCertStatus : ENUM8 { - kSuccess = 0; + enum CertificateChainTypeEnum : ENUM8 { + kDACCertificate = 1; + kPAICertificate = 2; + } + + enum NodeOperationalCertStatusEnum : ENUM8 { + kOk = 0; kInvalidPublicKey = 1; kInvalidNodeOpId = 2; kInvalidNOC = 3; @@ -942,17 +943,17 @@ server cluster OperationalCredentials = 62 { fabric_idx fabricIndex = 254; } - fabric_scoped struct FabricDescriptor { + fabric_scoped struct FabricDescriptorStruct { octet_string<65> rootPublicKey = 1; - vendor_id vendorId = 2; - fabric_id fabricId = 3; - node_id nodeId = 4; + vendor_id vendorID = 2; + fabric_id fabricID = 3; + node_id nodeID = 4; char_string<32> label = 5; fabric_idx fabricIndex = 254; } readonly attribute access(read: administer) NOCStruct NOCs[] = 0; - readonly attribute FabricDescriptor fabrics[] = 1; + readonly attribute FabricDescriptorStruct fabrics[] = 1; readonly attribute int8u supportedFabrics = 2; readonly attribute int8u commissionedFabrics = 3; readonly attribute OCTET_STRING trustedRootCertificates[] = 4; @@ -965,7 +966,7 @@ server cluster OperationalCredentials = 62 { } request struct CertificateChainRequestRequest { - INT8U certificateType = 0; + CertificateChainTypeEnum certificateType = 0; } request struct CSRRequestRequest { @@ -995,12 +996,12 @@ server cluster OperationalCredentials = 62 { } request struct AddTrustedRootCertificateRequest { - OCTET_STRING rootCertificate = 0; + OCTET_STRING rootCACertificate = 0; } response struct AttestationResponse = 1 { OCTET_STRING attestationElements = 0; - OCTET_STRING signature = 1; + OCTET_STRING attestationSignature = 1; } response struct CertificateChainResponse = 3 { @@ -1013,7 +1014,7 @@ server cluster OperationalCredentials = 62 { } response struct NOCResponse = 8 { - OperationalCertStatus statusCode = 0; + NodeOperationalCertStatusEnum statusCode = 0; optional fabric_idx fabricIndex = 1; optional CHAR_STRING debugText = 2; } @@ -1278,7 +1279,7 @@ server cluster ColorControl = 768 { } request struct MoveToColorTemperatureRequest { - INT16U colorTemperature = 0; + INT16U colorTemperatureMireds = 0; INT16U transitionTime = 1; BITMAP8 optionsMask = 2; BITMAP8 optionsOverride = 3; diff --git a/examples/chef/devices/rootnode_colortemperaturelight_hbUnzYVeyn.zap b/examples/chef/devices/rootnode_colortemperaturelight_hbUnzYVeyn.zap index f63cd021a54e1b..7f5d6b13b6277f 100644 --- a/examples/chef/devices/rootnode_colortemperaturelight_hbUnzYVeyn.zap +++ b/examples/chef/devices/rootnode_colortemperaturelight_hbUnzYVeyn.zap @@ -4361,7 +4361,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "PHYRate", + "type": "PHYRateEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -4617,7 +4617,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4669,7 +4669,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4681,7 +4681,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "CommissioningWindowStatus", + "type": "CommissioningWindowStatusEnum", "included": 1, "storageOption": "External", "singleton": 0, diff --git a/examples/chef/devices/rootnode_contactsensor_lFAGG1bfRO.matter b/examples/chef/devices/rootnode_contactsensor_lFAGG1bfRO.matter index c69ee132add8c0..c78e19271ca6bd 100644 --- a/examples/chef/devices/rootnode_contactsensor_lFAGG1bfRO.matter +++ b/examples/chef/devices/rootnode_contactsensor_lFAGG1bfRO.matter @@ -641,7 +641,7 @@ server cluster GeneralDiagnostics = 51 { kSoftwareReset = 6; } - enum HardwareFault : ENUM8 { + enum HardwareFaultEnum : ENUM8 { kUnspecified = 0; kRadio = 1; kSensor = 2; @@ -655,7 +655,7 @@ server cluster GeneralDiagnostics = 51 { kTamperDetected = 10; } - enum InterfaceType : ENUM8 { + enum InterfaceTypeEnum : ENUM8 { kUnspecified = 0; kWiFi = 1; kEthernet = 2; @@ -663,14 +663,14 @@ server cluster GeneralDiagnostics = 51 { kThread = 4; } - enum NetworkFaultType : ENUM8 { + enum NetworkFaultEnum : ENUM8 { kUnspecified = 0; kHardwareFailure = 1; kNetworkJammed = 2; kConnectionFailed = 3; } - enum RadioFault : ENUM8 { + enum RadioFaultEnum : ENUM8 { kUnspecified = 0; kWiFiFault = 1; kCellularFault = 2; @@ -688,22 +688,22 @@ server cluster GeneralDiagnostics = 51 { octet_string<8> hardwareAddress = 4; octet_string IPv4Addresses[] = 5; octet_string IPv6Addresses[] = 6; - InterfaceType type = 7; + InterfaceTypeEnum type = 7; } critical event HardwareFaultChange = 0 { - HardwareFault current[] = 0; - HardwareFault previous[] = 1; + HardwareFaultEnum current[] = 0; + HardwareFaultEnum previous[] = 1; } critical event RadioFaultChange = 1 { - RadioFault current[] = 0; - RadioFault previous[] = 1; + RadioFaultEnum current[] = 0; + RadioFaultEnum previous[] = 1; } critical event NetworkFaultChange = 2 { - NetworkFaultType current[] = 0; - NetworkFaultType previous[] = 1; + NetworkFaultEnum current[] = 0; + NetworkFaultEnum previous[] = 1; } critical event BootReason = 3 { @@ -715,9 +715,9 @@ server cluster GeneralDiagnostics = 51 { readonly attribute int64u upTime = 2; readonly attribute int32u totalOperationalHours = 3; readonly attribute BootReasonEnum bootReason = 4; - readonly attribute HardwareFault activeHardwareFaults[] = 5; - readonly attribute RadioFault activeRadioFaults[] = 6; - readonly attribute NetworkFaultType activeNetworkFaults[] = 7; + readonly attribute HardwareFaultEnum activeHardwareFaults[] = 5; + readonly attribute RadioFaultEnum activeRadioFaults[] = 6; + readonly attribute NetworkFaultEnum activeNetworkFaults[] = 7; readonly attribute boolean testEventTriggersEnabled = 8; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -803,7 +803,7 @@ server cluster Switch = 59 { } server cluster AdministratorCommissioning = 60 { - enum CommissioningWindowStatus : ENUM8 { + enum CommissioningWindowStatusEnum : ENUM8 { kWindowNotOpen = 0; kEnhancedWindowOpen = 1; kBasicWindowOpen = 2; @@ -815,7 +815,7 @@ server cluster AdministratorCommissioning = 60 { kWindowNotOpen = 4; } - readonly attribute CommissioningWindowStatus windowStatus = 0; + readonly attribute CommissioningWindowStatusEnum windowStatus = 0; readonly attribute nullable fabric_idx adminFabricIndex = 1; readonly attribute nullable int16u adminVendorId = 2; readonly attribute bitmap32 featureMap = 65532; @@ -839,8 +839,13 @@ server cluster AdministratorCommissioning = 60 { } server cluster OperationalCredentials = 62 { - enum OperationalCertStatus : ENUM8 { - kSuccess = 0; + enum CertificateChainTypeEnum : ENUM8 { + kDACCertificate = 1; + kPAICertificate = 2; + } + + enum NodeOperationalCertStatusEnum : ENUM8 { + kOk = 0; kInvalidPublicKey = 1; kInvalidNodeOpId = 2; kInvalidNOC = 3; @@ -858,17 +863,17 @@ server cluster OperationalCredentials = 62 { fabric_idx fabricIndex = 254; } - fabric_scoped struct FabricDescriptor { + fabric_scoped struct FabricDescriptorStruct { octet_string<65> rootPublicKey = 1; - vendor_id vendorId = 2; - fabric_id fabricId = 3; - node_id nodeId = 4; + vendor_id vendorID = 2; + fabric_id fabricID = 3; + node_id nodeID = 4; char_string<32> label = 5; fabric_idx fabricIndex = 254; } readonly attribute access(read: administer) NOCStruct NOCs[] = 0; - readonly attribute FabricDescriptor fabrics[] = 1; + readonly attribute FabricDescriptorStruct fabrics[] = 1; readonly attribute int8u supportedFabrics = 2; readonly attribute int8u commissionedFabrics = 3; readonly attribute OCTET_STRING trustedRootCertificates[] = 4; @@ -881,7 +886,7 @@ server cluster OperationalCredentials = 62 { } request struct CertificateChainRequestRequest { - INT8U certificateType = 0; + CertificateChainTypeEnum certificateType = 0; } request struct CSRRequestRequest { @@ -911,12 +916,12 @@ server cluster OperationalCredentials = 62 { } request struct AddTrustedRootCertificateRequest { - OCTET_STRING rootCertificate = 0; + OCTET_STRING rootCACertificate = 0; } response struct AttestationResponse = 1 { OCTET_STRING attestationElements = 0; - OCTET_STRING signature = 1; + OCTET_STRING attestationSignature = 1; } response struct CertificateChainResponse = 3 { @@ -929,7 +934,7 @@ server cluster OperationalCredentials = 62 { } response struct NOCResponse = 8 { - OperationalCertStatus statusCode = 0; + NodeOperationalCertStatusEnum statusCode = 0; optional fabric_idx fabricIndex = 1; optional CHAR_STRING debugText = 2; } diff --git a/examples/chef/devices/rootnode_contactsensor_lFAGG1bfRO.zap b/examples/chef/devices/rootnode_contactsensor_lFAGG1bfRO.zap index b6d56032c51f1f..54f47666dbe4c8 100644 --- a/examples/chef/devices/rootnode_contactsensor_lFAGG1bfRO.zap +++ b/examples/chef/devices/rootnode_contactsensor_lFAGG1bfRO.zap @@ -4265,7 +4265,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "PHYRate", + "type": "PHYRateEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -4489,7 +4489,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4541,7 +4541,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4553,7 +4553,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "CommissioningWindowStatus", + "type": "CommissioningWindowStatusEnum", "included": 1, "storageOption": "External", "singleton": 0, diff --git a/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.matter b/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.matter index 27653cb1f7f9ad..45473a2e4140b3 100644 --- a/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.matter +++ b/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.matter @@ -132,10 +132,6 @@ server cluster OnOff = 6 { kLighting = 0x1; } - bitmap SceneFeatures : BITMAP32 { - kSceneNames = 0x1; - } - readonly attribute boolean onOff = 0; readonly attribute boolean globalSceneControl = 16384; attribute int16u onTime = 16385; @@ -790,7 +786,7 @@ server cluster GeneralDiagnostics = 51 { kSoftwareReset = 6; } - enum HardwareFault : ENUM8 { + enum HardwareFaultEnum : ENUM8 { kUnspecified = 0; kRadio = 1; kSensor = 2; @@ -804,7 +800,7 @@ server cluster GeneralDiagnostics = 51 { kTamperDetected = 10; } - enum InterfaceType : ENUM8 { + enum InterfaceTypeEnum : ENUM8 { kUnspecified = 0; kWiFi = 1; kEthernet = 2; @@ -812,14 +808,14 @@ server cluster GeneralDiagnostics = 51 { kThread = 4; } - enum NetworkFaultType : ENUM8 { + enum NetworkFaultEnum : ENUM8 { kUnspecified = 0; kHardwareFailure = 1; kNetworkJammed = 2; kConnectionFailed = 3; } - enum RadioFault : ENUM8 { + enum RadioFaultEnum : ENUM8 { kUnspecified = 0; kWiFiFault = 1; kCellularFault = 2; @@ -837,22 +833,22 @@ server cluster GeneralDiagnostics = 51 { octet_string<8> hardwareAddress = 4; octet_string IPv4Addresses[] = 5; octet_string IPv6Addresses[] = 6; - InterfaceType type = 7; + InterfaceTypeEnum type = 7; } critical event HardwareFaultChange = 0 { - HardwareFault current[] = 0; - HardwareFault previous[] = 1; + HardwareFaultEnum current[] = 0; + HardwareFaultEnum previous[] = 1; } critical event RadioFaultChange = 1 { - RadioFault current[] = 0; - RadioFault previous[] = 1; + RadioFaultEnum current[] = 0; + RadioFaultEnum previous[] = 1; } critical event NetworkFaultChange = 2 { - NetworkFaultType current[] = 0; - NetworkFaultType previous[] = 1; + NetworkFaultEnum current[] = 0; + NetworkFaultEnum previous[] = 1; } critical event BootReason = 3 { @@ -864,9 +860,9 @@ server cluster GeneralDiagnostics = 51 { readonly attribute int64u upTime = 2; readonly attribute int32u totalOperationalHours = 3; readonly attribute BootReasonEnum bootReason = 4; - readonly attribute HardwareFault activeHardwareFaults[] = 5; - readonly attribute RadioFault activeRadioFaults[] = 6; - readonly attribute NetworkFaultType activeNetworkFaults[] = 7; + readonly attribute HardwareFaultEnum activeHardwareFaults[] = 5; + readonly attribute RadioFaultEnum activeRadioFaults[] = 6; + readonly attribute NetworkFaultEnum activeNetworkFaults[] = 7; readonly attribute boolean testEventTriggersEnabled = 8; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -952,7 +948,7 @@ server cluster Switch = 59 { } server cluster AdministratorCommissioning = 60 { - enum CommissioningWindowStatus : ENUM8 { + enum CommissioningWindowStatusEnum : ENUM8 { kWindowNotOpen = 0; kEnhancedWindowOpen = 1; kBasicWindowOpen = 2; @@ -964,7 +960,7 @@ server cluster AdministratorCommissioning = 60 { kWindowNotOpen = 4; } - readonly attribute CommissioningWindowStatus windowStatus = 0; + readonly attribute CommissioningWindowStatusEnum windowStatus = 0; readonly attribute nullable fabric_idx adminFabricIndex = 1; readonly attribute nullable int16u adminVendorId = 2; readonly attribute bitmap32 featureMap = 65532; @@ -988,8 +984,13 @@ server cluster AdministratorCommissioning = 60 { } server cluster OperationalCredentials = 62 { - enum OperationalCertStatus : ENUM8 { - kSuccess = 0; + enum CertificateChainTypeEnum : ENUM8 { + kDACCertificate = 1; + kPAICertificate = 2; + } + + enum NodeOperationalCertStatusEnum : ENUM8 { + kOk = 0; kInvalidPublicKey = 1; kInvalidNodeOpId = 2; kInvalidNOC = 3; @@ -1007,17 +1008,17 @@ server cluster OperationalCredentials = 62 { fabric_idx fabricIndex = 254; } - fabric_scoped struct FabricDescriptor { + fabric_scoped struct FabricDescriptorStruct { octet_string<65> rootPublicKey = 1; - vendor_id vendorId = 2; - fabric_id fabricId = 3; - node_id nodeId = 4; + vendor_id vendorID = 2; + fabric_id fabricID = 3; + node_id nodeID = 4; char_string<32> label = 5; fabric_idx fabricIndex = 254; } readonly attribute access(read: administer) NOCStruct NOCs[] = 0; - readonly attribute FabricDescriptor fabrics[] = 1; + readonly attribute FabricDescriptorStruct fabrics[] = 1; readonly attribute int8u supportedFabrics = 2; readonly attribute int8u commissionedFabrics = 3; readonly attribute OCTET_STRING trustedRootCertificates[] = 4; @@ -1030,7 +1031,7 @@ server cluster OperationalCredentials = 62 { } request struct CertificateChainRequestRequest { - INT8U certificateType = 0; + CertificateChainTypeEnum certificateType = 0; } request struct CSRRequestRequest { @@ -1060,12 +1061,12 @@ server cluster OperationalCredentials = 62 { } request struct AddTrustedRootCertificateRequest { - OCTET_STRING rootCertificate = 0; + OCTET_STRING rootCACertificate = 0; } response struct AttestationResponse = 1 { OCTET_STRING attestationElements = 0; - OCTET_STRING signature = 1; + OCTET_STRING attestationSignature = 1; } response struct CertificateChainResponse = 3 { @@ -1078,7 +1079,7 @@ server cluster OperationalCredentials = 62 { } response struct NOCResponse = 8 { - OperationalCertStatus statusCode = 0; + NodeOperationalCertStatusEnum statusCode = 0; optional fabric_idx fabricIndex = 1; optional CHAR_STRING debugText = 2; } diff --git a/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.zap b/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.zap index d05f0f2d5709a7..bbb0c0cd734d79 100644 --- a/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.zap +++ b/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.zap @@ -4265,7 +4265,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "PHYRate", + "type": "PHYRateEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -4489,7 +4489,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4541,7 +4541,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4553,7 +4553,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "CommissioningWindowStatus", + "type": "CommissioningWindowStatusEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -6997,7 +6997,7 @@ "enabled": 0, "attributes": [ { - "name": "occupancy", + "name": "Occupancy", "code": 0, "mfgCode": null, "side": "server", @@ -7013,7 +7013,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type", + "name": "OccupancySensorType", "code": 1, "mfgCode": null, "side": "server", @@ -7029,7 +7029,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type bitmap", + "name": "OccupancySensorTypeBitmap", "code": 2, "mfgCode": null, "side": "server", @@ -7045,7 +7045,7 @@ "reportableChange": 0 }, { - "name": "PIR occupied to unoccupied delay", + "name": "PIROccupiedToUnoccupiedDelay", "code": 16, "mfgCode": null, "side": "server", @@ -7061,7 +7061,7 @@ "reportableChange": 0 }, { - "name": "PIR unoccupied to occupied delay", + "name": "PIRUnoccupiedToOccupiedDelay", "code": 17, "mfgCode": null, "side": "server", @@ -7077,7 +7077,7 @@ "reportableChange": 0 }, { - "name": "PIR unoccupied to occupied threshold", + "name": "PIRUnoccupiedToOccupiedThreshold", "code": 18, "mfgCode": null, "side": "server", @@ -7093,7 +7093,7 @@ "reportableChange": 0 }, { - "name": "ultrasonic occupied to unoccupied delay", + "name": "UltrasonicOccupiedToUnoccupiedDelay", "code": 32, "mfgCode": null, "side": "server", @@ -7109,7 +7109,7 @@ "reportableChange": 0 }, { - "name": "ultrasonic unoccupied to occupied delay", + "name": "UltrasonicUnoccupiedToOccupiedDelay", "code": 33, "mfgCode": null, "side": "server", @@ -7125,7 +7125,7 @@ "reportableChange": 0 }, { - "name": "ultrasonic unoccupied to occupied threshold", + "name": "UltrasonicUnoccupiedToOccupiedThreshold", "code": 34, "mfgCode": null, "side": "server", @@ -7141,7 +7141,7 @@ "reportableChange": 0 }, { - "name": "physical contact occupied to unoccupied delay", + "name": "PhysicalContactOccupiedToUnoccupiedDelay", "code": 48, "mfgCode": null, "side": "server", @@ -7157,7 +7157,7 @@ "reportableChange": 0 }, { - "name": "physical contact unoccupied to occupied delay", + "name": "PhysicalContactUnoccupiedToOccupiedDelay", "code": 49, "mfgCode": null, "side": "server", @@ -7173,7 +7173,7 @@ "reportableChange": 0 }, { - "name": "physical contact unoccupied to occupied threshold", + "name": "PhysicalContactUnoccupiedToOccupiedThreshold", "code": 50, "mfgCode": null, "side": "server", diff --git a/examples/chef/devices/rootnode_doorlock_aNKYAreMXE.matter b/examples/chef/devices/rootnode_doorlock_aNKYAreMXE.matter index ce5e5271e3d548..20cc3bb20da76b 100644 --- a/examples/chef/devices/rootnode_doorlock_aNKYAreMXE.matter +++ b/examples/chef/devices/rootnode_doorlock_aNKYAreMXE.matter @@ -641,7 +641,7 @@ server cluster GeneralDiagnostics = 51 { kSoftwareReset = 6; } - enum HardwareFault : ENUM8 { + enum HardwareFaultEnum : ENUM8 { kUnspecified = 0; kRadio = 1; kSensor = 2; @@ -655,7 +655,7 @@ server cluster GeneralDiagnostics = 51 { kTamperDetected = 10; } - enum InterfaceType : ENUM8 { + enum InterfaceTypeEnum : ENUM8 { kUnspecified = 0; kWiFi = 1; kEthernet = 2; @@ -663,14 +663,14 @@ server cluster GeneralDiagnostics = 51 { kThread = 4; } - enum NetworkFaultType : ENUM8 { + enum NetworkFaultEnum : ENUM8 { kUnspecified = 0; kHardwareFailure = 1; kNetworkJammed = 2; kConnectionFailed = 3; } - enum RadioFault : ENUM8 { + enum RadioFaultEnum : ENUM8 { kUnspecified = 0; kWiFiFault = 1; kCellularFault = 2; @@ -688,22 +688,22 @@ server cluster GeneralDiagnostics = 51 { octet_string<8> hardwareAddress = 4; octet_string IPv4Addresses[] = 5; octet_string IPv6Addresses[] = 6; - InterfaceType type = 7; + InterfaceTypeEnum type = 7; } critical event HardwareFaultChange = 0 { - HardwareFault current[] = 0; - HardwareFault previous[] = 1; + HardwareFaultEnum current[] = 0; + HardwareFaultEnum previous[] = 1; } critical event RadioFaultChange = 1 { - RadioFault current[] = 0; - RadioFault previous[] = 1; + RadioFaultEnum current[] = 0; + RadioFaultEnum previous[] = 1; } critical event NetworkFaultChange = 2 { - NetworkFaultType current[] = 0; - NetworkFaultType previous[] = 1; + NetworkFaultEnum current[] = 0; + NetworkFaultEnum previous[] = 1; } critical event BootReason = 3 { @@ -715,9 +715,9 @@ server cluster GeneralDiagnostics = 51 { readonly attribute int64u upTime = 2; readonly attribute int32u totalOperationalHours = 3; readonly attribute BootReasonEnum bootReason = 4; - readonly attribute HardwareFault activeHardwareFaults[] = 5; - readonly attribute RadioFault activeRadioFaults[] = 6; - readonly attribute NetworkFaultType activeNetworkFaults[] = 7; + readonly attribute HardwareFaultEnum activeHardwareFaults[] = 5; + readonly attribute RadioFaultEnum activeRadioFaults[] = 6; + readonly attribute NetworkFaultEnum activeNetworkFaults[] = 7; readonly attribute boolean testEventTriggersEnabled = 8; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -803,7 +803,7 @@ server cluster Switch = 59 { } server cluster AdministratorCommissioning = 60 { - enum CommissioningWindowStatus : ENUM8 { + enum CommissioningWindowStatusEnum : ENUM8 { kWindowNotOpen = 0; kEnhancedWindowOpen = 1; kBasicWindowOpen = 2; @@ -815,7 +815,7 @@ server cluster AdministratorCommissioning = 60 { kWindowNotOpen = 4; } - readonly attribute CommissioningWindowStatus windowStatus = 0; + readonly attribute CommissioningWindowStatusEnum windowStatus = 0; readonly attribute nullable fabric_idx adminFabricIndex = 1; readonly attribute nullable int16u adminVendorId = 2; readonly attribute bitmap32 featureMap = 65532; @@ -839,8 +839,13 @@ server cluster AdministratorCommissioning = 60 { } server cluster OperationalCredentials = 62 { - enum OperationalCertStatus : ENUM8 { - kSuccess = 0; + enum CertificateChainTypeEnum : ENUM8 { + kDACCertificate = 1; + kPAICertificate = 2; + } + + enum NodeOperationalCertStatusEnum : ENUM8 { + kOk = 0; kInvalidPublicKey = 1; kInvalidNodeOpId = 2; kInvalidNOC = 3; @@ -858,17 +863,17 @@ server cluster OperationalCredentials = 62 { fabric_idx fabricIndex = 254; } - fabric_scoped struct FabricDescriptor { + fabric_scoped struct FabricDescriptorStruct { octet_string<65> rootPublicKey = 1; - vendor_id vendorId = 2; - fabric_id fabricId = 3; - node_id nodeId = 4; + vendor_id vendorID = 2; + fabric_id fabricID = 3; + node_id nodeID = 4; char_string<32> label = 5; fabric_idx fabricIndex = 254; } readonly attribute access(read: administer) NOCStruct NOCs[] = 0; - readonly attribute FabricDescriptor fabrics[] = 1; + readonly attribute FabricDescriptorStruct fabrics[] = 1; readonly attribute int8u supportedFabrics = 2; readonly attribute int8u commissionedFabrics = 3; readonly attribute OCTET_STRING trustedRootCertificates[] = 4; @@ -881,7 +886,7 @@ server cluster OperationalCredentials = 62 { } request struct CertificateChainRequestRequest { - INT8U certificateType = 0; + CertificateChainTypeEnum certificateType = 0; } request struct CSRRequestRequest { @@ -911,12 +916,12 @@ server cluster OperationalCredentials = 62 { } request struct AddTrustedRootCertificateRequest { - OCTET_STRING rootCertificate = 0; + OCTET_STRING rootCACertificate = 0; } response struct AttestationResponse = 1 { OCTET_STRING attestationElements = 0; - OCTET_STRING signature = 1; + OCTET_STRING attestationSignature = 1; } response struct CertificateChainResponse = 3 { @@ -929,7 +934,7 @@ server cluster OperationalCredentials = 62 { } response struct NOCResponse = 8 { - OperationalCertStatus statusCode = 0; + NodeOperationalCertStatusEnum statusCode = 0; optional fabric_idx fabricIndex = 1; optional CHAR_STRING debugText = 2; } @@ -1023,7 +1028,7 @@ server cluster FixedLabel = 64 { } server cluster DoorLock = 257 { - enum DlAlarmCode : ENUM8 { + enum AlarmCodeEnum : ENUM8 { kLockJammed = 0; kLockFactoryReset = 1; kLockRadioPowerCycled = 3; @@ -1034,13 +1039,13 @@ server cluster DoorLock = 257 { kForcedUser = 8; } - enum DlCredentialRule : ENUM8 { + enum CredentialRuleEnum : ENUM8 { kSingle = 0; - kDouble = 1; + kDual = 1; kTri = 2; } - enum DlCredentialType : ENUM8 { + enum CredentialTypeEnum : ENUM8 { kProgrammingPIN = 0; kPin = 1; kRfid = 2; @@ -1049,40 +1054,12 @@ server cluster DoorLock = 257 { kFace = 5; } - enum DlDataOperationType : ENUM8 { + enum DataOperationTypeEnum : ENUM8 { kAdd = 0; kClear = 1; kModify = 2; } - enum DlDoorState : ENUM8 { - kDoorOpen = 0; - kDoorClosed = 1; - kDoorJammed = 2; - kDoorForcedOpen = 3; - kDoorUnspecifiedError = 4; - kDoorAjar = 5; - } - - enum DlLockDataType : ENUM8 { - kUnspecified = 0; - kProgrammingCode = 1; - kUserIndex = 2; - kWeekDaySchedule = 3; - kYearDaySchedule = 4; - kHolidaySchedule = 5; - kPin = 6; - kRfid = 7; - kFingerprint = 8; - } - - enum DlLockOperationType : ENUM8 { - kLock = 0; - kUnlock = 1; - kNonAccessUserEvent = 2; - kForcedUserEvent = 3; - } - enum DlLockState : ENUM8 { kNotFullyLocked = 0; kLocked = 1; @@ -1103,35 +1080,6 @@ server cluster DoorLock = 257 { kDoorFurniture = 10; } - enum DlOperatingMode : ENUM8 { - kNormal = 0; - kVacation = 1; - kPrivacy = 2; - kNoRemoteLockUnlock = 3; - kPassage = 4; - } - - enum DlOperationError : ENUM8 { - kUnspecified = 0; - kInvalidCredential = 1; - kDisabledUserDenied = 2; - kRestricted = 3; - kInsufficientBattery = 4; - } - - enum DlOperationSource : ENUM8 { - kUnspecified = 0; - kManual = 1; - kProprietaryRemote = 2; - kKeypad = 3; - kAuto = 4; - kButton = 5; - kSchedule = 6; - kRemote = 7; - kRfid = 8; - kBiometric = 9; - } - enum DlStatus : ENUM8 { kSuccess = 0; kFailure = 1; @@ -1142,25 +1090,6 @@ server cluster DoorLock = 257 { kNotFound = 139; } - enum DlUserStatus : ENUM8 { - kAvailable = 0; - kOccupiedEnabled = 1; - kOccupiedDisabled = 3; - } - - enum DlUserType : ENUM8 { - kUnrestrictedUser = 0; - kYearDayScheduleUser = 1; - kWeekDayScheduleUser = 2; - kProgrammingUser = 3; - kNonAccessUser = 4; - kForcedUser = 5; - kDisposableUser = 6; - kExpiringUser = 7; - kScheduleRestrictedUser = 8; - kRemoteOnlyUser = 9; - } - enum DoorLockOperationEventCode : ENUM8 { kUnknownOrMfgSpecific = 0; kLock = 1; @@ -1212,19 +1141,83 @@ server cluster DoorLock = 257 { kNotSupported = 255; } - bitmap DlCredentialRuleMask : BITMAP8 { - kSingle = 0x1; - kDual = 0x2; - kTri = 0x4; + enum DoorStateEnum : ENUM8 { + kDoorOpen = 0; + kDoorClosed = 1; + kDoorJammed = 2; + kDoorForcedOpen = 3; + kDoorUnspecifiedError = 4; + kDoorAjar = 5; } - bitmap DlCredentialRulesSupport : BITMAP8 { - kSingle = 0x1; - kDual = 0x2; - kTri = 0x4; + enum LockDataTypeEnum : ENUM8 { + kUnspecified = 0; + kProgrammingCode = 1; + kUserIndex = 2; + kWeekDaySchedule = 3; + kYearDaySchedule = 4; + kHolidaySchedule = 5; + kPin = 6; + kRfid = 7; + kFingerprint = 8; + } + + enum LockOperationTypeEnum : ENUM8 { + kLock = 0; + kUnlock = 1; + kNonAccessUserEvent = 2; + kForcedUserEvent = 3; + } + + enum OperatingModeEnum : ENUM8 { + kNormal = 0; + kVacation = 1; + kPrivacy = 2; + kNoRemoteLockUnlock = 3; + kPassage = 4; + } + + enum OperationErrorEnum : ENUM8 { + kUnspecified = 0; + kInvalidCredential = 1; + kDisabledUserDenied = 2; + kRestricted = 3; + kInsufficientBattery = 4; + } + + enum OperationSourceEnum : ENUM8 { + kUnspecified = 0; + kManual = 1; + kProprietaryRemote = 2; + kKeypad = 3; + kAuto = 4; + kButton = 5; + kSchedule = 6; + kRemote = 7; + kRfid = 8; + kBiometric = 9; } - bitmap DlDaysMaskMap : BITMAP8 { + enum UserStatusEnum : ENUM8 { + kAvailable = 0; + kOccupiedEnabled = 1; + kOccupiedDisabled = 3; + } + + enum UserTypeEnum : ENUM8 { + kUnrestrictedUser = 0; + kYearDayScheduleUser = 1; + kWeekDayScheduleUser = 2; + kProgrammingUser = 3; + kNonAccessUser = 4; + kForcedUser = 5; + kDisposableUser = 6; + kExpiringUser = 7; + kScheduleRestrictedUser = 8; + kRemoteOnlyUser = 9; + } + + bitmap DaysMaskMap : BITMAP8 { kSunday = 0x1; kMonday = 0x2; kTuesday = 0x4; @@ -1234,6 +1227,18 @@ server cluster DoorLock = 257 { kSaturday = 0x40; } + bitmap DlCredentialRuleMask : BITMAP8 { + kSingle = 0x1; + kDual = 0x2; + kTri = 0x4; + } + + bitmap DlCredentialRulesSupport : BITMAP8 { + kSingle = 0x1; + kDual = 0x2; + kTri = 0x4; + } + bitmap DlDefaultConfigurationRegister : BITMAP16 { kEnableLocalProgrammingEnabled = 0x1; kKeypadInterfaceDefaultAccessEnabled = 0x2; @@ -1338,51 +1343,51 @@ server cluster DoorLock = 257 { } bitmap DoorLockFeature : BITMAP32 { - kPINCredentials = 0x1; - kRFIDCredentials = 0x2; + kPinCredential = 0x1; + kRfidCredential = 0x2; kFingerCredentials = 0x4; kLogging = 0x8; - kWeekDaySchedules = 0x10; + kWeekDayAccessSchedules = 0x10; kDoorPositionSensor = 0x20; kFaceCredentials = 0x40; - kCredentialsOTA = 0x80; - kUsersManagement = 0x100; - kNotifications = 0x200; - kYearDaySchedules = 0x400; + kCredentialsOverTheAirAccess = 0x80; + kUser = 0x100; + kNotification = 0x200; + kYearDayAccessSchedules = 0x400; kHolidaySchedules = 0x800; } critical event DoorLockAlarm = 0 { - DlAlarmCode alarmCode = 0; + AlarmCodeEnum alarmCode = 0; } critical event DoorStateChange = 1 { - DlDoorState doorState = 0; + DoorStateEnum doorState = 0; } critical event LockOperation = 2 { - DlLockOperationType lockOperationType = 0; - DlOperationSource operationSource = 1; + LockOperationTypeEnum lockOperationType = 0; + OperationSourceEnum operationSource = 1; nullable INT16U userIndex = 2; nullable fabric_idx fabricIndex = 3; nullable NODE_ID sourceNode = 4; - optional nullable DlCredential credentials[] = 5; + optional nullable CredentialStruct credentials[] = 5; } critical event LockOperationError = 3 { - DlLockOperationType lockOperationType = 0; - DlOperationSource operationSource = 1; - DlOperationError operationError = 2; + LockOperationTypeEnum lockOperationType = 0; + OperationSourceEnum operationSource = 1; + OperationErrorEnum operationError = 2; nullable INT16U userIndex = 3; nullable fabric_idx fabricIndex = 4; nullable NODE_ID sourceNode = 5; - optional nullable DlCredential credentials[] = 6; + optional nullable CredentialStruct credentials[] = 6; } info event LockUserChange = 4 { - DlLockDataType lockDataType = 0; - DlDataOperationType dataOperationType = 1; - DlOperationSource operationSource = 2; + LockDataTypeEnum lockDataType = 0; + DataOperationTypeEnum dataOperationType = 1; + OperationSourceEnum operationSource = 2; nullable INT16U userIndex = 3; nullable fabric_idx fabricIndex = 4; nullable NODE_ID sourceNode = 5; @@ -1396,7 +1401,7 @@ server cluster DoorLock = 257 { readonly attribute int8u maxPINCodeLength = 23; readonly attribute int8u minPINCodeLength = 24; attribute access(write: manage) int32u autoRelockTime = 35; - attribute access(write: manage) DlOperatingMode operatingMode = 37; + attribute access(write: manage) OperatingModeEnum operatingMode = 37; readonly attribute DlSupportedOperatingModes supportedOperatingModes = 38; attribute access(write: administer) int8u wrongCodeEntryLimit = 48; attribute access(write: administer) int8u userCodeTemporaryDisableTime = 49; @@ -1409,11 +1414,11 @@ server cluster DoorLock = 257 { readonly attribute int16u clusterRevision = 65533; request struct LockDoorRequest { - optional OCTET_STRING pinCode = 0; + optional OCTET_STRING PINCode = 0; } request struct UnlockDoorRequest { - optional OCTET_STRING pinCode = 0; + optional OCTET_STRING PINCode = 0; } timed command LockDoor(LockDoorRequest): DefaultSuccess = 0; diff --git a/examples/chef/devices/rootnode_doorlock_aNKYAreMXE.zap b/examples/chef/devices/rootnode_doorlock_aNKYAreMXE.zap index 9fa00e9ee01fab..762194fd8ad6a1 100644 --- a/examples/chef/devices/rootnode_doorlock_aNKYAreMXE.zap +++ b/examples/chef/devices/rootnode_doorlock_aNKYAreMXE.zap @@ -4265,7 +4265,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "PHYRate", + "type": "PHYRateEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -4489,7 +4489,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4541,7 +4541,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4553,7 +4553,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "CommissioningWindowStatus", + "type": "CommissioningWindowStatusEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -7067,7 +7067,7 @@ "code": 3, "mfgCode": null, "side": "server", - "type": "DlDoorState", + "type": "DoorStateEnum", "included": 0, "storageOption": "RAM", "singleton": 0, @@ -7371,7 +7371,7 @@ "code": 37, "mfgCode": null, "side": "server", - "type": "DlOperatingMode", + "type": "OperatingModeEnum", "included": 1, "storageOption": "RAM", "singleton": 0, @@ -8697,7 +8697,7 @@ "enabled": 0, "attributes": [ { - "name": "occupancy", + "name": "Occupancy", "code": 0, "mfgCode": null, "side": "server", @@ -8713,7 +8713,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type", + "name": "OccupancySensorType", "code": 1, "mfgCode": null, "side": "server", @@ -8729,7 +8729,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type bitmap", + "name": "OccupancySensorTypeBitmap", "code": 2, "mfgCode": null, "side": "server", @@ -8745,7 +8745,7 @@ "reportableChange": 0 }, { - "name": "PIR occupied to unoccupied delay", + "name": "PIROccupiedToUnoccupiedDelay", "code": 16, "mfgCode": null, "side": "server", @@ -8761,7 +8761,7 @@ "reportableChange": 0 }, { - "name": "PIR unoccupied to occupied delay", + "name": "PIRUnoccupiedToOccupiedDelay", "code": 17, "mfgCode": null, "side": "server", @@ -8777,7 +8777,7 @@ "reportableChange": 0 }, { - "name": "PIR unoccupied to occupied threshold", + "name": "PIRUnoccupiedToOccupiedThreshold", "code": 18, "mfgCode": null, "side": "server", @@ -8793,7 +8793,7 @@ "reportableChange": 0 }, { - "name": "ultrasonic occupied to unoccupied delay", + "name": "UltrasonicOccupiedToUnoccupiedDelay", "code": 32, "mfgCode": null, "side": "server", @@ -8809,7 +8809,7 @@ "reportableChange": 0 }, { - "name": "ultrasonic unoccupied to occupied delay", + "name": "UltrasonicUnoccupiedToOccupiedDelay", "code": 33, "mfgCode": null, "side": "server", @@ -8825,7 +8825,7 @@ "reportableChange": 0 }, { - "name": "ultrasonic unoccupied to occupied threshold", + "name": "UltrasonicUnoccupiedToOccupiedThreshold", "code": 34, "mfgCode": null, "side": "server", @@ -8841,7 +8841,7 @@ "reportableChange": 0 }, { - "name": "physical contact occupied to unoccupied delay", + "name": "PhysicalContactOccupiedToUnoccupiedDelay", "code": 48, "mfgCode": null, "side": "server", @@ -8857,7 +8857,7 @@ "reportableChange": 0 }, { - "name": "physical contact unoccupied to occupied delay", + "name": "PhysicalContactUnoccupiedToOccupiedDelay", "code": 49, "mfgCode": null, "side": "server", @@ -8873,7 +8873,7 @@ "reportableChange": 0 }, { - "name": "physical contact unoccupied to occupied threshold", + "name": "PhysicalContactUnoccupiedToOccupiedThreshold", "code": 50, "mfgCode": null, "side": "server", diff --git a/examples/chef/devices/rootnode_extendedcolorlight_8lcaaYJVAa.matter b/examples/chef/devices/rootnode_extendedcolorlight_8lcaaYJVAa.matter index 21f185e38eedc4..a2520e905c4478 100644 --- a/examples/chef/devices/rootnode_extendedcolorlight_8lcaaYJVAa.matter +++ b/examples/chef/devices/rootnode_extendedcolorlight_8lcaaYJVAa.matter @@ -132,10 +132,6 @@ server cluster OnOff = 6 { kLighting = 0x1; } - bitmap SceneFeatures : BITMAP32 { - kSceneNames = 0x1; - } - readonly attribute boolean onOff = 0; readonly attribute boolean globalSceneControl = 16384; attribute int16u onTime = 16385; @@ -790,7 +786,7 @@ server cluster GeneralDiagnostics = 51 { kSoftwareReset = 6; } - enum HardwareFault : ENUM8 { + enum HardwareFaultEnum : ENUM8 { kUnspecified = 0; kRadio = 1; kSensor = 2; @@ -804,7 +800,7 @@ server cluster GeneralDiagnostics = 51 { kTamperDetected = 10; } - enum InterfaceType : ENUM8 { + enum InterfaceTypeEnum : ENUM8 { kUnspecified = 0; kWiFi = 1; kEthernet = 2; @@ -812,14 +808,14 @@ server cluster GeneralDiagnostics = 51 { kThread = 4; } - enum NetworkFaultType : ENUM8 { + enum NetworkFaultEnum : ENUM8 { kUnspecified = 0; kHardwareFailure = 1; kNetworkJammed = 2; kConnectionFailed = 3; } - enum RadioFault : ENUM8 { + enum RadioFaultEnum : ENUM8 { kUnspecified = 0; kWiFiFault = 1; kCellularFault = 2; @@ -837,22 +833,22 @@ server cluster GeneralDiagnostics = 51 { octet_string<8> hardwareAddress = 4; octet_string IPv4Addresses[] = 5; octet_string IPv6Addresses[] = 6; - InterfaceType type = 7; + InterfaceTypeEnum type = 7; } critical event HardwareFaultChange = 0 { - HardwareFault current[] = 0; - HardwareFault previous[] = 1; + HardwareFaultEnum current[] = 0; + HardwareFaultEnum previous[] = 1; } critical event RadioFaultChange = 1 { - RadioFault current[] = 0; - RadioFault previous[] = 1; + RadioFaultEnum current[] = 0; + RadioFaultEnum previous[] = 1; } critical event NetworkFaultChange = 2 { - NetworkFaultType current[] = 0; - NetworkFaultType previous[] = 1; + NetworkFaultEnum current[] = 0; + NetworkFaultEnum previous[] = 1; } critical event BootReason = 3 { @@ -864,9 +860,9 @@ server cluster GeneralDiagnostics = 51 { readonly attribute int64u upTime = 2; readonly attribute int32u totalOperationalHours = 3; readonly attribute BootReasonEnum bootReason = 4; - readonly attribute HardwareFault activeHardwareFaults[] = 5; - readonly attribute RadioFault activeRadioFaults[] = 6; - readonly attribute NetworkFaultType activeNetworkFaults[] = 7; + readonly attribute HardwareFaultEnum activeHardwareFaults[] = 5; + readonly attribute RadioFaultEnum activeRadioFaults[] = 6; + readonly attribute NetworkFaultEnum activeNetworkFaults[] = 7; readonly attribute boolean testEventTriggersEnabled = 8; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -952,7 +948,7 @@ server cluster Switch = 59 { } server cluster AdministratorCommissioning = 60 { - enum CommissioningWindowStatus : ENUM8 { + enum CommissioningWindowStatusEnum : ENUM8 { kWindowNotOpen = 0; kEnhancedWindowOpen = 1; kBasicWindowOpen = 2; @@ -964,7 +960,7 @@ server cluster AdministratorCommissioning = 60 { kWindowNotOpen = 4; } - readonly attribute CommissioningWindowStatus windowStatus = 0; + readonly attribute CommissioningWindowStatusEnum windowStatus = 0; readonly attribute nullable fabric_idx adminFabricIndex = 1; readonly attribute nullable int16u adminVendorId = 2; readonly attribute bitmap32 featureMap = 65532; @@ -988,8 +984,13 @@ server cluster AdministratorCommissioning = 60 { } server cluster OperationalCredentials = 62 { - enum OperationalCertStatus : ENUM8 { - kSuccess = 0; + enum CertificateChainTypeEnum : ENUM8 { + kDACCertificate = 1; + kPAICertificate = 2; + } + + enum NodeOperationalCertStatusEnum : ENUM8 { + kOk = 0; kInvalidPublicKey = 1; kInvalidNodeOpId = 2; kInvalidNOC = 3; @@ -1007,17 +1008,17 @@ server cluster OperationalCredentials = 62 { fabric_idx fabricIndex = 254; } - fabric_scoped struct FabricDescriptor { + fabric_scoped struct FabricDescriptorStruct { octet_string<65> rootPublicKey = 1; - vendor_id vendorId = 2; - fabric_id fabricId = 3; - node_id nodeId = 4; + vendor_id vendorID = 2; + fabric_id fabricID = 3; + node_id nodeID = 4; char_string<32> label = 5; fabric_idx fabricIndex = 254; } readonly attribute access(read: administer) NOCStruct NOCs[] = 0; - readonly attribute FabricDescriptor fabrics[] = 1; + readonly attribute FabricDescriptorStruct fabrics[] = 1; readonly attribute int8u supportedFabrics = 2; readonly attribute int8u commissionedFabrics = 3; readonly attribute OCTET_STRING trustedRootCertificates[] = 4; @@ -1030,7 +1031,7 @@ server cluster OperationalCredentials = 62 { } request struct CertificateChainRequestRequest { - INT8U certificateType = 0; + CertificateChainTypeEnum certificateType = 0; } request struct CSRRequestRequest { @@ -1060,12 +1061,12 @@ server cluster OperationalCredentials = 62 { } request struct AddTrustedRootCertificateRequest { - OCTET_STRING rootCertificate = 0; + OCTET_STRING rootCACertificate = 0; } response struct AttestationResponse = 1 { OCTET_STRING attestationElements = 0; - OCTET_STRING signature = 1; + OCTET_STRING attestationSignature = 1; } response struct CertificateChainResponse = 3 { @@ -1078,7 +1079,7 @@ server cluster OperationalCredentials = 62 { } response struct NOCResponse = 8 { - OperationalCertStatus statusCode = 0; + NodeOperationalCertStatusEnum statusCode = 0; optional fabric_idx fabricIndex = 1; optional CHAR_STRING debugText = 2; } @@ -1344,7 +1345,7 @@ server cluster ColorControl = 768 { } request struct MoveToColorTemperatureRequest { - INT16U colorTemperature = 0; + INT16U colorTemperatureMireds = 0; INT16U transitionTime = 1; BITMAP8 optionsMask = 2; BITMAP8 optionsOverride = 3; diff --git a/examples/chef/devices/rootnode_extendedcolorlight_8lcaaYJVAa.zap b/examples/chef/devices/rootnode_extendedcolorlight_8lcaaYJVAa.zap index 072d59d064bcd3..1262c4cc74ad3b 100644 --- a/examples/chef/devices/rootnode_extendedcolorlight_8lcaaYJVAa.zap +++ b/examples/chef/devices/rootnode_extendedcolorlight_8lcaaYJVAa.zap @@ -4265,7 +4265,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "PHYRate", + "type": "PHYRateEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -4489,7 +4489,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4541,7 +4541,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4553,7 +4553,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "CommissioningWindowStatus", + "type": "CommissioningWindowStatusEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -8115,7 +8115,7 @@ "enabled": 0, "attributes": [ { - "name": "occupancy", + "name": "Occupancy", "code": 0, "mfgCode": null, "side": "server", @@ -8131,7 +8131,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type", + "name": "OccupancySensorType", "code": 1, "mfgCode": null, "side": "server", @@ -8147,7 +8147,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type bitmap", + "name": "OccupancySensorTypeBitmap", "code": 2, "mfgCode": null, "side": "server", @@ -8163,7 +8163,7 @@ "reportableChange": 0 }, { - "name": "PIR occupied to unoccupied delay", + "name": "PIROccupiedToUnoccupiedDelay", "code": 16, "mfgCode": null, "side": "server", @@ -8179,7 +8179,7 @@ "reportableChange": 0 }, { - "name": "PIR unoccupied to occupied delay", + "name": "PIRUnoccupiedToOccupiedDelay", "code": 17, "mfgCode": null, "side": "server", @@ -8195,7 +8195,7 @@ "reportableChange": 0 }, { - "name": "PIR unoccupied to occupied threshold", + "name": "PIRUnoccupiedToOccupiedThreshold", "code": 18, "mfgCode": null, "side": "server", @@ -8211,7 +8211,7 @@ "reportableChange": 0 }, { - "name": "ultrasonic occupied to unoccupied delay", + "name": "UltrasonicOccupiedToUnoccupiedDelay", "code": 32, "mfgCode": null, "side": "server", @@ -8227,7 +8227,7 @@ "reportableChange": 0 }, { - "name": "ultrasonic unoccupied to occupied delay", + "name": "UltrasonicUnoccupiedToOccupiedDelay", "code": 33, "mfgCode": null, "side": "server", @@ -8243,7 +8243,7 @@ "reportableChange": 0 }, { - "name": "ultrasonic unoccupied to occupied threshold", + "name": "UltrasonicUnoccupiedToOccupiedThreshold", "code": 34, "mfgCode": null, "side": "server", @@ -8259,7 +8259,7 @@ "reportableChange": 0 }, { - "name": "physical contact occupied to unoccupied delay", + "name": "PhysicalContactOccupiedToUnoccupiedDelay", "code": 48, "mfgCode": null, "side": "server", @@ -8275,7 +8275,7 @@ "reportableChange": 0 }, { - "name": "physical contact unoccupied to occupied delay", + "name": "PhysicalContactUnoccupiedToOccupiedDelay", "code": 49, "mfgCode": null, "side": "server", @@ -8291,7 +8291,7 @@ "reportableChange": 0 }, { - "name": "physical contact unoccupied to occupied threshold", + "name": "PhysicalContactUnoccupiedToOccupiedThreshold", "code": 50, "mfgCode": null, "side": "server", diff --git a/examples/chef/devices/rootnode_fan_7N2TobIlOX.matter b/examples/chef/devices/rootnode_fan_7N2TobIlOX.matter index 5458817123f751..e49282666e54ac 100644 --- a/examples/chef/devices/rootnode_fan_7N2TobIlOX.matter +++ b/examples/chef/devices/rootnode_fan_7N2TobIlOX.matter @@ -643,7 +643,7 @@ server cluster GeneralDiagnostics = 51 { kSoftwareReset = 6; } - enum HardwareFault : ENUM8 { + enum HardwareFaultEnum : ENUM8 { kUnspecified = 0; kRadio = 1; kSensor = 2; @@ -657,7 +657,7 @@ server cluster GeneralDiagnostics = 51 { kTamperDetected = 10; } - enum InterfaceType : ENUM8 { + enum InterfaceTypeEnum : ENUM8 { kUnspecified = 0; kWiFi = 1; kEthernet = 2; @@ -665,14 +665,14 @@ server cluster GeneralDiagnostics = 51 { kThread = 4; } - enum NetworkFaultType : ENUM8 { + enum NetworkFaultEnum : ENUM8 { kUnspecified = 0; kHardwareFailure = 1; kNetworkJammed = 2; kConnectionFailed = 3; } - enum RadioFault : ENUM8 { + enum RadioFaultEnum : ENUM8 { kUnspecified = 0; kWiFiFault = 1; kCellularFault = 2; @@ -690,22 +690,22 @@ server cluster GeneralDiagnostics = 51 { octet_string<8> hardwareAddress = 4; octet_string IPv4Addresses[] = 5; octet_string IPv6Addresses[] = 6; - InterfaceType type = 7; + InterfaceTypeEnum type = 7; } critical event HardwareFaultChange = 0 { - HardwareFault current[] = 0; - HardwareFault previous[] = 1; + HardwareFaultEnum current[] = 0; + HardwareFaultEnum previous[] = 1; } critical event RadioFaultChange = 1 { - RadioFault current[] = 0; - RadioFault previous[] = 1; + RadioFaultEnum current[] = 0; + RadioFaultEnum previous[] = 1; } critical event NetworkFaultChange = 2 { - NetworkFaultType current[] = 0; - NetworkFaultType previous[] = 1; + NetworkFaultEnum current[] = 0; + NetworkFaultEnum previous[] = 1; } critical event BootReason = 3 { @@ -717,9 +717,9 @@ server cluster GeneralDiagnostics = 51 { readonly attribute int64u upTime = 2; readonly attribute int32u totalOperationalHours = 3; readonly attribute BootReasonEnum bootReason = 4; - readonly attribute HardwareFault activeHardwareFaults[] = 5; - readonly attribute RadioFault activeRadioFaults[] = 6; - readonly attribute NetworkFaultType activeNetworkFaults[] = 7; + readonly attribute HardwareFaultEnum activeHardwareFaults[] = 5; + readonly attribute RadioFaultEnum activeRadioFaults[] = 6; + readonly attribute NetworkFaultEnum activeNetworkFaults[] = 7; readonly attribute boolean testEventTriggersEnabled = 8; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -807,7 +807,7 @@ server cluster Switch = 59 { } server cluster AdministratorCommissioning = 60 { - enum CommissioningWindowStatus : ENUM8 { + enum CommissioningWindowStatusEnum : ENUM8 { kWindowNotOpen = 0; kEnhancedWindowOpen = 1; kBasicWindowOpen = 2; @@ -819,7 +819,7 @@ server cluster AdministratorCommissioning = 60 { kWindowNotOpen = 4; } - readonly attribute CommissioningWindowStatus windowStatus = 0; + readonly attribute CommissioningWindowStatusEnum windowStatus = 0; readonly attribute nullable fabric_idx adminFabricIndex = 1; readonly attribute nullable int16u adminVendorId = 2; readonly attribute bitmap32 featureMap = 65532; @@ -843,8 +843,13 @@ server cluster AdministratorCommissioning = 60 { } server cluster OperationalCredentials = 62 { - enum OperationalCertStatus : ENUM8 { - kSuccess = 0; + enum CertificateChainTypeEnum : ENUM8 { + kDACCertificate = 1; + kPAICertificate = 2; + } + + enum NodeOperationalCertStatusEnum : ENUM8 { + kOk = 0; kInvalidPublicKey = 1; kInvalidNodeOpId = 2; kInvalidNOC = 3; @@ -862,17 +867,17 @@ server cluster OperationalCredentials = 62 { fabric_idx fabricIndex = 254; } - fabric_scoped struct FabricDescriptor { + fabric_scoped struct FabricDescriptorStruct { octet_string<65> rootPublicKey = 1; - vendor_id vendorId = 2; - fabric_id fabricId = 3; - node_id nodeId = 4; + vendor_id vendorID = 2; + fabric_id fabricID = 3; + node_id nodeID = 4; char_string<32> label = 5; fabric_idx fabricIndex = 254; } readonly attribute access(read: administer) NOCStruct NOCs[] = 0; - readonly attribute FabricDescriptor fabrics[] = 1; + readonly attribute FabricDescriptorStruct fabrics[] = 1; readonly attribute int8u supportedFabrics = 2; readonly attribute int8u commissionedFabrics = 3; readonly attribute OCTET_STRING trustedRootCertificates[] = 4; @@ -885,7 +890,7 @@ server cluster OperationalCredentials = 62 { } request struct CertificateChainRequestRequest { - INT8U certificateType = 0; + CertificateChainTypeEnum certificateType = 0; } request struct CSRRequestRequest { @@ -915,12 +920,12 @@ server cluster OperationalCredentials = 62 { } request struct AddTrustedRootCertificateRequest { - OCTET_STRING rootCertificate = 0; + OCTET_STRING rootCACertificate = 0; } response struct AttestationResponse = 1 { OCTET_STRING attestationElements = 0; - OCTET_STRING signature = 1; + OCTET_STRING attestationSignature = 1; } response struct CertificateChainResponse = 3 { @@ -933,7 +938,7 @@ server cluster OperationalCredentials = 62 { } response struct NOCResponse = 8 { - OperationalCertStatus statusCode = 0; + NodeOperationalCertStatusEnum statusCode = 0; optional fabric_idx fabricIndex = 1; optional CHAR_STRING debugText = 2; } diff --git a/examples/chef/devices/rootnode_fan_7N2TobIlOX.zap b/examples/chef/devices/rootnode_fan_7N2TobIlOX.zap index 18f92fc60a8cdd..606234eb628c0b 100644 --- a/examples/chef/devices/rootnode_fan_7N2TobIlOX.zap +++ b/examples/chef/devices/rootnode_fan_7N2TobIlOX.zap @@ -4409,7 +4409,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "PHYRate", + "type": "PHYRateEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -4665,7 +4665,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4717,7 +4717,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4729,7 +4729,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "CommissioningWindowStatus", + "type": "CommissioningWindowStatusEnum", "included": 1, "storageOption": "External", "singleton": 0, diff --git a/examples/chef/devices/rootnode_flowsensor_1zVxHedlaV.matter b/examples/chef/devices/rootnode_flowsensor_1zVxHedlaV.matter index 72618cd6321b30..15c106ea23462e 100644 --- a/examples/chef/devices/rootnode_flowsensor_1zVxHedlaV.matter +++ b/examples/chef/devices/rootnode_flowsensor_1zVxHedlaV.matter @@ -654,7 +654,7 @@ server cluster GeneralDiagnostics = 51 { kSoftwareReset = 6; } - enum HardwareFault : ENUM8 { + enum HardwareFaultEnum : ENUM8 { kUnspecified = 0; kRadio = 1; kSensor = 2; @@ -668,7 +668,7 @@ server cluster GeneralDiagnostics = 51 { kTamperDetected = 10; } - enum InterfaceType : ENUM8 { + enum InterfaceTypeEnum : ENUM8 { kUnspecified = 0; kWiFi = 1; kEthernet = 2; @@ -676,14 +676,14 @@ server cluster GeneralDiagnostics = 51 { kThread = 4; } - enum NetworkFaultType : ENUM8 { + enum NetworkFaultEnum : ENUM8 { kUnspecified = 0; kHardwareFailure = 1; kNetworkJammed = 2; kConnectionFailed = 3; } - enum RadioFault : ENUM8 { + enum RadioFaultEnum : ENUM8 { kUnspecified = 0; kWiFiFault = 1; kCellularFault = 2; @@ -701,22 +701,22 @@ server cluster GeneralDiagnostics = 51 { octet_string<8> hardwareAddress = 4; octet_string IPv4Addresses[] = 5; octet_string IPv6Addresses[] = 6; - InterfaceType type = 7; + InterfaceTypeEnum type = 7; } critical event HardwareFaultChange = 0 { - HardwareFault current[] = 0; - HardwareFault previous[] = 1; + HardwareFaultEnum current[] = 0; + HardwareFaultEnum previous[] = 1; } critical event RadioFaultChange = 1 { - RadioFault current[] = 0; - RadioFault previous[] = 1; + RadioFaultEnum current[] = 0; + RadioFaultEnum previous[] = 1; } critical event NetworkFaultChange = 2 { - NetworkFaultType current[] = 0; - NetworkFaultType previous[] = 1; + NetworkFaultEnum current[] = 0; + NetworkFaultEnum previous[] = 1; } critical event BootReason = 3 { @@ -728,9 +728,9 @@ server cluster GeneralDiagnostics = 51 { readonly attribute int64u upTime = 2; readonly attribute int32u totalOperationalHours = 3; readonly attribute BootReasonEnum bootReason = 4; - readonly attribute HardwareFault activeHardwareFaults[] = 5; - readonly attribute RadioFault activeRadioFaults[] = 6; - readonly attribute NetworkFaultType activeNetworkFaults[] = 7; + readonly attribute HardwareFaultEnum activeHardwareFaults[] = 5; + readonly attribute RadioFaultEnum activeRadioFaults[] = 6; + readonly attribute NetworkFaultEnum activeNetworkFaults[] = 7; readonly attribute boolean testEventTriggersEnabled = 8; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -816,7 +816,7 @@ server cluster Switch = 59 { } server cluster AdministratorCommissioning = 60 { - enum CommissioningWindowStatus : ENUM8 { + enum CommissioningWindowStatusEnum : ENUM8 { kWindowNotOpen = 0; kEnhancedWindowOpen = 1; kBasicWindowOpen = 2; @@ -828,7 +828,7 @@ server cluster AdministratorCommissioning = 60 { kWindowNotOpen = 4; } - readonly attribute CommissioningWindowStatus windowStatus = 0; + readonly attribute CommissioningWindowStatusEnum windowStatus = 0; readonly attribute nullable fabric_idx adminFabricIndex = 1; readonly attribute nullable int16u adminVendorId = 2; readonly attribute bitmap32 featureMap = 65532; @@ -852,8 +852,13 @@ server cluster AdministratorCommissioning = 60 { } server cluster OperationalCredentials = 62 { - enum OperationalCertStatus : ENUM8 { - kSuccess = 0; + enum CertificateChainTypeEnum : ENUM8 { + kDACCertificate = 1; + kPAICertificate = 2; + } + + enum NodeOperationalCertStatusEnum : ENUM8 { + kOk = 0; kInvalidPublicKey = 1; kInvalidNodeOpId = 2; kInvalidNOC = 3; @@ -871,17 +876,17 @@ server cluster OperationalCredentials = 62 { fabric_idx fabricIndex = 254; } - fabric_scoped struct FabricDescriptor { + fabric_scoped struct FabricDescriptorStruct { octet_string<65> rootPublicKey = 1; - vendor_id vendorId = 2; - fabric_id fabricId = 3; - node_id nodeId = 4; + vendor_id vendorID = 2; + fabric_id fabricID = 3; + node_id nodeID = 4; char_string<32> label = 5; fabric_idx fabricIndex = 254; } readonly attribute access(read: administer) NOCStruct NOCs[] = 0; - readonly attribute FabricDescriptor fabrics[] = 1; + readonly attribute FabricDescriptorStruct fabrics[] = 1; readonly attribute int8u supportedFabrics = 2; readonly attribute int8u commissionedFabrics = 3; readonly attribute OCTET_STRING trustedRootCertificates[] = 4; @@ -894,7 +899,7 @@ server cluster OperationalCredentials = 62 { } request struct CertificateChainRequestRequest { - INT8U certificateType = 0; + CertificateChainTypeEnum certificateType = 0; } request struct CSRRequestRequest { @@ -924,12 +929,12 @@ server cluster OperationalCredentials = 62 { } request struct AddTrustedRootCertificateRequest { - OCTET_STRING rootCertificate = 0; + OCTET_STRING rootCACertificate = 0; } response struct AttestationResponse = 1 { OCTET_STRING attestationElements = 0; - OCTET_STRING signature = 1; + OCTET_STRING attestationSignature = 1; } response struct CertificateChainResponse = 3 { @@ -942,7 +947,7 @@ server cluster OperationalCredentials = 62 { } response struct NOCResponse = 8 { - OperationalCertStatus statusCode = 0; + NodeOperationalCertStatusEnum statusCode = 0; optional fabric_idx fabricIndex = 1; optional CHAR_STRING debugText = 2; } diff --git a/examples/chef/devices/rootnode_flowsensor_1zVxHedlaV.zap b/examples/chef/devices/rootnode_flowsensor_1zVxHedlaV.zap index d644fe72e57caf..a906e41246cf76 100644 --- a/examples/chef/devices/rootnode_flowsensor_1zVxHedlaV.zap +++ b/examples/chef/devices/rootnode_flowsensor_1zVxHedlaV.zap @@ -4265,7 +4265,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "PHYRate", + "type": "PHYRateEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -4489,7 +4489,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4541,7 +4541,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4553,7 +4553,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "CommissioningWindowStatus", + "type": "CommissioningWindowStatusEnum", "included": 1, "storageOption": "External", "singleton": 0, diff --git a/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter b/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter index 48469c89fffca6..f2d7633500a71d 100644 --- a/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter +++ b/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter @@ -132,10 +132,6 @@ server cluster OnOff = 6 { kLighting = 0x1; } - bitmap SceneFeatures : BITMAP32 { - kSceneNames = 0x1; - } - readonly attribute boolean onOff = 0; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; @@ -783,7 +779,7 @@ server cluster GeneralDiagnostics = 51 { kSoftwareReset = 6; } - enum HardwareFault : ENUM8 { + enum HardwareFaultEnum : ENUM8 { kUnspecified = 0; kRadio = 1; kSensor = 2; @@ -797,7 +793,7 @@ server cluster GeneralDiagnostics = 51 { kTamperDetected = 10; } - enum InterfaceType : ENUM8 { + enum InterfaceTypeEnum : ENUM8 { kUnspecified = 0; kWiFi = 1; kEthernet = 2; @@ -805,14 +801,14 @@ server cluster GeneralDiagnostics = 51 { kThread = 4; } - enum NetworkFaultType : ENUM8 { + enum NetworkFaultEnum : ENUM8 { kUnspecified = 0; kHardwareFailure = 1; kNetworkJammed = 2; kConnectionFailed = 3; } - enum RadioFault : ENUM8 { + enum RadioFaultEnum : ENUM8 { kUnspecified = 0; kWiFiFault = 1; kCellularFault = 2; @@ -830,22 +826,22 @@ server cluster GeneralDiagnostics = 51 { octet_string<8> hardwareAddress = 4; octet_string IPv4Addresses[] = 5; octet_string IPv6Addresses[] = 6; - InterfaceType type = 7; + InterfaceTypeEnum type = 7; } critical event HardwareFaultChange = 0 { - HardwareFault current[] = 0; - HardwareFault previous[] = 1; + HardwareFaultEnum current[] = 0; + HardwareFaultEnum previous[] = 1; } critical event RadioFaultChange = 1 { - RadioFault current[] = 0; - RadioFault previous[] = 1; + RadioFaultEnum current[] = 0; + RadioFaultEnum previous[] = 1; } critical event NetworkFaultChange = 2 { - NetworkFaultType current[] = 0; - NetworkFaultType previous[] = 1; + NetworkFaultEnum current[] = 0; + NetworkFaultEnum previous[] = 1; } critical event BootReason = 3 { @@ -857,9 +853,9 @@ server cluster GeneralDiagnostics = 51 { readonly attribute int64u upTime = 2; readonly attribute int32u totalOperationalHours = 3; readonly attribute BootReasonEnum bootReason = 4; - readonly attribute HardwareFault activeHardwareFaults[] = 5; - readonly attribute RadioFault activeRadioFaults[] = 6; - readonly attribute NetworkFaultType activeNetworkFaults[] = 7; + readonly attribute HardwareFaultEnum activeHardwareFaults[] = 5; + readonly attribute RadioFaultEnum activeRadioFaults[] = 6; + readonly attribute NetworkFaultEnum activeNetworkFaults[] = 7; readonly attribute boolean testEventTriggersEnabled = 8; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -945,7 +941,7 @@ server cluster Switch = 59 { } server cluster AdministratorCommissioning = 60 { - enum CommissioningWindowStatus : ENUM8 { + enum CommissioningWindowStatusEnum : ENUM8 { kWindowNotOpen = 0; kEnhancedWindowOpen = 1; kBasicWindowOpen = 2; @@ -957,7 +953,7 @@ server cluster AdministratorCommissioning = 60 { kWindowNotOpen = 4; } - readonly attribute CommissioningWindowStatus windowStatus = 0; + readonly attribute CommissioningWindowStatusEnum windowStatus = 0; readonly attribute nullable fabric_idx adminFabricIndex = 1; readonly attribute nullable int16u adminVendorId = 2; readonly attribute bitmap32 featureMap = 65532; @@ -981,8 +977,13 @@ server cluster AdministratorCommissioning = 60 { } server cluster OperationalCredentials = 62 { - enum OperationalCertStatus : ENUM8 { - kSuccess = 0; + enum CertificateChainTypeEnum : ENUM8 { + kDACCertificate = 1; + kPAICertificate = 2; + } + + enum NodeOperationalCertStatusEnum : ENUM8 { + kOk = 0; kInvalidPublicKey = 1; kInvalidNodeOpId = 2; kInvalidNOC = 3; @@ -1000,17 +1001,17 @@ server cluster OperationalCredentials = 62 { fabric_idx fabricIndex = 254; } - fabric_scoped struct FabricDescriptor { + fabric_scoped struct FabricDescriptorStruct { octet_string<65> rootPublicKey = 1; - vendor_id vendorId = 2; - fabric_id fabricId = 3; - node_id nodeId = 4; + vendor_id vendorID = 2; + fabric_id fabricID = 3; + node_id nodeID = 4; char_string<32> label = 5; fabric_idx fabricIndex = 254; } readonly attribute access(read: administer) NOCStruct NOCs[] = 0; - readonly attribute FabricDescriptor fabrics[] = 1; + readonly attribute FabricDescriptorStruct fabrics[] = 1; readonly attribute int8u supportedFabrics = 2; readonly attribute int8u commissionedFabrics = 3; readonly attribute OCTET_STRING trustedRootCertificates[] = 4; @@ -1023,7 +1024,7 @@ server cluster OperationalCredentials = 62 { } request struct CertificateChainRequestRequest { - INT8U certificateType = 0; + CertificateChainTypeEnum certificateType = 0; } request struct CSRRequestRequest { @@ -1053,12 +1054,12 @@ server cluster OperationalCredentials = 62 { } request struct AddTrustedRootCertificateRequest { - OCTET_STRING rootCertificate = 0; + OCTET_STRING rootCACertificate = 0; } response struct AttestationResponse = 1 { OCTET_STRING attestationElements = 0; - OCTET_STRING signature = 1; + OCTET_STRING attestationSignature = 1; } response struct CertificateChainResponse = 3 { @@ -1071,7 +1072,7 @@ server cluster OperationalCredentials = 62 { } response struct NOCResponse = 8 { - OperationalCertStatus statusCode = 0; + NodeOperationalCertStatusEnum statusCode = 0; optional fabric_idx fabricIndex = 1; optional CHAR_STRING debugText = 2; } @@ -1166,9 +1167,9 @@ server cluster FixedLabel = 64 { client cluster Thermostat = 513 { enum SetpointAdjustMode : ENUM8 { - kHeatSetpoint = 0; - kCoolSetpoint = 1; - kHeatAndCoolSetpoints = 2; + kHeat = 0; + kCool = 1; + kBoth = 2; } enum ThermostatControlSequence : ENUM8 { @@ -1191,9 +1192,11 @@ client cluster Thermostat = 513 { kAuto = 1; kCool = 3; kHeat = 4; - kEmergencyHeating = 5; + kEmergencyHeat = 5; kPrecooling = 6; kFanOnly = 7; + kDry = 8; + kSleep = 9; } bitmap DayOfWeek : BITMAP8 { @@ -1204,21 +1207,21 @@ client cluster Thermostat = 513 { kThursday = 0x10; kFriday = 0x20; kSaturday = 0x40; - kAwayOrVacation = 0x80; + kAway = 0x80; } bitmap ModeForSequence : BITMAP8 { - kHeatSetpointFieldPresent = 0x1; - kCoolSetpointFieldPresent = 0x2; + kHeatSetpointPresent = 0x1; + kCoolSetpointPresent = 0x2; } bitmap ThermostatFeature : BITMAP32 { kHeating = 0x1; kCooling = 0x2; kOccupancy = 0x4; - kSchedule = 0x8; + kScheduleConfiguration = 0x8; kSetback = 0x10; - kAutomode = 0x20; + kAutoMode = 0x20; } readonly attribute nullable int16s localTemperature = 0; diff --git a/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.zap b/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.zap index 389dfb13326814..84283fedb10e2c 100644 --- a/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.zap +++ b/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.zap @@ -4265,7 +4265,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "PHYRate", + "type": "PHYRateEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -4489,7 +4489,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4541,7 +4541,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4553,7 +4553,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "CommissioningWindowStatus", + "type": "CommissioningWindowStatusEnum", "included": 1, "storageOption": "External", "singleton": 0, diff --git a/examples/chef/devices/rootnode_humiditysensor_Xyj4gda6Hb.matter b/examples/chef/devices/rootnode_humiditysensor_Xyj4gda6Hb.matter index f265729fd104df..1fea3cd56bb2f9 100644 --- a/examples/chef/devices/rootnode_humiditysensor_Xyj4gda6Hb.matter +++ b/examples/chef/devices/rootnode_humiditysensor_Xyj4gda6Hb.matter @@ -654,7 +654,7 @@ server cluster GeneralDiagnostics = 51 { kSoftwareReset = 6; } - enum HardwareFault : ENUM8 { + enum HardwareFaultEnum : ENUM8 { kUnspecified = 0; kRadio = 1; kSensor = 2; @@ -668,7 +668,7 @@ server cluster GeneralDiagnostics = 51 { kTamperDetected = 10; } - enum InterfaceType : ENUM8 { + enum InterfaceTypeEnum : ENUM8 { kUnspecified = 0; kWiFi = 1; kEthernet = 2; @@ -676,14 +676,14 @@ server cluster GeneralDiagnostics = 51 { kThread = 4; } - enum NetworkFaultType : ENUM8 { + enum NetworkFaultEnum : ENUM8 { kUnspecified = 0; kHardwareFailure = 1; kNetworkJammed = 2; kConnectionFailed = 3; } - enum RadioFault : ENUM8 { + enum RadioFaultEnum : ENUM8 { kUnspecified = 0; kWiFiFault = 1; kCellularFault = 2; @@ -701,22 +701,22 @@ server cluster GeneralDiagnostics = 51 { octet_string<8> hardwareAddress = 4; octet_string IPv4Addresses[] = 5; octet_string IPv6Addresses[] = 6; - InterfaceType type = 7; + InterfaceTypeEnum type = 7; } critical event HardwareFaultChange = 0 { - HardwareFault current[] = 0; - HardwareFault previous[] = 1; + HardwareFaultEnum current[] = 0; + HardwareFaultEnum previous[] = 1; } critical event RadioFaultChange = 1 { - RadioFault current[] = 0; - RadioFault previous[] = 1; + RadioFaultEnum current[] = 0; + RadioFaultEnum previous[] = 1; } critical event NetworkFaultChange = 2 { - NetworkFaultType current[] = 0; - NetworkFaultType previous[] = 1; + NetworkFaultEnum current[] = 0; + NetworkFaultEnum previous[] = 1; } critical event BootReason = 3 { @@ -728,9 +728,9 @@ server cluster GeneralDiagnostics = 51 { readonly attribute int64u upTime = 2; readonly attribute int32u totalOperationalHours = 3; readonly attribute BootReasonEnum bootReason = 4; - readonly attribute HardwareFault activeHardwareFaults[] = 5; - readonly attribute RadioFault activeRadioFaults[] = 6; - readonly attribute NetworkFaultType activeNetworkFaults[] = 7; + readonly attribute HardwareFaultEnum activeHardwareFaults[] = 5; + readonly attribute RadioFaultEnum activeRadioFaults[] = 6; + readonly attribute NetworkFaultEnum activeNetworkFaults[] = 7; readonly attribute boolean testEventTriggersEnabled = 8; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -816,7 +816,7 @@ server cluster Switch = 59 { } server cluster AdministratorCommissioning = 60 { - enum CommissioningWindowStatus : ENUM8 { + enum CommissioningWindowStatusEnum : ENUM8 { kWindowNotOpen = 0; kEnhancedWindowOpen = 1; kBasicWindowOpen = 2; @@ -828,7 +828,7 @@ server cluster AdministratorCommissioning = 60 { kWindowNotOpen = 4; } - readonly attribute CommissioningWindowStatus windowStatus = 0; + readonly attribute CommissioningWindowStatusEnum windowStatus = 0; readonly attribute nullable fabric_idx adminFabricIndex = 1; readonly attribute nullable int16u adminVendorId = 2; readonly attribute bitmap32 featureMap = 65532; @@ -852,8 +852,13 @@ server cluster AdministratorCommissioning = 60 { } server cluster OperationalCredentials = 62 { - enum OperationalCertStatus : ENUM8 { - kSuccess = 0; + enum CertificateChainTypeEnum : ENUM8 { + kDACCertificate = 1; + kPAICertificate = 2; + } + + enum NodeOperationalCertStatusEnum : ENUM8 { + kOk = 0; kInvalidPublicKey = 1; kInvalidNodeOpId = 2; kInvalidNOC = 3; @@ -871,17 +876,17 @@ server cluster OperationalCredentials = 62 { fabric_idx fabricIndex = 254; } - fabric_scoped struct FabricDescriptor { + fabric_scoped struct FabricDescriptorStruct { octet_string<65> rootPublicKey = 1; - vendor_id vendorId = 2; - fabric_id fabricId = 3; - node_id nodeId = 4; + vendor_id vendorID = 2; + fabric_id fabricID = 3; + node_id nodeID = 4; char_string<32> label = 5; fabric_idx fabricIndex = 254; } readonly attribute access(read: administer) NOCStruct NOCs[] = 0; - readonly attribute FabricDescriptor fabrics[] = 1; + readonly attribute FabricDescriptorStruct fabrics[] = 1; readonly attribute int8u supportedFabrics = 2; readonly attribute int8u commissionedFabrics = 3; readonly attribute OCTET_STRING trustedRootCertificates[] = 4; @@ -894,7 +899,7 @@ server cluster OperationalCredentials = 62 { } request struct CertificateChainRequestRequest { - INT8U certificateType = 0; + CertificateChainTypeEnum certificateType = 0; } request struct CSRRequestRequest { @@ -924,12 +929,12 @@ server cluster OperationalCredentials = 62 { } request struct AddTrustedRootCertificateRequest { - OCTET_STRING rootCertificate = 0; + OCTET_STRING rootCACertificate = 0; } response struct AttestationResponse = 1 { OCTET_STRING attestationElements = 0; - OCTET_STRING signature = 1; + OCTET_STRING attestationSignature = 1; } response struct CertificateChainResponse = 3 { @@ -942,7 +947,7 @@ server cluster OperationalCredentials = 62 { } response struct NOCResponse = 8 { - OperationalCertStatus statusCode = 0; + NodeOperationalCertStatusEnum statusCode = 0; optional fabric_idx fabricIndex = 1; optional CHAR_STRING debugText = 2; } diff --git a/examples/chef/devices/rootnode_humiditysensor_Xyj4gda6Hb.zap b/examples/chef/devices/rootnode_humiditysensor_Xyj4gda6Hb.zap index b0ea2523a99ffc..cc514f48c8e117 100644 --- a/examples/chef/devices/rootnode_humiditysensor_Xyj4gda6Hb.zap +++ b/examples/chef/devices/rootnode_humiditysensor_Xyj4gda6Hb.zap @@ -4265,7 +4265,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "PHYRate", + "type": "PHYRateEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -4489,7 +4489,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4541,7 +4541,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4553,7 +4553,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "CommissioningWindowStatus", + "type": "CommissioningWindowStatusEnum", "included": 1, "storageOption": "External", "singleton": 0, diff --git a/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.matter b/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.matter index db7357e0ee1066..4bc590e377fdcf 100644 --- a/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.matter +++ b/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.matter @@ -654,7 +654,7 @@ server cluster GeneralDiagnostics = 51 { kSoftwareReset = 6; } - enum HardwareFault : ENUM8 { + enum HardwareFaultEnum : ENUM8 { kUnspecified = 0; kRadio = 1; kSensor = 2; @@ -668,7 +668,7 @@ server cluster GeneralDiagnostics = 51 { kTamperDetected = 10; } - enum InterfaceType : ENUM8 { + enum InterfaceTypeEnum : ENUM8 { kUnspecified = 0; kWiFi = 1; kEthernet = 2; @@ -676,14 +676,14 @@ server cluster GeneralDiagnostics = 51 { kThread = 4; } - enum NetworkFaultType : ENUM8 { + enum NetworkFaultEnum : ENUM8 { kUnspecified = 0; kHardwareFailure = 1; kNetworkJammed = 2; kConnectionFailed = 3; } - enum RadioFault : ENUM8 { + enum RadioFaultEnum : ENUM8 { kUnspecified = 0; kWiFiFault = 1; kCellularFault = 2; @@ -701,22 +701,22 @@ server cluster GeneralDiagnostics = 51 { octet_string<8> hardwareAddress = 4; octet_string IPv4Addresses[] = 5; octet_string IPv6Addresses[] = 6; - InterfaceType type = 7; + InterfaceTypeEnum type = 7; } critical event HardwareFaultChange = 0 { - HardwareFault current[] = 0; - HardwareFault previous[] = 1; + HardwareFaultEnum current[] = 0; + HardwareFaultEnum previous[] = 1; } critical event RadioFaultChange = 1 { - RadioFault current[] = 0; - RadioFault previous[] = 1; + RadioFaultEnum current[] = 0; + RadioFaultEnum previous[] = 1; } critical event NetworkFaultChange = 2 { - NetworkFaultType current[] = 0; - NetworkFaultType previous[] = 1; + NetworkFaultEnum current[] = 0; + NetworkFaultEnum previous[] = 1; } critical event BootReason = 3 { @@ -728,9 +728,9 @@ server cluster GeneralDiagnostics = 51 { readonly attribute int64u upTime = 2; readonly attribute int32u totalOperationalHours = 3; readonly attribute BootReasonEnum bootReason = 4; - readonly attribute HardwareFault activeHardwareFaults[] = 5; - readonly attribute RadioFault activeRadioFaults[] = 6; - readonly attribute NetworkFaultType activeNetworkFaults[] = 7; + readonly attribute HardwareFaultEnum activeHardwareFaults[] = 5; + readonly attribute RadioFaultEnum activeRadioFaults[] = 6; + readonly attribute NetworkFaultEnum activeNetworkFaults[] = 7; readonly attribute boolean testEventTriggersEnabled = 8; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -816,7 +816,7 @@ server cluster Switch = 59 { } server cluster AdministratorCommissioning = 60 { - enum CommissioningWindowStatus : ENUM8 { + enum CommissioningWindowStatusEnum : ENUM8 { kWindowNotOpen = 0; kEnhancedWindowOpen = 1; kBasicWindowOpen = 2; @@ -828,7 +828,7 @@ server cluster AdministratorCommissioning = 60 { kWindowNotOpen = 4; } - readonly attribute CommissioningWindowStatus windowStatus = 0; + readonly attribute CommissioningWindowStatusEnum windowStatus = 0; readonly attribute nullable fabric_idx adminFabricIndex = 1; readonly attribute nullable int16u adminVendorId = 2; readonly attribute bitmap32 featureMap = 65532; @@ -852,8 +852,13 @@ server cluster AdministratorCommissioning = 60 { } server cluster OperationalCredentials = 62 { - enum OperationalCertStatus : ENUM8 { - kSuccess = 0; + enum CertificateChainTypeEnum : ENUM8 { + kDACCertificate = 1; + kPAICertificate = 2; + } + + enum NodeOperationalCertStatusEnum : ENUM8 { + kOk = 0; kInvalidPublicKey = 1; kInvalidNodeOpId = 2; kInvalidNOC = 3; @@ -871,17 +876,17 @@ server cluster OperationalCredentials = 62 { fabric_idx fabricIndex = 254; } - fabric_scoped struct FabricDescriptor { + fabric_scoped struct FabricDescriptorStruct { octet_string<65> rootPublicKey = 1; - vendor_id vendorId = 2; - fabric_id fabricId = 3; - node_id nodeId = 4; + vendor_id vendorID = 2; + fabric_id fabricID = 3; + node_id nodeID = 4; char_string<32> label = 5; fabric_idx fabricIndex = 254; } readonly attribute access(read: administer) NOCStruct NOCs[] = 0; - readonly attribute FabricDescriptor fabrics[] = 1; + readonly attribute FabricDescriptorStruct fabrics[] = 1; readonly attribute int8u supportedFabrics = 2; readonly attribute int8u commissionedFabrics = 3; readonly attribute OCTET_STRING trustedRootCertificates[] = 4; @@ -894,7 +899,7 @@ server cluster OperationalCredentials = 62 { } request struct CertificateChainRequestRequest { - INT8U certificateType = 0; + CertificateChainTypeEnum certificateType = 0; } request struct CSRRequestRequest { @@ -924,12 +929,12 @@ server cluster OperationalCredentials = 62 { } request struct AddTrustedRootCertificateRequest { - OCTET_STRING rootCertificate = 0; + OCTET_STRING rootCACertificate = 0; } response struct AttestationResponse = 1 { OCTET_STRING attestationElements = 0; - OCTET_STRING signature = 1; + OCTET_STRING attestationSignature = 1; } response struct CertificateChainResponse = 3 { @@ -942,7 +947,7 @@ server cluster OperationalCredentials = 62 { } response struct NOCResponse = 8 { - OperationalCertStatus statusCode = 0; + NodeOperationalCertStatusEnum statusCode = 0; optional fabric_idx fabricIndex = 1; optional CHAR_STRING debugText = 2; } diff --git a/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.zap b/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.zap index 82b2db2b128214..5695311d5c863d 100644 --- a/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.zap +++ b/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.zap @@ -4265,7 +4265,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "PHYRate", + "type": "PHYRateEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -4489,7 +4489,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4541,7 +4541,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4553,7 +4553,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "CommissioningWindowStatus", + "type": "CommissioningWindowStatusEnum", "included": 1, "storageOption": "External", "singleton": 0, diff --git a/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.matter b/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.matter index 0be99f3c8d0c9c..16d07dec7c877d 100644 --- a/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.matter +++ b/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.matter @@ -654,7 +654,7 @@ server cluster GeneralDiagnostics = 51 { kSoftwareReset = 6; } - enum HardwareFault : ENUM8 { + enum HardwareFaultEnum : ENUM8 { kUnspecified = 0; kRadio = 1; kSensor = 2; @@ -668,7 +668,7 @@ server cluster GeneralDiagnostics = 51 { kTamperDetected = 10; } - enum InterfaceType : ENUM8 { + enum InterfaceTypeEnum : ENUM8 { kUnspecified = 0; kWiFi = 1; kEthernet = 2; @@ -676,14 +676,14 @@ server cluster GeneralDiagnostics = 51 { kThread = 4; } - enum NetworkFaultType : ENUM8 { + enum NetworkFaultEnum : ENUM8 { kUnspecified = 0; kHardwareFailure = 1; kNetworkJammed = 2; kConnectionFailed = 3; } - enum RadioFault : ENUM8 { + enum RadioFaultEnum : ENUM8 { kUnspecified = 0; kWiFiFault = 1; kCellularFault = 2; @@ -701,22 +701,22 @@ server cluster GeneralDiagnostics = 51 { octet_string<8> hardwareAddress = 4; octet_string IPv4Addresses[] = 5; octet_string IPv6Addresses[] = 6; - InterfaceType type = 7; + InterfaceTypeEnum type = 7; } critical event HardwareFaultChange = 0 { - HardwareFault current[] = 0; - HardwareFault previous[] = 1; + HardwareFaultEnum current[] = 0; + HardwareFaultEnum previous[] = 1; } critical event RadioFaultChange = 1 { - RadioFault current[] = 0; - RadioFault previous[] = 1; + RadioFaultEnum current[] = 0; + RadioFaultEnum previous[] = 1; } critical event NetworkFaultChange = 2 { - NetworkFaultType current[] = 0; - NetworkFaultType previous[] = 1; + NetworkFaultEnum current[] = 0; + NetworkFaultEnum previous[] = 1; } critical event BootReason = 3 { @@ -728,9 +728,9 @@ server cluster GeneralDiagnostics = 51 { readonly attribute int64u upTime = 2; readonly attribute int32u totalOperationalHours = 3; readonly attribute BootReasonEnum bootReason = 4; - readonly attribute HardwareFault activeHardwareFaults[] = 5; - readonly attribute RadioFault activeRadioFaults[] = 6; - readonly attribute NetworkFaultType activeNetworkFaults[] = 7; + readonly attribute HardwareFaultEnum activeHardwareFaults[] = 5; + readonly attribute RadioFaultEnum activeRadioFaults[] = 6; + readonly attribute NetworkFaultEnum activeNetworkFaults[] = 7; readonly attribute boolean testEventTriggersEnabled = 8; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -816,7 +816,7 @@ server cluster Switch = 59 { } server cluster AdministratorCommissioning = 60 { - enum CommissioningWindowStatus : ENUM8 { + enum CommissioningWindowStatusEnum : ENUM8 { kWindowNotOpen = 0; kEnhancedWindowOpen = 1; kBasicWindowOpen = 2; @@ -828,7 +828,7 @@ server cluster AdministratorCommissioning = 60 { kWindowNotOpen = 4; } - readonly attribute CommissioningWindowStatus windowStatus = 0; + readonly attribute CommissioningWindowStatusEnum windowStatus = 0; readonly attribute nullable fabric_idx adminFabricIndex = 1; readonly attribute nullable int16u adminVendorId = 2; readonly attribute bitmap32 featureMap = 65532; @@ -852,8 +852,13 @@ server cluster AdministratorCommissioning = 60 { } server cluster OperationalCredentials = 62 { - enum OperationalCertStatus : ENUM8 { - kSuccess = 0; + enum CertificateChainTypeEnum : ENUM8 { + kDACCertificate = 1; + kPAICertificate = 2; + } + + enum NodeOperationalCertStatusEnum : ENUM8 { + kOk = 0; kInvalidPublicKey = 1; kInvalidNodeOpId = 2; kInvalidNOC = 3; @@ -871,17 +876,17 @@ server cluster OperationalCredentials = 62 { fabric_idx fabricIndex = 254; } - fabric_scoped struct FabricDescriptor { + fabric_scoped struct FabricDescriptorStruct { octet_string<65> rootPublicKey = 1; - vendor_id vendorId = 2; - fabric_id fabricId = 3; - node_id nodeId = 4; + vendor_id vendorID = 2; + fabric_id fabricID = 3; + node_id nodeID = 4; char_string<32> label = 5; fabric_idx fabricIndex = 254; } readonly attribute access(read: administer) NOCStruct NOCs[] = 0; - readonly attribute FabricDescriptor fabrics[] = 1; + readonly attribute FabricDescriptorStruct fabrics[] = 1; readonly attribute int8u supportedFabrics = 2; readonly attribute int8u commissionedFabrics = 3; readonly attribute OCTET_STRING trustedRootCertificates[] = 4; @@ -894,7 +899,7 @@ server cluster OperationalCredentials = 62 { } request struct CertificateChainRequestRequest { - INT8U certificateType = 0; + CertificateChainTypeEnum certificateType = 0; } request struct CSRRequestRequest { @@ -924,12 +929,12 @@ server cluster OperationalCredentials = 62 { } request struct AddTrustedRootCertificateRequest { - OCTET_STRING rootCertificate = 0; + OCTET_STRING rootCACertificate = 0; } response struct AttestationResponse = 1 { OCTET_STRING attestationElements = 0; - OCTET_STRING signature = 1; + OCTET_STRING attestationSignature = 1; } response struct CertificateChainResponse = 3 { @@ -942,7 +947,7 @@ server cluster OperationalCredentials = 62 { } response struct NOCResponse = 8 { - OperationalCertStatus statusCode = 0; + NodeOperationalCertStatusEnum statusCode = 0; optional fabric_idx fabricIndex = 1; optional CHAR_STRING debugText = 2; } diff --git a/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.zap b/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.zap index d35cf96b967b8e..3c9434f8a96a12 100644 --- a/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.zap +++ b/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.zap @@ -4265,7 +4265,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "PHYRate", + "type": "PHYRateEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -4489,7 +4489,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4541,7 +4541,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4553,7 +4553,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "CommissioningWindowStatus", + "type": "CommissioningWindowStatusEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -6001,7 +6001,7 @@ "enabled": 1, "attributes": [ { - "name": "occupancy", + "name": "Occupancy", "code": 0, "mfgCode": null, "side": "server", @@ -6017,7 +6017,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type", + "name": "OccupancySensorType", "code": 1, "mfgCode": null, "side": "server", @@ -6033,7 +6033,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type bitmap", + "name": "OccupancySensorTypeBitmap", "code": 2, "mfgCode": null, "side": "server", @@ -6049,7 +6049,7 @@ "reportableChange": 0 }, { - "name": "PIR occupied to unoccupied delay", + "name": "PIROccupiedToUnoccupiedDelay", "code": 16, "mfgCode": null, "side": "server", @@ -6065,7 +6065,7 @@ "reportableChange": 0 }, { - "name": "PIR unoccupied to occupied delay", + "name": "PIRUnoccupiedToOccupiedDelay", "code": 17, "mfgCode": null, "side": "server", @@ -6081,7 +6081,7 @@ "reportableChange": 0 }, { - "name": "PIR unoccupied to occupied threshold", + "name": "PIRUnoccupiedToOccupiedThreshold", "code": 18, "mfgCode": null, "side": "server", @@ -6097,7 +6097,7 @@ "reportableChange": 0 }, { - "name": "ultrasonic occupied to unoccupied delay", + "name": "UltrasonicOccupiedToUnoccupiedDelay", "code": 32, "mfgCode": null, "side": "server", @@ -6113,7 +6113,7 @@ "reportableChange": 0 }, { - "name": "ultrasonic unoccupied to occupied delay", + "name": "UltrasonicUnoccupiedToOccupiedDelay", "code": 33, "mfgCode": null, "side": "server", @@ -6129,7 +6129,7 @@ "reportableChange": 0 }, { - "name": "ultrasonic unoccupied to occupied threshold", + "name": "UltrasonicUnoccupiedToOccupiedThreshold", "code": 34, "mfgCode": null, "side": "server", @@ -6145,7 +6145,7 @@ "reportableChange": 0 }, { - "name": "physical contact occupied to unoccupied delay", + "name": "PhysicalContactOccupiedToUnoccupiedDelay", "code": 48, "mfgCode": null, "side": "server", @@ -6161,7 +6161,7 @@ "reportableChange": 0 }, { - "name": "physical contact unoccupied to occupied delay", + "name": "PhysicalContactUnoccupiedToOccupiedDelay", "code": 49, "mfgCode": null, "side": "server", @@ -6177,7 +6177,7 @@ "reportableChange": 0 }, { - "name": "physical contact unoccupied to occupied threshold", + "name": "PhysicalContactUnoccupiedToOccupiedThreshold", "code": 50, "mfgCode": null, "side": "server", diff --git a/examples/chef/devices/rootnode_onofflight_bbs1b7IaOV.matter b/examples/chef/devices/rootnode_onofflight_bbs1b7IaOV.matter index 59102bd916ab9f..4a2bf2810685a4 100644 --- a/examples/chef/devices/rootnode_onofflight_bbs1b7IaOV.matter +++ b/examples/chef/devices/rootnode_onofflight_bbs1b7IaOV.matter @@ -132,10 +132,6 @@ server cluster OnOff = 6 { kLighting = 0x1; } - bitmap SceneFeatures : BITMAP32 { - kSceneNames = 0x1; - } - readonly attribute boolean onOff = 0; readonly attribute boolean globalSceneControl = 16384; attribute int16u onTime = 16385; @@ -790,7 +786,7 @@ server cluster GeneralDiagnostics = 51 { kSoftwareReset = 6; } - enum HardwareFault : ENUM8 { + enum HardwareFaultEnum : ENUM8 { kUnspecified = 0; kRadio = 1; kSensor = 2; @@ -804,7 +800,7 @@ server cluster GeneralDiagnostics = 51 { kTamperDetected = 10; } - enum InterfaceType : ENUM8 { + enum InterfaceTypeEnum : ENUM8 { kUnspecified = 0; kWiFi = 1; kEthernet = 2; @@ -812,14 +808,14 @@ server cluster GeneralDiagnostics = 51 { kThread = 4; } - enum NetworkFaultType : ENUM8 { + enum NetworkFaultEnum : ENUM8 { kUnspecified = 0; kHardwareFailure = 1; kNetworkJammed = 2; kConnectionFailed = 3; } - enum RadioFault : ENUM8 { + enum RadioFaultEnum : ENUM8 { kUnspecified = 0; kWiFiFault = 1; kCellularFault = 2; @@ -837,22 +833,22 @@ server cluster GeneralDiagnostics = 51 { octet_string<8> hardwareAddress = 4; octet_string IPv4Addresses[] = 5; octet_string IPv6Addresses[] = 6; - InterfaceType type = 7; + InterfaceTypeEnum type = 7; } critical event HardwareFaultChange = 0 { - HardwareFault current[] = 0; - HardwareFault previous[] = 1; + HardwareFaultEnum current[] = 0; + HardwareFaultEnum previous[] = 1; } critical event RadioFaultChange = 1 { - RadioFault current[] = 0; - RadioFault previous[] = 1; + RadioFaultEnum current[] = 0; + RadioFaultEnum previous[] = 1; } critical event NetworkFaultChange = 2 { - NetworkFaultType current[] = 0; - NetworkFaultType previous[] = 1; + NetworkFaultEnum current[] = 0; + NetworkFaultEnum previous[] = 1; } critical event BootReason = 3 { @@ -864,9 +860,9 @@ server cluster GeneralDiagnostics = 51 { readonly attribute int64u upTime = 2; readonly attribute int32u totalOperationalHours = 3; readonly attribute BootReasonEnum bootReason = 4; - readonly attribute HardwareFault activeHardwareFaults[] = 5; - readonly attribute RadioFault activeRadioFaults[] = 6; - readonly attribute NetworkFaultType activeNetworkFaults[] = 7; + readonly attribute HardwareFaultEnum activeHardwareFaults[] = 5; + readonly attribute RadioFaultEnum activeRadioFaults[] = 6; + readonly attribute NetworkFaultEnum activeNetworkFaults[] = 7; readonly attribute boolean testEventTriggersEnabled = 8; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -952,7 +948,7 @@ server cluster Switch = 59 { } server cluster AdministratorCommissioning = 60 { - enum CommissioningWindowStatus : ENUM8 { + enum CommissioningWindowStatusEnum : ENUM8 { kWindowNotOpen = 0; kEnhancedWindowOpen = 1; kBasicWindowOpen = 2; @@ -964,7 +960,7 @@ server cluster AdministratorCommissioning = 60 { kWindowNotOpen = 4; } - readonly attribute CommissioningWindowStatus windowStatus = 0; + readonly attribute CommissioningWindowStatusEnum windowStatus = 0; readonly attribute nullable fabric_idx adminFabricIndex = 1; readonly attribute nullable int16u adminVendorId = 2; readonly attribute bitmap32 featureMap = 65532; @@ -988,8 +984,13 @@ server cluster AdministratorCommissioning = 60 { } server cluster OperationalCredentials = 62 { - enum OperationalCertStatus : ENUM8 { - kSuccess = 0; + enum CertificateChainTypeEnum : ENUM8 { + kDACCertificate = 1; + kPAICertificate = 2; + } + + enum NodeOperationalCertStatusEnum : ENUM8 { + kOk = 0; kInvalidPublicKey = 1; kInvalidNodeOpId = 2; kInvalidNOC = 3; @@ -1007,17 +1008,17 @@ server cluster OperationalCredentials = 62 { fabric_idx fabricIndex = 254; } - fabric_scoped struct FabricDescriptor { + fabric_scoped struct FabricDescriptorStruct { octet_string<65> rootPublicKey = 1; - vendor_id vendorId = 2; - fabric_id fabricId = 3; - node_id nodeId = 4; + vendor_id vendorID = 2; + fabric_id fabricID = 3; + node_id nodeID = 4; char_string<32> label = 5; fabric_idx fabricIndex = 254; } readonly attribute access(read: administer) NOCStruct NOCs[] = 0; - readonly attribute FabricDescriptor fabrics[] = 1; + readonly attribute FabricDescriptorStruct fabrics[] = 1; readonly attribute int8u supportedFabrics = 2; readonly attribute int8u commissionedFabrics = 3; readonly attribute OCTET_STRING trustedRootCertificates[] = 4; @@ -1030,7 +1031,7 @@ server cluster OperationalCredentials = 62 { } request struct CertificateChainRequestRequest { - INT8U certificateType = 0; + CertificateChainTypeEnum certificateType = 0; } request struct CSRRequestRequest { @@ -1060,12 +1061,12 @@ server cluster OperationalCredentials = 62 { } request struct AddTrustedRootCertificateRequest { - OCTET_STRING rootCertificate = 0; + OCTET_STRING rootCACertificate = 0; } response struct AttestationResponse = 1 { OCTET_STRING attestationElements = 0; - OCTET_STRING signature = 1; + OCTET_STRING attestationSignature = 1; } response struct CertificateChainResponse = 3 { @@ -1078,7 +1079,7 @@ server cluster OperationalCredentials = 62 { } response struct NOCResponse = 8 { - OperationalCertStatus statusCode = 0; + NodeOperationalCertStatusEnum statusCode = 0; optional fabric_idx fabricIndex = 1; optional CHAR_STRING debugText = 2; } diff --git a/examples/chef/devices/rootnode_onofflight_bbs1b7IaOV.zap b/examples/chef/devices/rootnode_onofflight_bbs1b7IaOV.zap index fdf7bd415d6c65..853ea2338bcc7b 100644 --- a/examples/chef/devices/rootnode_onofflight_bbs1b7IaOV.zap +++ b/examples/chef/devices/rootnode_onofflight_bbs1b7IaOV.zap @@ -4265,7 +4265,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "PHYRate", + "type": "PHYRateEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -4489,7 +4489,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4541,7 +4541,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4553,7 +4553,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "CommissioningWindowStatus", + "type": "CommissioningWindowStatusEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -6997,7 +6997,7 @@ "enabled": 0, "attributes": [ { - "name": "occupancy", + "name": "Occupancy", "code": 0, "mfgCode": null, "side": "server", @@ -7013,7 +7013,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type", + "name": "OccupancySensorType", "code": 1, "mfgCode": null, "side": "server", @@ -7029,7 +7029,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type bitmap", + "name": "OccupancySensorTypeBitmap", "code": 2, "mfgCode": null, "side": "server", @@ -7045,7 +7045,7 @@ "reportableChange": 0 }, { - "name": "PIR occupied to unoccupied delay", + "name": "PIROccupiedToUnoccupiedDelay", "code": 16, "mfgCode": null, "side": "server", @@ -7061,7 +7061,7 @@ "reportableChange": 0 }, { - "name": "PIR unoccupied to occupied delay", + "name": "PIRUnoccupiedToOccupiedDelay", "code": 17, "mfgCode": null, "side": "server", @@ -7077,7 +7077,7 @@ "reportableChange": 0 }, { - "name": "PIR unoccupied to occupied threshold", + "name": "PIRUnoccupiedToOccupiedThreshold", "code": 18, "mfgCode": null, "side": "server", @@ -7093,7 +7093,7 @@ "reportableChange": 0 }, { - "name": "ultrasonic occupied to unoccupied delay", + "name": "UltrasonicOccupiedToUnoccupiedDelay", "code": 32, "mfgCode": null, "side": "server", @@ -7109,7 +7109,7 @@ "reportableChange": 0 }, { - "name": "ultrasonic unoccupied to occupied delay", + "name": "UltrasonicUnoccupiedToOccupiedDelay", "code": 33, "mfgCode": null, "side": "server", @@ -7125,7 +7125,7 @@ "reportableChange": 0 }, { - "name": "ultrasonic unoccupied to occupied threshold", + "name": "UltrasonicUnoccupiedToOccupiedThreshold", "code": 34, "mfgCode": null, "side": "server", @@ -7141,7 +7141,7 @@ "reportableChange": 0 }, { - "name": "physical contact occupied to unoccupied delay", + "name": "PhysicalContactOccupiedToUnoccupiedDelay", "code": 48, "mfgCode": null, "side": "server", @@ -7157,7 +7157,7 @@ "reportableChange": 0 }, { - "name": "physical contact unoccupied to occupied delay", + "name": "PhysicalContactUnoccupiedToOccupiedDelay", "code": 49, "mfgCode": null, "side": "server", @@ -7173,7 +7173,7 @@ "reportableChange": 0 }, { - "name": "physical contact unoccupied to occupied threshold", + "name": "PhysicalContactUnoccupiedToOccupiedThreshold", "code": 50, "mfgCode": null, "side": "server", diff --git a/examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.matter b/examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.matter index a7784c6df29601..861c60deef8bef 100644 --- a/examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.matter +++ b/examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.matter @@ -132,10 +132,6 @@ client cluster OnOff = 6 { kLighting = 0x1; } - bitmap SceneFeatures : BITMAP32 { - kSceneNames = 0x1; - } - readonly attribute boolean onOff = 0; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; @@ -178,10 +174,6 @@ server cluster OnOff = 6 { kLighting = 0x1; } - bitmap SceneFeatures : BITMAP32 { - kSceneNames = 0x1; - } - readonly attribute boolean onOff = 0; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; @@ -733,7 +725,7 @@ server cluster GeneralDiagnostics = 51 { kSoftwareReset = 6; } - enum HardwareFault : ENUM8 { + enum HardwareFaultEnum : ENUM8 { kUnspecified = 0; kRadio = 1; kSensor = 2; @@ -747,7 +739,7 @@ server cluster GeneralDiagnostics = 51 { kTamperDetected = 10; } - enum InterfaceType : ENUM8 { + enum InterfaceTypeEnum : ENUM8 { kUnspecified = 0; kWiFi = 1; kEthernet = 2; @@ -755,14 +747,14 @@ server cluster GeneralDiagnostics = 51 { kThread = 4; } - enum NetworkFaultType : ENUM8 { + enum NetworkFaultEnum : ENUM8 { kUnspecified = 0; kHardwareFailure = 1; kNetworkJammed = 2; kConnectionFailed = 3; } - enum RadioFault : ENUM8 { + enum RadioFaultEnum : ENUM8 { kUnspecified = 0; kWiFiFault = 1; kCellularFault = 2; @@ -780,22 +772,22 @@ server cluster GeneralDiagnostics = 51 { octet_string<8> hardwareAddress = 4; octet_string IPv4Addresses[] = 5; octet_string IPv6Addresses[] = 6; - InterfaceType type = 7; + InterfaceTypeEnum type = 7; } critical event HardwareFaultChange = 0 { - HardwareFault current[] = 0; - HardwareFault previous[] = 1; + HardwareFaultEnum current[] = 0; + HardwareFaultEnum previous[] = 1; } critical event RadioFaultChange = 1 { - RadioFault current[] = 0; - RadioFault previous[] = 1; + RadioFaultEnum current[] = 0; + RadioFaultEnum previous[] = 1; } critical event NetworkFaultChange = 2 { - NetworkFaultType current[] = 0; - NetworkFaultType previous[] = 1; + NetworkFaultEnum current[] = 0; + NetworkFaultEnum previous[] = 1; } critical event BootReason = 3 { @@ -807,9 +799,9 @@ server cluster GeneralDiagnostics = 51 { readonly attribute int64u upTime = 2; readonly attribute int32u totalOperationalHours = 3; readonly attribute BootReasonEnum bootReason = 4; - readonly attribute HardwareFault activeHardwareFaults[] = 5; - readonly attribute RadioFault activeRadioFaults[] = 6; - readonly attribute NetworkFaultType activeNetworkFaults[] = 7; + readonly attribute HardwareFaultEnum activeHardwareFaults[] = 5; + readonly attribute RadioFaultEnum activeRadioFaults[] = 6; + readonly attribute NetworkFaultEnum activeNetworkFaults[] = 7; readonly attribute boolean testEventTriggersEnabled = 8; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -895,7 +887,7 @@ server cluster Switch = 59 { } server cluster AdministratorCommissioning = 60 { - enum CommissioningWindowStatus : ENUM8 { + enum CommissioningWindowStatusEnum : ENUM8 { kWindowNotOpen = 0; kEnhancedWindowOpen = 1; kBasicWindowOpen = 2; @@ -907,7 +899,7 @@ server cluster AdministratorCommissioning = 60 { kWindowNotOpen = 4; } - readonly attribute CommissioningWindowStatus windowStatus = 0; + readonly attribute CommissioningWindowStatusEnum windowStatus = 0; readonly attribute nullable fabric_idx adminFabricIndex = 1; readonly attribute nullable int16u adminVendorId = 2; readonly attribute bitmap32 featureMap = 65532; @@ -931,8 +923,13 @@ server cluster AdministratorCommissioning = 60 { } server cluster OperationalCredentials = 62 { - enum OperationalCertStatus : ENUM8 { - kSuccess = 0; + enum CertificateChainTypeEnum : ENUM8 { + kDACCertificate = 1; + kPAICertificate = 2; + } + + enum NodeOperationalCertStatusEnum : ENUM8 { + kOk = 0; kInvalidPublicKey = 1; kInvalidNodeOpId = 2; kInvalidNOC = 3; @@ -950,17 +947,17 @@ server cluster OperationalCredentials = 62 { fabric_idx fabricIndex = 254; } - fabric_scoped struct FabricDescriptor { + fabric_scoped struct FabricDescriptorStruct { octet_string<65> rootPublicKey = 1; - vendor_id vendorId = 2; - fabric_id fabricId = 3; - node_id nodeId = 4; + vendor_id vendorID = 2; + fabric_id fabricID = 3; + node_id nodeID = 4; char_string<32> label = 5; fabric_idx fabricIndex = 254; } readonly attribute access(read: administer) NOCStruct NOCs[] = 0; - readonly attribute FabricDescriptor fabrics[] = 1; + readonly attribute FabricDescriptorStruct fabrics[] = 1; readonly attribute int8u supportedFabrics = 2; readonly attribute int8u commissionedFabrics = 3; readonly attribute OCTET_STRING trustedRootCertificates[] = 4; @@ -973,7 +970,7 @@ server cluster OperationalCredentials = 62 { } request struct CertificateChainRequestRequest { - INT8U certificateType = 0; + CertificateChainTypeEnum certificateType = 0; } request struct CSRRequestRequest { @@ -1003,12 +1000,12 @@ server cluster OperationalCredentials = 62 { } request struct AddTrustedRootCertificateRequest { - OCTET_STRING rootCertificate = 0; + OCTET_STRING rootCACertificate = 0; } response struct AttestationResponse = 1 { OCTET_STRING attestationElements = 0; - OCTET_STRING signature = 1; + OCTET_STRING attestationSignature = 1; } response struct CertificateChainResponse = 3 { @@ -1021,7 +1018,7 @@ server cluster OperationalCredentials = 62 { } response struct NOCResponse = 8 { - OperationalCertStatus statusCode = 0; + NodeOperationalCertStatusEnum statusCode = 0; optional fabric_idx fabricIndex = 1; optional CHAR_STRING debugText = 2; } diff --git a/examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.zap b/examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.zap index e9bc2f416caf63..e13b9fd80ecad1 100644 --- a/examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.zap +++ b/examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.zap @@ -4265,7 +4265,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "PHYRate", + "type": "PHYRateEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -4489,7 +4489,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4541,7 +4541,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4553,7 +4553,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "CommissioningWindowStatus", + "type": "CommissioningWindowStatusEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -6997,7 +6997,7 @@ "enabled": 0, "attributes": [ { - "name": "occupancy", + "name": "Occupancy", "code": 0, "mfgCode": null, "side": "server", @@ -7013,7 +7013,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type", + "name": "OccupancySensorType", "code": 1, "mfgCode": null, "side": "server", @@ -7029,7 +7029,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type bitmap", + "name": "OccupancySensorTypeBitmap", "code": 2, "mfgCode": null, "side": "server", @@ -7045,7 +7045,7 @@ "reportableChange": 0 }, { - "name": "PIR occupied to unoccupied delay", + "name": "PIROccupiedToUnoccupiedDelay", "code": 16, "mfgCode": null, "side": "server", @@ -7061,7 +7061,7 @@ "reportableChange": 0 }, { - "name": "PIR unoccupied to occupied delay", + "name": "PIRUnoccupiedToOccupiedDelay", "code": 17, "mfgCode": null, "side": "server", @@ -7077,7 +7077,7 @@ "reportableChange": 0 }, { - "name": "PIR unoccupied to occupied threshold", + "name": "PIRUnoccupiedToOccupiedThreshold", "code": 18, "mfgCode": null, "side": "server", @@ -7093,7 +7093,7 @@ "reportableChange": 0 }, { - "name": "ultrasonic occupied to unoccupied delay", + "name": "UltrasonicOccupiedToUnoccupiedDelay", "code": 32, "mfgCode": null, "side": "server", @@ -7109,7 +7109,7 @@ "reportableChange": 0 }, { - "name": "ultrasonic unoccupied to occupied delay", + "name": "UltrasonicUnoccupiedToOccupiedDelay", "code": 33, "mfgCode": null, "side": "server", @@ -7125,7 +7125,7 @@ "reportableChange": 0 }, { - "name": "ultrasonic unoccupied to occupied threshold", + "name": "UltrasonicUnoccupiedToOccupiedThreshold", "code": 34, "mfgCode": null, "side": "server", @@ -7141,7 +7141,7 @@ "reportableChange": 0 }, { - "name": "physical contact occupied to unoccupied delay", + "name": "PhysicalContactOccupiedToUnoccupiedDelay", "code": 48, "mfgCode": null, "side": "server", @@ -7157,7 +7157,7 @@ "reportableChange": 0 }, { - "name": "physical contact unoccupied to occupied delay", + "name": "PhysicalContactUnoccupiedToOccupiedDelay", "code": 49, "mfgCode": null, "side": "server", @@ -7173,7 +7173,7 @@ "reportableChange": 0 }, { - "name": "physical contact unoccupied to occupied threshold", + "name": "PhysicalContactUnoccupiedToOccupiedThreshold", "code": 50, "mfgCode": null, "side": "server", diff --git a/examples/chef/devices/rootnode_onoffpluginunit_Wtf8ss5EBY.matter b/examples/chef/devices/rootnode_onoffpluginunit_Wtf8ss5EBY.matter index 2c32faa6b37c00..237b62a61af864 100644 --- a/examples/chef/devices/rootnode_onoffpluginunit_Wtf8ss5EBY.matter +++ b/examples/chef/devices/rootnode_onoffpluginunit_Wtf8ss5EBY.matter @@ -132,10 +132,6 @@ server cluster OnOff = 6 { kLighting = 0x1; } - bitmap SceneFeatures : BITMAP32 { - kSceneNames = 0x1; - } - readonly attribute boolean onOff = 0; readonly attribute boolean globalSceneControl = 16384; attribute int16u onTime = 16385; @@ -691,7 +687,7 @@ server cluster GeneralDiagnostics = 51 { kSoftwareReset = 6; } - enum HardwareFault : ENUM8 { + enum HardwareFaultEnum : ENUM8 { kUnspecified = 0; kRadio = 1; kSensor = 2; @@ -705,7 +701,7 @@ server cluster GeneralDiagnostics = 51 { kTamperDetected = 10; } - enum InterfaceType : ENUM8 { + enum InterfaceTypeEnum : ENUM8 { kUnspecified = 0; kWiFi = 1; kEthernet = 2; @@ -713,14 +709,14 @@ server cluster GeneralDiagnostics = 51 { kThread = 4; } - enum NetworkFaultType : ENUM8 { + enum NetworkFaultEnum : ENUM8 { kUnspecified = 0; kHardwareFailure = 1; kNetworkJammed = 2; kConnectionFailed = 3; } - enum RadioFault : ENUM8 { + enum RadioFaultEnum : ENUM8 { kUnspecified = 0; kWiFiFault = 1; kCellularFault = 2; @@ -738,22 +734,22 @@ server cluster GeneralDiagnostics = 51 { octet_string<8> hardwareAddress = 4; octet_string IPv4Addresses[] = 5; octet_string IPv6Addresses[] = 6; - InterfaceType type = 7; + InterfaceTypeEnum type = 7; } critical event HardwareFaultChange = 0 { - HardwareFault current[] = 0; - HardwareFault previous[] = 1; + HardwareFaultEnum current[] = 0; + HardwareFaultEnum previous[] = 1; } critical event RadioFaultChange = 1 { - RadioFault current[] = 0; - RadioFault previous[] = 1; + RadioFaultEnum current[] = 0; + RadioFaultEnum previous[] = 1; } critical event NetworkFaultChange = 2 { - NetworkFaultType current[] = 0; - NetworkFaultType previous[] = 1; + NetworkFaultEnum current[] = 0; + NetworkFaultEnum previous[] = 1; } critical event BootReason = 3 { @@ -765,9 +761,9 @@ server cluster GeneralDiagnostics = 51 { readonly attribute int64u upTime = 2; readonly attribute int32u totalOperationalHours = 3; readonly attribute BootReasonEnum bootReason = 4; - readonly attribute HardwareFault activeHardwareFaults[] = 5; - readonly attribute RadioFault activeRadioFaults[] = 6; - readonly attribute NetworkFaultType activeNetworkFaults[] = 7; + readonly attribute HardwareFaultEnum activeHardwareFaults[] = 5; + readonly attribute RadioFaultEnum activeRadioFaults[] = 6; + readonly attribute NetworkFaultEnum activeNetworkFaults[] = 7; readonly attribute boolean testEventTriggersEnabled = 8; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -853,7 +849,7 @@ server cluster Switch = 59 { } server cluster AdministratorCommissioning = 60 { - enum CommissioningWindowStatus : ENUM8 { + enum CommissioningWindowStatusEnum : ENUM8 { kWindowNotOpen = 0; kEnhancedWindowOpen = 1; kBasicWindowOpen = 2; @@ -865,7 +861,7 @@ server cluster AdministratorCommissioning = 60 { kWindowNotOpen = 4; } - readonly attribute CommissioningWindowStatus windowStatus = 0; + readonly attribute CommissioningWindowStatusEnum windowStatus = 0; readonly attribute nullable fabric_idx adminFabricIndex = 1; readonly attribute nullable int16u adminVendorId = 2; readonly attribute bitmap32 featureMap = 65532; @@ -889,8 +885,13 @@ server cluster AdministratorCommissioning = 60 { } server cluster OperationalCredentials = 62 { - enum OperationalCertStatus : ENUM8 { - kSuccess = 0; + enum CertificateChainTypeEnum : ENUM8 { + kDACCertificate = 1; + kPAICertificate = 2; + } + + enum NodeOperationalCertStatusEnum : ENUM8 { + kOk = 0; kInvalidPublicKey = 1; kInvalidNodeOpId = 2; kInvalidNOC = 3; @@ -908,17 +909,17 @@ server cluster OperationalCredentials = 62 { fabric_idx fabricIndex = 254; } - fabric_scoped struct FabricDescriptor { + fabric_scoped struct FabricDescriptorStruct { octet_string<65> rootPublicKey = 1; - vendor_id vendorId = 2; - fabric_id fabricId = 3; - node_id nodeId = 4; + vendor_id vendorID = 2; + fabric_id fabricID = 3; + node_id nodeID = 4; char_string<32> label = 5; fabric_idx fabricIndex = 254; } readonly attribute access(read: administer) NOCStruct NOCs[] = 0; - readonly attribute FabricDescriptor fabrics[] = 1; + readonly attribute FabricDescriptorStruct fabrics[] = 1; readonly attribute int8u supportedFabrics = 2; readonly attribute int8u commissionedFabrics = 3; readonly attribute OCTET_STRING trustedRootCertificates[] = 4; @@ -931,7 +932,7 @@ server cluster OperationalCredentials = 62 { } request struct CertificateChainRequestRequest { - INT8U certificateType = 0; + CertificateChainTypeEnum certificateType = 0; } request struct CSRRequestRequest { @@ -961,12 +962,12 @@ server cluster OperationalCredentials = 62 { } request struct AddTrustedRootCertificateRequest { - OCTET_STRING rootCertificate = 0; + OCTET_STRING rootCACertificate = 0; } response struct AttestationResponse = 1 { OCTET_STRING attestationElements = 0; - OCTET_STRING signature = 1; + OCTET_STRING attestationSignature = 1; } response struct CertificateChainResponse = 3 { @@ -979,7 +980,7 @@ server cluster OperationalCredentials = 62 { } response struct NOCResponse = 8 { - OperationalCertStatus statusCode = 0; + NodeOperationalCertStatusEnum statusCode = 0; optional fabric_idx fabricIndex = 1; optional CHAR_STRING debugText = 2; } diff --git a/examples/chef/devices/rootnode_onoffpluginunit_Wtf8ss5EBY.zap b/examples/chef/devices/rootnode_onoffpluginunit_Wtf8ss5EBY.zap index 030fdd2b4d723a..840c952037046e 100644 --- a/examples/chef/devices/rootnode_onoffpluginunit_Wtf8ss5EBY.zap +++ b/examples/chef/devices/rootnode_onoffpluginunit_Wtf8ss5EBY.zap @@ -4265,7 +4265,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "PHYRate", + "type": "PHYRateEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -4489,7 +4489,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4541,7 +4541,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4553,7 +4553,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "CommissioningWindowStatus", + "type": "CommissioningWindowStatusEnum", "included": 1, "storageOption": "External", "singleton": 0, diff --git a/examples/chef/devices/rootnode_pressuresensor_s0qC9wLH4k.matter b/examples/chef/devices/rootnode_pressuresensor_s0qC9wLH4k.matter index 1d12e24554afc5..8619eb1664e965 100644 --- a/examples/chef/devices/rootnode_pressuresensor_s0qC9wLH4k.matter +++ b/examples/chef/devices/rootnode_pressuresensor_s0qC9wLH4k.matter @@ -659,7 +659,7 @@ server cluster GeneralDiagnostics = 51 { kSoftwareReset = 6; } - enum HardwareFault : ENUM8 { + enum HardwareFaultEnum : ENUM8 { kUnspecified = 0; kRadio = 1; kSensor = 2; @@ -673,7 +673,7 @@ server cluster GeneralDiagnostics = 51 { kTamperDetected = 10; } - enum InterfaceType : ENUM8 { + enum InterfaceTypeEnum : ENUM8 { kUnspecified = 0; kWiFi = 1; kEthernet = 2; @@ -681,14 +681,14 @@ server cluster GeneralDiagnostics = 51 { kThread = 4; } - enum NetworkFaultType : ENUM8 { + enum NetworkFaultEnum : ENUM8 { kUnspecified = 0; kHardwareFailure = 1; kNetworkJammed = 2; kConnectionFailed = 3; } - enum RadioFault : ENUM8 { + enum RadioFaultEnum : ENUM8 { kUnspecified = 0; kWiFiFault = 1; kCellularFault = 2; @@ -706,22 +706,22 @@ server cluster GeneralDiagnostics = 51 { octet_string<8> hardwareAddress = 4; octet_string IPv4Addresses[] = 5; octet_string IPv6Addresses[] = 6; - InterfaceType type = 7; + InterfaceTypeEnum type = 7; } critical event HardwareFaultChange = 0 { - HardwareFault current[] = 0; - HardwareFault previous[] = 1; + HardwareFaultEnum current[] = 0; + HardwareFaultEnum previous[] = 1; } critical event RadioFaultChange = 1 { - RadioFault current[] = 0; - RadioFault previous[] = 1; + RadioFaultEnum current[] = 0; + RadioFaultEnum previous[] = 1; } critical event NetworkFaultChange = 2 { - NetworkFaultType current[] = 0; - NetworkFaultType previous[] = 1; + NetworkFaultEnum current[] = 0; + NetworkFaultEnum previous[] = 1; } critical event BootReason = 3 { @@ -733,9 +733,9 @@ server cluster GeneralDiagnostics = 51 { readonly attribute int64u upTime = 2; readonly attribute int32u totalOperationalHours = 3; readonly attribute BootReasonEnum bootReason = 4; - readonly attribute HardwareFault activeHardwareFaults[] = 5; - readonly attribute RadioFault activeRadioFaults[] = 6; - readonly attribute NetworkFaultType activeNetworkFaults[] = 7; + readonly attribute HardwareFaultEnum activeHardwareFaults[] = 5; + readonly attribute RadioFaultEnum activeRadioFaults[] = 6; + readonly attribute NetworkFaultEnum activeNetworkFaults[] = 7; readonly attribute boolean testEventTriggersEnabled = 8; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -821,7 +821,7 @@ server cluster Switch = 59 { } server cluster AdministratorCommissioning = 60 { - enum CommissioningWindowStatus : ENUM8 { + enum CommissioningWindowStatusEnum : ENUM8 { kWindowNotOpen = 0; kEnhancedWindowOpen = 1; kBasicWindowOpen = 2; @@ -833,7 +833,7 @@ server cluster AdministratorCommissioning = 60 { kWindowNotOpen = 4; } - readonly attribute CommissioningWindowStatus windowStatus = 0; + readonly attribute CommissioningWindowStatusEnum windowStatus = 0; readonly attribute nullable fabric_idx adminFabricIndex = 1; readonly attribute nullable int16u adminVendorId = 2; readonly attribute bitmap32 featureMap = 65532; @@ -857,8 +857,13 @@ server cluster AdministratorCommissioning = 60 { } server cluster OperationalCredentials = 62 { - enum OperationalCertStatus : ENUM8 { - kSuccess = 0; + enum CertificateChainTypeEnum : ENUM8 { + kDACCertificate = 1; + kPAICertificate = 2; + } + + enum NodeOperationalCertStatusEnum : ENUM8 { + kOk = 0; kInvalidPublicKey = 1; kInvalidNodeOpId = 2; kInvalidNOC = 3; @@ -876,17 +881,17 @@ server cluster OperationalCredentials = 62 { fabric_idx fabricIndex = 254; } - fabric_scoped struct FabricDescriptor { + fabric_scoped struct FabricDescriptorStruct { octet_string<65> rootPublicKey = 1; - vendor_id vendorId = 2; - fabric_id fabricId = 3; - node_id nodeId = 4; + vendor_id vendorID = 2; + fabric_id fabricID = 3; + node_id nodeID = 4; char_string<32> label = 5; fabric_idx fabricIndex = 254; } readonly attribute access(read: administer) NOCStruct NOCs[] = 0; - readonly attribute FabricDescriptor fabrics[] = 1; + readonly attribute FabricDescriptorStruct fabrics[] = 1; readonly attribute int8u supportedFabrics = 2; readonly attribute int8u commissionedFabrics = 3; readonly attribute OCTET_STRING trustedRootCertificates[] = 4; @@ -899,7 +904,7 @@ server cluster OperationalCredentials = 62 { } request struct CertificateChainRequestRequest { - INT8U certificateType = 0; + CertificateChainTypeEnum certificateType = 0; } request struct CSRRequestRequest { @@ -929,12 +934,12 @@ server cluster OperationalCredentials = 62 { } request struct AddTrustedRootCertificateRequest { - OCTET_STRING rootCertificate = 0; + OCTET_STRING rootCACertificate = 0; } response struct AttestationResponse = 1 { OCTET_STRING attestationElements = 0; - OCTET_STRING signature = 1; + OCTET_STRING attestationSignature = 1; } response struct CertificateChainResponse = 3 { @@ -947,7 +952,7 @@ server cluster OperationalCredentials = 62 { } response struct NOCResponse = 8 { - OperationalCertStatus statusCode = 0; + NodeOperationalCertStatusEnum statusCode = 0; optional fabric_idx fabricIndex = 1; optional CHAR_STRING debugText = 2; } diff --git a/examples/chef/devices/rootnode_pressuresensor_s0qC9wLH4k.zap b/examples/chef/devices/rootnode_pressuresensor_s0qC9wLH4k.zap index e940d9becfa527..1aaea5bc177e86 100644 --- a/examples/chef/devices/rootnode_pressuresensor_s0qC9wLH4k.zap +++ b/examples/chef/devices/rootnode_pressuresensor_s0qC9wLH4k.zap @@ -4265,7 +4265,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "PHYRate", + "type": "PHYRateEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -4489,7 +4489,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4541,7 +4541,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4553,7 +4553,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "CommissioningWindowStatus", + "type": "CommissioningWindowStatusEnum", "included": 1, "storageOption": "External", "singleton": 0, diff --git a/examples/chef/devices/rootnode_speaker_RpzeXdimqA.matter b/examples/chef/devices/rootnode_speaker_RpzeXdimqA.matter index 7ae15fd75b220d..71a51a8ad27c61 100644 --- a/examples/chef/devices/rootnode_speaker_RpzeXdimqA.matter +++ b/examples/chef/devices/rootnode_speaker_RpzeXdimqA.matter @@ -129,10 +129,6 @@ server cluster OnOff = 6 { kLighting = 0x1; } - bitmap SceneFeatures : BITMAP32 { - kSceneNames = 0x1; - } - readonly attribute boolean onOff = 0; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; @@ -781,7 +777,7 @@ server cluster GeneralDiagnostics = 51 { kSoftwareReset = 6; } - enum HardwareFault : ENUM8 { + enum HardwareFaultEnum : ENUM8 { kUnspecified = 0; kRadio = 1; kSensor = 2; @@ -795,7 +791,7 @@ server cluster GeneralDiagnostics = 51 { kTamperDetected = 10; } - enum InterfaceType : ENUM8 { + enum InterfaceTypeEnum : ENUM8 { kUnspecified = 0; kWiFi = 1; kEthernet = 2; @@ -803,14 +799,14 @@ server cluster GeneralDiagnostics = 51 { kThread = 4; } - enum NetworkFaultType : ENUM8 { + enum NetworkFaultEnum : ENUM8 { kUnspecified = 0; kHardwareFailure = 1; kNetworkJammed = 2; kConnectionFailed = 3; } - enum RadioFault : ENUM8 { + enum RadioFaultEnum : ENUM8 { kUnspecified = 0; kWiFiFault = 1; kCellularFault = 2; @@ -828,22 +824,22 @@ server cluster GeneralDiagnostics = 51 { octet_string<8> hardwareAddress = 4; octet_string IPv4Addresses[] = 5; octet_string IPv6Addresses[] = 6; - InterfaceType type = 7; + InterfaceTypeEnum type = 7; } critical event HardwareFaultChange = 0 { - HardwareFault current[] = 0; - HardwareFault previous[] = 1; + HardwareFaultEnum current[] = 0; + HardwareFaultEnum previous[] = 1; } critical event RadioFaultChange = 1 { - RadioFault current[] = 0; - RadioFault previous[] = 1; + RadioFaultEnum current[] = 0; + RadioFaultEnum previous[] = 1; } critical event NetworkFaultChange = 2 { - NetworkFaultType current[] = 0; - NetworkFaultType previous[] = 1; + NetworkFaultEnum current[] = 0; + NetworkFaultEnum previous[] = 1; } critical event BootReason = 3 { @@ -855,9 +851,9 @@ server cluster GeneralDiagnostics = 51 { readonly attribute int64u upTime = 2; readonly attribute int32u totalOperationalHours = 3; readonly attribute BootReasonEnum bootReason = 4; - readonly attribute HardwareFault activeHardwareFaults[] = 5; - readonly attribute RadioFault activeRadioFaults[] = 6; - readonly attribute NetworkFaultType activeNetworkFaults[] = 7; + readonly attribute HardwareFaultEnum activeHardwareFaults[] = 5; + readonly attribute RadioFaultEnum activeRadioFaults[] = 6; + readonly attribute NetworkFaultEnum activeNetworkFaults[] = 7; readonly attribute boolean testEventTriggersEnabled = 8; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -943,7 +939,7 @@ server cluster Switch = 59 { } server cluster AdministratorCommissioning = 60 { - enum CommissioningWindowStatus : ENUM8 { + enum CommissioningWindowStatusEnum : ENUM8 { kWindowNotOpen = 0; kEnhancedWindowOpen = 1; kBasicWindowOpen = 2; @@ -955,7 +951,7 @@ server cluster AdministratorCommissioning = 60 { kWindowNotOpen = 4; } - readonly attribute CommissioningWindowStatus windowStatus = 0; + readonly attribute CommissioningWindowStatusEnum windowStatus = 0; readonly attribute nullable fabric_idx adminFabricIndex = 1; readonly attribute nullable int16u adminVendorId = 2; readonly attribute bitmap32 featureMap = 65532; @@ -979,8 +975,13 @@ server cluster AdministratorCommissioning = 60 { } server cluster OperationalCredentials = 62 { - enum OperationalCertStatus : ENUM8 { - kSuccess = 0; + enum CertificateChainTypeEnum : ENUM8 { + kDACCertificate = 1; + kPAICertificate = 2; + } + + enum NodeOperationalCertStatusEnum : ENUM8 { + kOk = 0; kInvalidPublicKey = 1; kInvalidNodeOpId = 2; kInvalidNOC = 3; @@ -998,17 +999,17 @@ server cluster OperationalCredentials = 62 { fabric_idx fabricIndex = 254; } - fabric_scoped struct FabricDescriptor { + fabric_scoped struct FabricDescriptorStruct { octet_string<65> rootPublicKey = 1; - vendor_id vendorId = 2; - fabric_id fabricId = 3; - node_id nodeId = 4; + vendor_id vendorID = 2; + fabric_id fabricID = 3; + node_id nodeID = 4; char_string<32> label = 5; fabric_idx fabricIndex = 254; } readonly attribute access(read: administer) NOCStruct NOCs[] = 0; - readonly attribute FabricDescriptor fabrics[] = 1; + readonly attribute FabricDescriptorStruct fabrics[] = 1; readonly attribute int8u supportedFabrics = 2; readonly attribute int8u commissionedFabrics = 3; readonly attribute OCTET_STRING trustedRootCertificates[] = 4; @@ -1021,7 +1022,7 @@ server cluster OperationalCredentials = 62 { } request struct CertificateChainRequestRequest { - INT8U certificateType = 0; + CertificateChainTypeEnum certificateType = 0; } request struct CSRRequestRequest { @@ -1051,12 +1052,12 @@ server cluster OperationalCredentials = 62 { } request struct AddTrustedRootCertificateRequest { - OCTET_STRING rootCertificate = 0; + OCTET_STRING rootCACertificate = 0; } response struct AttestationResponse = 1 { OCTET_STRING attestationElements = 0; - OCTET_STRING signature = 1; + OCTET_STRING attestationSignature = 1; } response struct CertificateChainResponse = 3 { @@ -1069,7 +1070,7 @@ server cluster OperationalCredentials = 62 { } response struct NOCResponse = 8 { - OperationalCertStatus statusCode = 0; + NodeOperationalCertStatusEnum statusCode = 0; optional fabric_idx fabricIndex = 1; optional CHAR_STRING debugText = 2; } diff --git a/examples/chef/devices/rootnode_speaker_RpzeXdimqA.zap b/examples/chef/devices/rootnode_speaker_RpzeXdimqA.zap index 8c17b74ebf9486..3a9b8f5f7642f4 100644 --- a/examples/chef/devices/rootnode_speaker_RpzeXdimqA.zap +++ b/examples/chef/devices/rootnode_speaker_RpzeXdimqA.zap @@ -4265,7 +4265,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "PHYRate", + "type": "PHYRateEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -4489,7 +4489,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4541,7 +4541,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4553,7 +4553,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "CommissioningWindowStatus", + "type": "CommissioningWindowStatusEnum", "included": 1, "storageOption": "External", "singleton": 0, diff --git a/examples/chef/devices/rootnode_temperaturesensor_Qy1zkNW7c3.matter b/examples/chef/devices/rootnode_temperaturesensor_Qy1zkNW7c3.matter index 2049ec09dfdeac..64926a1ef16c9c 100644 --- a/examples/chef/devices/rootnode_temperaturesensor_Qy1zkNW7c3.matter +++ b/examples/chef/devices/rootnode_temperaturesensor_Qy1zkNW7c3.matter @@ -654,7 +654,7 @@ server cluster GeneralDiagnostics = 51 { kSoftwareReset = 6; } - enum HardwareFault : ENUM8 { + enum HardwareFaultEnum : ENUM8 { kUnspecified = 0; kRadio = 1; kSensor = 2; @@ -668,7 +668,7 @@ server cluster GeneralDiagnostics = 51 { kTamperDetected = 10; } - enum InterfaceType : ENUM8 { + enum InterfaceTypeEnum : ENUM8 { kUnspecified = 0; kWiFi = 1; kEthernet = 2; @@ -676,14 +676,14 @@ server cluster GeneralDiagnostics = 51 { kThread = 4; } - enum NetworkFaultType : ENUM8 { + enum NetworkFaultEnum : ENUM8 { kUnspecified = 0; kHardwareFailure = 1; kNetworkJammed = 2; kConnectionFailed = 3; } - enum RadioFault : ENUM8 { + enum RadioFaultEnum : ENUM8 { kUnspecified = 0; kWiFiFault = 1; kCellularFault = 2; @@ -701,22 +701,22 @@ server cluster GeneralDiagnostics = 51 { octet_string<8> hardwareAddress = 4; octet_string IPv4Addresses[] = 5; octet_string IPv6Addresses[] = 6; - InterfaceType type = 7; + InterfaceTypeEnum type = 7; } critical event HardwareFaultChange = 0 { - HardwareFault current[] = 0; - HardwareFault previous[] = 1; + HardwareFaultEnum current[] = 0; + HardwareFaultEnum previous[] = 1; } critical event RadioFaultChange = 1 { - RadioFault current[] = 0; - RadioFault previous[] = 1; + RadioFaultEnum current[] = 0; + RadioFaultEnum previous[] = 1; } critical event NetworkFaultChange = 2 { - NetworkFaultType current[] = 0; - NetworkFaultType previous[] = 1; + NetworkFaultEnum current[] = 0; + NetworkFaultEnum previous[] = 1; } critical event BootReason = 3 { @@ -728,9 +728,9 @@ server cluster GeneralDiagnostics = 51 { readonly attribute int64u upTime = 2; readonly attribute int32u totalOperationalHours = 3; readonly attribute BootReasonEnum bootReason = 4; - readonly attribute HardwareFault activeHardwareFaults[] = 5; - readonly attribute RadioFault activeRadioFaults[] = 6; - readonly attribute NetworkFaultType activeNetworkFaults[] = 7; + readonly attribute HardwareFaultEnum activeHardwareFaults[] = 5; + readonly attribute RadioFaultEnum activeRadioFaults[] = 6; + readonly attribute NetworkFaultEnum activeNetworkFaults[] = 7; readonly attribute boolean testEventTriggersEnabled = 8; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -816,7 +816,7 @@ server cluster Switch = 59 { } server cluster AdministratorCommissioning = 60 { - enum CommissioningWindowStatus : ENUM8 { + enum CommissioningWindowStatusEnum : ENUM8 { kWindowNotOpen = 0; kEnhancedWindowOpen = 1; kBasicWindowOpen = 2; @@ -828,7 +828,7 @@ server cluster AdministratorCommissioning = 60 { kWindowNotOpen = 4; } - readonly attribute CommissioningWindowStatus windowStatus = 0; + readonly attribute CommissioningWindowStatusEnum windowStatus = 0; readonly attribute nullable fabric_idx adminFabricIndex = 1; readonly attribute nullable int16u adminVendorId = 2; readonly attribute bitmap32 featureMap = 65532; @@ -852,8 +852,13 @@ server cluster AdministratorCommissioning = 60 { } server cluster OperationalCredentials = 62 { - enum OperationalCertStatus : ENUM8 { - kSuccess = 0; + enum CertificateChainTypeEnum : ENUM8 { + kDACCertificate = 1; + kPAICertificate = 2; + } + + enum NodeOperationalCertStatusEnum : ENUM8 { + kOk = 0; kInvalidPublicKey = 1; kInvalidNodeOpId = 2; kInvalidNOC = 3; @@ -871,17 +876,17 @@ server cluster OperationalCredentials = 62 { fabric_idx fabricIndex = 254; } - fabric_scoped struct FabricDescriptor { + fabric_scoped struct FabricDescriptorStruct { octet_string<65> rootPublicKey = 1; - vendor_id vendorId = 2; - fabric_id fabricId = 3; - node_id nodeId = 4; + vendor_id vendorID = 2; + fabric_id fabricID = 3; + node_id nodeID = 4; char_string<32> label = 5; fabric_idx fabricIndex = 254; } readonly attribute access(read: administer) NOCStruct NOCs[] = 0; - readonly attribute FabricDescriptor fabrics[] = 1; + readonly attribute FabricDescriptorStruct fabrics[] = 1; readonly attribute int8u supportedFabrics = 2; readonly attribute int8u commissionedFabrics = 3; readonly attribute OCTET_STRING trustedRootCertificates[] = 4; @@ -894,7 +899,7 @@ server cluster OperationalCredentials = 62 { } request struct CertificateChainRequestRequest { - INT8U certificateType = 0; + CertificateChainTypeEnum certificateType = 0; } request struct CSRRequestRequest { @@ -924,12 +929,12 @@ server cluster OperationalCredentials = 62 { } request struct AddTrustedRootCertificateRequest { - OCTET_STRING rootCertificate = 0; + OCTET_STRING rootCACertificate = 0; } response struct AttestationResponse = 1 { OCTET_STRING attestationElements = 0; - OCTET_STRING signature = 1; + OCTET_STRING attestationSignature = 1; } response struct CertificateChainResponse = 3 { @@ -942,7 +947,7 @@ server cluster OperationalCredentials = 62 { } response struct NOCResponse = 8 { - OperationalCertStatus statusCode = 0; + NodeOperationalCertStatusEnum statusCode = 0; optional fabric_idx fabricIndex = 1; optional CHAR_STRING debugText = 2; } diff --git a/examples/chef/devices/rootnode_temperaturesensor_Qy1zkNW7c3.zap b/examples/chef/devices/rootnode_temperaturesensor_Qy1zkNW7c3.zap index 731d43c63bd333..ce8db3d22c5b91 100644 --- a/examples/chef/devices/rootnode_temperaturesensor_Qy1zkNW7c3.zap +++ b/examples/chef/devices/rootnode_temperaturesensor_Qy1zkNW7c3.zap @@ -4265,7 +4265,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "PHYRate", + "type": "PHYRateEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -4489,7 +4489,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4541,7 +4541,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4553,7 +4553,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "CommissioningWindowStatus", + "type": "CommissioningWindowStatusEnum", "included": 1, "storageOption": "External", "singleton": 0, diff --git a/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter b/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter index 27132a0f02235a..5c255f0f39dfff 100644 --- a/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter +++ b/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter @@ -641,7 +641,7 @@ server cluster GeneralDiagnostics = 51 { kSoftwareReset = 6; } - enum HardwareFault : ENUM8 { + enum HardwareFaultEnum : ENUM8 { kUnspecified = 0; kRadio = 1; kSensor = 2; @@ -655,7 +655,7 @@ server cluster GeneralDiagnostics = 51 { kTamperDetected = 10; } - enum InterfaceType : ENUM8 { + enum InterfaceTypeEnum : ENUM8 { kUnspecified = 0; kWiFi = 1; kEthernet = 2; @@ -663,14 +663,14 @@ server cluster GeneralDiagnostics = 51 { kThread = 4; } - enum NetworkFaultType : ENUM8 { + enum NetworkFaultEnum : ENUM8 { kUnspecified = 0; kHardwareFailure = 1; kNetworkJammed = 2; kConnectionFailed = 3; } - enum RadioFault : ENUM8 { + enum RadioFaultEnum : ENUM8 { kUnspecified = 0; kWiFiFault = 1; kCellularFault = 2; @@ -688,22 +688,22 @@ server cluster GeneralDiagnostics = 51 { octet_string<8> hardwareAddress = 4; octet_string IPv4Addresses[] = 5; octet_string IPv6Addresses[] = 6; - InterfaceType type = 7; + InterfaceTypeEnum type = 7; } critical event HardwareFaultChange = 0 { - HardwareFault current[] = 0; - HardwareFault previous[] = 1; + HardwareFaultEnum current[] = 0; + HardwareFaultEnum previous[] = 1; } critical event RadioFaultChange = 1 { - RadioFault current[] = 0; - RadioFault previous[] = 1; + RadioFaultEnum current[] = 0; + RadioFaultEnum previous[] = 1; } critical event NetworkFaultChange = 2 { - NetworkFaultType current[] = 0; - NetworkFaultType previous[] = 1; + NetworkFaultEnum current[] = 0; + NetworkFaultEnum previous[] = 1; } critical event BootReason = 3 { @@ -715,9 +715,9 @@ server cluster GeneralDiagnostics = 51 { readonly attribute int64u upTime = 2; readonly attribute int32u totalOperationalHours = 3; readonly attribute BootReasonEnum bootReason = 4; - readonly attribute HardwareFault activeHardwareFaults[] = 5; - readonly attribute RadioFault activeRadioFaults[] = 6; - readonly attribute NetworkFaultType activeNetworkFaults[] = 7; + readonly attribute HardwareFaultEnum activeHardwareFaults[] = 5; + readonly attribute RadioFaultEnum activeRadioFaults[] = 6; + readonly attribute NetworkFaultEnum activeNetworkFaults[] = 7; readonly attribute boolean testEventTriggersEnabled = 8; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -803,7 +803,7 @@ server cluster Switch = 59 { } server cluster AdministratorCommissioning = 60 { - enum CommissioningWindowStatus : ENUM8 { + enum CommissioningWindowStatusEnum : ENUM8 { kWindowNotOpen = 0; kEnhancedWindowOpen = 1; kBasicWindowOpen = 2; @@ -815,7 +815,7 @@ server cluster AdministratorCommissioning = 60 { kWindowNotOpen = 4; } - readonly attribute CommissioningWindowStatus windowStatus = 0; + readonly attribute CommissioningWindowStatusEnum windowStatus = 0; readonly attribute nullable fabric_idx adminFabricIndex = 1; readonly attribute nullable int16u adminVendorId = 2; readonly attribute bitmap32 featureMap = 65532; @@ -839,8 +839,13 @@ server cluster AdministratorCommissioning = 60 { } server cluster OperationalCredentials = 62 { - enum OperationalCertStatus : ENUM8 { - kSuccess = 0; + enum CertificateChainTypeEnum : ENUM8 { + kDACCertificate = 1; + kPAICertificate = 2; + } + + enum NodeOperationalCertStatusEnum : ENUM8 { + kOk = 0; kInvalidPublicKey = 1; kInvalidNodeOpId = 2; kInvalidNOC = 3; @@ -858,17 +863,17 @@ server cluster OperationalCredentials = 62 { fabric_idx fabricIndex = 254; } - fabric_scoped struct FabricDescriptor { + fabric_scoped struct FabricDescriptorStruct { octet_string<65> rootPublicKey = 1; - vendor_id vendorId = 2; - fabric_id fabricId = 3; - node_id nodeId = 4; + vendor_id vendorID = 2; + fabric_id fabricID = 3; + node_id nodeID = 4; char_string<32> label = 5; fabric_idx fabricIndex = 254; } readonly attribute access(read: administer) NOCStruct NOCs[] = 0; - readonly attribute FabricDescriptor fabrics[] = 1; + readonly attribute FabricDescriptorStruct fabrics[] = 1; readonly attribute int8u supportedFabrics = 2; readonly attribute int8u commissionedFabrics = 3; readonly attribute OCTET_STRING trustedRootCertificates[] = 4; @@ -881,7 +886,7 @@ server cluster OperationalCredentials = 62 { } request struct CertificateChainRequestRequest { - INT8U certificateType = 0; + CertificateChainTypeEnum certificateType = 0; } request struct CSRRequestRequest { @@ -911,12 +916,12 @@ server cluster OperationalCredentials = 62 { } request struct AddTrustedRootCertificateRequest { - OCTET_STRING rootCertificate = 0; + OCTET_STRING rootCACertificate = 0; } response struct AttestationResponse = 1 { OCTET_STRING attestationElements = 0; - OCTET_STRING signature = 1; + OCTET_STRING attestationSignature = 1; } response struct CertificateChainResponse = 3 { @@ -929,7 +934,7 @@ server cluster OperationalCredentials = 62 { } response struct NOCResponse = 8 { - OperationalCertStatus statusCode = 0; + NodeOperationalCertStatusEnum statusCode = 0; optional fabric_idx fabricIndex = 1; optional CHAR_STRING debugText = 2; } @@ -1024,9 +1029,9 @@ server cluster FixedLabel = 64 { server cluster Thermostat = 513 { enum SetpointAdjustMode : ENUM8 { - kHeatSetpoint = 0; - kCoolSetpoint = 1; - kHeatAndCoolSetpoints = 2; + kHeat = 0; + kCool = 1; + kBoth = 2; } enum ThermostatControlSequence : ENUM8 { @@ -1049,9 +1054,11 @@ server cluster Thermostat = 513 { kAuto = 1; kCool = 3; kHeat = 4; - kEmergencyHeating = 5; + kEmergencyHeat = 5; kPrecooling = 6; kFanOnly = 7; + kDry = 8; + kSleep = 9; } bitmap DayOfWeek : BITMAP8 { @@ -1062,21 +1069,21 @@ server cluster Thermostat = 513 { kThursday = 0x10; kFriday = 0x20; kSaturday = 0x40; - kAwayOrVacation = 0x80; + kAway = 0x80; } bitmap ModeForSequence : BITMAP8 { - kHeatSetpointFieldPresent = 0x1; - kCoolSetpointFieldPresent = 0x2; + kHeatSetpointPresent = 0x1; + kCoolSetpointPresent = 0x2; } bitmap ThermostatFeature : BITMAP32 { kHeating = 0x1; kCooling = 0x2; kOccupancy = 0x4; - kSchedule = 0x8; + kScheduleConfiguration = 0x8; kSetback = 0x10; - kAutomode = 0x20; + kAutoMode = 0x20; } readonly attribute nullable int16s localTemperature = 0; diff --git a/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.zap b/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.zap index 68ba1f5e73a9db..bfa8a28fa4a94c 100644 --- a/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.zap +++ b/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.zap @@ -4313,7 +4313,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "PHYRate", + "type": "PHYRateEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -4537,7 +4537,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4589,7 +4589,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4601,7 +4601,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "CommissioningWindowStatus", + "type": "CommissioningWindowStatusEnum", "included": 1, "storageOption": "External", "singleton": 0, diff --git a/examples/chef/devices/rootnode_windowcovering_RLCxaGi9Yx.matter b/examples/chef/devices/rootnode_windowcovering_RLCxaGi9Yx.matter index 58e6dd7c2391f1..185d06293ab795 100644 --- a/examples/chef/devices/rootnode_windowcovering_RLCxaGi9Yx.matter +++ b/examples/chef/devices/rootnode_windowcovering_RLCxaGi9Yx.matter @@ -641,7 +641,7 @@ server cluster GeneralDiagnostics = 51 { kSoftwareReset = 6; } - enum HardwareFault : ENUM8 { + enum HardwareFaultEnum : ENUM8 { kUnspecified = 0; kRadio = 1; kSensor = 2; @@ -655,7 +655,7 @@ server cluster GeneralDiagnostics = 51 { kTamperDetected = 10; } - enum InterfaceType : ENUM8 { + enum InterfaceTypeEnum : ENUM8 { kUnspecified = 0; kWiFi = 1; kEthernet = 2; @@ -663,14 +663,14 @@ server cluster GeneralDiagnostics = 51 { kThread = 4; } - enum NetworkFaultType : ENUM8 { + enum NetworkFaultEnum : ENUM8 { kUnspecified = 0; kHardwareFailure = 1; kNetworkJammed = 2; kConnectionFailed = 3; } - enum RadioFault : ENUM8 { + enum RadioFaultEnum : ENUM8 { kUnspecified = 0; kWiFiFault = 1; kCellularFault = 2; @@ -688,22 +688,22 @@ server cluster GeneralDiagnostics = 51 { octet_string<8> hardwareAddress = 4; octet_string IPv4Addresses[] = 5; octet_string IPv6Addresses[] = 6; - InterfaceType type = 7; + InterfaceTypeEnum type = 7; } critical event HardwareFaultChange = 0 { - HardwareFault current[] = 0; - HardwareFault previous[] = 1; + HardwareFaultEnum current[] = 0; + HardwareFaultEnum previous[] = 1; } critical event RadioFaultChange = 1 { - RadioFault current[] = 0; - RadioFault previous[] = 1; + RadioFaultEnum current[] = 0; + RadioFaultEnum previous[] = 1; } critical event NetworkFaultChange = 2 { - NetworkFaultType current[] = 0; - NetworkFaultType previous[] = 1; + NetworkFaultEnum current[] = 0; + NetworkFaultEnum previous[] = 1; } critical event BootReason = 3 { @@ -715,9 +715,9 @@ server cluster GeneralDiagnostics = 51 { readonly attribute int64u upTime = 2; readonly attribute int32u totalOperationalHours = 3; readonly attribute BootReasonEnum bootReason = 4; - readonly attribute HardwareFault activeHardwareFaults[] = 5; - readonly attribute RadioFault activeRadioFaults[] = 6; - readonly attribute NetworkFaultType activeNetworkFaults[] = 7; + readonly attribute HardwareFaultEnum activeHardwareFaults[] = 5; + readonly attribute RadioFaultEnum activeRadioFaults[] = 6; + readonly attribute NetworkFaultEnum activeNetworkFaults[] = 7; readonly attribute boolean testEventTriggersEnabled = 8; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -803,7 +803,7 @@ server cluster Switch = 59 { } server cluster AdministratorCommissioning = 60 { - enum CommissioningWindowStatus : ENUM8 { + enum CommissioningWindowStatusEnum : ENUM8 { kWindowNotOpen = 0; kEnhancedWindowOpen = 1; kBasicWindowOpen = 2; @@ -815,7 +815,7 @@ server cluster AdministratorCommissioning = 60 { kWindowNotOpen = 4; } - readonly attribute CommissioningWindowStatus windowStatus = 0; + readonly attribute CommissioningWindowStatusEnum windowStatus = 0; readonly attribute nullable fabric_idx adminFabricIndex = 1; readonly attribute nullable int16u adminVendorId = 2; readonly attribute bitmap32 featureMap = 65532; @@ -839,8 +839,13 @@ server cluster AdministratorCommissioning = 60 { } server cluster OperationalCredentials = 62 { - enum OperationalCertStatus : ENUM8 { - kSuccess = 0; + enum CertificateChainTypeEnum : ENUM8 { + kDACCertificate = 1; + kPAICertificate = 2; + } + + enum NodeOperationalCertStatusEnum : ENUM8 { + kOk = 0; kInvalidPublicKey = 1; kInvalidNodeOpId = 2; kInvalidNOC = 3; @@ -858,17 +863,17 @@ server cluster OperationalCredentials = 62 { fabric_idx fabricIndex = 254; } - fabric_scoped struct FabricDescriptor { + fabric_scoped struct FabricDescriptorStruct { octet_string<65> rootPublicKey = 1; - vendor_id vendorId = 2; - fabric_id fabricId = 3; - node_id nodeId = 4; + vendor_id vendorID = 2; + fabric_id fabricID = 3; + node_id nodeID = 4; char_string<32> label = 5; fabric_idx fabricIndex = 254; } readonly attribute access(read: administer) NOCStruct NOCs[] = 0; - readonly attribute FabricDescriptor fabrics[] = 1; + readonly attribute FabricDescriptorStruct fabrics[] = 1; readonly attribute int8u supportedFabrics = 2; readonly attribute int8u commissionedFabrics = 3; readonly attribute OCTET_STRING trustedRootCertificates[] = 4; @@ -881,7 +886,7 @@ server cluster OperationalCredentials = 62 { } request struct CertificateChainRequestRequest { - INT8U certificateType = 0; + CertificateChainTypeEnum certificateType = 0; } request struct CSRRequestRequest { @@ -911,12 +916,12 @@ server cluster OperationalCredentials = 62 { } request struct AddTrustedRootCertificateRequest { - OCTET_STRING rootCertificate = 0; + OCTET_STRING rootCACertificate = 0; } response struct AttestationResponse = 1 { OCTET_STRING attestationElements = 0; - OCTET_STRING signature = 1; + OCTET_STRING attestationSignature = 1; } response struct CertificateChainResponse = 3 { @@ -929,7 +934,7 @@ server cluster OperationalCredentials = 62 { } response struct NOCResponse = 8 { - OperationalCertStatus statusCode = 0; + NodeOperationalCertStatusEnum statusCode = 0; optional fabric_idx fabricIndex = 1; optional CHAR_STRING debugText = 2; } diff --git a/examples/chef/devices/rootnode_windowcovering_RLCxaGi9Yx.zap b/examples/chef/devices/rootnode_windowcovering_RLCxaGi9Yx.zap index 7beb18da0550d7..7c5b00a6a08671 100644 --- a/examples/chef/devices/rootnode_windowcovering_RLCxaGi9Yx.zap +++ b/examples/chef/devices/rootnode_windowcovering_RLCxaGi9Yx.zap @@ -4265,7 +4265,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "PHYRate", + "type": "PHYRateEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -4489,7 +4489,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4541,7 +4541,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4553,7 +4553,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "CommissioningWindowStatus", + "type": "CommissioningWindowStatusEnum", "included": 1, "storageOption": "External", "singleton": 0, diff --git a/examples/chef/efr32/BUILD.gn b/examples/chef/efr32/BUILD.gn index e5464094d29cf3..dd843668af0fdc 100644 --- a/examples/chef/efr32/BUILD.gn +++ b/examples/chef/efr32/BUILD.gn @@ -35,51 +35,17 @@ assert(current_os == "freertos") chef_project_dir = "${chip_root}/examples/chef" efr32_project_dir = "${chef_project_dir}/efr32" -examples_plat_dir = "${chip_root}/examples/platform/efr32" +examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32" +examples_common_plat_dir = "${chip_root}/examples/platform/silabs" +app_data_model = "${efr32_project_dir}:chef-comon" +import("${examples_plat_dir}/args.gni") declare_args() { # Dump memory usage at link time. chip_print_memory_usage = false - - # Monitor & log memory usage at runtime. - enable_heap_monitoring = false - - # Enable Sleepy end device - enable_sleepy_device = false - - # OTA timeout in seconds - OTA_periodic_query_timeout = 86400 - - # Wifi related stuff - they are overridden by gn -args="use_wf200=true" - use_wf200 = false - use_rs911x = false - use_rs911x_sockets = false - sl_wfx_config_softap = false - sl_wfx_config_scan = true - - # Disable LCD on supported devices - disable_lcd = false - sample_name = "" } -declare_args() { - # Enables LCD Qr Code on supported devices - show_qr_code = !disable_lcd -} - -# qr code cannot be true if lcd is disabled -assert(!(disable_lcd && show_qr_code)) - -# Sanity check -assert(!(chip_enable_wifi && chip_enable_openthread)) -assert(!(use_rs911x && chip_enable_openthread)) -assert(!(use_wf200 && chip_enable_openthread)) -if (chip_enable_wifi) { - assert(use_rs911x || use_wf200) - enable_openthread_cli = false -} - chip_data_model("chef-common") { zap_file = "${chef_project_dir}/devices/${sample_name}.zap" @@ -87,35 +53,6 @@ chip_data_model("chef-common") { is_server = true } -# ThunderBoards, Explorer Kit and MGM240L do not support LCD (No LCD) -if (silabs_board == "BRD4166A" || silabs_board == "BRD2601B" || - silabs_board == "BRD2703A" || silabs_board == "BRD4319A") { - show_qr_code = false - disable_lcd = true -} - -# WiFi settings -if (chip_enable_wifi) { - wifi_sdk_dir = "${chip_root}/third_party/efr32_sdk/repo/matter/wifi" - efr32_lwip_defs = [ "LWIP_NETIF_API=1" ] - efr32_lwip_defs += [ - "LWIP_IPV4=1", - "LWIP_ARP=1", - "LWIP_ICMP=1", - "LWIP_DHCP=1", - "LWIP_IPV6_ND=1", - "LWIP_IGMP=1", - ] - - if (use_rs911x) { - wiseconnect_sdk_root = - "${chip_root}/third_party/efr32_sdk/wiseconnect-wifi-bt-sdk" - import("${wifi_sdk_dir}/rs911x/rs911x.gni") - } else { - import("${wifi_sdk_dir}/wf200/wf200.gni") - } -} - efr32_sdk("sdk") { sources = [ "${efr32_project_dir}/include/CHIPProjectConfig.h", @@ -123,141 +60,46 @@ efr32_sdk("sdk") { ] include_dirs = [ - "${chip_root}/src/platform/EFR32", + "${chip_root}/src/platform/silabs/EFR32", "${efr32_project_dir}/include", "${examples_plat_dir}", "${chip_root}/src/lib", + "${examples_common_plat_dir}", ] - defines = [ - "BOARD_ID=${silabs_board}", - "OTA_PERIODIC_TIMEOUT=${OTA_periodic_query_timeout}", - ] + if (use_wf200) { + # TODO efr32_sdk should not need a header from this location + include_dirs += [ "${examples_plat_dir}/wf200" ] + } + defines = [] if (chip_enable_pw_rpc) { defines += [ "HAL_VCOM_ENABLE=1", "PW_RPC_ENABLED", ] } - - # WiFi Settings - if (chip_enable_wifi) { - if (use_rs911x) { - defines += rs911x_defs - include_dirs += rs911x_plat_incs - } else if (use_wf200) { - defines += wf200_defs - include_dirs += wf200_plat_incs - } - - if (use_rs911x_sockets) { - include_dirs += [ "${examples_plat_dir}/wifi/rsi-sockets" ] - defines += rs911x_sock_defs - } else { - # Using LWIP instead of the native TCP/IP stack - defines += efr32_lwip_defs - } - - if (sl_wfx_config_softap) { - defines += [ "SL_WFX_CONFIG_SOFTAP" ] - } - if (sl_wfx_config_scan) { - defines += [ "SL_WFX_CONFIG_SCAN" ] - } - } } efr32_executable("chef_app") { output_name = "chip-efr32-chef-example.out" + public_configs = [ "${efr32_sdk_build_root}:silabs_config" ] include_dirs = [ "include" ] defines = [] sources = [ - "${examples_plat_dir}/BaseApplication.cpp", - "${examples_plat_dir}/efr32_utils.cpp", - "${examples_plat_dir}/heap_4_silabs.c", - "${examples_plat_dir}/init_efrPlatform.cpp", - "${examples_plat_dir}/matter_config.cpp", "src/AppTask.cpp", "src/LightingManager.cpp", "src/ZclCallbacks.cpp", "src/main.cpp", ] - if (use_wstk_leds) { - sources += [ "${examples_plat_dir}/LEDWidget.cpp" ] - } - - if (chip_enable_pw_rpc || chip_build_libshell || enable_openthread_cli || - use_wf200 || use_rs911x) { - sources += [ "${examples_plat_dir}/uart.cpp" ] - } - deps = [ ":chef-common", ":sdk", - "${chip_root}/examples/providers:device_info_provider", - "${chip_root}/src/lib", - "${chip_root}/src/setup_payload", + "${examples_plat_dir}:efr32-common", ] - # OpenThread Settings - if (chip_enable_openthread) { - deps += [ - "${chip_root}/third_party/openthread:openthread", - "${chip_root}/third_party/openthread:openthread-platform", - "${examples_plat_dir}:efr-matter-shell", - ] - } - - if (chip_enable_ota_requestor) { - defines += [ "EFR32_OTA_ENABLED" ] - sources += [ "${examples_plat_dir}/OTAConfig.cpp" ] - } - - # WiFi Settings - if (chip_enable_wifi) { - if (use_rs911x) { - sources += rs911x_src_plat - - # All the stuff from wiseconnect - sources += rs911x_src_sapi - - # Apparently - the rsi library needs this (though we may not use use it) - sources += rs911x_src_sock - include_dirs += rs911x_inc_plat - - if (use_rs911x_sockets) { - # - # Using native sockets inside RS911x - # - include_dirs += rs911x_sock_inc - } else { - # - # We use LWIP - not built-in sockets - # - sources += rs911x_src_lwip - } - } else if (use_wf200) { - sources += wf200_plat_src - include_dirs += wf200_plat_incs - } - } - - if (!disable_lcd) { - sources += [ - "${examples_plat_dir}/display/demo-ui.c", - "${examples_plat_dir}/display/lcd.cpp", - ] - include_dirs += [ "${examples_plat_dir}/display" ] - defines += [ "DISPLAY_ENABLED" ] - if (show_qr_code) { - defines += [ "QR_CODE_ENABLED" ] - deps += [ "${chip_root}/examples/common/QRCode" ] - } - } - if (chip_enable_pw_rpc) { defines += [ "PW_RPC_ENABLED", @@ -274,8 +116,8 @@ efr32_executable("chef_app") { sources += [ "${chip_root}/examples/common/pigweed/RpcService.cpp", "${chip_root}/examples/common/pigweed/efr32/PigweedLoggerMutex.cpp", - "${examples_plat_dir}/PigweedLogger.cpp", - "${examples_plat_dir}/Rpc.cpp", + "${examples_common_plat_dir}/PigweedLogger.cpp", + "${examples_common_plat_dir}/Rpc.cpp", ] deps += [ @@ -303,11 +145,6 @@ efr32_executable("chef_app") { ] } - if (enable_heap_monitoring) { - sources += [ "${examples_plat_dir}/MemMonitoring.cpp" ] - defines += [ "HEAP_MONITORING" ] - } - ldscript = "${examples_plat_dir}/ldscripts/${silabs_family}.ld" inputs = [ ldscript ] @@ -329,16 +166,6 @@ efr32_executable("chef_app") { ] } - # Attestation Credentials - if (chip_build_platform_attestation_credentials_provider) { - deps += [ "${examples_plat_dir}:efr32-attestation-credentials" ] - } - - # Factory Data Provider - if (use_efr32_factory_data_provider) { - deps += [ "${examples_plat_dir}:efr32-factory-data-provider" ] - } - output_dir = root_out_dir } diff --git a/examples/chef/efr32/src/AppTask.cpp b/examples/chef/efr32/src/AppTask.cpp index 3de9bff17a49f9..240f2116cf0ef9 100644 --- a/examples/chef/efr32/src/AppTask.cpp +++ b/examples/chef/efr32/src/AppTask.cpp @@ -33,8 +33,6 @@ #endif // QR_CODE_ENABLED #endif // DISPLAY_ENABLED -#include -#include #include #include #include diff --git a/examples/chef/esp32/main/main.cpp b/examples/chef/esp32/main/main.cpp index 225815f8043b70..fc17db7d72d346 100644 --- a/examples/chef/esp32/main/main.cpp +++ b/examples/chef/esp32/main/main.cpp @@ -38,11 +38,8 @@ #include #include -#include -#include #include #include -#include #include #include #include diff --git a/examples/chef/sample_app_util/test_files/sample_zap_file.zap b/examples/chef/sample_app_util/test_files/sample_zap_file.zap index 983188af02fd42..c39c7211e098c5 100644 --- a/examples/chef/sample_app_util/test_files/sample_zap_file.zap +++ b/examples/chef/sample_app_util/test_files/sample_zap_file.zap @@ -1074,7 +1074,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "4", "reportable": 1, "minInterval": 1, "maxInterval": 65534, diff --git a/examples/chip-tool/BUILD.gn b/examples/chip-tool/BUILD.gn index 1ca148ceeb1246..97df8a48b5051d 100644 --- a/examples/chip-tool/BUILD.gn +++ b/examples/chip-tool/BUILD.gn @@ -28,6 +28,7 @@ assert(chip_build_tools) config("config") { include_dirs = [ ".", + "${chip_root}/examples/common", "${chip_root}/zzz_generated/app-common/app-common", "${chip_root}/zzz_generated/chip-tool", "${chip_root}/src/lib", @@ -59,6 +60,8 @@ static_library("chip-tool-utils") { "commands/common/Commands.h", "commands/common/CredentialIssuerCommands.h", "commands/common/HexConversion.h", + "commands/common/RemoteDataModelLogger.cpp", + "commands/common/RemoteDataModelLogger.h", "commands/delay/SleepCommand.cpp", "commands/delay/WaitForCommissioneeCommand.cpp", "commands/discover/DiscoverCommand.cpp", @@ -85,13 +88,11 @@ static_library("chip-tool-utils") { deps = [] if (config_use_interactive_mode) { - sources += [ - "commands/interactive/InteractiveCommands.cpp", - "commands/interactive/WebSocketServer.cpp", - "commands/interactive/WebSocketServer.h", - "commands/interactive/WebSocketServerDelegate.h", + sources += [ "commands/interactive/InteractiveCommands.cpp" ] + deps += [ + "${chip_root}/examples/common/websocket-server", + "${editline_root}:editline", ] - deps += [ "${editline_root}:editline" ] } if (config_enable_yaml_tests) { @@ -110,10 +111,10 @@ static_library("chip-tool-utils") { "${chip_root}/src/controller/data_model", "${chip_root}/src/credentials:file_attestation_trust_store", "${chip_root}/src/lib", + "${chip_root}/src/lib/support/jsontlv", "${chip_root}/src/platform", "${chip_root}/third_party/inipp", "${chip_root}/third_party/jsoncpp", - "${chip_root}/third_party/libwebsockets", ] public_configs = [ ":config" ] diff --git a/examples/chip-tool/commands/clusters/ClusterCommand.h b/examples/chip-tool/commands/clusters/ClusterCommand.h index c2562843e024a8..eb9a7167948bf5 100644 --- a/examples/chip-tool/commands/clusters/ClusterCommand.h +++ b/examples/chip-tool/commands/clusters/ClusterCommand.h @@ -74,6 +74,8 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub CHIP_ERROR error = status.ToChipError(); if (CHIP_NO_ERROR != error) { + ReturnOnFailure(RemoteDataModelLogger::LogErrorAsJSON(path, status)); + ChipLogError(chipTool, "Response Failure: %s", chip::ErrorStr(error)); mError = error; return; @@ -81,6 +83,8 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub if (data != nullptr) { + ReturnOnFailure(RemoteDataModelLogger::LogCommandAsJSON(path, data)); + error = DataModelLogger::LogCommand(path, data); if (CHIP_NO_ERROR != error) { @@ -93,6 +97,8 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub virtual void OnError(const chip::app::CommandSender * client, CHIP_ERROR error) override { + ReturnOnFailure(RemoteDataModelLogger::LogErrorAsJSON(error)); + ChipLogProgress(chipTool, "Error: %s", chip::ErrorStr(error)); mError = error; } diff --git a/examples/chip-tool/commands/clusters/DataModelLogger.h b/examples/chip-tool/commands/clusters/DataModelLogger.h index 38a2fb1812f3f4..5ffb775d0bf01a 100644 --- a/examples/chip-tool/commands/clusters/DataModelLogger.h +++ b/examples/chip-tool/commands/clusters/DataModelLogger.h @@ -24,7 +24,9 @@ #include #include #include +#include #include +#include #include class DataModelLogger diff --git a/examples/chip-tool/commands/clusters/ReportCommand.h b/examples/chip-tool/commands/clusters/ReportCommand.h index eae5fa8ee51054..f7e1993e26b70b 100644 --- a/examples/chip-tool/commands/clusters/ReportCommand.h +++ b/examples/chip-tool/commands/clusters/ReportCommand.h @@ -37,6 +37,8 @@ class ReportCommand : public InteractionModelReports, public ModelCommand, publi CHIP_ERROR error = status.ToChipError(); if (CHIP_NO_ERROR != error) { + ReturnOnFailure(RemoteDataModelLogger::LogErrorAsJSON(path, status)); + ChipLogError(chipTool, "Response Failure: %s", chip::ErrorStr(error)); mError = error; return; @@ -49,6 +51,8 @@ class ReportCommand : public InteractionModelReports, public ModelCommand, publi return; } + ReturnOnFailure(RemoteDataModelLogger::LogAttributeAsJSON(path, data)); + error = DataModelLogger::LogAttribute(path, data); if (CHIP_NO_ERROR != error) { @@ -66,6 +70,8 @@ class ReportCommand : public InteractionModelReports, public ModelCommand, publi CHIP_ERROR error = status->ToChipError(); if (CHIP_NO_ERROR != error) { + ReturnOnFailure(RemoteDataModelLogger::LogErrorAsJSON(eventHeader, *status)); + ChipLogError(chipTool, "Response Failure: %s", chip::ErrorStr(error)); mError = error; return; @@ -79,6 +85,8 @@ class ReportCommand : public InteractionModelReports, public ModelCommand, publi return; } + ReturnOnFailure(RemoteDataModelLogger::LogEventAsJSON(eventHeader, data)); + CHIP_ERROR error = DataModelLogger::LogEvent(eventHeader, data); if (CHIP_NO_ERROR != error) { diff --git a/examples/chip-tool/commands/clusters/WriteAttributeCommand.h b/examples/chip-tool/commands/clusters/WriteAttributeCommand.h index 9b5e8f3ef70728..c3cea8783dbdd0 100644 --- a/examples/chip-tool/commands/clusters/WriteAttributeCommand.h +++ b/examples/chip-tool/commands/clusters/WriteAttributeCommand.h @@ -23,12 +23,22 @@ #include "DataModelLogger.h" #include "ModelCommand.h" +constexpr const char * kWriteCommandKey = "write"; +constexpr const char * kWriteByIdCommandKey = "write-by-id"; +constexpr const char * kForceWriteCommandKey = "force-write"; + +enum class WriteCommandType +{ + kWrite, // regular, writable attributes + kForceWrite, // forced writes, send a write command on something expected to fail +}; + template > class WriteAttribute : public InteractionModelWriter, public ModelCommand, public chip::app::WriteClient::Callback { public: WriteAttribute(CredentialIssuerCommands * credsIssuerConfig) : - InteractionModelWriter(this), ModelCommand("write-by-id", credsIssuerConfig) + InteractionModelWriter(this), ModelCommand(kWriteByIdCommandKey, credsIssuerConfig) { AddArgumentClusterIds(); AddArgumentAttributeIds(); @@ -37,7 +47,7 @@ class WriteAttribute : public InteractionModelWriter, public ModelCommand, publi } WriteAttribute(chip::ClusterId clusterId, CredentialIssuerCommands * credsIssuerConfig) : - InteractionModelWriter(this), ModelCommand("write-by-id", credsIssuerConfig), mClusterIds(1, clusterId) + InteractionModelWriter(this), ModelCommand(kWriteByIdCommandKey, credsIssuerConfig), mClusterIds(1, clusterId) { AddArgumentAttributeIds(); AddArgumentAttributeValues(); @@ -46,8 +56,8 @@ class WriteAttribute : public InteractionModelWriter, public ModelCommand, publi template WriteAttribute(chip::ClusterId clusterId, const char * attributeName, minType minValue, maxType maxValue, - chip::AttributeId attributeId, CredentialIssuerCommands * credsIssuerConfig) : - WriteAttribute(clusterId, attributeId, credsIssuerConfig) + chip::AttributeId attributeId, WriteCommandType commandType, CredentialIssuerCommands * credsIssuerConfig) : + WriteAttribute(clusterId, attributeId, commandType, credsIssuerConfig) { AddArgumentAttributeName(attributeName); AddArgumentAttributeValues(static_cast(minValue), static_cast(maxValue)); @@ -55,8 +65,8 @@ class WriteAttribute : public InteractionModelWriter, public ModelCommand, publi } WriteAttribute(chip::ClusterId clusterId, const char * attributeName, float minValue, float maxValue, - chip::AttributeId attributeId, CredentialIssuerCommands * credsIssuerConfig) : - WriteAttribute(clusterId, attributeId, credsIssuerConfig) + chip::AttributeId attributeId, WriteCommandType commandType, CredentialIssuerCommands * credsIssuerConfig) : + WriteAttribute(clusterId, attributeId, commandType, credsIssuerConfig) { AddArgumentAttributeName(attributeName); AddArgumentAttributeValues(minValue, maxValue); @@ -64,8 +74,8 @@ class WriteAttribute : public InteractionModelWriter, public ModelCommand, publi } WriteAttribute(chip::ClusterId clusterId, const char * attributeName, double minValue, double maxValue, - chip::AttributeId attributeId, CredentialIssuerCommands * credsIssuerConfig) : - WriteAttribute(clusterId, attributeId, credsIssuerConfig) + chip::AttributeId attributeId, WriteCommandType commandType, CredentialIssuerCommands * credsIssuerConfig) : + WriteAttribute(clusterId, attributeId, commandType, credsIssuerConfig) { AddArgumentAttributeName(attributeName); AddArgumentAttributeValues(minValue, maxValue); @@ -73,8 +83,8 @@ class WriteAttribute : public InteractionModelWriter, public ModelCommand, publi } WriteAttribute(chip::ClusterId clusterId, const char * attributeName, chip::AttributeId attributeId, - CredentialIssuerCommands * credsIssuerConfig) : - WriteAttribute(clusterId, attributeId, credsIssuerConfig) + WriteCommandType commandType, CredentialIssuerCommands * credsIssuerConfig) : + WriteAttribute(clusterId, attributeId, commandType, credsIssuerConfig) { AddArgumentAttributeName(attributeName); AddArgumentAttributeValues(); @@ -82,8 +92,9 @@ class WriteAttribute : public InteractionModelWriter, public ModelCommand, publi } WriteAttribute(chip::ClusterId clusterId, const char * attributeName, chip::AttributeId attributeId, - TypedComplexArgument & attributeParser, CredentialIssuerCommands * credsIssuerConfig) : - WriteAttribute(clusterId, attributeId, credsIssuerConfig) + TypedComplexArgument & attributeParser, WriteCommandType commandType, + CredentialIssuerCommands * credsIssuerConfig) : + WriteAttribute(clusterId, attributeId, commandType, credsIssuerConfig) { AddArgumentAttributeName(attributeName); AddArgumentAttributeValues(attributeParser); @@ -109,6 +120,8 @@ class WriteAttribute : public InteractionModelWriter, public ModelCommand, publi CHIP_ERROR error = status.ToChipError(); if (CHIP_NO_ERROR != error) { + ReturnOnFailure(RemoteDataModelLogger::LogErrorAsJSON(path, status)); + ChipLogError(chipTool, "Response Failure: %s", chip::ErrorStr(error)); mError = error; } @@ -116,6 +129,8 @@ class WriteAttribute : public InteractionModelWriter, public ModelCommand, publi void OnError(const chip::app::WriteClient * client, CHIP_ERROR error) override { + ReturnOnFailure(RemoteDataModelLogger::LogErrorAsJSON(error)); + ChipLogProgress(chipTool, "Error: %s", chip::ErrorStr(error)); mError = error; } @@ -155,7 +170,7 @@ class WriteAttribute : public InteractionModelWriter, public ModelCommand, publi protected: WriteAttribute(const char * attributeName, CredentialIssuerCommands * credsIssuerConfig) : - InteractionModelWriter(this), ModelCommand("write", credsIssuerConfig) + InteractionModelWriter(this), ModelCommand(kWriteCommandKey, credsIssuerConfig) { // Subclasses are responsible for calling AddArguments. } @@ -240,9 +255,11 @@ class WriteAttribute : public InteractionModelWriter, public ModelCommand, publi private: // This constructor is private as it is not intended to be used from outside the class. - WriteAttribute(chip::ClusterId clusterId, chip::AttributeId attributeId, CredentialIssuerCommands * credsIssuerConfig) : - InteractionModelWriter(this), ModelCommand("write", credsIssuerConfig), mClusterIds(1, clusterId), - mAttributeIds(1, attributeId) + WriteAttribute(chip::ClusterId clusterId, chip::AttributeId attributeId, WriteCommandType commandType, + CredentialIssuerCommands * credsIssuerConfig) : + InteractionModelWriter(this), + ModelCommand(commandType == WriteCommandType::kWrite ? kWriteCommandKey : kForceWriteCommandKey, credsIssuerConfig), + mClusterIds(1, clusterId), mAttributeIds(1, attributeId) {} std::vector mClusterIds; @@ -257,8 +274,8 @@ class WriteAttributeAsComplex : public WriteAttribute { public: WriteAttributeAsComplex(chip::ClusterId clusterId, const char * attributeName, chip::AttributeId attributeId, - CredentialIssuerCommands * credsIssuerConfig) : - WriteAttribute(clusterId, attributeName, attributeId, mAttributeParser, credsIssuerConfig) + WriteCommandType commandType, CredentialIssuerCommands * credsIssuerConfig) : + WriteAttribute(clusterId, attributeName, attributeId, mAttributeParser, commandType, credsIssuerConfig) {} private: diff --git a/examples/chip-tool/commands/common/CHIPCommand.cpp b/examples/chip-tool/commands/common/CHIPCommand.cpp index 53dc8184e8d395..b445ab88ce434c 100644 --- a/examples/chip-tool/commands/common/CHIPCommand.cpp +++ b/examples/chip-tool/commands/common/CHIPCommand.cpp @@ -102,6 +102,7 @@ CHIP_ERROR CHIPCommand::MaybeSetUpStack() factoryInitParams.fabricIndependentStorage = &mDefaultStorage; factoryInitParams.operationalKeystore = &mOperationalKeystore; factoryInitParams.opCertStore = &mOpCertStore; + factoryInitParams.enableServerInteractions = NeedsOperationalAdvertising(); // Init group data provider that will be used for all group keys and IPKs for the // chip-tool-configured fabrics. This is OK to do once since the fabric tables @@ -177,7 +178,7 @@ void CHIPCommand::MaybeTearDownStack() CHIP_ERROR CHIPCommand::EnsureCommissionerForIdentity(std::string identity) { chip::NodeId nodeId; - ReturnErrorOnFailure(GetCommissionerNodeId(identity, &nodeId)); + ReturnErrorOnFailure(GetIdentityNodeId(identity, &nodeId)); CommissionerIdentity lookupKey{ identity, nodeId }; if (mCommissioners.find(lookupKey) != mCommissioners.end()) { @@ -309,7 +310,7 @@ std::string CHIPCommand::GetIdentity() return name; } -CHIP_ERROR CHIPCommand::GetCommissionerNodeId(std::string identity, chip::NodeId * nodeId) +CHIP_ERROR CHIPCommand::GetIdentityNodeId(std::string identity, chip::NodeId * nodeId) { if (mCommissionerNodeId.HasValue()) { @@ -373,7 +374,7 @@ chip::Controller::DeviceCommissioner & CHIPCommand::GetCommissioner(std::string VerifyOrDie(EnsureCommissionerForIdentity(identity) == CHIP_NO_ERROR); chip::NodeId nodeId; - VerifyOrDie(GetCommissionerNodeId(identity, &nodeId) == CHIP_NO_ERROR); + VerifyOrDie(GetIdentityNodeId(identity, &nodeId) == CHIP_NO_ERROR); CommissionerIdentity lookupKey{ identity, nodeId }; auto item = mCommissioners.find(lookupKey); VerifyOrDie(item != mCommissioners.end()); diff --git a/examples/chip-tool/commands/common/CHIPCommand.h b/examples/chip-tool/commands/common/CHIPCommand.h index 1b5b3690ea3ee6..ee46ada917b944 100644 --- a/examples/chip-tool/commands/common/CHIPCommand.h +++ b/examples/chip-tool/commands/common/CHIPCommand.h @@ -123,6 +123,11 @@ class CHIPCommand : public Command // use member values that Shutdown will normally reset. virtual bool DeferInteractiveCleanup() { return false; } + // If true, the controller will be created with server capabilities enabled, + // such as advertising operational nodes over DNS-SD and accepting incoming + // CASE sessions. + virtual bool NeedsOperationalAdvertising() { return false; } + // Execute any deferred cleanups. Used when exiting interactive mode. static void ExecuteDeferredCleanups(intptr_t ignored); @@ -139,7 +144,7 @@ class CHIPCommand : public Command CredentialIssuerCommands * mCredIssuerCmds; std::string GetIdentity(); - CHIP_ERROR GetCommissionerNodeId(std::string identity, chip::NodeId * nodeId); + CHIP_ERROR GetIdentityNodeId(std::string identity, chip::NodeId * nodeId); void SetIdentity(const char * name); // This method returns the commissioner instance to be used for running the command. diff --git a/examples/chip-tool/commands/common/Commands.cpp b/examples/chip-tool/commands/common/Commands.cpp index 4e9c508f0fb4f8..749cbdcc739250 100644 --- a/examples/chip-tool/commands/common/Commands.cpp +++ b/examples/chip-tool/commands/common/Commands.cpp @@ -21,11 +21,88 @@ #include "Command.h" #include +#include +#include #include +#include #include #include +#include "../clusters/JsonParser.h" + +namespace { + +char kInteractiveModeName[] = ""; +constexpr size_t kInteractiveModeArgumentsMaxLength = 32; +constexpr const char * kOptionalArgumentPrefix = "--"; +constexpr const char * kJsonClusterKey = "cluster"; +constexpr const char * kJsonCommandKey = "command"; +constexpr const char * kJsonCommandSpecifierKey = "command_specifier"; +constexpr const char * kJsonArgumentsKey = "arguments"; + +std::vector GetArgumentsFromJson(Command * command, Json::Value & value, bool optional) +{ + std::vector args; + for (size_t i = 0; i < command->GetArgumentsCount(); i++) + { + auto argName = command->GetArgumentName(i); + for (auto const & memberName : value.getMemberNames()) + { + if (strcasecmp(argName, memberName.c_str()) != 0) + { + continue; + } + + if (command->GetArgumentIsOptional(i) != optional) + { + continue; + } + + if (optional) + { + args.push_back(std::string(kOptionalArgumentPrefix) + argName); + } + + auto argValue = value[memberName].asString(); + args.push_back(std::move(argValue)); + break; + } + } + return args; +}; + +// Check for arguments with a starting '"' but no ending '"': those +// would indicate that people are using double-quoting, not single +// quoting, on arguments with spaces. +static void DetectAndLogMismatchedDoubleQuotes(int argc, char ** argv) +{ + for (int curArg = 0; curArg < argc; ++curArg) + { + char * arg = argv[curArg]; + if (!arg) + { + continue; + } + + auto len = strlen(arg); + if (len == 0) + { + continue; + } + + if (arg[0] == '"' && arg[len - 1] != '"') + { + ChipLogError(chipTool, + "Mismatched '\"' detected in argument: '%s'. Use single quotes to delimit arguments with spaces " + "in them: 'x y', not \"x y\".", + arg); + } + } +} + +} // namespace + void Commands::Register(const char * clusterName, commands_list commandsList) { for (auto & command : commandsList) @@ -55,15 +132,42 @@ int Commands::Run(int argc, char ** argv) return (err == CHIP_NO_ERROR) ? EXIT_SUCCESS : EXIT_FAILURE; } -int Commands::RunInteractive(int argc, char ** argv) +int Commands::RunInteractive(const char * command) { - CHIP_ERROR err = RunCommand(argc, argv, true); - if (err == CHIP_NO_ERROR) + std::vector arguments; + VerifyOrReturnValue(DecodeArgumentsFromInteractiveMode(command, arguments), EXIT_FAILURE); + + if (arguments.size() > (kInteractiveModeArgumentsMaxLength - 1 /* for interactive mode name */)) + { + ChipLogError(chipTool, "Too many arguments. Ignoring."); + arguments.resize(kInteractiveModeArgumentsMaxLength - 1); + } + + int argc = 0; + char * argv[kInteractiveModeArgumentsMaxLength] = {}; + argv[argc++] = kInteractiveModeName; + + std::string commandStr; + for (auto & arg : arguments) + { + argv[argc] = new char[arg.size() + 1]; + strcpy(argv[argc++], arg.c_str()); + commandStr += arg; + commandStr += " "; + } + + ChipLogProgress(chipTool, "Command: %s", commandStr.c_str()); + auto err = RunCommand(argc, argv, true); + + // Do not delete arg[0] + for (auto i = 1; i < argc; i++) { - return EXIT_SUCCESS; + delete[] argv[i]; } - ChipLogError(chipTool, "Run command failure: %s", chip::ErrorStr(err)); - return EXIT_FAILURE; + + VerifyOrReturnValue(CHIP_NO_ERROR == err, EXIT_FAILURE, ChipLogError(chipTool, "Run command failure: %s", chip::ErrorStr(err))); + + return EXIT_SUCCESS; } CHIP_ERROR Commands::RunCommand(int argc, char ** argv, bool interactive) @@ -142,6 +246,10 @@ CHIP_ERROR Commands::RunCommand(int argc, char ** argv, bool interactive) int argumentsPosition = isGlobalCommand ? 4 : 3; if (!command->InitArguments(argc - argumentsPosition, &argv[argumentsPosition])) { + if (interactive) + { + DetectAndLogMismatchedDoubleQuotes(argc - argumentsPosition, &argv[argumentsPosition]); + } ShowCommand(argv[0], argv[1], command); return CHIP_ERROR_INVALID_ARGUMENT; } @@ -192,7 +300,8 @@ Command * Commands::GetGlobalCommand(CommandsVector & commands, std::string comm bool Commands::IsAttributeCommand(std::string commandName) const { - return commandName.compare("read") == 0 || commandName.compare("write") == 0 || commandName.compare("subscribe") == 0; + return commandName.compare("read") == 0 || commandName.compare("write") == 0 || commandName.compare("force-write") == 0 || + commandName.compare("subscribe") == 0; } bool Commands::IsEventCommand(std::string commandName) const @@ -233,6 +342,7 @@ void Commands::ShowCluster(std::string executable, std::string clusterName, Comm fprintf(stderr, " +-------------------------------------------------------------------------------------+\n"); bool readCommand = false; bool writeCommand = false; + bool writeOverrideCommand = false; bool subscribeCommand = false; bool readEventCommand = false; bool subscribeEventCommand = false; @@ -250,6 +360,10 @@ void Commands::ShowCluster(std::string executable, std::string clusterName, Comm { writeCommand = true; } + else if (strcmp(command->GetName(), "force-write") == 0 && !writeOverrideCommand) + { + writeOverrideCommand = true; + } else if (strcmp(command->GetName(), "subscribe") == 0 && !subscribeCommand) { subscribeCommand = true; @@ -368,3 +482,90 @@ void Commands::ShowCommand(std::string executable, std::string clusterName, Comm fprintf(stderr, "%s\n", description.c_str()); } } + +bool Commands::DecodeArgumentsFromInteractiveMode(const char * command, std::vector & args) +{ + // Remote clients may not know the ordering of arguments, so instead of a strict ordering arguments can + // be passed in as a json payload encoded in base64 and are reordered on the fly. + return IsJsonString(command) ? DecodeArgumentsFromBase64EncodedJson(command, args) + : DecodeArgumentsFromStringStream(command, args); +} + +bool Commands::DecodeArgumentsFromBase64EncodedJson(const char * json, std::vector & args) +{ + Json::Value jsonValue; + bool parsed = JsonParser::ParseCustomArgument(json, json + kJsonStringPrefixLen, jsonValue); + VerifyOrReturnValue(parsed, false, ChipLogError(chipTool, "Error while parsing json.")); + VerifyOrReturnValue(jsonValue.isObject(), false, ChipLogError(chipTool, "Unexpected json type.")); + VerifyOrReturnValue(jsonValue.isMember(kJsonClusterKey), false, + ChipLogError(chipTool, "'%s' key not found in json.", kJsonClusterKey)); + VerifyOrReturnValue(jsonValue.isMember(kJsonCommandKey), false, + ChipLogError(chipTool, "'%s' key not found in json.", kJsonCommandKey)); + VerifyOrReturnValue(jsonValue.isMember(kJsonArgumentsKey), false, + ChipLogError(chipTool, "'%s' key not found in json.", kJsonArgumentsKey)); + VerifyOrReturnValue(IsBase64String(jsonValue[kJsonArgumentsKey].asString().c_str()), false, + ChipLogError(chipTool, "'arguments' is not a base64 string.")); + + auto clusterName = jsonValue[kJsonClusterKey].asString(); + auto commandName = jsonValue[kJsonCommandKey].asString(); + auto arguments = jsonValue[kJsonArgumentsKey].asString(); + + auto cluster = GetCluster(clusterName); + VerifyOrReturnValue(cluster != mClusters.end(), false, + ChipLogError(chipTool, "Cluster '%s' is not supported.", clusterName.c_str())); + + auto command = GetCommand(cluster->second, commandName); + + if (jsonValue.isMember(kJsonCommandSpecifierKey) && IsGlobalCommand(commandName)) + { + auto commandSpecifierName = jsonValue[kJsonCommandSpecifierKey].asString(); + command = GetGlobalCommand(cluster->second, commandName, commandSpecifierName); + } + VerifyOrReturnValue(nullptr != command, false, ChipLogError(chipTool, "Unknown command.")); + + auto encodedData = arguments.c_str(); + encodedData += kBase64StringPrefixLen; + + size_t encodedDataSize = strlen(encodedData); + size_t expectedMaxDecodedSize = BASE64_MAX_DECODED_LEN(encodedDataSize); + + chip::Platform::ScopedMemoryBuffer decodedData; + VerifyOrReturnValue(decodedData.Calloc(expectedMaxDecodedSize + 1 /* for null */), false); + + size_t decodedDataSize = chip::Base64Decode(encodedData, static_cast(encodedDataSize), decodedData.Get()); + VerifyOrReturnValue(decodedDataSize != 0, false, ChipLogError(chipTool, "Error while decoding base64 data.")); + + decodedData.Get()[decodedDataSize] = '\0'; + + Json::Value jsonArguments; + bool parsedArguments = JsonParser::ParseCustomArgument(encodedData, chip::Uint8::to_char(decodedData.Get()), jsonArguments); + VerifyOrReturnValue(parsedArguments, false, ChipLogError(chipTool, "Error while parsing json.")); + VerifyOrReturnValue(jsonArguments.isObject(), false, ChipLogError(chipTool, "Unexpected json type, expects and object.")); + + auto mandatoryArguments = GetArgumentsFromJson(command, jsonArguments, false /* addOptional */); + auto optionalArguments = GetArgumentsFromJson(command, jsonArguments, true /* addOptional */); + + args.push_back(std::move(clusterName)); + args.push_back(std::move(commandName)); + if (jsonValue.isMember(kJsonCommandSpecifierKey)) + { + auto commandSpecifierName = jsonValue[kJsonCommandSpecifierKey].asString(); + args.push_back(std::move(commandSpecifierName)); + } + args.insert(args.end(), mandatoryArguments.begin(), mandatoryArguments.end()); + args.insert(args.end(), optionalArguments.begin(), optionalArguments.end()); + + return true; +} + +bool Commands::DecodeArgumentsFromStringStream(const char * command, std::vector & args) +{ + std::string arg; + std::stringstream ss(command); + while (ss >> std::quoted(arg, '\'')) + { + args.push_back(std::move(arg)); + } + + return true; +} diff --git a/examples/chip-tool/commands/common/Commands.h b/examples/chip-tool/commands/common/Commands.h index 57475b1c027087..80f585931f65db 100644 --- a/examples/chip-tool/commands/common/Commands.h +++ b/examples/chip-tool/commands/common/Commands.h @@ -32,7 +32,7 @@ class Commands void Register(const char * clusterName, commands_list commandsList); int Run(int argc, char ** argv); - int RunInteractive(int argc, char ** argv); + int RunInteractive(const char * command); private: CHIP_ERROR RunCommand(int argc, char ** argv, bool interactive = false); @@ -50,6 +50,10 @@ class Commands void ShowClusterEvents(std::string executable, std::string clusterName, std::string commandName, CommandsVector & commands); void ShowCommand(std::string executable, std::string clusterName, Command * command); + bool DecodeArgumentsFromInteractiveMode(const char * command, std::vector & args); + bool DecodeArgumentsFromBase64EncodedJson(const char * encodedData, std::vector & args); + bool DecodeArgumentsFromStringStream(const char * command, std::vector & args); + std::map mClusters; #ifdef CONFIG_USE_LOCAL_STORAGE PersistentStorage mStorage; diff --git a/examples/chip-tool/commands/common/CredentialIssuerCommands.h b/examples/chip-tool/commands/common/CredentialIssuerCommands.h index 1ea712ffa9593f..afb36773529e1e 100644 --- a/examples/chip-tool/commands/common/CredentialIssuerCommands.h +++ b/examples/chip-tool/commands/common/CredentialIssuerCommands.h @@ -73,6 +73,8 @@ class CredentialIssuerCommands virtual chip::Controller::OperationalCredentialsDelegate * GetCredentialIssuer() = 0; + virtual void SetCredentialIssuerCATValues(chip::CATValues cats) = 0; + /** * @brief * This function is used to Generate NOC Chain for the Controller/Commissioner. Parameters follow the example implementation, diff --git a/examples/chip-tool/commands/common/CustomStringPrefix.h b/examples/chip-tool/commands/common/CustomStringPrefix.h index a3133b3876b393..b761a358f5850c 100644 --- a/examples/chip-tool/commands/common/CustomStringPrefix.h +++ b/examples/chip-tool/commands/common/CustomStringPrefix.h @@ -18,12 +18,28 @@ #pragma once +static constexpr char kJsonStringPrefix[] = "json:"; +constexpr size_t kJsonStringPrefixLen = ArraySize(kJsonStringPrefix) - 1; // Don't count the null + +static constexpr char kBase64StringPrefix[] = "base64:"; +constexpr size_t kBase64StringPrefixLen = ArraySize(kBase64StringPrefix) - 1; // Don't count the null + static constexpr char kHexStringPrefix[] = "hex:"; constexpr size_t kHexStringPrefixLen = ArraySize(kHexStringPrefix) - 1; // Don't count the null static constexpr char kStrStringPrefix[] = "str:"; constexpr size_t kStrStringPrefixLen = ArraySize(kStrStringPrefix) - 1; // Don't count the null +inline bool IsJsonString(const char * str) +{ + return strncmp(str, kJsonStringPrefix, kJsonStringPrefixLen) == 0; +} + +inline bool IsBase64String(const char * str) +{ + return strncmp(str, kBase64StringPrefix, kBase64StringPrefixLen) == 0; +} + inline bool IsHexString(const char * str) { return strncmp(str, kHexStringPrefix, kHexStringPrefixLen) == 0; diff --git a/examples/chip-tool/commands/common/RemoteDataModelLogger.cpp b/examples/chip-tool/commands/common/RemoteDataModelLogger.cpp new file mode 100644 index 00000000000000..1b397dfe8989d0 --- /dev/null +++ b/examples/chip-tool/commands/common/RemoteDataModelLogger.cpp @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "RemoteDataModelLogger.h" + +#include + +constexpr const char * kClusterIdKey = "clusterId"; +constexpr const char * kEndpointIdKey = "endpointId"; +constexpr const char * kAttributeIdKey = "attributeId"; +constexpr const char * kEventIdKey = "eventId"; +constexpr const char * kCommandIdKey = "commandId"; +constexpr const char * kErrorIdKey = "error"; +constexpr const char * kClusterErrorIdKey = "clusterError"; +constexpr const char * kValueKey = "value"; +constexpr const char * kNodeIdKey = "nodeId"; + +namespace { +RemoteDataModelLoggerDelegate * gDelegate; + +CHIP_ERROR LogError(Json::Value & value, const chip::app::StatusIB & status) +{ + if (status.mClusterStatus.HasValue()) + { + auto statusValue = status.mClusterStatus.Value(); + value[kClusterErrorIdKey] = statusValue; + } + +#if CHIP_CONFIG_IM_STATUS_CODE_VERBOSE_FORMAT + auto statusName = chip::Protocols::InteractionModel::StatusName(status.mStatus); + value[kErrorIdKey] = statusName; +#else + auto statusName = status.mStatus; + value[kErrorIdKey] = chip::to_underlying(statusName); +#endif // CHIP_CONFIG_IM_STATUS_CODE_VERBOSE_FORMAT + + auto valueStr = chip::JsonToString(value); + return gDelegate->LogJSON(valueStr.c_str()); +} +} // namespace + +namespace RemoteDataModelLogger { +CHIP_ERROR LogAttributeAsJSON(const chip::app::ConcreteDataAttributePath & path, chip::TLV::TLVReader * data) +{ + VerifyOrReturnError(gDelegate != nullptr, CHIP_NO_ERROR); + + Json::Value value; + value[kClusterIdKey] = path.mClusterId; + value[kEndpointIdKey] = path.mEndpointId; + value[kAttributeIdKey] = path.mAttributeId; + + chip::TLV::TLVReader reader; + reader.Init(*data); + ReturnErrorOnFailure(chip::TlvToJson(reader, value)); + + auto valueStr = chip::JsonToString(value); + return gDelegate->LogJSON(valueStr.c_str()); +} + +CHIP_ERROR LogErrorAsJSON(const chip::app::ConcreteDataAttributePath & path, const chip::app::StatusIB & status) +{ + VerifyOrReturnError(gDelegate != nullptr, CHIP_NO_ERROR); + + Json::Value value; + value[kClusterIdKey] = path.mClusterId; + value[kEndpointIdKey] = path.mEndpointId; + value[kAttributeIdKey] = path.mAttributeId; + + return LogError(value, status); +} + +CHIP_ERROR LogCommandAsJSON(const chip::app::ConcreteCommandPath & path, chip::TLV::TLVReader * data) +{ + VerifyOrReturnError(gDelegate != nullptr, CHIP_NO_ERROR); + + Json::Value value; + value[kClusterIdKey] = path.mClusterId; + value[kEndpointIdKey] = path.mEndpointId; + value[kCommandIdKey] = path.mCommandId; + + chip::TLV::TLVReader reader; + reader.Init(*data); + ReturnErrorOnFailure(chip::TlvToJson(reader, value)); + + auto valueStr = chip::JsonToString(value); + return gDelegate->LogJSON(valueStr.c_str()); +} + +CHIP_ERROR LogErrorAsJSON(const chip::app::ConcreteCommandPath & path, const chip::app::StatusIB & status) +{ + VerifyOrReturnError(gDelegate != nullptr, CHIP_NO_ERROR); + + Json::Value value; + value[kClusterIdKey] = path.mClusterId; + value[kEndpointIdKey] = path.mEndpointId; + value[kCommandIdKey] = path.mCommandId; + + return LogError(value, status); +} + +CHIP_ERROR LogEventAsJSON(const chip::app::EventHeader & header, chip::TLV::TLVReader * data) +{ + VerifyOrReturnError(gDelegate != nullptr, CHIP_NO_ERROR); + + Json::Value value; + value[kClusterIdKey] = header.mPath.mClusterId; + value[kEndpointIdKey] = header.mPath.mEndpointId; + value[kEventIdKey] = header.mPath.mEventId; + + chip::TLV::TLVReader reader; + reader.Init(*data); + ReturnErrorOnFailure(chip::TlvToJson(reader, value)); + + auto valueStr = chip::JsonToString(value); + return gDelegate->LogJSON(valueStr.c_str()); +} + +CHIP_ERROR LogErrorAsJSON(const chip::app::EventHeader & header, const chip::app::StatusIB & status) +{ + VerifyOrReturnError(gDelegate != nullptr, CHIP_NO_ERROR); + + Json::Value value; + value[kClusterIdKey] = header.mPath.mClusterId; + value[kEndpointIdKey] = header.mPath.mEndpointId; + value[kEventIdKey] = header.mPath.mEventId; + + return LogError(value, status); +} + +CHIP_ERROR LogErrorAsJSON(const CHIP_ERROR & error) +{ + VerifyOrReturnError(gDelegate != nullptr, CHIP_NO_ERROR); + + Json::Value value; + chip::app::StatusIB status; + status.InitFromChipError(error); + return LogError(value, status); +} + +CHIP_ERROR LogGetCommissionerNodeId(chip::NodeId value) +{ + VerifyOrReturnError(gDelegate != nullptr, CHIP_NO_ERROR); + + Json::Value rootValue; + rootValue[kValueKey] = Json::Value(); + rootValue[kValueKey][kNodeIdKey] = value; + + auto valueStr = chip::JsonToString(rootValue); + return gDelegate->LogJSON(valueStr.c_str()); +} + +void SetDelegate(RemoteDataModelLoggerDelegate * delegate) +{ + gDelegate = delegate; +} +}; // namespace RemoteDataModelLogger diff --git a/examples/chip-tool/commands/common/RemoteDataModelLogger.h b/examples/chip-tool/commands/common/RemoteDataModelLogger.h new file mode 100644 index 00000000000000..a1d2464748cff0 --- /dev/null +++ b/examples/chip-tool/commands/common/RemoteDataModelLogger.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#pragma once + +#include +#include +#include +#include + +class RemoteDataModelLoggerDelegate +{ +public: + CHIP_ERROR virtual LogJSON(const char *) = 0; + virtual ~RemoteDataModelLoggerDelegate(){}; +}; + +namespace RemoteDataModelLogger { +CHIP_ERROR LogAttributeAsJSON(const chip::app::ConcreteDataAttributePath & path, chip::TLV::TLVReader * data); +CHIP_ERROR LogErrorAsJSON(const chip::app::ConcreteDataAttributePath & path, const chip::app::StatusIB & status); +CHIP_ERROR LogCommandAsJSON(const chip::app::ConcreteCommandPath & path, chip::TLV::TLVReader * data); +CHIP_ERROR LogErrorAsJSON(const chip::app::ConcreteCommandPath & path, const chip::app::StatusIB & status); +CHIP_ERROR LogEventAsJSON(const chip::app::EventHeader & header, chip::TLV::TLVReader * data); +CHIP_ERROR LogErrorAsJSON(const chip::app::EventHeader & header, const chip::app::StatusIB & status); +CHIP_ERROR LogErrorAsJSON(const CHIP_ERROR & error); +CHIP_ERROR LogGetCommissionerNodeId(chip::NodeId value); +void SetDelegate(RemoteDataModelLoggerDelegate * delegate); +}; // namespace RemoteDataModelLogger diff --git a/examples/chip-tool/commands/example/ExampleCredentialIssuerCommands.h b/examples/chip-tool/commands/example/ExampleCredentialIssuerCommands.h index e06466ca4ab67d..a8694f02ff894e 100644 --- a/examples/chip-tool/commands/example/ExampleCredentialIssuerCommands.h +++ b/examples/chip-tool/commands/example/ExampleCredentialIssuerCommands.h @@ -45,6 +45,7 @@ class ExampleCredentialIssuerCommands : public CredentialIssuerCommands return CHIP_NO_ERROR; } chip::Controller::OperationalCredentialsDelegate * GetCredentialIssuer() override { return &mOpCredsIssuer; } + void SetCredentialIssuerCATValues(chip::CATValues cats) override { mOpCredsIssuer.SetCATValuesForNextNOCRequest(cats); } CHIP_ERROR GenerateControllerNOCChain(chip::NodeId nodeId, chip::FabricId fabricId, const chip::CATValues & cats, chip::Crypto::P256Keypair & keypair, chip::MutableByteSpan & rcac, chip::MutableByteSpan & icac, chip::MutableByteSpan & noc) override diff --git a/examples/chip-tool/commands/interactive/InteractiveCommands.cpp b/examples/chip-tool/commands/interactive/InteractiveCommands.cpp index e887391a12031a..854b0877df0cd5 100644 --- a/examples/chip-tool/commands/interactive/InteractiveCommands.cpp +++ b/examples/chip-tool/commands/interactive/InteractiveCommands.cpp @@ -21,14 +21,13 @@ #include #include -#include -#include -char kInteractiveModeName[] = ""; constexpr const char * kInteractiveModePrompt = ">>> "; -constexpr uint8_t kInteractiveModeArgumentsMaxLength = 32; constexpr const char * kInteractiveModeHistoryFilePath = "/tmp/chip_tool_history"; constexpr const char * kInteractiveModeStopCommand = "quit()"; +constexpr const char * kCategoryError = "Error"; +constexpr const char * kCategoryProgress = "Info"; +constexpr const char * kCategoryDetail = "Debug"; namespace { @@ -44,6 +43,133 @@ void ENFORCE_FORMAT(3, 0) LoggingCallback(const char * module, uint8_t category, ClearLine(); } +struct InteractiveServerResultLog +{ + std::string module; + std::string message; + std::string messageType; +}; + +struct InteractiveServerResult +{ + bool mEnabled = false; + bool mIsAsyncReport = false; + int mStatus = EXIT_SUCCESS; + std::vector mResults; + std::vector mLogs; + + void Setup(bool isAsyncReport) + { + mEnabled = true; + mIsAsyncReport = isAsyncReport; + } + + void Reset() + { + mEnabled = false; + mIsAsyncReport = false; + mStatus = EXIT_SUCCESS; + mResults.clear(); + mLogs.clear(); + } + + bool IsAsyncReport() const { return mIsAsyncReport; } + + void MaybeAddLog(const char * module, uint8_t category, const char * base64Message) + { + VerifyOrReturn(mEnabled); + + const char * messageType = nullptr; + switch (category) + { + case chip::Logging::kLogCategory_Error: + messageType = kCategoryError; + break; + case chip::Logging::kLogCategory_Progress: + messageType = kCategoryProgress; + break; + case chip::Logging::kLogCategory_Detail: + messageType = kCategoryDetail; + break; + } + + mLogs.push_back(InteractiveServerResultLog({ module, base64Message, messageType })); + } + + void MaybeAddResult(const char * result) + { + VerifyOrReturn(mEnabled); + mResults.push_back(result); + } + + std::string AsJsonString() const + { + std::string resultsStr; + if (mResults.size()) + { + for (const auto & result : mResults) + { + resultsStr = resultsStr + result + ","; + } + + // Remove last comma. + resultsStr.pop_back(); + } + + if (mStatus != EXIT_SUCCESS) + { + if (resultsStr.size()) + { + resultsStr = resultsStr + ","; + } + resultsStr = resultsStr + "{ \"error\": \"FAILURE\" }"; + } + + std::string logsStr; + if (mLogs.size()) + { + for (const auto & log : mLogs) + { + logsStr = logsStr + "{"; + logsStr = logsStr + " \"module\": \"" + log.module + "\","; + logsStr = logsStr + " \"category\": \"" + log.messageType + "\","; + logsStr = logsStr + " \"message\": \"" + log.message + "\""; + logsStr = logsStr + "},"; + } + + // Remove last comma. + logsStr.pop_back(); + } + + std::string jsonLog; + jsonLog = jsonLog + "{"; + jsonLog = jsonLog + " \"results\": [" + resultsStr + "],"; + jsonLog = jsonLog + " \"logs\": [" + logsStr + "]"; + jsonLog = jsonLog + "}"; + + return jsonLog; + } +}; + +InteractiveServerResult gInteractiveServerResult; + +void ENFORCE_FORMAT(3, 0) InteractiveServerLoggingCallback(const char * module, uint8_t category, const char * msg, va_list args) +{ + va_list args_copy; + va_copy(args_copy, args); + + chip::Logging::Platform::LogV(module, category, msg, args); + + char message[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE]; + vsnprintf(message, sizeof(message), msg, args_copy); + va_end(args_copy); + + char base64Message[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE * 2] = {}; + chip::Base64Encode(chip::Uint8::from_char(message), static_cast(strlen(message)), base64Message); + + gInteractiveServerResult.MaybeAddLog(module, category, base64Message); +} + char * GetCommand(char * command) { if (command != nullptr) @@ -67,15 +193,44 @@ char * GetCommand(char * command) CHIP_ERROR InteractiveServerCommand::RunCommand() { + // Logs needs to be redirected in order to refresh the screen appropriately when something + // is dumped to stdout while the user is typing a command. + chip::Logging::SetLogRedirectCallback(InteractiveServerLoggingCallback); + + RemoteDataModelLogger::SetDelegate(this); ReturnErrorOnFailure(mWebSocketServer.Run(mPort, this)); + gInteractiveServerResult.Reset(); SetCommandExitStatus(CHIP_NO_ERROR); return CHIP_NO_ERROR; } +void SendOverWebSocket(intptr_t context) +{ + auto server = reinterpret_cast(context); + server->Send(gInteractiveServerResult.AsJsonString().c_str()); + gInteractiveServerResult.Reset(); +} + bool InteractiveServerCommand::OnWebSocketMessageReceived(char * msg) { - return ParseCommand(msg); + bool isAsyncReport = strlen(msg) == 0; + gInteractiveServerResult.Setup(isAsyncReport); + VerifyOrReturnValue(!isAsyncReport, true); + + auto shouldStop = ParseCommand(msg, &gInteractiveServerResult.mStatus); + chip::DeviceLayer::PlatformMgr().ScheduleWork(SendOverWebSocket, reinterpret_cast(&mWebSocketServer)); + return shouldStop; +} + +CHIP_ERROR InteractiveServerCommand::LogJSON(const char * json) +{ + gInteractiveServerResult.MaybeAddResult(json); + if (gInteractiveServerResult.IsAsyncReport()) + { + chip::DeviceLayer::PlatformMgr().ScheduleWork(SendOverWebSocket, reinterpret_cast(&mWebSocketServer)); + } + return CHIP_NO_ERROR; } CHIP_ERROR InteractiveStartCommand::RunCommand() @@ -87,10 +242,11 @@ CHIP_ERROR InteractiveStartCommand::RunCommand() chip::Logging::SetLogRedirectCallback(LoggingCallback); char * command = nullptr; + int status; while (true) { command = GetCommand(command); - if (command != nullptr && !ParseCommand(command)) + if (command != nullptr && !ParseCommand(command, &status)) { break; } @@ -106,7 +262,7 @@ CHIP_ERROR InteractiveStartCommand::RunCommand() return CHIP_NO_ERROR; } -bool InteractiveCommand::ParseCommand(char * command) +bool InteractiveCommand::ParseCommand(char * command, int * status) { if (strcmp(command, kInteractiveModeStopCommand) == 0) { @@ -114,31 +270,14 @@ bool InteractiveCommand::ParseCommand(char * command) return false; } - char * args[kInteractiveModeArgumentsMaxLength]; - args[0] = kInteractiveModeName; - int argsCount = 1; - std::string arg; - - std::stringstream ss(command); - while (ss >> std::quoted(arg, '\'')) - { - if (argsCount == kInteractiveModeArgumentsMaxLength) - { - ChipLogError(chipTool, "Too many arguments. Ignoring."); - return true; - } - - char * carg = new char[arg.size() + 1]; - strcpy(carg, arg.c_str()); - args[argsCount++] = carg; - } - ClearLine(); - mHandler->RunInteractive(argsCount, args); - // Do not delete arg[0] - while (--argsCount) - delete[] args[argsCount]; + *status = mHandler->RunInteractive(command); return true; } + +bool InteractiveCommand::NeedsOperationalAdvertising() +{ + return mAdvertiseOperational.ValueOr(true); +} diff --git a/examples/chip-tool/commands/interactive/InteractiveCommands.h b/examples/chip-tool/commands/interactive/InteractiveCommands.h index 830c9d5fd408f2..0b4ead9f9cbbf5 100644 --- a/examples/chip-tool/commands/interactive/InteractiveCommands.h +++ b/examples/chip-tool/commands/interactive/InteractiveCommands.h @@ -18,10 +18,11 @@ #pragma once +#include "../clusters/DataModelLogger.h" #include "../common/CHIPCommand.h" #include "../common/Commands.h" -#include "WebSocketServer.h" +#include class Commands; @@ -30,15 +31,20 @@ class InteractiveCommand : public CHIPCommand public: InteractiveCommand(const char * name, Commands * commandsHandler, CredentialIssuerCommands * credsIssuerConfig) : CHIPCommand(name, credsIssuerConfig), mHandler(commandsHandler) - {} + { + AddArgument("advertise-operational", 0, 1, &mAdvertiseOperational, + "Advertise operational node over DNS-SD and accept incoming CASE sessions."); + } /////////// CHIPCommand Interface ///////// chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(0); } + bool NeedsOperationalAdvertising() override; - bool ParseCommand(char * command); + bool ParseCommand(char * command, int * status); private: Commands * mHandler = nullptr; + chip::Optional mAdvertiseOperational; }; class InteractiveStartCommand : public InteractiveCommand @@ -52,7 +58,7 @@ class InteractiveStartCommand : public InteractiveCommand CHIP_ERROR RunCommand() override; }; -class InteractiveServerCommand : public InteractiveCommand, public WebSocketServerDelegate +class InteractiveServerCommand : public InteractiveCommand, public WebSocketServerDelegate, public RemoteDataModelLoggerDelegate { public: InteractiveServerCommand(Commands * commandsHandler, CredentialIssuerCommands * credsIssuerConfig) : @@ -67,6 +73,9 @@ class InteractiveServerCommand : public InteractiveCommand, public WebSocketServ /////////// WebSocketServerDelegate Interface ///////// bool OnWebSocketMessageReceived(char * msg) override; + /////////// RemoteDataModelLoggerDelegate interface ///////// + CHIP_ERROR LogJSON(const char * json) override; + private: WebSocketServer mWebSocketServer; chip::Optional mPort; diff --git a/examples/chip-tool/commands/pairing/Commands.h b/examples/chip-tool/commands/pairing/Commands.h index 871b282ebd781d..0401c8888fffd7 100644 --- a/examples/chip-tool/commands/pairing/Commands.h +++ b/examples/chip-tool/commands/pairing/Commands.h @@ -21,6 +21,7 @@ #include "commands/common/Commands.h" #include "commands/pairing/CloseSessionCommand.h" #include "commands/pairing/CommissionedListCommand.h" +#include "commands/pairing/GetCommissionerNodeIdCommand.h" #include "commands/pairing/OpenCommissioningWindowCommand.h" #include "commands/pairing/PairingCommand.h" @@ -220,6 +221,7 @@ void registerCommandsPairing(Commands & commands, CredentialIssuerCommands * cre make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), + make_unique(credsIssuerConfig), }; commands.Register(clusterName, clusterCommands); diff --git a/examples/chip-tool/commands/pairing/GetCommissionerNodeIdCommand.h b/examples/chip-tool/commands/pairing/GetCommissionerNodeIdCommand.h new file mode 100644 index 00000000000000..9d3d3deabd83d7 --- /dev/null +++ b/examples/chip-tool/commands/pairing/GetCommissionerNodeIdCommand.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#pragma once + +#include "../common/CHIPCommand.h" + +class GetCommissionerNodeIdCommand : public CHIPCommand +{ +public: + GetCommissionerNodeIdCommand(CredentialIssuerCommands * credIssuerCommands) : + CHIPCommand("get-commissioner-node-id", credIssuerCommands) + {} + + /////////// CHIPCommand Interface ///////// + CHIP_ERROR RunCommand() override + { + chip::NodeId id; + ReturnErrorOnFailure(GetIdentityNodeId(GetIdentity(), &id)); + ChipLogProgress(chipTool, "Commissioner Node Id 0x:" ChipLogFormatX64, ChipLogValueX64(id)); + + ReturnErrorOnFailure(RemoteDataModelLogger::LogGetCommissionerNodeId(id)); + SetCommandExitStatus(CHIP_NO_ERROR); + return CHIP_NO_ERROR; + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(10); } +}; diff --git a/examples/chip-tool/commands/pairing/PairingCommand.cpp b/examples/chip-tool/commands/pairing/PairingCommand.cpp index 9c185024ad2075..6467e8ffcbe989 100644 --- a/examples/chip-tool/commands/pairing/PairingCommand.cpp +++ b/examples/chip-tool/commands/pairing/PairingCommand.cpp @@ -33,6 +33,21 @@ using namespace ::chip::Controller; CHIP_ERROR PairingCommand::RunCommand() { CurrentCommissioner().RegisterPairingDelegate(this); + // Clear the CATs in OperationalCredentialsIssuer + mCredIssuerCmds->SetCredentialIssuerCATValues(kUndefinedCATs); + + if (mCASEAuthTags.HasValue() && mCASEAuthTags.Value().size() <= kMaxSubjectCATAttributeCount) + { + CATValues cats = kUndefinedCATs; + for (size_t index = 0; index < mCASEAuthTags.Value().size(); ++index) + { + cats.values[index] = mCASEAuthTags.Value()[index]; + } + if (cats.AreValid()) + { + mCredIssuerCmds->SetCredentialIssuerCATValues(cats); + } + } return RunInternal(mNodeId); } @@ -72,6 +87,10 @@ CommissioningParameters PairingCommand::GetCommissioningParameters() { auto params = CommissioningParameters(); params.SetSkipCommissioningComplete(mSkipCommissioningComplete.ValueOr(false)); + if (mBypassAttestationVerifier.ValueOr(false)) + { + params.SetDeviceAttestationDelegate(this); + } switch (mNetworkType) { @@ -281,3 +300,19 @@ void PairingCommand::OnCurrentFabricRemove(void * context, NodeId nodeId, CHIP_E command->SetCommandExitStatus(err); } + +chip::Optional PairingCommand::FailSafeExpiryTimeoutSecs() const +{ + // We don't need to set additional failsafe timeout as we don't ask the final user if he wants to continue + return chip::Optional(); +} + +void PairingCommand::OnDeviceAttestationCompleted(chip::Controller::DeviceCommissioner * deviceCommissioner, + chip::DeviceProxy * device, + const chip::Credentials::DeviceAttestationVerifier::AttestationDeviceInfo & info, + chip::Credentials::AttestationVerificationResult attestationResult) +{ + // Bypass attestation verification, continue with success + deviceCommissioner->ContinueCommissioningAfterDeviceAttestation(device, + chip::Credentials::AttestationVerificationResult::kSuccess); +} diff --git a/examples/chip-tool/commands/pairing/PairingCommand.h b/examples/chip-tool/commands/pairing/PairingCommand.h index 4919ec89de8ad1..656b4c60d4db02 100644 --- a/examples/chip-tool/commands/pairing/PairingCommand.h +++ b/examples/chip-tool/commands/pairing/PairingCommand.h @@ -48,7 +48,8 @@ enum class PairingNetworkType class PairingCommand : public CHIPCommand, public chip::Controller::DevicePairingDelegate, - public chip::Controller::DeviceDiscoveryDelegate + public chip::Controller::DeviceDiscoveryDelegate, + public chip::Credentials::DeviceAttestationDelegate { public: PairingCommand(const char * commandName, PairingMode mode, PairingNetworkType networkType, @@ -60,6 +61,10 @@ class PairingCommand : public CHIPCommand, mCurrentFabricRemoveCallback(OnCurrentFabricRemove, this) { AddArgument("node-id", 0, UINT64_MAX, &mNodeId); + AddArgument("bypass-attestation-verifier", 0, 1, &mBypassAttestationVerifier, + "Bypass the attestation verifier. If not provided or false, the attestation verifier is not bypassed." + " If true, the commissioning will continue in case of attestation verification failure."); + AddArgument("case-auth-tags", 1, UINT32_MAX, &mCASEAuthTags, "The CATs to be encoded in the NOC sent to the commissionee"); switch (networkType) { @@ -158,6 +163,12 @@ class PairingCommand : public CHIPCommand, void OnDiscoveredDevice(const chip::Dnssd::DiscoveredNodeData & nodeData) override; bool IsDiscoverOnce() { return mDiscoverOnce.ValueOr(false); } + /////////// DeviceAttestationDelegate ///////// + chip::Optional FailSafeExpiryTimeoutSecs() const override; + void OnDeviceAttestationCompleted(chip::Controller::DeviceCommissioner * deviceCommissioner, chip::DeviceProxy * device, + const chip::Credentials::DeviceAttestationVerifier::AttestationDeviceInfo & info, + chip::Credentials::AttestationVerificationResult attestationResult) override; + private: CHIP_ERROR RunInternal(NodeId remoteId); CHIP_ERROR Pair(NodeId remoteId, PeerAddress address); @@ -177,6 +188,8 @@ class PairingCommand : public CHIPCommand, chip::Optional mUseOnlyOnNetworkDiscovery; chip::Optional mPaseOnly; chip::Optional mSkipCommissioningComplete; + chip::Optional mBypassAttestationVerifier; + chip::Optional> mCASEAuthTags; uint16_t mRemotePort; uint16_t mDiscriminator; uint32_t mSetupPINCode; diff --git a/examples/chip-tool/commands/tests/TestCommand.h b/examples/chip-tool/commands/tests/TestCommand.h index c140fb689afde7..b1de8a20517024 100644 --- a/examples/chip-tool/commands/tests/TestCommand.h +++ b/examples/chip-tool/commands/tests/TestCommand.h @@ -78,12 +78,6 @@ class TestCommand : public TestRunner, chip::Controller::DeviceCommissioner & GetCommissioner(const char * identity) override { - // Best effort to get NodeId - if this fails, GetCommissioner will also fail - chip::NodeId id; - if (GetCommissionerNodeId(identity, &id) == CHIP_NO_ERROR) - { - mCommissionerNodeId.SetValue(id); - } return CHIPCommand::GetCommissioner(identity); }; @@ -101,7 +95,6 @@ class TestCommand : public TestRunner, chip::Optional mPICSFilePath; chip::Optional mTimeout; - chip::Optional mCommissionerNodeId; std::map> mDevices; // When set to false, prevents interaction model events from affecting the current test status. diff --git a/examples/chip-tool/templates/commands.zapt b/examples/chip-tool/templates/commands.zapt index b56772d44a5ad5..2fcc7e1abb94e2 100644 --- a/examples/chip-tool/templates/commands.zapt +++ b/examples/chip-tool/templates/commands.zapt @@ -93,21 +93,17 @@ void registerCluster{{asUpperCamelCase name}}(Commands & commands, CredentialIss {{/zcl_attributes_server}} make_unique>(Id, credsIssuerConfig), // {{#zcl_attributes_server}} - {{#if isWritable}} {{#if_chip_complex}} - make_unique>(Id, "{{cleanse_label_as_kebab_case (asUpperCamelCase name)}}", Attributes::{{asUpperCamelCase name}}::Id, credsIssuerConfig), // + make_unique>(Id, "{{cleanse_label_as_kebab_case (asUpperCamelCase name)}}", Attributes::{{asUpperCamelCase name}}::Id, WriteCommandType::k{{#unless isWritable}}Force{{/unless}}Write, credsIssuerConfig), // {{else if (isString type)}} - make_unique>(Id, "{{cleanse_label_as_kebab_case (asUpperCamelCase name)}}", Attributes::{{asUpperCamelCase name}}::Id, credsIssuerConfig), // + make_unique>(Id, "{{cleanse_label_as_kebab_case (asUpperCamelCase name)}}", Attributes::{{asUpperCamelCase name}}::Id, WriteCommandType::k{{#unless isWritable}}Force{{/unless}}Write, credsIssuerConfig), // {{else}} - make_unique>(Id, "{{cleanse_label_as_kebab_case (asUpperCamelCase name)}}", {{as_type_min_value type language='c++'}}, {{as_type_max_value type language='c++'}}, Attributes::{{asUpperCamelCase name}}::Id, credsIssuerConfig), // + make_unique>(Id, "{{cleanse_label_as_kebab_case (asUpperCamelCase name)}}", {{as_type_min_value type language='c++'}}, {{as_type_max_value type language='c++'}}, Attributes::{{asUpperCamelCase name}}::Id, WriteCommandType::k{{#unless isWritable}}Force{{/unless}}Write, credsIssuerConfig), // {{/if_chip_complex}} - {{/if}} {{/zcl_attributes_server}} make_unique(Id, credsIssuerConfig), // {{#zcl_attributes_server}} - {{#if isReportable}} make_unique(Id, "{{cleanse_label_as_kebab_case (asUpperCamelCase name)}}", Attributes::{{asUpperCamelCase name}}::Id, credsIssuerConfig), // - {{/if}} {{/zcl_attributes_server}} // // Events diff --git a/examples/chip-tool/templates/tests/partials/test_cluster.zapt b/examples/chip-tool/templates/tests/partials/test_cluster.zapt index 0eba4f18f22913..a968b9f1241839 100644 --- a/examples/chip-tool/templates/tests/partials/test_cluster.zapt +++ b/examples/chip-tool/templates/tests/partials/test_cluster.zapt @@ -48,14 +48,6 @@ private: void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override { - - // Allow yaml to access the current commissioner node id. - // Default to 0 (undefined node id) so we know if this isn't - // set correctly. - // Reset on every step in case it changed. - chip::NodeId commissionerNodeId = mCommissionerNodeId.ValueOr(0); - (void) commissionerNodeId; - bool shouldContinue = false; switch (mTestIndex - 1) @@ -80,12 +72,6 @@ private: CHIP_ERROR DoTestStep(uint16_t testIndex) override { using namespace chip::app::Clusters; - // Allow yaml to access the current commissioner node id. - // Default to 0 (undefined node id) so we know if this isn't - // set correctly. - // Reset on every step in case it changed. - chip::NodeId commissionerNodeId = mCommissionerNodeId.ValueOr(0); - (void) commissionerNodeId; switch (testIndex) { {{#chip_tests_items}} diff --git a/examples/common/m5stack-tft/repo b/examples/common/m5stack-tft/repo index a1ece2c500cf17..3344a8105f8dfe 160000 --- a/examples/common/m5stack-tft/repo +++ b/examples/common/m5stack-tft/repo @@ -1 +1 @@ -Subproject commit a1ece2c500cf179db8f0c7dbc7bb8f3ace562142 +Subproject commit 3344a8105f8dfecb95832f369733cf6f863a1662 diff --git a/examples/common/pigweed/protos/attributes_service.proto b/examples/common/pigweed/protos/attributes_service.proto index 6f09e9faa7ba9a..99ca55f5f46e65 100644 --- a/examples/common/pigweed/protos/attributes_service.proto +++ b/examples/common/pigweed/protos/attributes_service.proto @@ -101,7 +101,7 @@ enum ClusterType { ZCL_THREAD_NETWORK_DIAGNOSTICS_CLUSTER_ID = 0x0035; ZCL_WIFI_NETWORK_DIAGNOSTICS_CLUSTER_ID = 0x0036; ZCL_ETHERNET_NETWORK_DIAGNOSTICS_CLUSTER_ID = 0x0037; - ZCL_BRIDGED_DEVICE_BASIC_CLUSTER_ID = 0x0039; + ZCL_BRIDGED_DEVICE_BASIC_INFORMATION_CLUSTER_ID = 0x0039; ZCL_SWITCH_CLUSTER_ID = 0x003B; ZCL_ADMINISTRATOR_COMMISSIONING_CLUSTER_ID = 0x003C; ZCL_OPERATIONAL_CREDENTIALS_CLUSTER_ID = 0x003E; diff --git a/examples/common/pigweed/rpc_services/Attributes.h b/examples/common/pigweed/rpc_services/Attributes.h index ba3453df43ed86..223ec3336f25bb 100644 --- a/examples/common/pigweed/rpc_services/Attributes.h +++ b/examples/common/pigweed/rpc_services/Attributes.h @@ -21,7 +21,6 @@ #include "app/util/attribute-storage.h" #include "attributes_service/attributes_service.rpc.pb.h" #include "pigweed/rpc_services/internal/StatusUtils.h" -#include #include #include #include diff --git a/examples/common/pigweed/rpc_services/Device.h b/examples/common/pigweed/rpc_services/Device.h index 758ecc9c454259..e82095a59a309e 100644 --- a/examples/common/pigweed/rpc_services/Device.h +++ b/examples/common/pigweed/rpc_services/Device.h @@ -372,7 +372,7 @@ class Device : public pw_rpc::nanopb::Device::Service if (DeviceLayer::GetDeviceInstanceInfoProvider()->GetSerialNumber(response.serial_number, sizeof(response.serial_number)) != CHIP_NO_ERROR) { - return pw::Status::Internal(); + response.serial_number[0] = '\0'; // optional serial field not set. } // Create buffer for QR code that can fit max size and null terminator. @@ -430,7 +430,7 @@ class Device : public pw_rpc::nanopb::Device::Service if (Server::GetInstance().GetCommissioningWindowManager().IsCommissioningWindowOpen() && Server::GetInstance().GetCommissioningWindowManager().CommissioningWindowStatusForCluster() != - app::Clusters::AdministratorCommissioning::CommissioningWindowStatus::kEnhancedWindowOpen) + app::Clusters::AdministratorCommissioning::CommissioningWindowStatusEnum::kEnhancedWindowOpen) { // Cache values before closing to restore them after restart. app::DataModel::Nullable vendorId = Server::GetInstance().GetCommissioningWindowManager().GetOpenerVendorId(); @@ -444,7 +444,7 @@ class Device : public pw_rpc::nanopb::Device::Service } // Let other tasks possibly work since Commissioning window close/open are "heavy" if (Server::GetInstance().GetCommissioningWindowManager().CommissioningWindowStatusForCluster() != - app::Clusters::AdministratorCommissioning::CommissioningWindowStatus::kWindowNotOpen && + app::Clusters::AdministratorCommissioning::CommissioningWindowStatusEnum::kWindowNotOpen && !vendorId.IsNull() && !fabricIndex.IsNull()) { DeviceLayer::StackLock lock; diff --git a/examples/common/pigweed/rpc_services/Lighting.h b/examples/common/pigweed/rpc_services/Lighting.h index 533267a54c59bd..fb394cced45ef3 100644 --- a/examples/common/pigweed/rpc_services/Lighting.h +++ b/examples/common/pigweed/rpc_services/Lighting.h @@ -21,8 +21,8 @@ #include "app/util/attribute-storage.h" #include "lighting_service/lighting_service.rpc.pb.h" #include "pigweed/rpc_services/internal/StatusUtils.h" -#include -#include +#include +#include #include #include @@ -41,14 +41,12 @@ class Lighting : public pw_rpc::nanopb::Lighting::Service DeviceLayer::StackLock lock; uint8_t on = request.on; - RETURN_STATUS_IF_NOT_OK( - emberAfWriteServerAttribute(1, app::Clusters::OnOff::Id, ZCL_ON_OFF_ATTRIBUTE_ID, &on, ZCL_BOOLEAN_ATTRIBUTE_ID)); + RETURN_STATUS_IF_NOT_OK(app::Clusters::OnOff::Attributes::OnOff::Set(1, on)); if (mSupportLevel && request.has_level) { // Clip level to max uint8_t level = std::min(request.level, static_cast(std::numeric_limits::max())); - RETURN_STATUS_IF_NOT_OK(emberAfWriteServerAttribute(kEndpoint, app::Clusters::LevelControl::Id, - ZCL_CURRENT_LEVEL_ATTRIBUTE_ID, &level, ZCL_INT8U_ATTRIBUTE_TYPE)); + RETURN_STATUS_IF_NOT_OK(app::Clusters::LevelControl::Attributes::CurrentLevel::Set(kEndpoint, level)); } if (mSupportColor && request.has_color) @@ -57,11 +55,8 @@ class Lighting : public pw_rpc::nanopb::Lighting::Service // Clip color to max uint8_t hue = std::min(request.color.hue, kColorMax); uint8_t saturation = std::min(request.color.saturation, kColorMax); - RETURN_STATUS_IF_NOT_OK(emberAfWriteServerAttribute( - 1, app::Clusters::ColorControl::Id, ZCL_COLOR_CONTROL_CURRENT_HUE_ATTRIBUTE_ID, &hue, ZCL_INT8U_ATTRIBUTE_TYPE)); - RETURN_STATUS_IF_NOT_OK(emberAfWriteServerAttribute(kEndpoint, app::Clusters::ColorControl::Id, - ZCL_COLOR_CONTROL_CURRENT_SATURATION_ATTRIBUTE_ID, &saturation, - ZCL_INT8U_ATTRIBUTE_TYPE)); + RETURN_STATUS_IF_NOT_OK(app::Clusters::ColorControl::Attributes::CurrentHue::Set(1, hue)); + RETURN_STATUS_IF_NOT_OK(app::Clusters::ColorControl::Attributes::CurrentSaturation::Set(kEndpoint, saturation)); } return pw::OkStatus(); } @@ -70,28 +65,27 @@ class Lighting : public pw_rpc::nanopb::Lighting::Service { DeviceLayer::StackLock lock; - uint8_t on; - uint8_t level; + bool on; + app::DataModel::Nullable level; uint8_t hue; uint8_t saturation; - RETURN_STATUS_IF_NOT_OK(emberAfReadServerAttribute(1, app::Clusters::OnOff::Id, ZCL_ON_OFF_ATTRIBUTE_ID, &on, sizeof(on))); + RETURN_STATUS_IF_NOT_OK(app::Clusters::OnOff::Attributes::OnOff::Get(1, &on)); response.on = on; if (mSupportLevel) { - RETURN_STATUS_IF_NOT_OK(emberAfReadServerAttribute(1, app::Clusters::LevelControl::Id, ZCL_CURRENT_LEVEL_ATTRIBUTE_ID, - &level, sizeof(level))); - response.level = level; - response.has_level = true; + RETURN_STATUS_IF_NOT_OK(app::Clusters::LevelControl::Attributes::CurrentLevel::Get(1, level)); + if (!level.IsNull()) + { + response.level = level.Value(); + response.has_level = true; + } } if (mSupportColor) { - RETURN_STATUS_IF_NOT_OK(emberAfReadServerAttribute(kEndpoint, app::Clusters::ColorControl::Id, - ZCL_COLOR_CONTROL_CURRENT_HUE_ATTRIBUTE_ID, &hue, sizeof(hue))); - RETURN_STATUS_IF_NOT_OK(emberAfReadServerAttribute(kEndpoint, app::Clusters::ColorControl::Id, - ZCL_COLOR_CONTROL_CURRENT_SATURATION_ATTRIBUTE_ID, &saturation, - sizeof(saturation))); + RETURN_STATUS_IF_NOT_OK(app::Clusters::ColorControl::Attributes::CurrentHue::Get(kEndpoint, &hue)); + RETURN_STATUS_IF_NOT_OK(app::Clusters::ColorControl::Attributes::CurrentSaturation::Get(kEndpoint, &saturation)); response.color.hue = hue; response.color.saturation = saturation; response.has_color = true; diff --git a/examples/common/pigweed/rpc_services/Locking.h b/examples/common/pigweed/rpc_services/Locking.h index 5400da3479f849..6d2e912858b47f 100644 --- a/examples/common/pigweed/rpc_services/Locking.h +++ b/examples/common/pigweed/rpc_services/Locking.h @@ -21,7 +21,6 @@ #include "app/util/attribute-storage.h" #include "locking_service/locking_service.rpc.pb.h" #include "pigweed/rpc_services/internal/StatusUtils.h" -#include #include #include diff --git a/examples/common/screen-framework/CMakeLists.txt b/examples/common/screen-framework/CMakeLists.txt index e7d6e37512ecbd..5b5739e12c2df5 100644 --- a/examples/common/screen-framework/CMakeLists.txt +++ b/examples/common/screen-framework/CMakeLists.txt @@ -3,4 +3,4 @@ idf_component_register(SRCS "Display.cpp" "Screen.cpp" "ListScreen.cpp" INCLUDE_DIRS "include" - PRIV_REQUIRES tft chip) + PRIV_REQUIRES tft chip driver) diff --git a/examples/common/tracing/decoder/interaction_model/DecoderCustomLog.cpp b/examples/common/tracing/decoder/interaction_model/DecoderCustomLog.cpp index 47a0b850955da2..f6b014704296ae 100644 --- a/examples/common/tracing/decoder/interaction_model/DecoderCustomLog.cpp +++ b/examples/common/tracing/decoder/interaction_model/DecoderCustomLog.cpp @@ -263,7 +263,7 @@ CHIP_ERROR LogAddTrustedRootCertificateRequest(TLV::TLVReader & reader) app::Clusters::OperationalCredentials::Commands::AddTrustedRootCertificate::DecodableType value; ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, value)); - LogCertificate("RCACValue", value.rootCertificate); + LogCertificate("RCACValue", value.rootCACertificate); return CHIP_NO_ERROR; } diff --git a/examples/pigweed-app/efr32/.gn b/examples/common/websocket-server/BUILD.gn similarity index 61% rename from examples/pigweed-app/efr32/.gn rename to examples/common/websocket-server/BUILD.gn index 81cec9d11a421b..fdd17300cecd06 100644 --- a/examples/pigweed-app/efr32/.gn +++ b/examples/common/websocket-server/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Project CHIP Authors +# Copyright (c) 2023 Project CHIP Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -13,16 +13,19 @@ # limitations under the License. import("//build_overrides/build.gni") +import("//build_overrides/chip.gni") -# The location of the build configuration file. -buildconfig = "${build_root}/config/BUILDCONFIG.gn" +static_library("websocket-server") { + output_name = "libWebSocketServer" -# CHIP uses angle bracket includes. -check_system_includes = true + sources = [ + "WebSocketServer.cpp", + "WebSocketServer.h", + "WebSocketServerDelegate.h", + ] -default_args = { - target_cpu = "arm" - target_os = "freertos" - - import("//args.gni") + public_deps = [ + "${chip_root}/src/lib/support", + "${chip_root}/third_party/libwebsockets", + ] } diff --git a/examples/chip-tool/commands/interactive/WebSocketServer.cpp b/examples/common/websocket-server/WebSocketServer.cpp similarity index 87% rename from examples/chip-tool/commands/interactive/WebSocketServer.cpp rename to examples/common/websocket-server/WebSocketServer.cpp index c7269b38af538f..867180b976c012 100644 --- a/examples/chip-tool/commands/interactive/WebSocketServer.cpp +++ b/examples/common/websocket-server/WebSocketServer.cpp @@ -18,10 +18,15 @@ #include "WebSocketServer.h" +#include +#include + constexpr uint16_t kDefaultWebSocketServerPort = 9002; constexpr uint16_t kMaxMessageBufferLen = 8192; namespace { +lws * gWebSocketInstance = nullptr; + void LogWebSocketCallbackReason(lws_callback_reasons reason) { #if CHIP_DETAIL_LOGGING @@ -121,6 +126,14 @@ static int OnWebSocketCallback(lws * wsi, lws_callback_reasons reason, void * us { lws_callback_on_writable(wsi); } + else if (LWS_CALLBACK_ESTABLISHED == reason) + { + gWebSocketInstance = wsi; + } + else if (LWS_CALLBACK_WSI_DESTROY == reason) + { + gWebSocketInstance = nullptr; + } return 0; } @@ -145,3 +158,15 @@ CHIP_ERROR WebSocketServer::Run(chip::Optional port, WebSocketServerDe lws_context_default_loop_run_destroy(context); return CHIP_NO_ERROR; } + +CHIP_ERROR WebSocketServer::Send(const char * msg) +{ + VerifyOrReturnError(nullptr != gWebSocketInstance, CHIP_ERROR_INCORRECT_STATE); + + chip::Platform::ScopedMemoryBuffer buffer; + VerifyOrReturnError(buffer.Calloc(LWS_PRE + strlen(msg)), CHIP_ERROR_NO_MEMORY); + memcpy(&buffer[LWS_PRE], (void *) msg, strlen(msg)); + lws_write(gWebSocketInstance, &buffer[LWS_PRE], strlen(msg), LWS_WRITE_TEXT); + + return CHIP_NO_ERROR; +} diff --git a/examples/chip-tool/commands/interactive/WebSocketServer.h b/examples/common/websocket-server/WebSocketServer.h similarity index 95% rename from examples/chip-tool/commands/interactive/WebSocketServer.h rename to examples/common/websocket-server/WebSocketServer.h index d24ab07f88f217..712cf185d8f4a0 100644 --- a/examples/chip-tool/commands/interactive/WebSocketServer.h +++ b/examples/common/websocket-server/WebSocketServer.h @@ -22,10 +22,10 @@ #include #include -#include class WebSocketServer { public: CHIP_ERROR Run(chip::Optional port, WebSocketServerDelegate * delegate); + CHIP_ERROR Send(const char * msg); }; diff --git a/examples/chip-tool/commands/interactive/WebSocketServerDelegate.h b/examples/common/websocket-server/WebSocketServerDelegate.h similarity index 100% rename from examples/chip-tool/commands/interactive/WebSocketServerDelegate.h rename to examples/common/websocket-server/WebSocketServerDelegate.h diff --git a/examples/contact-sensor-app/contact-sensor-common/contact-sensor-app.matter b/examples/contact-sensor-app/contact-sensor-common/contact-sensor-app.matter index 098518172743c1..82fdf54ec8544d 100644 --- a/examples/contact-sensor-app/contact-sensor-common/contact-sensor-app.matter +++ b/examples/contact-sensor-app/contact-sensor-common/contact-sensor-app.matter @@ -644,7 +644,7 @@ server cluster GeneralDiagnostics = 51 { kSoftwareReset = 6; } - enum HardwareFault : ENUM8 { + enum HardwareFaultEnum : ENUM8 { kUnspecified = 0; kRadio = 1; kSensor = 2; @@ -658,7 +658,7 @@ server cluster GeneralDiagnostics = 51 { kTamperDetected = 10; } - enum InterfaceType : ENUM8 { + enum InterfaceTypeEnum : ENUM8 { kUnspecified = 0; kWiFi = 1; kEthernet = 2; @@ -666,14 +666,14 @@ server cluster GeneralDiagnostics = 51 { kThread = 4; } - enum NetworkFaultType : ENUM8 { + enum NetworkFaultEnum : ENUM8 { kUnspecified = 0; kHardwareFailure = 1; kNetworkJammed = 2; kConnectionFailed = 3; } - enum RadioFault : ENUM8 { + enum RadioFaultEnum : ENUM8 { kUnspecified = 0; kWiFiFault = 1; kCellularFault = 2; @@ -691,22 +691,22 @@ server cluster GeneralDiagnostics = 51 { octet_string<8> hardwareAddress = 4; octet_string IPv4Addresses[] = 5; octet_string IPv6Addresses[] = 6; - InterfaceType type = 7; + InterfaceTypeEnum type = 7; } critical event HardwareFaultChange = 0 { - HardwareFault current[] = 0; - HardwareFault previous[] = 1; + HardwareFaultEnum current[] = 0; + HardwareFaultEnum previous[] = 1; } critical event RadioFaultChange = 1 { - RadioFault current[] = 0; - RadioFault previous[] = 1; + RadioFaultEnum current[] = 0; + RadioFaultEnum previous[] = 1; } critical event NetworkFaultChange = 2 { - NetworkFaultType current[] = 0; - NetworkFaultType previous[] = 1; + NetworkFaultEnum current[] = 0; + NetworkFaultEnum previous[] = 1; } critical event BootReason = 3 { @@ -718,9 +718,9 @@ server cluster GeneralDiagnostics = 51 { readonly attribute int64u upTime = 2; readonly attribute int32u totalOperationalHours = 3; readonly attribute BootReasonEnum bootReason = 4; - readonly attribute HardwareFault activeHardwareFaults[] = 5; - readonly attribute RadioFault activeRadioFaults[] = 6; - readonly attribute NetworkFaultType activeNetworkFaults[] = 7; + readonly attribute HardwareFaultEnum activeHardwareFaults[] = 5; + readonly attribute RadioFaultEnum activeRadioFaults[] = 6; + readonly attribute NetworkFaultEnum activeNetworkFaults[] = 7; readonly attribute boolean testEventTriggersEnabled = 8; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -951,6 +951,11 @@ server cluster WiFiNetworkDiagnostics = 54 { kAx = 5; } + bitmap WiFiNetworkDiagnosticsFeature : BITMAP32 { + kPacketCounts = 0x1; + kErrorCounts = 0x2; + } + info event Disconnection = 0 { INT16U reasonCode = 0; } @@ -984,7 +989,7 @@ server cluster WiFiNetworkDiagnostics = 54 { } server cluster EthernetNetworkDiagnostics = 55 { - enum PHYRate : ENUM8 { + enum PHYRateEnum : ENUM8 { kRate10M = 0; kRate100M = 1; kRate1G = 2; @@ -997,7 +1002,12 @@ server cluster EthernetNetworkDiagnostics = 55 { kRate400G = 9; } - readonly attribute nullable PHYRate PHYRate = 0; + bitmap EthernetNetworkDiagnosticsFeature : BITMAP32 { + kPacketCounts = 0x1; + kErrorCounts = 0x2; + } + + readonly attribute nullable PHYRateEnum PHYRate = 0; readonly attribute nullable boolean fullDuplex = 1; readonly attribute int64u packetRxCount = 2; readonly attribute int64u packetTxCount = 3; @@ -1013,7 +1023,7 @@ server cluster EthernetNetworkDiagnostics = 55 { } server cluster AdministratorCommissioning = 60 { - enum CommissioningWindowStatus : ENUM8 { + enum CommissioningWindowStatusEnum : ENUM8 { kWindowNotOpen = 0; kEnhancedWindowOpen = 1; kBasicWindowOpen = 2; @@ -1025,7 +1035,7 @@ server cluster AdministratorCommissioning = 60 { kWindowNotOpen = 4; } - readonly attribute CommissioningWindowStatus windowStatus = 0; + readonly attribute CommissioningWindowStatusEnum windowStatus = 0; readonly attribute nullable fabric_idx adminFabricIndex = 1; readonly attribute nullable int16u adminVendorId = 2; readonly attribute bitmap32 featureMap = 65532; @@ -1049,8 +1059,13 @@ server cluster AdministratorCommissioning = 60 { } server cluster OperationalCredentials = 62 { - enum OperationalCertStatus : ENUM8 { - kSuccess = 0; + enum CertificateChainTypeEnum : ENUM8 { + kDACCertificate = 1; + kPAICertificate = 2; + } + + enum NodeOperationalCertStatusEnum : ENUM8 { + kOk = 0; kInvalidPublicKey = 1; kInvalidNodeOpId = 2; kInvalidNOC = 3; @@ -1068,17 +1083,17 @@ server cluster OperationalCredentials = 62 { fabric_idx fabricIndex = 254; } - fabric_scoped struct FabricDescriptor { + fabric_scoped struct FabricDescriptorStruct { octet_string<65> rootPublicKey = 1; - vendor_id vendorId = 2; - fabric_id fabricId = 3; - node_id nodeId = 4; + vendor_id vendorID = 2; + fabric_id fabricID = 3; + node_id nodeID = 4; char_string<32> label = 5; fabric_idx fabricIndex = 254; } readonly attribute access(read: administer) NOCStruct NOCs[] = 0; - readonly attribute FabricDescriptor fabrics[] = 1; + readonly attribute FabricDescriptorStruct fabrics[] = 1; readonly attribute int8u supportedFabrics = 2; readonly attribute int8u commissionedFabrics = 3; readonly attribute OCTET_STRING trustedRootCertificates[] = 4; @@ -1091,7 +1106,7 @@ server cluster OperationalCredentials = 62 { } request struct CertificateChainRequestRequest { - INT8U certificateType = 0; + CertificateChainTypeEnum certificateType = 0; } request struct CSRRequestRequest { @@ -1121,12 +1136,12 @@ server cluster OperationalCredentials = 62 { } request struct AddTrustedRootCertificateRequest { - OCTET_STRING rootCertificate = 0; + OCTET_STRING rootCACertificate = 0; } response struct AttestationResponse = 1 { OCTET_STRING attestationElements = 0; - OCTET_STRING signature = 1; + OCTET_STRING attestationSignature = 1; } response struct CertificateChainResponse = 3 { @@ -1139,7 +1154,7 @@ server cluster OperationalCredentials = 62 { } response struct NOCResponse = 8 { - OperationalCertStatus statusCode = 0; + NodeOperationalCertStatusEnum statusCode = 0; optional fabric_idx fabricIndex = 1; optional CHAR_STRING debugText = 2; } @@ -1278,7 +1293,7 @@ endpoint 0 { callback attribute extension; callback attribute subjectsPerAccessControlEntry default = 4; callback attribute targetsPerAccessControlEntry default = 3; - callback attribute accessControlEntriesPerFabric default = 3; + callback attribute accessControlEntriesPerFabric default = 4; callback attribute attributeList; ram attribute featureMap; ram attribute clusterRevision default = 1; diff --git a/examples/contact-sensor-app/contact-sensor-common/contact-sensor-app.zap b/examples/contact-sensor-app/contact-sensor-common/contact-sensor-app.zap index 712ff2eb9379d2..d0aea5bc5a7eb2 100644 --- a/examples/contact-sensor-app/contact-sensor-common/contact-sensor-app.zap +++ b/examples/contact-sensor-app/contact-sensor-common/contact-sensor-app.zap @@ -1076,7 +1076,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "4", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -4361,7 +4361,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "PHYRate", + "type": "PHYRateEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -4585,7 +4585,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4637,7 +4637,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4649,7 +4649,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "CommissioningWindowStatus", + "type": "CommissioningWindowStatusEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -8579,7 +8579,7 @@ "enabled": 1, "attributes": [ { - "name": "occupancy", + "name": "Occupancy", "code": 0, "mfgCode": null, "side": "server", @@ -8595,7 +8595,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type", + "name": "OccupancySensorType", "code": 1, "mfgCode": null, "side": "server", @@ -8611,7 +8611,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type bitmap", + "name": "OccupancySensorTypeBitmap", "code": 2, "mfgCode": null, "side": "server", diff --git a/examples/contact-sensor-app/nxp/k32w/k32w0/main/AppTask.cpp b/examples/contact-sensor-app/nxp/k32w/k32w0/main/AppTask.cpp index ef070c33c64273..504513e643e107 100644 --- a/examples/contact-sensor-app/nxp/k32w/k32w0/main/AppTask.cpp +++ b/examples/contact-sensor-app/nxp/k32w/k32w0/main/AppTask.cpp @@ -30,8 +30,7 @@ #include #include -#include -#include +#include #include #include @@ -854,8 +853,7 @@ void AppTask::UpdateClusterStateInternal(intptr_t arg) uint8_t newValue = ContactSensorMgr().IsContactClosed(); // write the new on/off value - EmberAfStatus status = emberAfWriteAttribute(1, app::Clusters::BooleanState::Id, ZCL_STATE_VALUE_ATTRIBUTE_ID, - (uint8_t *) &newValue, ZCL_BOOLEAN_ATTRIBUTE_TYPE); + EmberAfStatus status = app::Clusters::BooleanState::Attributes::StateValue::Set(1, newValue); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: updating boolean status value %x", status); @@ -873,8 +871,7 @@ void AppTask::UpdateDeviceStateInternal(intptr_t arg) bool stateValueAttrValue = 0; /* get onoff attribute value */ - (void) emberAfReadAttribute(1, app::Clusters::BooleanState::Id, ZCL_STATE_VALUE_ATTRIBUTE_ID, (uint8_t *) &stateValueAttrValue, - 1); + (void) app::Clusters::BooleanState::Attributes::StateValue::Get(1, &stateValueAttrValue); #if !cPWR_UsePowerDownMode /* set the device state */ sContactSensorLED.Set(stateValueAttrValue); diff --git a/examples/contact-sensor-app/telink/CMakeLists.txt b/examples/contact-sensor-app/telink/CMakeLists.txt index a2ddd3d332163f..144d1eaab34f88 100755 --- a/examples/contact-sensor-app/telink/CMakeLists.txt +++ b/examples/contact-sensor-app/telink/CMakeLists.txt @@ -51,7 +51,8 @@ target_sources(app PRIVATE src/ZclCallbacks.cpp ${TELINK_COMMON}/util/src/LEDWidget.cpp ${TELINK_COMMON}/util/src/ButtonManager.cpp - ${TELINK_COMMON}/util/src/ThreadUtil.cpp) + ${TELINK_COMMON}/util/src/ThreadUtil.cpp + ${TELINK_COMMON}/util/src/PWMDevice.cpp) chip_configure_data_model(app INCLUDE_SERVER diff --git a/examples/contact-sensor-app/telink/README.md b/examples/contact-sensor-app/telink/README.md index 31b004dd7aaa5b..a41fadcc3bacb8 100755 --- a/examples/contact-sensor-app/telink/README.md +++ b/examples/contact-sensor-app/telink/README.md @@ -64,14 +64,33 @@ The following buttons are available on **tlsr9518adk80d** board: ### LEDs -**Red** LED indicates current state of Thread network. It ables to be in +#### Indicate current state of Thread network + +**Red** LED indicates current state of Thread network. It is able to be in following states: | State | Description | | :-------------------------- | :--------------------------------------------------------------------------- | | Blinks with short pulses | Device is not commissioned to Thread, Thread is disabled | -| Blinls with frequent pulses | Device is commissioned, Thread enabled. Device trying to JOIN thread network | -| Blinks with whde pulses | Device commissioned and joined to thread network as CHILD | +| Blinks with frequent pulses | Device is commissioned, Thread enabled. Device trying to JOIN thread network | +| Blinks with wide pulses | Device commissioned and joined to thread network as CHILD | + +#### Indicate identify of device + +**Green** LED used to identify the device. The LED starts blinking when the +Identify command of the Identify cluster is received. The command's argument can +be used to specify the the effect. It is able to be in following effects: + +| Effect | Description | +| :------------------------------ | :------------------------------------------------------------------- | +| Blinks (200 ms on/200 ms off) | Blink (EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK) | +| Breathe (during 1000 ms) | Breathe (EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE) | +| Blinks (50 ms on/950 ms off) | Okay (EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY) | +| Blinks (1000 ms on/1000 ms off) | Channel Change (EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE) | +| Blinks (950 ms on/50 ms off) | Finish (EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_FINISH_EFFECT) | +| LED off | Stop (EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT) | + +#### Indicate current state of Contact Sensor **Blue** LED shows current state of Contact Sensor diff --git a/examples/contact-sensor-app/telink/include/AppConfig.h b/examples/contact-sensor-app/telink/include/AppConfig.h index 01128b76e4d929..4e4f556036bcfa 100755 --- a/examples/contact-sensor-app/telink/include/AppConfig.h +++ b/examples/contact-sensor-app/telink/include/AppConfig.h @@ -29,9 +29,7 @@ #define BUTTON_PIN_2 0 // LEDs config -// System led config -#define SYSTEM_STATE_LED_PORT DEVICE_DT_GET(DT_NODELABEL(gpiob)) -#define SYSTEM_STATE_LED_PIN 7 - -// Contact state led -#define CONTACT_STATE_LED_PIN 4 +#define LEDS_PORT DEVICE_DT_GET(DT_NODELABEL(gpiob)) +#define SYSTEM_STATE_LED 7 +#define CONTACT_STATE_LED 4 +#define LIGHTING_PWM_SPEC_IDENTIFY_GREEN PWM_DT_SPEC_GET(DT_ALIAS(pwm_led3)) diff --git a/examples/contact-sensor-app/telink/include/AppEvent.h b/examples/contact-sensor-app/telink/include/AppEvent.h index 4051ba31cbb465..5306a8076d0804 100755 --- a/examples/contact-sensor-app/telink/include/AppEvent.h +++ b/examples/contact-sensor-app/telink/include/AppEvent.h @@ -32,6 +32,8 @@ struct AppEvent kEventType_Button = 0, kEventType_Timer, kEventType_UpdateLedState, + kEventType_IdentifyStart, + kEventType_IdentifyStop, kEventType_Contact, }; diff --git a/examples/contact-sensor-app/telink/include/AppTask.h b/examples/contact-sensor-app/telink/include/AppTask.h index ad6f98c7c2cf66..0cf75d63696004 100644 --- a/examples/contact-sensor-app/telink/include/AppTask.h +++ b/examples/contact-sensor-app/telink/include/AppTask.h @@ -21,6 +21,7 @@ #include "AppEvent.h" #include "ContactSensorManager.h" #include "LEDWidget.h" +#include "PWMDevice.h" #include @@ -36,14 +37,17 @@ #define APP_ERROR_UNHANDLED_EVENT CHIP_APPLICATION_ERROR(0x03) struct k_timer; +struct Identify; class AppTask { public: CHIP_ERROR StartApp(void); - void PostContactActionRequest(ContactSensorManager::Action aAction); void PostEvent(AppEvent * event); + static void IdentifyEffectHandler(EmberAfIdentifyEffectIdentifier aEffect); + + void PostContactActionRequest(ContactSensorManager::Action aAction); void UpdateClusterState(void); void UpdateDeviceState(void); @@ -54,6 +58,8 @@ class AppTask friend AppTask & GetAppTask(void); CHIP_ERROR Init(void); + static void ActionIdentifyStateUpdateHandler(k_timer * timer); + void DispatchEvent(AppEvent * event); static void OnStateChanged(ContactSensorManager::State aState); @@ -76,6 +82,7 @@ class AppTask static void StartBleAdvHandler(AppEvent * aEvent); static void ContactActionEventHandler(AppEvent * aEvent); static void UpdateLedStateEventHandler(AppEvent * aEvent); + static void UpdateIdentifyStateEventHandler(AppEvent * aEvent); static void InitButtons(void); @@ -84,6 +91,7 @@ class AppTask bool mSyncClusterToButtonAction = false; static AppTask sAppTask; + PWMDevice mPwmIdentifyLed; #if CONFIG_CHIP_FACTORY_DATA // chip::DeviceLayer::FactoryDataProvider mFactoryDataProvider; diff --git a/examples/contact-sensor-app/telink/prj.conf b/examples/contact-sensor-app/telink/prj.conf index 6c4ad9d8975f05..3c582145b38a29 100755 --- a/examples/contact-sensor-app/telink/prj.conf +++ b/examples/contact-sensor-app/telink/prj.conf @@ -21,6 +21,9 @@ # enable GPIO CONFIG_GPIO=y +# enable PWM +CONFIG_PWM=y + # OpenThread configs CONFIG_OPENTHREAD_MTD=y CONFIG_OPENTHREAD_FTD=n diff --git a/examples/contact-sensor-app/telink/src/AppTask.cpp b/examples/contact-sensor-app/telink/src/AppTask.cpp index a2dc322fcc50de..375b649928b5a1 100644 --- a/examples/contact-sensor-app/telink/src/AppTask.cpp +++ b/examples/contact-sensor-app/telink/src/AppTask.cpp @@ -25,9 +25,7 @@ #include "ThreadUtil.h" #include -#include -#include -#include +#include #include #include #include @@ -43,7 +41,7 @@ #include #include -LOG_MODULE_DECLARE(app); +LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL); using namespace ::chip; using namespace ::chip::app; @@ -51,16 +49,28 @@ using namespace ::chip::Credentials; using namespace ::chip::DeviceLayer; namespace { +constexpr int kFactoryResetTriggerTimeout = 2000; +constexpr int kAppEventQueueSize = 10; +constexpr uint8_t kButtonPushEvent = 1; +constexpr uint8_t kButtonReleaseEvent = 0; +constexpr EndpointId kEndpointId = 1; +constexpr uint8_t kDefaultMinLevel = 0; +constexpr uint8_t kDefaultMaxLevel = 254; +constexpr uint32_t kIdentifyBlinkRateMs = 200; +constexpr uint32_t kIdentifyOkayOnRateMs = 50; +constexpr uint32_t kIdentifyOkayOffRateMs = 950; +constexpr uint32_t kIdentifyFinishOnRateMs = 950; +constexpr uint32_t kIdentifyFinishOffRateMs = 50; +constexpr uint32_t kIdentifyChannelChangeRateMs = 1000; +constexpr uint32_t kIdentifyBreatheRateMs = 1000; + +const struct pwm_dt_spec sPwmIdentifySpecGreenLed = LIGHTING_PWM_SPEC_IDENTIFY_GREEN; -constexpr int kFactoryResetTriggerTimeout = 2000; -constexpr int kAppEventQueueSize = 10; -constexpr uint8_t kButtonPushEvent = 1; -constexpr uint8_t kButtonReleaseEvent = 0; - +#if CONFIG_CHIP_FACTORY_DATA // NOTE! This key is for test/certification only and should not be available in production devices! -// If CONFIG_CHIP_FACTORY_DATA is enabled, this value is read from the factory data. uint8_t sTestEventTriggerEnableKey[TestEventTriggerDelegate::kEnableKeyLength] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }; +#endif K_MSGQ_DEFINE(sAppEventQueue, sizeof(AppEvent), kAppEventQueueSize, alignof(AppEvent)); k_timer sFactoryResetTimer; @@ -82,29 +92,11 @@ chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; void OnIdentifyTriggerEffect(Identify * identify) { - switch (identify->mCurrentEffectIdentifier) - { - case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK: - ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK"); - break; - case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE: - ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE"); - break; - case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY: - ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY"); - break; - case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE: - ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE"); - break; - default: - ChipLogProgress(Zcl, "No identifier effect"); - break; - } - return; + AppTask::IdentifyEffectHandler(identify->mCurrentEffectIdentifier); } Identify sIdentify = { - chip::EndpointId{ 1 }, + kEndpointId, [](Identify *) { ChipLogProgress(Zcl, "OnIdentifyStart"); }, [](Identify *) { ChipLogProgress(Zcl, "OnIdentifyStop"); }, EMBER_ZCL_IDENTIFY_IDENTIFY_TYPE_VISIBLE_LED, @@ -126,20 +118,18 @@ class AppFabricTableDelegate : public FabricTable::Delegate } }; -CHIP_ERROR AppTask::Init() +CHIP_ERROR AppTask::Init(void) { - CHIP_ERROR err; - LOG_INF("SW Version: %u, %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION, CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING); // Initialize status LED - LEDWidget::InitGpio(SYSTEM_STATE_LED_PORT); + LEDWidget::InitGpio(LEDS_PORT); LEDWidget::SetStateUpdateCallback(LEDStateUpdateHandler); - sStatusLED.Init(SYSTEM_STATE_LED_PIN); + sStatusLED.Init(SYSTEM_STATE_LED); UpdateStatusLED(); - sContactSensorLED.Init(CONTACT_STATE_LED_PIN); + sContactSensorLED.Init(CONTACT_STATE_LED); sContactSensorLED.Set(ContactSensorMgr().IsContactClosed()); UpdateDeviceState(); @@ -150,6 +140,16 @@ CHIP_ERROR AppTask::Init() k_timer_init(&sFactoryResetTimer, &AppTask::FactoryResetTimerTimeoutCallback, nullptr); k_timer_user_data_set(&sFactoryResetTimer, this); + // Initialize PWM Identify led + CHIP_ERROR err = sAppTask.mPwmIdentifyLed.Init(&sPwmIdentifySpecGreenLed, kDefaultMinLevel, kDefaultMaxLevel, kDefaultMaxLevel); + if (err != CHIP_NO_ERROR) + { + LOG_ERR("Green IDENTIFY PWM Device Init fail"); + return err; + } + + sAppTask.mPwmIdentifyLed.SetCallbacks(nullptr, nullptr, ActionIdentifyStateUpdateHandler); + // Initialize CHIP server #if CONFIG_CHIP_FACTORY_DATA ReturnErrorOnFailure(mFactoryDataProvider.Init()); @@ -254,6 +254,56 @@ CHIP_ERROR AppTask::StartApp(void) } } +void AppTask::IdentifyEffectHandler(EmberAfIdentifyEffectIdentifier aEffect) +{ + AppEvent event; + event.Type = AppEvent::kEventType_IdentifyStart; + + switch (aEffect) + { + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK: + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK"); + event.Handler = [](AppEvent *) { + sAppTask.mPwmIdentifyLed.InitiateBlinkAction(kIdentifyBlinkRateMs, kIdentifyBlinkRateMs); + }; + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE: + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE"); + event.Handler = [](AppEvent *) { + sAppTask.mPwmIdentifyLed.InitiateBreatheAction(PWMDevice::kBreatheType_Both, kIdentifyBreatheRateMs); + }; + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY: + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY"); + event.Handler = [](AppEvent *) { + sAppTask.mPwmIdentifyLed.InitiateBlinkAction(kIdentifyOkayOnRateMs, kIdentifyOkayOffRateMs); + }; + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE: + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE"); + event.Handler = [](AppEvent *) { + sAppTask.mPwmIdentifyLed.InitiateBlinkAction(kIdentifyChannelChangeRateMs, kIdentifyChannelChangeRateMs); + }; + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_FINISH_EFFECT: + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_FINISH_EFFECT"); + event.Handler = [](AppEvent *) { + sAppTask.mPwmIdentifyLed.InitiateBlinkAction(kIdentifyFinishOnRateMs, kIdentifyFinishOffRateMs); + }; + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT: + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT"); + event.Handler = [](AppEvent *) { sAppTask.mPwmIdentifyLed.StopAction(); }; + event.Type = AppEvent::kEventType_IdentifyStop; + break; + default: + ChipLogProgress(Zcl, "No identifier effect"); + return; + } + + sAppTask.PostEvent(&event); +} + void AppTask::PostContactActionRequest(ContactSensorManager::Action aAction) { AppEvent event; @@ -306,8 +356,7 @@ void AppTask::UpdateClusterStateInternal(intptr_t arg) ChipLogProgress(NotSpecified, "emberAfWriteAttribute : %d", newValue); // write the new boolean state value - EmberAfStatus status = emberAfWriteAttribute(1, ZCL_BOOLEAN_STATE_CLUSTER_ID, ZCL_STATE_VALUE_ATTRIBUTE_ID, - (uint8_t *) &newValue, ZCL_BOOLEAN_ATTRIBUTE_TYPE); + EmberAfStatus status = app::Clusters::BooleanState::Attributes::StateValue::Set(1, newValue); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: updating boolean status value %x", status); @@ -446,6 +495,19 @@ void AppTask::ChipEventHandler(const ChipDeviceEvent * event, intptr_t /* arg */ } } +void AppTask::ActionIdentifyStateUpdateHandler(k_timer * timer) +{ + AppEvent event; + event.Type = AppEvent::kEventType_UpdateLedState; + event.Handler = UpdateIdentifyStateEventHandler; + sAppTask.PostEvent(&event); +} + +void AppTask::UpdateIdentifyStateEventHandler(AppEvent * aEvent) +{ + sAppTask.mPwmIdentifyLed.UpdateAction(); +} + void AppTask::PostEvent(AppEvent * aEvent) { if (k_msgq_put(&sAppEventQueue, aEvent, K_NO_WAIT) != 0) @@ -517,7 +579,7 @@ void AppTask::UpdateDeviceStateInternal(intptr_t arg) bool stateValueAttrValue = 0; /* get boolean state attribute value */ - (void) emberAfReadAttribute(1, ZCL_BOOLEAN_STATE_CLUSTER_ID, ZCL_STATE_VALUE_ATTRIBUTE_ID, (uint8_t *) &stateValueAttrValue, 1); + (void) app::Clusters::BooleanState::Attributes::StateValue::Get(1, &stateValueAttrValue); ChipLogProgress(NotSpecified, "emberAfReadAttribute : %d", stateValueAttrValue); sContactSensorLED.Set(stateValueAttrValue); diff --git a/examples/contact-sensor-app/telink/src/ContactSensorManager.cpp b/examples/contact-sensor-app/telink/src/ContactSensorManager.cpp index b555e4e0a2c958..c0a7612084d000 100644 --- a/examples/contact-sensor-app/telink/src/ContactSensorManager.cpp +++ b/examples/contact-sensor-app/telink/src/ContactSensorManager.cpp @@ -27,7 +27,7 @@ #include #include -LOG_MODULE_DECLARE(app); +LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL); ContactSensorManager ContactSensorManager::sContactSensor; diff --git a/examples/contact-sensor-app/telink/src/ZclCallbacks.cpp b/examples/contact-sensor-app/telink/src/ZclCallbacks.cpp index 89d6aed77f16d2..1b8424eeb1e90c 100644 --- a/examples/contact-sensor-app/telink/src/ZclCallbacks.cpp +++ b/examples/contact-sensor-app/telink/src/ZclCallbacks.cpp @@ -26,6 +26,8 @@ using namespace chip; using namespace chip::app::Clusters; +LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL); + void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size, uint8_t * value) { diff --git a/examples/contact-sensor-app/telink/src/main.cpp b/examples/contact-sensor-app/telink/src/main.cpp index e71632de12fddb..9dd145f55ba0c9 100755 --- a/examples/contact-sensor-app/telink/src/main.cpp +++ b/examples/contact-sensor-app/telink/src/main.cpp @@ -23,7 +23,7 @@ #include -LOG_MODULE_REGISTER(app); +LOG_MODULE_REGISTER(app, CONFIG_CHIP_APP_LOG_LEVEL); using namespace ::chip; using namespace ::chip::Inet; diff --git a/examples/darwin-framework-tool/BUILD.gn b/examples/darwin-framework-tool/BUILD.gn index cea7f9d794ff57..231ebac679b240 100644 --- a/examples/darwin-framework-tool/BUILD.gn +++ b/examples/darwin-framework-tool/BUILD.gn @@ -139,6 +139,8 @@ executable("darwin-framework-tool") { "commands/common/MTRLogging.h", "commands/pairing/Commands.h", "commands/pairing/DeviceControllerDelegateBridge.mm", + "commands/pairing/GetCommissionerNodeIdCommand.h", + "commands/pairing/GetCommissionerNodeIdCommand.mm", "commands/pairing/OpenCommissioningWindowCommand.h", "commands/pairing/OpenCommissioningWindowCommand.mm", "commands/pairing/PairingCommandBridge.mm", diff --git a/examples/darwin-framework-tool/commands/clusters/ReportCommandBridge.h b/examples/darwin-framework-tool/commands/clusters/ReportCommandBridge.h index 9b88ce50514724..97e480ac974844 100644 --- a/examples/darwin-framework-tool/commands/clusters/ReportCommandBridge.h +++ b/examples/darwin-framework-tool/commands/clusters/ReportCommandBridge.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Project CHIP Authors + * Copyright (c) 2022-2023 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -134,7 +134,7 @@ class SubscribeAttribute : public ModelCommand { params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); } if (mAutoResubscribe.HasValue()) { - params.resubscribeIfLost = mAutoResubscribe.Value(); + params.resubscribeAutomatically = mAutoResubscribe.Value(); } [device subscribeToAttributesWithEndpointID:[NSNumber numberWithUnsignedShort:endpointId] @@ -184,6 +184,24 @@ class SubscribeEvent : public ModelCommand { public: SubscribeEvent() : ModelCommand("subscribe-all-events") + { + AddCommonArguments(); + } + + SubscribeEvent(chip::ClusterId clusterId, bool isClusterAny = false) + : ModelCommand("subscribe-event-by-id") + , mClusterId(clusterId) + { + if (isClusterAny == true) { + AddArgument("cluster-id", 0, UINT32_MAX, &mClusterId); + } + AddArgument("event-id", 0, UINT32_MAX, &mEventId); + AddArgument("event-min", 0, UINT64_MAX, &mEventNumber); + AddArgument("is-urgent", 0, 1, &mIsUrgent); + AddCommonArguments(); + } + + void AddCommonArguments() { AddArgument("min-interval", 0, UINT16_MAX, &mMinInterval); AddArgument("max-interval", 0, UINT16_MAX, &mMaxInterval); @@ -199,34 +217,61 @@ class SubscribeEvent : public ModelCommand { dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); MTRSubscribeParams * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mEventNumber.HasValue()) { + params.minEventNumber = [NSNumber numberWithUnsignedLongLong:mEventNumber.Value()]; + } if (mKeepSubscriptions.HasValue()) { params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); } + if (mIsUrgent.HasValue()) { + params.reportEventsUrgently = mIsUrgent.Value(); + } if (mAutoResubscribe.HasValue()) { - params.resubscribeIfLost = mAutoResubscribe.Value(); + params.resubscribeAutomatically = mAutoResubscribe.Value(); } - [device subscribeWithQueue:callbackQueue - params:params - clusterStateCacheContainer:nil - attributeReportHandler:^(NSArray * value) { - SetCommandExitStatus(CHIP_NO_ERROR); - } - eventReportHandler:^(NSArray * value) { - for (id item in value) { - NSLog(@"Response Item: %@", [item description]); + if (strcmp(GetName(), "subscribe-event-by-id") == 0) { + [device subscribeToEventsWithEndpointID:(endpointId == chip::kInvalidEndpointId) + ? nil + : [NSNumber numberWithUnsignedShort:endpointId] + clusterID:(mClusterId == chip::kInvalidClusterId) ? nil : [NSNumber numberWithUnsignedInteger:mClusterId] + eventID:(mEventId == chip::kInvalidEventId) ? nil : [NSNumber numberWithUnsignedInteger:mEventId] + params:params + queue:callbackQueue + reportHandler:^(NSArray *> * _Nullable values, NSError * _Nullable error) { + if (values) { + for (id item in values) { + NSLog(@"Response Item: %@", [item description]); + } + } + SetCommandExitStatus(error); } - SetCommandExitStatus(CHIP_NO_ERROR); - } - errorHandler:^(NSError * error) { - SetCommandExitStatus(error); - } - subscriptionEstablished:^() { - mSubscriptionEstablished = YES; - } - resubscriptionScheduled:^(NSError * error, NSNumber * resubscriptionDelay) { - NSLog(@"Subscription dropped with error %@. Resubscription in %@ms", error, resubscriptionDelay); - }]; + subscriptionEstablished:^() { + mSubscriptionEstablished = YES; + }]; + } else { + [device subscribeWithQueue:callbackQueue + params:params + clusterStateCacheContainer:nil + attributeReportHandler:^(NSArray * value) { + SetCommandExitStatus(CHIP_NO_ERROR); + } + eventReportHandler:^(NSArray * value) { + for (id item in value) { + NSLog(@"Response Item: %@", [item description]); + } + SetCommandExitStatus(CHIP_NO_ERROR); + } + errorHandler:^(NSError * error) { + SetCommandExitStatus(error); + } + subscriptionEstablished:^() { + mSubscriptionEstablished = YES; + } + resubscriptionScheduled:^(NSError * error, NSNumber * resubscriptionDelay) { + NSLog(@"Subscription dropped with error %@. Resubscription in %@ms", error, resubscriptionDelay); + }]; + } return CHIP_NO_ERROR; } @@ -237,7 +282,82 @@ class SubscribeEvent : public ModelCommand { chip::Optional mKeepSubscriptions; chip::Optional mAutoResubscribe; chip::Optional mEventNumber; + chip::Optional mIsUrgent; bool mSubscriptionEstablished = NO; uint16_t mMinInterval; uint16_t mMaxInterval; + + void Shutdown() override + { + mSubscriptionEstablished = NO; + ModelCommand::Shutdown(); + } + + bool DeferInteractiveCleanup() override { return mSubscriptionEstablished; } + +private: + chip::ClusterId mClusterId; + chip::EventId mEventId; +}; + +class ReadEvent : public ModelCommand { +public: + ReadEvent() + : ModelCommand("read-event-by-id") + { + AddArgument("cluster-id", 0, UINT32_MAX, &mClusterId); + AddArgument("event-id", 0, UINT32_MAX, &mEventId); + AddArgument("event-min", 0, UINT64_MAX, &mEventNumber); + ModelCommand::AddArguments(); + } + + ReadEvent(chip::ClusterId clusterId) + : ModelCommand("read-event-by-id") + , mClusterId(clusterId) + { + AddArgument("event-id", 0, UINT32_MAX, &mEventId); + AddArgument("event-min", 0, UINT64_MAX, &mEventNumber); + ModelCommand::AddArguments(); + } + + ~ReadEvent() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * _Nonnull device, chip::EndpointId endpointId) override + { + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + MTRReadParams * params = [[MTRReadParams alloc] init]; + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mEventNumber.HasValue()) { + params.minEventNumber = [NSNumber numberWithUnsignedLongLong:mEventNumber.Value()]; + } + + [device + readEventsWithEndpointID:(endpointId == chip::kInvalidEndpointId) ? nil : [NSNumber numberWithUnsignedShort:endpointId] + clusterID:(mClusterId == chip::kInvalidClusterId) ? nil : [NSNumber numberWithUnsignedInteger:mClusterId] + eventID:(mEventId == chip::kInvalidEventId) ? nil : [NSNumber numberWithUnsignedInteger:mEventId] + params:params + queue:callbackQueue + completion:^(NSArray *> * _Nullable values, NSError * _Nullable error) { + if (error != nil) { + LogNSError("Error reading event", error); + } + if (values) { + for (id item in values) { + NSLog(@"Response Item: %@", [item description]); + } + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } + +protected: + chip::Optional mFabricFiltered; + chip::Optional mEventNumber; + +private: + chip::ClusterId mClusterId; + chip::AttributeId mEventId; }; diff --git a/examples/darwin-framework-tool/commands/interactive/InteractiveCommands.mm b/examples/darwin-framework-tool/commands/interactive/InteractiveCommands.mm index a251d517e6b83e..4188da365574c5 100644 --- a/examples/darwin-framework-tool/commands/interactive/InteractiveCommands.mm +++ b/examples/darwin-framework-tool/commands/interactive/InteractiveCommands.mm @@ -21,12 +21,8 @@ #include #include -#include -#include -char kInteractiveModeName[] = ""; constexpr const char * kInteractiveModePrompt = ">>> "; -constexpr uint8_t kInteractiveModeArgumentsMaxLength = 32; constexpr const char * kInteractiveModeHistoryFilePath = "/tmp/darwin_framework_tool_history"; constexpr const char * kInteractiveModeStopCommand = "quit()"; @@ -144,29 +140,7 @@ el_status_t StopFunction() return NO; } - char * args[kInteractiveModeArgumentsMaxLength]; - args[0] = kInteractiveModeName; - int argsCount = 1; - std::string arg; - - std::stringstream ss(command); - while (ss >> std::quoted(arg, '\'')) { - if (argsCount == kInteractiveModeArgumentsMaxLength) { - ChipLogError(chipTool, "Too many arguments. Ignoring."); - return YES; - } - - char * carg = new char[arg.size() + 1]; - strcpy(carg, arg.c_str()); - args[argsCount++] = carg; - } - ClearLine(); - mHandler->RunInteractive(argsCount, args); - - // Do not delete arg[0] - while (--argsCount) - delete[] args[argsCount]; - + mHandler->RunInteractive(command); return YES; } diff --git a/examples/darwin-framework-tool/commands/pairing/Commands.h b/examples/darwin-framework-tool/commands/pairing/Commands.h index 16c57b5d4ddd0f..69eb9f39352e51 100644 --- a/examples/darwin-framework-tool/commands/pairing/Commands.h +++ b/examples/darwin-framework-tool/commands/pairing/Commands.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Project CHIP Authors + * Copyright (c) 2022-2023 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -20,9 +20,10 @@ #import +#include "GetCommissionerNodeIdCommand.h" #include "OpenCommissioningWindowCommand.h" #include "PairingCommandBridge.h" -#include "PrepareCommissioningCommand.h" +#include "PreWarmCommissioningCommand.h" class PairCode : public PairingCommandBridge { @@ -72,7 +73,8 @@ void registerCommandsPairing(Commands & commands) make_unique(), make_unique(), make_unique(), - make_unique(), + make_unique(), + make_unique(), }; commands.Register(clusterName, clusterCommands); diff --git a/examples/darwin-framework-tool/commands/pairing/GetCommissionerNodeIdCommand.h b/examples/darwin-framework-tool/commands/pairing/GetCommissionerNodeIdCommand.h new file mode 100644 index 00000000000000..c07d3c2ac80899 --- /dev/null +++ b/examples/darwin-framework-tool/commands/pairing/GetCommissionerNodeIdCommand.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#pragma once + +#include "../common/CHIPCommandBridge.h" + +class GetCommissionerNodeIdCommand : public CHIPCommandBridge +{ +public: + GetCommissionerNodeIdCommand() : CHIPCommandBridge("get-commissioner-node-id") {} + + /////////// CHIPCommand Interface ///////// + CHIP_ERROR RunCommand() override; + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(0); } +}; diff --git a/examples/darwin-framework-tool/commands/pairing/GetCommissionerNodeIdCommand.mm b/examples/darwin-framework-tool/commands/pairing/GetCommissionerNodeIdCommand.mm new file mode 100644 index 00000000000000..48502f84641b58 --- /dev/null +++ b/examples/darwin-framework-tool/commands/pairing/GetCommissionerNodeIdCommand.mm @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#import + +#include "GetCommissionerNodeIdCommand.h" + +CHIP_ERROR GetCommissionerNodeIdCommand::RunCommand() +{ + auto * controller = CurrentCommissioner(); + VerifyOrReturnError(nil != controller, CHIP_ERROR_INCORRECT_STATE); + + auto id = [controller.controllerNodeId unsignedLongLongValue]; + ChipLogProgress(chipTool, "Commissioner Node Id 0x:" ChipLogFormatX64, ChipLogValueX64(id)); + + SetCommandExitStatus(CHIP_NO_ERROR); + return CHIP_NO_ERROR; +} diff --git a/examples/darwin-framework-tool/commands/pairing/PrepareCommissioningCommand.h b/examples/darwin-framework-tool/commands/pairing/PreWarmCommissioningCommand.h similarity index 75% rename from examples/darwin-framework-tool/commands/pairing/PrepareCommissioningCommand.h rename to examples/darwin-framework-tool/commands/pairing/PreWarmCommissioningCommand.h index c1fd777cf1146a..f3508b8040296c 100644 --- a/examples/darwin-framework-tool/commands/pairing/PrepareCommissioningCommand.h +++ b/examples/darwin-framework-tool/commands/pairing/PreWarmCommissioningCommand.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Project CHIP Authors + * Copyright (c) 2022-2023 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,10 +23,10 @@ #import "MTRError_Utils.h" -class PrepareCommissioningCommand : public CHIPCommandBridge { +class PreWarmCommissioningCommand : public CHIPCommandBridge { public: - PrepareCommissioningCommand() - : CHIPCommandBridge("prepare-commissioning") + PreWarmCommissioningCommand() + : CHIPCommandBridge("pre-warm-commissioning") { } @@ -35,12 +35,7 @@ class PrepareCommissioningCommand : public CHIPCommandBridge { CHIP_ERROR RunCommand() override { auto * controller = CurrentCommissioner(); - NSError * error; - if (![controller prepareCommissioningSession:&error]) { - auto err = MTRErrorToCHIPErrorCode(error); - SetCommandExitStatus(err); - return err; - } + [controller preWarmCommissioningSession]; // In interactive mode, we don't want to block the UI until the end of `GetWaitDuration`. So returns early. if (IsInteractive()) { diff --git a/examples/darwin-framework-tool/commands/provider/OTASoftwareUpdateInteractive.mm b/examples/darwin-framework-tool/commands/provider/OTASoftwareUpdateInteractive.mm index 77ca8d51a022a5..b2f2b3b0731988 100644 --- a/examples/darwin-framework-tool/commands/provider/OTASoftwareUpdateInteractive.mm +++ b/examples/darwin-framework-tool/commands/provider/OTASoftwareUpdateInteractive.mm @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2022 Project CHIP Authors + * Copyright (c) 2022-2023 Project CHIP Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,8 +38,7 @@ return nil; } - NSError * error; - return [MTROTAHeader headerFromData:[NSData dataWithBytes:buffer.data() length:buffer.size()] error:&error]; + return [[MTROTAHeader alloc] initWithData:[NSData dataWithBytes:buffer.data() length:buffer.size()]]; } // Parses the JSON filepath and extracts DeviceSoftwareVersionModel parameters diff --git a/examples/darwin-framework-tool/commands/tests/TestCommandBridge.h b/examples/darwin-framework-tool/commands/tests/TestCommandBridge.h index 7ee409968b1501..0828e1d1eccac5 100644 --- a/examples/darwin-framework-tool/commands/tests/TestCommandBridge.h +++ b/examples/darwin-framework-tool/commands/tests/TestCommandBridge.h @@ -154,9 +154,6 @@ class TestCommandBridge : public CHIPCommandBridge, VerifyOrReturnError(controller != nil, CHIP_ERROR_INCORRECT_STATE); SetIdentity(identity); - if (controller.controllerNodeId != nil) { - mCommissionerNodeId.SetValue([controller.controllerNodeId unsignedLongLongValue]); - } // Invalidate our existing CASE session; otherwise trying to work with // our device will just reuse it without establishing a new CASE @@ -184,10 +181,6 @@ class TestCommandBridge : public CHIPCommandBridge, VerifyOrReturnError(controller != nil, CHIP_ERROR_INCORRECT_STATE); SetIdentity(identity); - if (controller.controllerNodeId != nil) { - mCommissionerNodeId.SetValue([controller.controllerNodeId unsignedLongLongValue]); - } - [controller setDeviceControllerDelegate:mDeviceControllerDelegate queue:mCallbackQueue]; [mDeviceControllerDelegate setDeviceId:value.nodeId]; [mDeviceControllerDelegate setActive:YES]; @@ -208,6 +201,26 @@ class TestCommandBridge : public CHIPCommandBridge, return MTRErrorToCHIPErrorCode(err); } + CHIP_ERROR GetCommissionerNodeId(const char * _Nullable identity, + const chip::app::Clusters::CommissionerCommands::Commands::GetCommissionerNodeId::Type & value, + void (^_Nonnull OnResponse)(const chip::GetCommissionerNodeIdResponse &)) + { + auto * controller = GetCommissioner(identity); + VerifyOrReturnError(controller != nil, CHIP_ERROR_INCORRECT_STATE); + + auto id = [controller.controllerNodeId unsignedLongLongValue]; + ChipLogProgress(chipTool, "Commissioner Node Id: %llu", id); + + chip::GetCommissionerNodeIdResponse outValue; + outValue.nodeId = id; + + dispatch_async(mCallbackQueue, ^{ + OnResponse(outValue); + }); + + return CHIP_NO_ERROR; + } + /////////// SystemCommands Interface ///////// CHIP_ERROR ContinueOnChipMainThread(CHIP_ERROR err) override { @@ -226,9 +239,6 @@ class TestCommandBridge : public CHIPCommandBridge, MTRDeviceController * controller = GetCommissioner(identity); SetIdentity(identity); - if (controller != nil && controller.controllerNodeId != nil) { - mCommissionerNodeId.SetValue([controller.controllerNodeId unsignedLongLongValue]); - } return mConnectedDevices[identity]; } @@ -270,7 +280,6 @@ class TestCommandBridge : public CHIPCommandBridge, chip::Optional mPICSFilePath; chip::Optional mEndpointId; chip::Optional mTimeout; - chip::Optional mCommissionerNodeId; bool CheckConstraintStartsWith( const char * _Nonnull itemName, const NSString * _Nonnull current, const char * _Nonnull expected) @@ -589,19 +598,19 @@ NS_ASSUME_NONNULL_BEGIN using namespace chip::app::Clusters::OperationalCredentials; if (CHIP_ERROR_INVALID_PUBLIC_KEY == err) { - return StatusIB(Status::Failure, to_underlying(OperationalCertStatus::kInvalidPublicKey)); + return StatusIB(Status::Failure, to_underlying(NodeOperationalCertStatusEnum::kInvalidPublicKey)); } if (CHIP_ERROR_WRONG_NODE_ID == err) { - return StatusIB(Status::Failure, to_underlying(OperationalCertStatus::kInvalidNodeOpId)); + return StatusIB(Status::Failure, to_underlying(NodeOperationalCertStatusEnum::kInvalidNodeOpId)); } if (CHIP_ERROR_UNSUPPORTED_CERT_FORMAT == err) { - return StatusIB(Status::Failure, to_underlying(OperationalCertStatus::kInvalidNOC)); + return StatusIB(Status::Failure, to_underlying(NodeOperationalCertStatusEnum::kInvalidNOC)); } if (CHIP_ERROR_FABRIC_EXISTS == err) { - return StatusIB(Status::Failure, to_underlying(OperationalCertStatus::kFabricConflict)); + return StatusIB(Status::Failure, to_underlying(NodeOperationalCertStatusEnum::kFabricConflict)); } if (CHIP_ERROR_INVALID_FABRIC_INDEX == err) { - return StatusIB(Status::Failure, to_underlying(OperationalCertStatus::kInvalidFabricIndex)); + return StatusIB(Status::Failure, to_underlying(NodeOperationalCertStatusEnum::kInvalidFabricIndex)); } return StatusIB(err); diff --git a/examples/darwin-framework-tool/templates/commands.zapt b/examples/darwin-framework-tool/templates/commands.zapt index 0b6f7367cb3d98..9db578ce5a1134 100644 --- a/examples/darwin-framework-tool/templates/commands.zapt +++ b/examples/darwin-framework-tool/templates/commands.zapt @@ -231,7 +231,7 @@ public: params.filterByFabric = mFabricFiltered.Value(); } if (mAutoResubscribe.HasValue()) { - params.resubscribeIfLost = mAutoResubscribe.Value(); + params.resubscribeAutomatically = mAutoResubscribe.Value(); } [cluster subscribe{{>attribute}}WithParams:params subscriptionEstablished:^(){ mSubscriptionEstablished=YES; } @@ -292,6 +292,12 @@ void registerCluster{{asUpperCamelCase name}}(Commands & commands) {{/if}} {{/unless}} {{/chip_server_cluster_attributes}} + {{#zcl_events}} + {{#first}} + make_unique(Id), // + make_unique(Id), // + {{/first}} + {{/zcl_events}} }; commands.Register(clusterName, clusterCommands); @@ -308,6 +314,8 @@ void registerClusterAny(Commands & commands) make_unique(), // make_unique(), // make_unique(), // + make_unique(), // + make_unique(chip::kInvalidClusterId, true), // make_unique(), // }; diff --git a/examples/darwin-framework-tool/templates/tests/ciTests.json b/examples/darwin-framework-tool/templates/tests/ciTests.json index 77f97d3ce7e0a3..98bff77d169c2f 100644 --- a/examples/darwin-framework-tool/templates/tests/ciTests.json +++ b/examples/darwin-framework-tool/templates/tests/ciTests.json @@ -27,6 +27,8 @@ "Test_TC_TSTAT_2_2", "Test_TC_ACL_2_4", "Test_TC_ACL_2_7", - "Test_TC_ACL_2_9" + "Test_TC_ACL_2_8", + "Test_TC_ACL_2_9", + "Test_TC_ACL_2_10" ] } diff --git a/examples/darwin-framework-tool/templates/tests/partials/test_cluster.zapt b/examples/darwin-framework-tool/templates/tests/partials/test_cluster.zapt index ab878c23fd6846..a3d06aa879cebe 100644 --- a/examples/darwin-framework-tool/templates/tests/partials/test_cluster.zapt +++ b/examples/darwin-framework-tool/templates/tests/partials/test_cluster.zapt @@ -23,17 +23,10 @@ class {{filename}}: public TestCommandBridge { } - // Allow yaml to access the current commissioner node id. - // Default to 0 (undefined node id) so we know if this isn't - // set correctly. - // Reset on every step in case it changed. - chip::NodeId commissionerNodeId = mCommissionerNodeId.ValueOr(0); - /////////// TestCommand Interface ///////// void NextTest() override { CHIP_ERROR err = CHIP_NO_ERROR; - commissionerNodeId = mCommissionerNodeId.ValueOr(0); if (0 == mTestIndex) { @@ -140,10 +133,31 @@ class {{filename}}: public TestCommandBridge {{#chip_tests_item_parameters}} {{>commandValue ns=parent.cluster container=(asPropertyValue dontUnwrapValue=true) definedValue=definedValue depth=0}} {{/chip_tests_item_parameters}} + {{#if (and (isStrEqual cluster "CommissionerCommands") (isStrEqual command "GetCommissionerNodeId"))}} + return {{command}}("{{identity}}", value, ^(const chip::{{command}}Response & values) { + {{#chip_tests_item_responses}} + {{#chip_tests_item_response_parameters}} + {{#if hasExpectedValue}} + { + id actualValue = values.{{asStructPropertyName name}} + {{>check_test_value actual="actualValue" expected=expectedValue cluster=../cluster}} + } + {{/if}} + {{>maybeCheckExpectedConstraints}} + {{#if saveAs}} + { + {{saveAs}} = [[NSNumber alloc] initWithUnsignedLongLong:values.{{asStructPropertyName name}}]; + } + {{/if}} + {{/chip_tests_item_response_parameters}} + {{/chip_tests_item_responses}} + NextTest(); + }); + {{else}} return {{command}}("{{identity}}", value); + {{/if}} {{else}} MTRBaseDevice * device = GetDevice("{{identity}}"); - commissionerNodeId = mCommissionerNodeId.ValueOr(0); __auto_type * cluster = [[MTRBaseCluster{{>cluster}} alloc] initWithDevice:device endpointID:@({{endpoint}}) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); diff --git a/examples/dynamic-bridge-app/bridge-common/bridge-app.matter b/examples/dynamic-bridge-app/bridge-common/bridge-app.matter index 9a5e0494d24228..d163a578653bf5 100644 --- a/examples/dynamic-bridge-app/bridge-common/bridge-app.matter +++ b/examples/dynamic-bridge-app/bridge-common/bridge-app.matter @@ -75,10 +75,6 @@ server cluster OnOff = 6 { kLighting = 0x1; } - bitmap SceneFeatures : BITMAP32 { - kSceneNames = 0x1; - } - readonly attribute boolean onOff = 0; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -801,7 +797,7 @@ server cluster GeneralDiagnostics = 51 { kSoftwareReset = 6; } - enum HardwareFault : ENUM8 { + enum HardwareFaultEnum : ENUM8 { kUnspecified = 0; kRadio = 1; kSensor = 2; @@ -815,7 +811,7 @@ server cluster GeneralDiagnostics = 51 { kTamperDetected = 10; } - enum InterfaceType : ENUM8 { + enum InterfaceTypeEnum : ENUM8 { kUnspecified = 0; kWiFi = 1; kEthernet = 2; @@ -823,14 +819,14 @@ server cluster GeneralDiagnostics = 51 { kThread = 4; } - enum NetworkFaultType : ENUM8 { + enum NetworkFaultEnum : ENUM8 { kUnspecified = 0; kHardwareFailure = 1; kNetworkJammed = 2; kConnectionFailed = 3; } - enum RadioFault : ENUM8 { + enum RadioFaultEnum : ENUM8 { kUnspecified = 0; kWiFiFault = 1; kCellularFault = 2; @@ -848,22 +844,22 @@ server cluster GeneralDiagnostics = 51 { octet_string<8> hardwareAddress = 4; octet_string IPv4Addresses[] = 5; octet_string IPv6Addresses[] = 6; - InterfaceType type = 7; + InterfaceTypeEnum type = 7; } critical event HardwareFaultChange = 0 { - HardwareFault current[] = 0; - HardwareFault previous[] = 1; + HardwareFaultEnum current[] = 0; + HardwareFaultEnum previous[] = 1; } critical event RadioFaultChange = 1 { - RadioFault current[] = 0; - RadioFault previous[] = 1; + RadioFaultEnum current[] = 0; + RadioFaultEnum previous[] = 1; } critical event NetworkFaultChange = 2 { - NetworkFaultType current[] = 0; - NetworkFaultType previous[] = 1; + NetworkFaultEnum current[] = 0; + NetworkFaultEnum previous[] = 1; } critical event BootReason = 3 { @@ -875,9 +871,9 @@ server cluster GeneralDiagnostics = 51 { readonly attribute int64u upTime = 2; readonly attribute int32u totalOperationalHours = 3; readonly attribute BootReasonEnum bootReason = 4; - readonly attribute HardwareFault activeHardwareFaults[] = 5; - readonly attribute RadioFault activeRadioFaults[] = 6; - readonly attribute NetworkFaultType activeNetworkFaults[] = 7; + readonly attribute HardwareFaultEnum activeHardwareFaults[] = 5; + readonly attribute RadioFaultEnum activeRadioFaults[] = 6; + readonly attribute NetworkFaultEnum activeNetworkFaults[] = 7; readonly attribute boolean testEventTriggersEnabled = 8; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; @@ -1107,6 +1103,11 @@ server cluster WiFiNetworkDiagnostics = 54 { kAx = 5; } + bitmap WiFiNetworkDiagnosticsFeature : BITMAP32 { + kPacketCounts = 0x1; + kErrorCounts = 0x2; + } + info event Disconnection = 0 { INT16U reasonCode = 0; } @@ -1138,7 +1139,7 @@ server cluster WiFiNetworkDiagnostics = 54 { } server cluster EthernetNetworkDiagnostics = 55 { - enum PHYRate : ENUM8 { + enum PHYRateEnum : ENUM8 { kRate10M = 0; kRate100M = 1; kRate1G = 2; @@ -1151,7 +1152,12 @@ server cluster EthernetNetworkDiagnostics = 55 { kRate400G = 9; } - readonly attribute nullable PHYRate PHYRate = 0; + bitmap EthernetNetworkDiagnosticsFeature : BITMAP32 { + kPacketCounts = 0x1; + kErrorCounts = 0x2; + } + + readonly attribute nullable PHYRateEnum PHYRate = 0; readonly attribute nullable boolean fullDuplex = 1; readonly attribute int64u packetRxCount = 2; readonly attribute int64u packetTxCount = 3; @@ -1213,7 +1219,7 @@ server cluster Switch = 59 { } server cluster AdministratorCommissioning = 60 { - enum CommissioningWindowStatus : ENUM8 { + enum CommissioningWindowStatusEnum : ENUM8 { kWindowNotOpen = 0; kEnhancedWindowOpen = 1; kBasicWindowOpen = 2; @@ -1225,7 +1231,7 @@ server cluster AdministratorCommissioning = 60 { kWindowNotOpen = 4; } - readonly attribute CommissioningWindowStatus windowStatus = 0; + readonly attribute CommissioningWindowStatusEnum windowStatus = 0; readonly attribute nullable fabric_idx adminFabricIndex = 1; readonly attribute nullable int16u adminVendorId = 2; readonly attribute command_id generatedCommandList[] = 65528; @@ -1252,8 +1258,13 @@ server cluster AdministratorCommissioning = 60 { } server cluster OperationalCredentials = 62 { - enum OperationalCertStatus : ENUM8 { - kSuccess = 0; + enum CertificateChainTypeEnum : ENUM8 { + kDACCertificate = 1; + kPAICertificate = 2; + } + + enum NodeOperationalCertStatusEnum : ENUM8 { + kOk = 0; kInvalidPublicKey = 1; kInvalidNodeOpId = 2; kInvalidNOC = 3; @@ -1271,17 +1282,17 @@ server cluster OperationalCredentials = 62 { fabric_idx fabricIndex = 254; } - fabric_scoped struct FabricDescriptor { + fabric_scoped struct FabricDescriptorStruct { octet_string<65> rootPublicKey = 1; - vendor_id vendorId = 2; - fabric_id fabricId = 3; - node_id nodeId = 4; + vendor_id vendorID = 2; + fabric_id fabricID = 3; + node_id nodeID = 4; char_string<32> label = 5; fabric_idx fabricIndex = 254; } readonly attribute access(read: administer) NOCStruct NOCs[] = 0; - readonly attribute FabricDescriptor fabrics[] = 1; + readonly attribute FabricDescriptorStruct fabrics[] = 1; readonly attribute int8u supportedFabrics = 2; readonly attribute int8u commissionedFabrics = 3; readonly attribute OCTET_STRING trustedRootCertificates[] = 4; @@ -1297,7 +1308,7 @@ server cluster OperationalCredentials = 62 { } request struct CertificateChainRequestRequest { - INT8U certificateType = 0; + CertificateChainTypeEnum certificateType = 0; } request struct CSRRequestRequest { @@ -1327,12 +1338,12 @@ server cluster OperationalCredentials = 62 { } request struct AddTrustedRootCertificateRequest { - OCTET_STRING rootCertificate = 0; + OCTET_STRING rootCACertificate = 0; } response struct AttestationResponse = 1 { OCTET_STRING attestationElements = 0; - OCTET_STRING signature = 1; + OCTET_STRING attestationSignature = 1; } response struct CertificateChainResponse = 3 { @@ -1345,7 +1356,7 @@ server cluster OperationalCredentials = 62 { } response struct NOCResponse = 8 { - OperationalCertStatus statusCode = 0; + NodeOperationalCertStatusEnum statusCode = 0; optional fabric_idx fabricIndex = 1; optional CHAR_STRING debugText = 2; } @@ -1473,7 +1484,7 @@ endpoint 0 { callback attribute extension; callback attribute subjectsPerAccessControlEntry default = 4; callback attribute targetsPerAccessControlEntry default = 3; - callback attribute accessControlEntriesPerFabric default = 3; + callback attribute accessControlEntriesPerFabric default = 4; callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute attributeList; diff --git a/examples/dynamic-bridge-app/bridge-common/bridge-app.zap b/examples/dynamic-bridge-app/bridge-common/bridge-app.zap index 28c59bdbd6369e..63842b374dc5a8 100644 --- a/examples/dynamic-bridge-app/bridge-common/bridge-app.zap +++ b/examples/dynamic-bridge-app/bridge-common/bridge-app.zap @@ -358,7 +358,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "4", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -3855,7 +3855,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "PHYRate", + "type": "PHYRateEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -4029,7 +4029,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4097,7 +4097,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4109,7 +4109,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "CommissioningWindowStatus", + "type": "CommissioningWindowStatusEnum", "included": 1, "storageOption": "External", "singleton": 0, diff --git a/examples/dynamic-bridge-app/linux/BUILD.gn b/examples/dynamic-bridge-app/linux/BUILD.gn index 1ed00756d01bcc..03e3cb4fcee25b 100644 --- a/examples/dynamic-bridge-app/linux/BUILD.gn +++ b/examples/dynamic-bridge-app/linux/BUILD.gn @@ -115,6 +115,8 @@ executable("dynamic-chip-bridge-app") { } output_dir = root_out_dir + + configs += ["${chip_root}/src:includes"] } group("linux") { diff --git a/examples/dynamic-bridge-app/linux/DynamicDevice.cpp b/examples/dynamic-bridge-app/linux/DynamicDevice.cpp index e9b99c94b0537a..94ef87edfbc1e4 100644 --- a/examples/dynamic-bridge-app/linux/DynamicDevice.cpp +++ b/examples/dynamic-bridge-app/linux/DynamicDevice.cpp @@ -18,7 +18,7 @@ */ #include -#include +#include #include #include "DynamicDevice.h" @@ -31,10 +31,14 @@ namespace { static const int kDescriptorAttributeArraySize = 254; DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(descriptorAttrs) -DECLARE_DYNAMIC_ATTRIBUTE(ZCL_DEVICE_LIST_ATTRIBUTE_ID, ARRAY, kDescriptorAttributeArraySize, 0), /* device list */ - DECLARE_DYNAMIC_ATTRIBUTE(ZCL_SERVER_LIST_ATTRIBUTE_ID, ARRAY, kDescriptorAttributeArraySize, 0), /* server list */ - DECLARE_DYNAMIC_ATTRIBUTE(ZCL_CLIENT_LIST_ATTRIBUTE_ID, ARRAY, kDescriptorAttributeArraySize, 0), /* client list */ - DECLARE_DYNAMIC_ATTRIBUTE(ZCL_PARTS_LIST_ATTRIBUTE_ID, ARRAY, kDescriptorAttributeArraySize, 0), /* parts list */ +DECLARE_DYNAMIC_ATTRIBUTE(chip::app::Clusters::Descriptor::Attributes::DeviceTypeList::Id, ARRAY, kDescriptorAttributeArraySize, + 0), /* device list */ + DECLARE_DYNAMIC_ATTRIBUTE(chip::app::Clusters::Descriptor::Attributes::ServerList::Id, ARRAY, kDescriptorAttributeArraySize, + 0), /* server list */ + DECLARE_DYNAMIC_ATTRIBUTE(chip::app::Clusters::Descriptor::Attributes::ClientList::Id, ARRAY, kDescriptorAttributeArraySize, + 0), /* client list */ + DECLARE_DYNAMIC_ATTRIBUTE(chip::app::Clusters::Descriptor::Attributes::PartsList::Id, ARRAY, kDescriptorAttributeArraySize, + 0), /* parts list */ DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); } // namespace diff --git a/examples/dynamic-bridge-app/linux/README.md b/examples/dynamic-bridge-app/linux/README.md index aff20863c752c7..1e1d4f3fb9f141 100644 --- a/examples/dynamic-bridge-app/linux/README.md +++ b/examples/dynamic-bridge-app/linux/README.md @@ -87,7 +87,7 @@ clusters as well as the root descriptor cluster. The example demonstrates the use of dynamic endpoints and the concept of adding and removing endpoints at runtime. First, the example declares a `bridgedLightEndpoint` data structure for a Light endpoint with `OnOff`, -`Descriptor`, `BridgedDeviceBasic`, and `FixedLabel` clusters. +`Descriptor`, `BridgedDeviceBasicInformation`, and `FixedLabel` clusters. Using this declared endpoint structure, three endpoints for three bridged lights are dynamically added at endpoint ID's `2`, `3`, and `4`, representing @@ -99,10 +99,10 @@ A fourth light, `Light 4`, is then added occupying endpoint ID `5`. Finally, `Light 2` is re-added, and will occupy endpoint ID `6`. -All endpoints populate the `Bridged Device Basic` and `Fixed Label` clusters. In -the `Bridged Device Basic` cluster, the `reachable` attribute is simulated. In -the `Fixed Label` cluster, the `LabelList` attribute is simulated with the -value/label pair `"room"`/`[light name]`. +All endpoints populate the `Bridged Device Basic Information` and `Fixed Label` +clusters. In the `Bridged Device Basic Information` cluster, the `reachable` +attribute is simulated. In the `Fixed Label` cluster, the `LabelList` attribute +is simulated with the value/label pair `"room"`/`[light name]`. ## Building diff --git a/examples/dynamic-bridge-app/linux/UserInputBackend.cpp b/examples/dynamic-bridge-app/linux/UserInputBackend.cpp index 9bdf4b8e689710..5347919a552d30 100644 --- a/examples/dynamic-bridge-app/linux/UserInputBackend.cpp +++ b/examples/dynamic-bridge-app/linux/UserInputBackend.cpp @@ -2,6 +2,7 @@ #include "DynamicDevice.h" #include "main.h" +#include #include #include @@ -120,7 +121,8 @@ void AddCluster(const std::vector & tokens) auto c = CreateCluster(cluster_name.c_str()); if (c) { - g_pending->AddCluster(std::make_unique(std::move(c))); + g_pending->AddCluster( + std::make_unique(std::move(c), c->GetIncomingCommandList(), c->GetOutgoingCommandList())); } else { @@ -285,20 +287,20 @@ void ParseValue(std::vector * data, uint16_t size, const std::string & { case ZCL_OCTET_STRING_ATTRIBUTE_TYPE: case ZCL_CHAR_STRING_ATTRIBUTE_TYPE: - wr.PutString(chip::TLV::Tag(), str.data(), (uint32_t) str.size()); + wr.PutString(chip::TLV::AnonymousTag(), str.data(), (uint32_t) str.size()); break; case ZCL_LONG_OCTET_STRING_ATTRIBUTE_TYPE: case ZCL_LONG_CHAR_STRING_ATTRIBUTE_TYPE: - wr.PutBytes(chip::TLV::Tag(), (const uint8_t *) str.data(), (uint32_t) str.size()); + wr.PutBytes(chip::TLV::AnonymousTag(), (const uint8_t *) str.data(), (uint32_t) str.size()); break; case ZCL_STRUCT_ATTRIBUTE_TYPE: // Writing structs not supported yet break; case ZCL_SINGLE_ATTRIBUTE_TYPE: - wr.Put(chip::TLV::Tag(), (float) atof(str.c_str())); + wr.Put(chip::TLV::AnonymousTag(), (float) atof(str.c_str())); break; case ZCL_DOUBLE_ATTRIBUTE_TYPE: - wr.Put(chip::TLV::Tag(), atof(str.c_str())); + wr.Put(chip::TLV::AnonymousTag(), atof(str.c_str())); break; case ZCL_INT8S_ATTRIBUTE_TYPE: case ZCL_INT16S_ATTRIBUTE_TYPE: @@ -308,7 +310,7 @@ void ParseValue(std::vector * data, uint16_t size, const std::string & case ZCL_INT48S_ATTRIBUTE_TYPE: case ZCL_INT56S_ATTRIBUTE_TYPE: case ZCL_INT64S_ATTRIBUTE_TYPE: - wr.Put(chip::TLV::Tag(), (int64_t) strtoll(str.c_str(), nullptr, 10)); + wr.Put(chip::TLV::AnonymousTag(), (int64_t) strtoll(str.c_str(), nullptr, 10)); break; case ZCL_INT8U_ATTRIBUTE_TYPE: @@ -319,12 +321,12 @@ void ParseValue(std::vector * data, uint16_t size, const std::string & case ZCL_INT48U_ATTRIBUTE_TYPE: case ZCL_INT56U_ATTRIBUTE_TYPE: case ZCL_INT64U_ATTRIBUTE_TYPE: - wr.Put(chip::TLV::Tag(), (uint64_t) strtoll(str.c_str(), nullptr, 10)); + wr.Put(chip::TLV::AnonymousTag(), (uint64_t) strtoll(str.c_str(), nullptr, 10)); break; default: // Assume integer - wr.Put(chip::TLV::Tag(), (int64_t) strtoll(str.c_str(), nullptr, 10)); + wr.Put(chip::TLV::AnonymousTag(), (int64_t) strtoll(str.c_str(), nullptr, 10)); break; } wr.Finalize(); diff --git a/examples/dynamic-bridge-app/linux/bridge_service.h b/examples/dynamic-bridge-app/linux/bridge_service.h index faa744e7fba228..4e5cc1e057b4dc 100644 --- a/examples/dynamic-bridge-app/linux/bridge_service.h +++ b/examples/dynamic-bridge-app/linux/bridge_service.h @@ -21,8 +21,6 @@ #include "app/util/attribute-storage.h" #include "bridge_service/bridge_service.rpc.pb.h" #include "pigweed/rpc_services/internal/StatusUtils.h" -#include -#include #include namespace chip { diff --git a/examples/dynamic-bridge-app/linux/include/ActionCluster.h b/examples/dynamic-bridge-app/linux/include/ActionCluster.h index 4253cb1d3244ff..a5a830c044710d 100644 --- a/examples/dynamic-bridge-app/linux/include/ActionCluster.h +++ b/examples/dynamic-bridge-app/linux/include/ActionCluster.h @@ -18,7 +18,7 @@ #pragma once -#include +#include #include #include diff --git a/examples/dynamic-bridge-app/linux/include/Device.h b/examples/dynamic-bridge-app/linux/include/Device.h index 9cac09efe6f699..1ecf4d6bac4f2e 100644 --- a/examples/dynamic-bridge-app/linux/include/Device.h +++ b/examples/dynamic-bridge-app/linux/include/Device.h @@ -18,7 +18,7 @@ #pragma once -#include +#include #include #include diff --git a/examples/dynamic-bridge-app/linux/include/GeneratedClusters.h b/examples/dynamic-bridge-app/linux/include/GeneratedClusters.h index 99f1c5e06bc98b..02ad1aaeaf7423 100644 --- a/examples/dynamic-bridge-app/linux/include/GeneratedClusters.h +++ b/examples/dynamic-bridge-app/linux/include/GeneratedClusters.h @@ -8,13 +8,13 @@ #include "data-model/Attribute.h" // Required for default initialization of cluster revisions. -static constexpr uint16_t ZCL_DESCRIPTOR_CLUSTER_REVISION = 1; -static constexpr uint16_t ZCL_BRIDGED_DEVICE_BASIC_CLUSTER_REVISION = 1; -static constexpr uint16_t ZCL_FIXED_LABEL_CLUSTER_REVISION = 1; -static constexpr uint16_t ZCL_ON_OFF_CLUSTER_REVISION = 4; -static constexpr uint16_t ZCL_SWITCH_CLUSTER_REVISION = 1; -static constexpr uint16_t ZCL_LEVEL_CONTROL_CLUSTER_REVISION = 1; -static constexpr uint16_t ZCL_TEMPERATURE_MEASUREMENT_CLUSTER_REVISION = 1; +static constexpr uint16_t ZCL_DESCRIPTOR_CLUSTER_REVISION = 1; +static constexpr uint16_t ZCL_BRIDGED_DEVICE_BASIC_INFORMATION_CLUSTER_REVISION = 1; +static constexpr uint16_t ZCL_FIXED_LABEL_CLUSTER_REVISION = 1; +static constexpr uint16_t ZCL_ON_OFF_CLUSTER_REVISION = 4; +static constexpr uint16_t ZCL_SWITCH_CLUSTER_REVISION = 1; +static constexpr uint16_t ZCL_LEVEL_CONTROL_CLUSTER_REVISION = 1; +static constexpr uint16_t ZCL_TEMPERATURE_MEASUREMENT_CLUSTER_REVISION = 1; class GeneratedCluster { @@ -24,4 +24,16 @@ class GeneratedCluster virtual chip::ClusterId GetClusterId() = 0; // Gets the list of available attributes for this cluster. virtual std::vector GetAttributes() = 0; + + // Returns a list of client to server commands. Can be nullptr or terminated by 0xFFFF_FFFF. + // The returned list mirrors the `acceptedCommandList` field in `EmberAfCluster` + // This function is used to pass a command list when creating a `DynamicCluster` and its underlying `EmberAfCluster`. See + // `AddCluster` in `UserInputBackend`. + virtual const chip::CommandId * GetIncomingCommandList() { return nullptr; } + + // Returns a list of server generated commands (responses to client commands). Can be nullptr or terminated by 0xFFFF_FFFF. + // The returned list mirrors the `generatedCommandList` field in `EmberAfCluster` + // This function is used to pass a command list when creating a `DynamicCluster` and its underlying `EmberAfCluster`. See + // `AddCluster` in `UserInputBackend`. + virtual const chip::CommandId * GetOutgoingCommandList() { return nullptr; } }; diff --git a/examples/dynamic-bridge-app/linux/include/data-model/Attribute.h b/examples/dynamic-bridge-app/linux/include/data-model/Attribute.h index 7a7be2a997036c..8a75f811c4b3bc 100644 --- a/examples/dynamic-bridge-app/linux/include/data-model/Attribute.h +++ b/examples/dynamic-bridge-app/linux/include/data-model/Attribute.h @@ -27,6 +27,8 @@ class AttributeInterface // Read the contents of the attribute. virtual CHIP_ERROR Read(const chip::app::ConcreteReadAttributePath & aPath, chip::app::AttributeValueEncoder & aEncoder) = 0; + + virtual CHIP_ERROR Read(const chip::app::ConcreteReadAttributePath & aPath, chip::TLV::TLVWriter & writer) = 0; }; // This is the base type for implementing an attribute @@ -52,6 +54,23 @@ struct Attribute : public AttributeInterface return chip::app::DataModel::Encode(aPath, aEncoder, mData); } + template >::value, bool> = true> + CHIP_ERROR ReadValue(const chip::app::ConcreteReadAttributePath & aPath, chip::TLV::TLVWriter & writer, Type & value) + { + return chip::app::DataModel::Encode(aPath, writer, chip::TLV::AnonymousTag(), value); + } + + template >::value, bool> = true> + CHIP_ERROR ReadValue(const chip::app::ConcreteReadAttributePath & aPath, chip::TLV::TLVWriter & writer, Type & value) + { + return chip::app::DataModel::Encode(writer, chip::TLV::AnonymousTag(), value); + } + + CHIP_ERROR Read(const chip::app::ConcreteReadAttributePath & aPath, chip::TLV::TLVWriter & writer) override + { + return ReadValue(aPath, writer, mData); + } + void operator=(const Type & value) { mData = value; } const Type & Peek() const { return mData; } diff --git a/examples/dynamic-bridge-app/linux/include/data-model/DataModel.h b/examples/dynamic-bridge-app/linux/include/data-model/DataModel.h index fde7bf07841f43..6f78787830e3f3 100644 --- a/examples/dynamic-bridge-app/linux/include/data-model/DataModel.h +++ b/examples/dynamic-bridge-app/linux/include/data-model/DataModel.h @@ -65,6 +65,7 @@ CHIP_ERROR Encode(const ConcreteReadAttributePath &, AttributeValueEncoder & aEn /* * @brief * Lists that are string-like should be encoded as char/byte spans. + * Encode using a given AttributeValueEncoder. */ template < typename X, @@ -74,11 +75,26 @@ CHIP_ERROR Encode(const ConcreteReadAttributePath & aPath, AttributeValueEncoder return aEncoder.Encode(Span>(x.data(), x.size())); } +/* + * @brief + * Lists that are string-like should be encoded as char/byte spans. + * Encode using a given TLVWriter. + */ +template < + typename X, + std::enable_if_t>::value && sizeof(std::decay_t) == sizeof(char), bool> = true> +CHIP_ERROR Encode(const ConcreteReadAttributePath & aPath, TLV::TLVWriter & writer, TLV::Tag tag, const X & x) +{ + return writer.Put(tag, Span>(x.data(), x.size())); +} + /* * @brief * * If an item is requested from a list, encode just that single item, or the entire list otherwise. * + * Encodes items using a given AttributeValueEncoder. + * * The object must satisfy the following constraints * size() must return an integer * begin() must return a type conforming to LegacyRandomAccessIterator @@ -113,6 +129,46 @@ CHIP_ERROR Encode(const ConcreteReadAttributePath & aPath, AttributeValueEncoder }); } +/* + * @brief + * + * If an item is requested from a list, encode just that single item, or the entire list otherwise. + * + * Encodes items using a given TLVWriter. + * + * The object must satisfy the following constraints + * size() must return an integer + * begin() must return a type conforming to LegacyRandomAccessIterator + * + * This is const X& instead of X&& because it is "more specialized" and so this overload will + * be chosen if possible. + */ +template < + typename X, + std::enable_if_t>::value && (sizeof(std::decay_t) > sizeof(char)), bool> = true> +CHIP_ERROR Encode(const ConcreteReadAttributePath & aPath, TLV::TLVWriter & writer, TLV::Tag tag, const X & x) +{ + if (aPath.mListIndex.HasValue()) + { + uint16_t index = aPath.mListIndex.Value(); + if (index >= x.size()) + return CHIP_ERROR_INVALID_ARGUMENT; + + auto it = x.begin(); + std::advance(it, index); + return Encode(writer, tag, *it); + } + TLV::TLVType type; + + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Array, type)); + for (auto & item : x) + { + ReturnErrorOnFailure(Encode(writer, tag, item)); + } + ReturnErrorOnFailure(writer.EndContainer(type)); + return CHIP_NO_ERROR; +} + /* * @brief * Set of overloaded encode methods that can be called from AttributeAccessInterface::Read diff --git a/examples/dynamic-bridge-app/linux/include/main.h b/examples/dynamic-bridge-app/linux/include/main.h index 30df5ae0248f9c..d11982d85fbc55 100644 --- a/examples/dynamic-bridge-app/linux/include/main.h +++ b/examples/dynamic-bridge-app/linux/include/main.h @@ -62,3 +62,5 @@ chip::Span GetActionListInfo(chip::EndpointId parentId); chip::Optional LookupClusterByName(const char * name); std::unique_ptr CreateCluster(const char * name); std::unique_ptr CreateCluster(chip::ClusterId id); +EmberAfStatus HandleReadOnOffAttribute(Attribute * attribute, uint8_t * buffer, uint16_t maxReadLength); +EmberAfStatus HandleWriteOnOffAttribute(Attribute * attribute, uint8_t * buffer); diff --git a/examples/dynamic-bridge-app/linux/main.cpp b/examples/dynamic-bridge-app/linux/main.cpp index 1c6ed2300771c7..1bbe05ef64aced 100644 --- a/examples/dynamic-bridge-app/linux/main.cpp +++ b/examples/dynamic-bridge-app/linux/main.cpp @@ -22,7 +22,7 @@ #include -#include +#include #include #include #include @@ -85,6 +85,8 @@ struct CommonAttributeAccessInterface : public chip::app::AttributeAccessInterfa CHIP_ERROR Read(const chip::app::ConcreteReadAttributePath & aPath, chip::app::AttributeValueEncoder & aEncoder) override; CHIP_ERROR Write(const chip::app::ConcreteDataAttributePath & aPath, chip::app::AttributeValueDecoder & aDecoder) override; + CHIP_ERROR Read(const chip::app::ConcreteReadAttributePath & aPath, TLV::TLVWriter & writer); + void OnListWriteBegin(const chip::app::ConcreteAttributePath & aPath) override; void OnListWriteEnd(const chip::app::ConcreteAttributePath & aPath, bool aWriteWasSuccessful) override; }; @@ -97,7 +99,9 @@ CommonCluster * CommonAttributeAccessInterface::FindCluster(const chip::app::Con for (auto c : dev->clusters()) { if (c->GetClusterId() == path.mClusterId) + { return static_cast(c); + } } } return nullptr; @@ -108,10 +112,14 @@ CHIP_ERROR CommonAttributeAccessInterface::Read(const chip::app::ConcreteReadAtt { CommonCluster * c = FindCluster(aPath); if (!c) - return CHIP_ERROR_NOT_IMPLEMENTED; + { + return CHIP_ERROR_NOT_FOUND; + } AttributeInterface * a = c->FindAttribute(aPath.mAttributeId); if (!a) - return CHIP_ERROR_NOT_IMPLEMENTED; + { + return CHIP_ERROR_NOT_FOUND; + } return a->Read(aPath, aEncoder); } @@ -120,10 +128,27 @@ CHIP_ERROR CommonAttributeAccessInterface::Write(const chip::app::ConcreteDataAt { CommonCluster * c = FindCluster(aPath); if (!c) - return CHIP_ERROR_NOT_IMPLEMENTED; + { + return CHIP_ERROR_NOT_FOUND; + } return c->ForwardWriteToBridge(aPath, aDecoder); } +CHIP_ERROR CommonAttributeAccessInterface::Read(const chip::app::ConcreteReadAttributePath & aPath, chip::TLV::TLVWriter & writer) +{ + CommonCluster * c = FindCluster(aPath); + if (!c) + { + return CHIP_ERROR_NOT_FOUND; + } + AttributeInterface * a = c->FindAttribute(aPath.mAttributeId); + if (!a) + { + return CHIP_ERROR_NOT_FOUND; + } + return a->Read(aPath, writer); +} + void CommonAttributeAccessInterface::OnListWriteBegin(const chip::app::ConcreteAttributePath & aPath) { CommonCluster * c = FindCluster(aPath); @@ -131,7 +156,9 @@ void CommonAttributeAccessInterface::OnListWriteBegin(const chip::app::ConcreteA { AttributeInterface * a = c->FindAttribute(aPath.mAttributeId); if (a) + { a->ListWriteBegin(aPath); + } } } @@ -142,7 +169,9 @@ void CommonAttributeAccessInterface::OnListWriteEnd(const chip::app::ConcreteAtt { AttributeInterface * a = c->FindAttribute(aPath.mAttributeId); if (a) + { a->ListWriteEnd(aPath, aWriteWasSuccessful); + } } } @@ -176,6 +205,134 @@ std::unique_ptr CreateCluster(chip::ClusterId id) return nullptr; } +CHIP_ERROR TLVWriteValue(chip::TLV::TLVWriter & wr, const Span & v) +{ + return wr.PutString(chip::TLV::AnonymousTag(), v); +} + +CHIP_ERROR TLVWriteValue(chip::TLV::TLVWriter & wr, const bool & v) +{ + return wr.PutBoolean(chip::TLV::AnonymousTag(), v); +} + +template +CHIP_ERROR TLVWriteValue(chip::TLV::TLVWriter & wr, const T & v) +{ + return wr.Put(chip::TLV::AnonymousTag(), v); +} + +CHIP_ERROR WriteValueToBuffer(const bool & value, chip::Span buffer) +{ + if (buffer.size() != 1) + { + return CHIP_ERROR_INVALID_ARGUMENT; + } + *(buffer.data()) = value ? 1 : 0; + return CHIP_NO_ERROR; +} + +template +CHIP_ERROR WriteValueToBuffer(const T & value, chip::Span buffer) +{ + size_t value_size = sizeof(value); + if (buffer.size() != value_size) + { + return CHIP_ERROR_INVALID_ARGUMENT; + } + memcpy(buffer.data(), &value, value_size); + return CHIP_NO_ERROR; +} + +template +CHIP_ERROR WriteValueToBuffer(chip::TLV::TLVReader & reader, chip::Span buffer) +{ + T v; + ReturnErrorOnFailure(chip::app::DataModel::Decode(reader, v)); + return WriteValueToBuffer(v, buffer); +} + +// Describes a conversion direction between: +// - A binary buffer (passed from ember internals) +// - A TLV data buffer (used by TLVWriter and TLVReader) +enum ConversionDirection +{ + BUFFER_TO_TLV, + TLV_TO_BUFFER +}; + +template +CHIP_ERROR PerformTLVBufferConversion(std::vector * tlvData, chip::Span buffer, + ConversionDirection convert_direction) +{ + CHIP_ERROR err; + if (convert_direction == BUFFER_TO_TLV) + { + // buffer.size() is ignored here, because it was called from the external write ember callback, + // which does not provide a buffer size + chip::TLV::TLVWriter wr; + wr.Init(tlvData->data(), tlvData->size()); + T value; + memcpy(&value, buffer.data(), sizeof(T)); + err = TLVWriteValue(wr, value); + wr.Finalize(); + tlvData->resize(wr.GetLengthWritten()); + } + else + { + chip::TLV::TLVReader rd; + rd.Init(tlvData->data(), tlvData->size()); + rd.Next(); + err = WriteValueToBuffer(rd, buffer); + } + return err; +} + +CHIP_ERROR PerformTLVBufferConversionForType(std::vector * tlvData, chip::Span buffer, EmberAfAttributeType type, + ConversionDirection convert_direction) +{ + switch (type) + { + case ZCL_OCTET_STRING_ATTRIBUTE_TYPE: + case ZCL_CHAR_STRING_ATTRIBUTE_TYPE: + return PerformTLVBufferConversion>(tlvData, buffer, convert_direction); + case ZCL_LONG_OCTET_STRING_ATTRIBUTE_TYPE: + case ZCL_LONG_CHAR_STRING_ATTRIBUTE_TYPE: + return PerformTLVBufferConversion(tlvData, buffer, convert_direction); + case ZCL_STRUCT_ATTRIBUTE_TYPE: + // structs not supported yet + return CHIP_ERROR_NOT_IMPLEMENTED; + case ZCL_SINGLE_ATTRIBUTE_TYPE: + return PerformTLVBufferConversion(tlvData, buffer, convert_direction); + case ZCL_DOUBLE_ATTRIBUTE_TYPE: + return PerformTLVBufferConversion(tlvData, buffer, convert_direction); + case ZCL_INT8S_ATTRIBUTE_TYPE: + case ZCL_INT16S_ATTRIBUTE_TYPE: + case ZCL_INT24S_ATTRIBUTE_TYPE: + case ZCL_INT32S_ATTRIBUTE_TYPE: + case ZCL_INT40S_ATTRIBUTE_TYPE: + case ZCL_INT48S_ATTRIBUTE_TYPE: + case ZCL_INT56S_ATTRIBUTE_TYPE: + case ZCL_INT64S_ATTRIBUTE_TYPE: + return PerformTLVBufferConversion(tlvData, buffer, convert_direction); + case ZCL_INT8U_ATTRIBUTE_TYPE: + case ZCL_INT16U_ATTRIBUTE_TYPE: + case ZCL_INT24U_ATTRIBUTE_TYPE: + case ZCL_INT32U_ATTRIBUTE_TYPE: + case ZCL_INT40U_ATTRIBUTE_TYPE: + case ZCL_INT48U_ATTRIBUTE_TYPE: + case ZCL_INT56U_ATTRIBUTE_TYPE: + case ZCL_INT64U_ATTRIBUTE_TYPE: + return PerformTLVBufferConversion(tlvData, buffer, convert_direction); + case ZCL_BOOLEAN_ATTRIBUTE_TYPE: + return PerformTLVBufferConversion(tlvData, buffer, convert_direction); + case ZCL_BITMAP32_ATTRIBUTE_TYPE: + return PerformTLVBufferConversion(tlvData, buffer, convert_direction); + default: + // Assume integer + return PerformTLVBufferConversion(tlvData, buffer, convert_direction); + } +} + bool emberAfActionsClusterInstantActionCallback(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Actions::Commands::InstantAction::DecodableType & commandData) { @@ -184,12 +341,126 @@ bool emberAfActionsClusterInstantActionCallback(app::CommandHandler * commandObj return true; } +EmberAfStatus emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, + const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer, + uint16_t maxReadLength) +{ + uint16_t endpointIndex = emberAfGetDynamicIndexFromEndpoint(endpoint); + + if ((endpointIndex >= CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT) || (gDevices[endpointIndex] == nullptr)) + { + ChipLogError(DeviceLayer, "Could not find dynamic endpoint: %d", endpoint); + return EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT; + } + + chip::app::AttributeAccessInterface * accessInterface = chip::app::GetAttributeAccessOverride(endpoint, clusterId); + + if (accessInterface == nullptr) + { + ChipLogError(DeviceLayer, "Cluster %d has no attribute access override", clusterId); + return EMBER_ZCL_STATUS_FAILURE; + } + + // adding 64 bytes as padding to include the staging buffer used by + // TLVReader and TLVWriter, which is 17 bytes + std::vector tlvData(attributeMetadata->size + 64); + + // read the attribute and write it to `data` + chip::TLV::TLVWriter writer; + writer.Init(tlvData.data(), tlvData.size()); + + // this cast is safe because all the registered attribute accessors are of type `CommonAttributeAccessInterface`. See `main()` + CHIP_ERROR err = static_cast(accessInterface) + ->Read(chip::app::ConcreteDataAttributePath(endpoint, clusterId, attributeMetadata->attributeId), writer); + if (err != CHIP_NO_ERROR) + { + ChipLogError(DeviceLayer, "%" CHIP_ERROR_FORMAT, err.Format()); + ChipLogError(DeviceLayer, "Attribute access interface failed to read attribute %d, for endpoint %d cluster %d", + attributeMetadata->attributeId, endpoint, clusterId); + return EMBER_ZCL_STATUS_FAILURE; + } + writer.Finalize(); + tlvData.resize(writer.GetLengthWritten()); + + // read from `data` and write to `buffer` + + // maxReadLength here is the maximum number of bytes to read from the attribute value and to write into the buffer. + err = PerformTLVBufferConversionForType(&tlvData, chip::Span(buffer, maxReadLength), attributeMetadata->attributeType, + TLV_TO_BUFFER); + if (err != CHIP_NO_ERROR) + { + ChipLogError(DeviceLayer, "%" CHIP_ERROR_FORMAT, err.Format()); + ChipLogError(DeviceLayer, "Failed to write attribute to buffer. Endpoint %d, Cluster %d, Attribute %d", endpoint, clusterId, + attributeMetadata->attributeId); + return EMBER_ZCL_STATUS_FAILURE; + } + + return EMBER_ZCL_STATUS_SUCCESS; +} + +EmberAfStatus emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId, + const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer) +{ + uint16_t endpointIndex = emberAfGetDynamicIndexFromEndpoint(endpoint); + + if ((endpointIndex >= CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT) || (gDevices[endpointIndex] == nullptr)) + { + ChipLogError(DeviceLayer, "Could not find dynamic endpoint: %d", endpoint); + return EMBER_ZCL_STATUS_FAILURE; + } + + chip::app::AttributeAccessInterface * accessInterface = chip::app::GetAttributeAccessOverride(endpoint, clusterId); + + if (accessInterface == nullptr) + { + ChipLogError(DeviceLayer, "Cluster %d has no attribute access override", clusterId); + return EMBER_ZCL_STATUS_FAILURE; + } + + // adding 64 bytes as padding to include the staging buffer used by + // TLVReader and TLVWriter, which is 17 bytes + std::vector tlvData(attributeMetadata->size + 64); + + // read from `buffer` and write to `data` + + // buffer size will not be used in this code path, so we set it to 0. See `PerformTLVBufferConversion` + CHIP_ERROR err = PerformTLVBufferConversionForType(&tlvData, chip::Span(buffer, 0), attributeMetadata->attributeType, + BUFFER_TO_TLV); + if (err != CHIP_NO_ERROR) + { + ChipLogError(DeviceLayer, "%" CHIP_ERROR_FORMAT, err.Format()); + ChipLogError(DeviceLayer, "Failed to read value from buffer: Endpoint %d, Cluster %d, Attribute %d", endpoint, clusterId, + attributeMetadata->attributeId); + return EMBER_ZCL_STATUS_FAILURE; + } + + // read from `data` and write to attribute + chip::TLV::TLVReader reader; + reader.Init(tlvData.data(), tlvData.size()); + reader.Next(); + chip::app::AttributeValueDecoder decoder(reader, chip::Access::SubjectDescriptor()); + err = + accessInterface->Write(chip::app::ConcreteReadAttributePath(endpoint, clusterId, attributeMetadata->attributeId), decoder); + if (err != CHIP_NO_ERROR) + { + ChipLogError(DeviceLayer, "%" CHIP_ERROR_FORMAT, err.Format()); + ChipLogError(DeviceLayer, + "Attribute access interface failed to write attribute value. Endpoint %d, Cluster %d, Attribute %d", endpoint, + clusterId, attributeMetadata->attributeId); + return EMBER_ZCL_STATUS_FAILURE; + } + + return EMBER_ZCL_STATUS_SUCCESS; +} + Device * FindDeviceEndpoint(chip::EndpointId id) { for (auto dev : gDevices) { if (dev && dev->GetEndpointId() == id) + { return dev; + } } return nullptr; } @@ -261,7 +532,9 @@ Room * FindRoom(const std::string & name) for (auto & room : gRooms) { if (room.GetName() == name) + { return &room; + } } return nullptr; } diff --git a/examples/java-matter-controller/java/src/com/matter/controller/Main.java b/examples/java-matter-controller/java/src/com/matter/controller/Main.java index ffeefb43699a2e..0e24c6dc1c212d 100644 --- a/examples/java-matter-controller/java/src/com/matter/controller/Main.java +++ b/examples/java-matter-controller/java/src/com/matter/controller/Main.java @@ -112,9 +112,6 @@ public static void main(String[] args) { try { commandManager.run(args); - } catch (IllegalArgumentException e) { - logger.log(Level.INFO, "Arguments init failed with exception: " + e.getMessage()); - System.exit(1); } catch (Exception e) { logger.log(Level.INFO, "Run command failed with exception: " + e.getMessage()); System.exit(1); diff --git a/examples/java-matter-controller/java/src/com/matter/controller/commands/common/CommandManager.java b/examples/java-matter-controller/java/src/com/matter/controller/commands/common/CommandManager.java index 2e1b373873478a..47e184ec3ae4d7 100644 --- a/examples/java-matter-controller/java/src/com/matter/controller/commands/common/CommandManager.java +++ b/examples/java-matter-controller/java/src/com/matter/controller/commands/common/CommandManager.java @@ -96,8 +96,14 @@ public final void run(String[] args) throws Exception { // need skip over binary and command name and only get arguments String[] temp = Arrays.copyOfRange(args, 2, args.length); - command.initArguments(temp.length, temp); - showCommand(args[0], command); + try { + command.initArguments(temp.length, temp); + } catch (IllegalArgumentException e) { + logger.log(Level.INFO, "Arguments init failed with exception: " + e.getMessage()); + showCommand(args[0], command); + System.exit(1); + } + command.run(); } diff --git a/examples/light-switch-app/ameba/main/DeviceCallbacks.cpp b/examples/light-switch-app/ameba/main/DeviceCallbacks.cpp index 679faf925f5873..b0ffa52dbe050c 100644 --- a/examples/light-switch-app/ameba/main/DeviceCallbacks.cpp +++ b/examples/light-switch-app/ameba/main/DeviceCallbacks.cpp @@ -25,7 +25,7 @@ #include "DeviceCallbacks.h" #include "CHIPDeviceManager.h" -#include +#include #include #include #include @@ -154,7 +154,7 @@ void IdentifyTimerHandler(Layer * systemLayer, void * appState, CHIP_ERROR error void DeviceCallbacks::OnIdentifyPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { - VerifyOrExit(attributeId == ZCL_IDENTIFY_TIME_ATTRIBUTE_ID, + VerifyOrExit(attributeId == Identify::Attributes::IdentifyTime::Id, ChipLogError(DeviceLayer, "[%s] Unhandled Attribute ID: '0x%04x", TAG, attributeId)); VerifyOrExit(endpointId == 1, ChipLogError(DeviceLayer, "[%s] Unexpected EndPoint ID: `0x%02x'", TAG, endpointId)); diff --git a/examples/light-switch-app/esp32/main/Button.cpp b/examples/light-switch-app/esp32/main/Button.cpp index 5ee8d6886c079f..0f14b694c39093 100644 --- a/examples/light-switch-app/esp32/main/Button.cpp +++ b/examples/light-switch-app/esp32/main/Button.cpp @@ -26,7 +26,7 @@ static const char * TAG = "Button"; static Button::ButtonPressCallback button_press_handler = nullptr; -static void IRAM_ATTR gpio_isr_handler(void * arg) +static void gpio_isr_handler(void * arg) { if (button_press_handler != nullptr) { diff --git a/examples/light-switch-app/esp32/main/CMakeLists.txt b/examples/light-switch-app/esp32/main/CMakeLists.txt index 9fecd318807163..960d2c14d4da9b 100644 --- a/examples/light-switch-app/esp32/main/CMakeLists.txt +++ b/examples/light-switch-app/esp32/main/CMakeLists.txt @@ -25,7 +25,6 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated/attributes" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/light-switch-app/zap-generated" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/providers" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/ota" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/common" @@ -59,7 +58,7 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ota-requestor" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/groups-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/group-key-mgmt-server" - PRIV_REQUIRES chip QRCode bt app_update) + PRIV_REQUIRES chip QRCode bt app_update driver nvs_flash spi_flash) get_filename_component(CHIP_ROOT ${CMAKE_SOURCE_DIR}/third_party/connectedhomeip REALPATH) include("${CHIP_ROOT}/build/chip/esp32/esp32_codegen.cmake") diff --git a/examples/light-switch-app/esp32/main/DeviceCallbacks.cpp b/examples/light-switch-app/esp32/main/DeviceCallbacks.cpp index 4e4c62e2fd45c9..c99c0fe1e42f23 100644 --- a/examples/light-switch-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/light-switch-app/esp32/main/DeviceCallbacks.cpp @@ -36,8 +36,9 @@ using namespace chip::app::Clusters; void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, ClusterId clusterId, AttributeId attributeId, uint8_t mask, uint8_t type, uint16_t size, uint8_t * value) { - ESP_LOGI(TAG, "PostAttributeChangeCallback - Cluster ID: '0x%04x', EndPoint ID: '0x%02x', Attribute ID: '0x%04x'", clusterId, - endpointId, attributeId); + ESP_LOGI(TAG, + "PostAttributeChangeCallback - Cluster ID: '0x%04" PRIx32 "', EndPoint ID: '0x%02x', Attribute ID: '0x%04" PRIx32 "'", + clusterId, endpointId, attributeId); switch (clusterId) { @@ -45,7 +46,7 @@ void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Clus OnOffSwitchConfigurationAttributeChangeCallback(endpointId, attributeId, type, value, size); break; default: - ESP_LOGI(TAG, "Unhandled cluster ID: %d", clusterId); + ESP_LOGI(TAG, "Unhandled cluster ID: %" PRIu32, clusterId); break; } diff --git a/examples/light-switch-app/esp32/main/main.cpp b/examples/light-switch-app/esp32/main/main.cpp index af37ae2bad6d5b..9383817e3c095d 100644 --- a/examples/light-switch-app/esp32/main/main.cpp +++ b/examples/light-switch-app/esp32/main/main.cpp @@ -22,8 +22,8 @@ #include "AppTask.h" #include "BindingHandler.h" +#include "esp_idf_version.h" #include "esp_log.h" -#include "esp_spi_flash.h" #include "esp_system.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" @@ -44,6 +44,13 @@ #include #endif // CONFIG_ENABLE_ESP32_DEVICE_INFO_PROVIDER +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) +#include "esp_spi_flash.h" +#else +#include "esp_chip_info.h" +#include "esp_flash.h" +#endif + using namespace ::chip; using namespace ::chip::Credentials; using namespace ::chip::DeviceManager; @@ -98,7 +105,7 @@ extern "C" void app_main() CHIP_ERROR error = deviceMgr.Init(&EchoCallbacks); if (error != CHIP_NO_ERROR) { - ESP_LOGE(TAG, "device.Init() failed: %s", ErrorStr(error)); + ESP_LOGE(TAG, "device.Init() failed: %" CHIP_ERROR_FORMAT, error.Format()); return; } @@ -130,6 +137,6 @@ extern "C" void app_main() error = GetAppTask().StartAppTask(); if (error != CHIP_NO_ERROR) { - ESP_LOGE(TAG, "GetAppTask().StartAppTask() failed : %s", ErrorStr(error)); + ESP_LOGE(TAG, "GetAppTask().StartAppTask() failed : %" CHIP_ERROR_FORMAT, error.Format()); } } diff --git a/examples/light-switch-app/genio/src/AppTask.cpp b/examples/light-switch-app/genio/src/AppTask.cpp index 4fd88497239959..f820d05ef14b05 100644 --- a/examples/light-switch-app/genio/src/AppTask.cpp +++ b/examples/light-switch-app/genio/src/AppTask.cpp @@ -25,8 +25,6 @@ #include "qrcodegen.h" -#include -#include #include #include #include diff --git a/examples/light-switch-app/light-switch-common/light-switch-app.matter b/examples/light-switch-app/light-switch-common/light-switch-app.matter index a192969c34f31d..8bc09b16a52def 100644 --- a/examples/light-switch-app/light-switch-common/light-switch-app.matter +++ b/examples/light-switch-app/light-switch-common/light-switch-app.matter @@ -143,17 +143,21 @@ server cluster Groups = 4 { } client cluster Scenes = 5 { + bitmap SceneFeatures : BITMAP32 { + kSceneNames = 0x1; + } + bitmap ScenesCopyMode : BITMAP8 { kCopyAllScenes = 0x1; } struct ExtensionFieldSet { - cluster_id clusterId = 0; + cluster_id clusterID = 0; AttributeValuePair attributeValueList[] = 1; } struct AttributeValuePair { - optional attrib_id attributeId = 0; + optional attrib_id attributeID = 0; int8u attributeValue[] = 1; } @@ -166,52 +170,52 @@ client cluster Scenes = 5 { readonly attribute int16u clusterRevision = 65533; request struct AddSceneRequest { - group_id groupId = 0; - INT8U sceneId = 1; + group_id groupID = 0; + INT8U sceneID = 1; INT16U transitionTime = 2; CHAR_STRING sceneName = 3; ExtensionFieldSet extensionFieldSets[] = 4; } request struct ViewSceneRequest { - group_id groupId = 0; - INT8U sceneId = 1; + group_id groupID = 0; + INT8U sceneID = 1; } request struct RemoveSceneRequest { - group_id groupId = 0; - INT8U sceneId = 1; + group_id groupID = 0; + INT8U sceneID = 1; } request struct RemoveAllScenesRequest { - group_id groupId = 0; + group_id groupID = 0; } request struct StoreSceneRequest { - group_id groupId = 0; - INT8U sceneId = 1; + group_id groupID = 0; + INT8U sceneID = 1; } request struct RecallSceneRequest { - group_id groupId = 0; - INT8U sceneId = 1; + group_id groupID = 0; + INT8U sceneID = 1; optional nullable INT16U transitionTime = 2; } request struct GetSceneMembershipRequest { - group_id groupId = 0; + group_id groupID = 0; } response struct AddSceneResponse = 0 { ENUM8 status = 0; - group_id groupId = 1; - INT8U sceneId = 2; + group_id groupID = 1; + INT8U sceneID = 2; } response struct ViewSceneResponse = 1 { ENUM8 status = 0; - group_id groupId = 1; - INT8U sceneId = 2; + group_id groupID = 1; + INT8U sceneID = 2; optional INT16U transitionTime = 3; optional CHAR_STRING sceneName = 4; optional ExtensionFieldSet extensionFieldSets[] = 5; @@ -219,25 +223,25 @@ client cluster Scenes = 5 { response struct RemoveSceneResponse = 2 { ENUM8 status = 0; - group_id groupId = 1; - INT8U sceneId = 2; + group_id groupID = 1; + INT8U sceneID = 2; } response struct RemoveAllScenesResponse = 3 { ENUM8 status = 0; - group_id groupId = 1; + group_id groupID = 1; } response struct StoreSceneResponse = 4 { ENUM8 status = 0; - group_id groupId = 1; - INT8U sceneId = 2; + group_id groupID = 1; + INT8U sceneID = 2; } response struct GetSceneMembershipResponse = 6 { ENUM8 status = 0; nullable INT8U capacity = 1; - group_id groupId = 2; + group_id groupID = 2; optional INT8U sceneList[] = 3; } @@ -280,10 +284,6 @@ client cluster OnOff = 6 { kLighting = 0x1; } - bitmap SceneFeatures : BITMAP32 { - kSceneNames = 0x1; - } - readonly attribute boolean onOff = 0; readonly attribute boolean globalSceneControl = 16384; attribute int16u onTime = 16385; @@ -846,7 +846,7 @@ server cluster GeneralDiagnostics = 51 { kSoftwareReset = 6; } - enum HardwareFault : ENUM8 { + enum HardwareFaultEnum : ENUM8 { kUnspecified = 0; kRadio = 1; kSensor = 2; @@ -860,7 +860,7 @@ server cluster GeneralDiagnostics = 51 { kTamperDetected = 10; } - enum InterfaceType : ENUM8 { + enum InterfaceTypeEnum : ENUM8 { kUnspecified = 0; kWiFi = 1; kEthernet = 2; @@ -868,14 +868,14 @@ server cluster GeneralDiagnostics = 51 { kThread = 4; } - enum NetworkFaultType : ENUM8 { + enum NetworkFaultEnum : ENUM8 { kUnspecified = 0; kHardwareFailure = 1; kNetworkJammed = 2; kConnectionFailed = 3; } - enum RadioFault : ENUM8 { + enum RadioFaultEnum : ENUM8 { kUnspecified = 0; kWiFiFault = 1; kCellularFault = 2; @@ -893,22 +893,22 @@ server cluster GeneralDiagnostics = 51 { octet_string<8> hardwareAddress = 4; octet_string IPv4Addresses[] = 5; octet_string IPv6Addresses[] = 6; - InterfaceType type = 7; + InterfaceTypeEnum type = 7; } critical event HardwareFaultChange = 0 { - HardwareFault current[] = 0; - HardwareFault previous[] = 1; + HardwareFaultEnum current[] = 0; + HardwareFaultEnum previous[] = 1; } critical event RadioFaultChange = 1 { - RadioFault current[] = 0; - RadioFault previous[] = 1; + RadioFaultEnum current[] = 0; + RadioFaultEnum previous[] = 1; } critical event NetworkFaultChange = 2 { - NetworkFaultType current[] = 0; - NetworkFaultType previous[] = 1; + NetworkFaultEnum current[] = 0; + NetworkFaultEnum previous[] = 1; } critical event BootReason = 3 { @@ -920,9 +920,9 @@ server cluster GeneralDiagnostics = 51 { readonly attribute int64u upTime = 2; readonly attribute int32u totalOperationalHours = 3; readonly attribute BootReasonEnum bootReason = 4; - readonly attribute HardwareFault activeHardwareFaults[] = 5; - readonly attribute RadioFault activeRadioFaults[] = 6; - readonly attribute NetworkFaultType activeNetworkFaults[] = 7; + readonly attribute HardwareFaultEnum activeHardwareFaults[] = 5; + readonly attribute RadioFaultEnum activeRadioFaults[] = 6; + readonly attribute NetworkFaultEnum activeNetworkFaults[] = 7; readonly attribute boolean testEventTriggersEnabled = 8; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -1153,6 +1153,11 @@ server cluster WiFiNetworkDiagnostics = 54 { kAx = 5; } + bitmap WiFiNetworkDiagnosticsFeature : BITMAP32 { + kPacketCounts = 0x1; + kErrorCounts = 0x2; + } + info event Disconnection = 0 { INT16U reasonCode = 0; } @@ -1186,7 +1191,7 @@ server cluster WiFiNetworkDiagnostics = 54 { } server cluster EthernetNetworkDiagnostics = 55 { - enum PHYRate : ENUM8 { + enum PHYRateEnum : ENUM8 { kRate10M = 0; kRate100M = 1; kRate1G = 2; @@ -1199,7 +1204,12 @@ server cluster EthernetNetworkDiagnostics = 55 { kRate400G = 9; } - readonly attribute nullable PHYRate PHYRate = 0; + bitmap EthernetNetworkDiagnosticsFeature : BITMAP32 { + kPacketCounts = 0x1; + kErrorCounts = 0x2; + } + + readonly attribute nullable PHYRateEnum PHYRate = 0; readonly attribute nullable boolean fullDuplex = 1; readonly attribute int64u packetRxCount = 2; readonly attribute int64u packetTxCount = 3; @@ -1263,7 +1273,7 @@ server cluster Switch = 59 { } server cluster AdministratorCommissioning = 60 { - enum CommissioningWindowStatus : ENUM8 { + enum CommissioningWindowStatusEnum : ENUM8 { kWindowNotOpen = 0; kEnhancedWindowOpen = 1; kBasicWindowOpen = 2; @@ -1275,7 +1285,7 @@ server cluster AdministratorCommissioning = 60 { kWindowNotOpen = 4; } - readonly attribute CommissioningWindowStatus windowStatus = 0; + readonly attribute CommissioningWindowStatusEnum windowStatus = 0; readonly attribute nullable fabric_idx adminFabricIndex = 1; readonly attribute nullable int16u adminVendorId = 2; readonly attribute bitmap32 featureMap = 65532; @@ -1299,8 +1309,13 @@ server cluster AdministratorCommissioning = 60 { } server cluster OperationalCredentials = 62 { - enum OperationalCertStatus : ENUM8 { - kSuccess = 0; + enum CertificateChainTypeEnum : ENUM8 { + kDACCertificate = 1; + kPAICertificate = 2; + } + + enum NodeOperationalCertStatusEnum : ENUM8 { + kOk = 0; kInvalidPublicKey = 1; kInvalidNodeOpId = 2; kInvalidNOC = 3; @@ -1318,17 +1333,17 @@ server cluster OperationalCredentials = 62 { fabric_idx fabricIndex = 254; } - fabric_scoped struct FabricDescriptor { + fabric_scoped struct FabricDescriptorStruct { octet_string<65> rootPublicKey = 1; - vendor_id vendorId = 2; - fabric_id fabricId = 3; - node_id nodeId = 4; + vendor_id vendorID = 2; + fabric_id fabricID = 3; + node_id nodeID = 4; char_string<32> label = 5; fabric_idx fabricIndex = 254; } readonly attribute access(read: administer) NOCStruct NOCs[] = 0; - readonly attribute FabricDescriptor fabrics[] = 1; + readonly attribute FabricDescriptorStruct fabrics[] = 1; readonly attribute int8u supportedFabrics = 2; readonly attribute int8u commissionedFabrics = 3; readonly attribute OCTET_STRING trustedRootCertificates[] = 4; @@ -1341,7 +1356,7 @@ server cluster OperationalCredentials = 62 { } request struct CertificateChainRequestRequest { - INT8U certificateType = 0; + CertificateChainTypeEnum certificateType = 0; } request struct CSRRequestRequest { @@ -1371,12 +1386,12 @@ server cluster OperationalCredentials = 62 { } request struct AddTrustedRootCertificateRequest { - OCTET_STRING rootCertificate = 0; + OCTET_STRING rootCACertificate = 0; } response struct AttestationResponse = 1 { OCTET_STRING attestationElements = 0; - OCTET_STRING signature = 1; + OCTET_STRING attestationSignature = 1; } response struct CertificateChainResponse = 3 { @@ -1389,7 +1404,7 @@ server cluster OperationalCredentials = 62 { } response struct NOCResponse = 8 { - OperationalCertStatus statusCode = 0; + NodeOperationalCertStatusEnum statusCode = 0; optional fabric_idx fabricIndex = 1; optional CHAR_STRING debugText = 2; } @@ -1653,7 +1668,7 @@ client cluster ColorControl = 768 { } request struct MoveToColorTemperatureRequest { - INT16U colorTemperature = 0; + INT16U colorTemperatureMireds = 0; INT16U transitionTime = 1; BITMAP8 optionsMask = 2; BITMAP8 optionsOverride = 3; @@ -1742,7 +1757,7 @@ endpoint 0 { callback attribute extension; callback attribute subjectsPerAccessControlEntry default = 4; callback attribute targetsPerAccessControlEntry default = 3; - callback attribute accessControlEntriesPerFabric default = 3; + callback attribute accessControlEntriesPerFabric default = 4; callback attribute attributeList; ram attribute featureMap; ram attribute clusterRevision default = 1; diff --git a/examples/light-switch-app/light-switch-common/light-switch-app.zap b/examples/light-switch-app/light-switch-common/light-switch-app.zap index deb9aab1940f3e..f80ec1681c888d 100644 --- a/examples/light-switch-app/light-switch-common/light-switch-app.zap +++ b/examples/light-switch-app/light-switch-common/light-switch-app.zap @@ -1124,7 +1124,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "4", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -4343,7 +4343,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "PHYRate", + "type": "PHYRateEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -4567,7 +4567,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4619,7 +4619,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4631,7 +4631,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "CommissioningWindowStatus", + "type": "CommissioningWindowStatusEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -8075,7 +8075,7 @@ "enabled": 0, "attributes": [ { - "name": "occupancy", + "name": "Occupancy", "code": 0, "mfgCode": null, "side": "server", @@ -8091,7 +8091,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type", + "name": "OccupancySensorType", "code": 1, "mfgCode": null, "side": "server", @@ -8107,7 +8107,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type bitmap", + "name": "OccupancySensorTypeBitmap", "code": 2, "mfgCode": null, "side": "server", diff --git a/examples/light-switch-app/nrfconnect/main/AppTask.cpp b/examples/light-switch-app/nrfconnect/main/AppTask.cpp index bf28af3f97fab5..d2f7a6a6581c8d 100644 --- a/examples/light-switch-app/nrfconnect/main/AppTask.cpp +++ b/examples/light-switch-app/nrfconnect/main/AppTask.cpp @@ -185,7 +185,7 @@ CHIP_ERROR AppTask::Init() // Initialize DFU #ifdef CONFIG_MCUMGR_SMP_BT - GetDFUOverSMP().Init(RequestSMPAdvertisingStart); + GetDFUOverSMP().Init(); GetDFUOverSMP().ConfirmNewImage(); #endif @@ -646,16 +646,6 @@ void AppTask::FunctionTimerTimeoutCallback(k_timer * timer) } } -#ifdef CONFIG_MCUMGR_SMP_BT -void AppTask::RequestSMPAdvertisingStart(void) -{ - AppEvent event; - event.Type = AppEventType::StartSMPAdvertising; - event.Handler = [](const AppEvent &) { GetDFUOverSMP().StartBLEAdvertising(); }; - PostEvent(event); -} -#endif - void AppTask::PostEvent(const AppEvent & event) { if (k_msgq_put(&sAppEventQueue, &event, K_NO_WAIT) != 0) diff --git a/examples/light-switch-app/nrfconnect/main/include/AppEvent.h b/examples/light-switch-app/nrfconnect/main/include/AppEvent.h index b3248e3e0c29d6..98a3bb54a5244f 100644 --- a/examples/light-switch-app/nrfconnect/main/include/AppEvent.h +++ b/examples/light-switch-app/nrfconnect/main/include/AppEvent.h @@ -33,7 +33,6 @@ enum class AppEventType : uint8_t UpdateLedState, IdentifyStart, IdentifyStop, - StartSMPAdvertising }; enum class FunctionEvent : uint8_t diff --git a/examples/light-switch-app/nrfconnect/main/include/AppTask.h b/examples/light-switch-app/nrfconnect/main/include/AppTask.h index 9bd5ac4f5d98c0..5c7e2278976c00 100644 --- a/examples/light-switch-app/nrfconnect/main/include/AppTask.h +++ b/examples/light-switch-app/nrfconnect/main/include/AppTask.h @@ -84,10 +84,6 @@ class AppTask static void StartTimer(Timer, uint32_t); static void CancelTimer(Timer); -#ifdef CONFIG_MCUMGR_SMP_BT - static void RequestSMPAdvertisingStart(void); -#endif - FunctionEvent mFunction = FunctionEvent::NoneSelected; #if CONFIG_CHIP_FACTORY_DATA diff --git a/examples/light-switch-app/silabs/SiWx917/BUILD.gn b/examples/light-switch-app/silabs/SiWx917/BUILD.gn index b7bf2c938faf45..5972ad7265fbc4 100644 --- a/examples/light-switch-app/silabs/SiWx917/BUILD.gn +++ b/examples/light-switch-app/silabs/SiWx917/BUILD.gn @@ -49,15 +49,9 @@ declare_args() { OTA_periodic_query_timeout = 86400 # Wifi related stuff - they are overridden by gn -args="use_wf200=true" - use_wf200 = false - use_rs911x = false - use_rs911x_sockets = false sl_wfx_config_softap = false sl_wfx_config_scan = true - # Disable LCD on supported devices - disable_lcd = true - # Argument to Disable IPv4 for wifi(rs911) chip_enable_wifi_ipv4 = false @@ -71,14 +65,6 @@ declare_args() { chip_default_wifi_psk = "" } -declare_args() { - # Enables LCD Qr Code on supported devices - show_qr_code = !disable_lcd -} - -# qr code cannot be true if lcd is disabled -assert(!(disable_lcd && show_qr_code)) - # Sanity check assert(!(chip_enable_wifi && chip_enable_openthread)) assert(!(use_rs911x && chip_enable_openthread)) @@ -147,6 +133,7 @@ efr32_sdk("sdk") { ] include_dirs = [ + "${chip_root}/examples/light-switch-app/silabs/common", "${chip_root}/src/platform/silabs/SiWx917", "${efr32_project_dir}/include", "${examples_plat_dir}", @@ -200,6 +187,8 @@ efr32_executable("light_switch_app") { defines = [] sources = [ + "${chip_root}/examples/light-switch-app/silabs/common/BindingHandler.cpp", + "${chip_root}/examples/light-switch-app/silabs/common/LightSwitchMgr.cpp", "${examples_common_plat_dir}/heap_4_silabs.c", "${examples_plat_dir}/BaseApplication.cpp", "${examples_plat_dir}/init_ccpPlatform.cpp", @@ -207,7 +196,6 @@ efr32_executable("light_switch_app") { "${examples_plat_dir}/siwx917_utils.cpp", "src/AppTask.cpp", "src/ZclCallbacks.cpp", - "src/binding-handler.cpp", "src/main.cpp", ] @@ -228,6 +216,12 @@ efr32_executable("light_switch_app") { "${chip_root}/src/setup_payload", ] + if (chip_build_libshell) { + sources += [ + "${chip_root}/examples/light-switch-app/silabs/common/ShellCommands.cpp", + ] + } + # Attestation Credentials if (chip_build_platform_attestation_credentials_provider) { deps += [ "${examples_plat_dir}:siwx917-attestation-credentials" ] diff --git a/examples/light-switch-app/silabs/SiWx917/README.md b/examples/light-switch-app/silabs/SiWx917/README.md index b08f29749e09cd..b20818392ebb72 100644 --- a/examples/light-switch-app/silabs/SiWx917/README.md +++ b/examples/light-switch-app/silabs/SiWx917/README.md @@ -1,10 +1,10 @@ -# Matter EFR32 Light Switch Example +# Matter SiWx917 Light Switch Example -An example showing the use of CHIP on the Silicon Labs EFR32 MG12 and MG24. +An example showing the use of CHIP on the Silicon Labs SiWx917 SoC device.
-- [Matter EFR32 Light Switch Example](#matter-efr32-light-switch-example) +- [Matter SiWx917 Light Switch Example](#matter-siwx917-light-switch-example) - [Introduction](#introduction) - [Building](#building) - [Linux](#linux) @@ -13,11 +13,8 @@ An example showing the use of CHIP on the Silicon Labs EFR32 MG12 and MG24. - [Viewing Logging Output](#viewing-logging-output) - [Running the Complete Example](#running-the-complete-example) - [Notes](#notes) - - [On Border Router:](#on-border-router) - [On PC(Linux):](#on-pclinux) - - [Running RPC console](#running-rpc-console) - [Memory settings](#memory-settings) - - [OTA Software Update](#ota-software-update) - [Building options](#building-options) - [Disabling logging](#disabling-logging) - [Debug build / release build](#debug-build--release-build) @@ -34,18 +31,19 @@ An example showing the use of CHIP on the Silicon Labs EFR32 MG12 and MG24. ## Introduction -The EFR32 light switch example provides a baseline demonstration of a on-off -light switch device, built using Matter and the Silicon Labs gecko SDK. It can -be controlled by a Chip controller over an Openthread or Wifi network. +The SiWx917 light switch example provides a baseline demonstration of an on-off +light switch device, built using Matter, the Silicon Labs Gecko SDK, and the +Silicon Labs WiseMCU SDK. It can be controlled by a Chip controller over a Wi-Fi +network. -The EFR32 device can be commissioned over Bluetooth Low Energy where the device -and the Chip controller will exchange security information with the Rendez-vous -procedure. If using Thread, Thread Network credentials are then provided to the -EFR32 device which will then join the network. +The SiWx917 device can be commissioned over Bluetooth Low Energy where the +device and the Chip controller will exchange security information with the +rendezvous procedure. Wi-Fi Network credentials are then provided to the SiWx917 +device which will then join the Wi-Fi network. If the LCD is enabled, the LCD on the Silabs WSTK shows a QR Code containing the needed commissioning information for the BLE connection and starting the -Rendez-vous procedure. +rendezvous procedure. The light switch example is intended to serve both as a means to explore the workings of Matter as well as a template for creating real products based on the @@ -78,263 +76,59 @@ Silicon Labs platform. > [Hardware Requirements](https://github.com/SiliconLabs/matter/blob/latest/docs/silabs/general/HARDWARE_REQUIREMENTS.md) > in the Silicon Labs Matter Github Repo - MG12 boards: - - - BRD4161A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm - - BRD4162A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4163A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm, - 868MHz@19dBm - - BRD4164A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm - - BRD4166A / SLTB004A / Thunderboard Sense 2 / 2.4GHz@10dBm - - BRD4170A / SLWSTK6000B / Multiband Wireless Starter Kit / 2.4GHz@19dBm, - 915MHz@19dBm - - BRD4304A / SLWSTK6000B / MGM12P Module / 2.4GHz@19dBm - - MG21 boards: Currently not supported due to RAM limitation. - - - BRD4180A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - - MG24 boards : - - - BRD2601B / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD2703A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4186A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4186C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4187A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - - BRD4187C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - - MG12 boards: - - - BRD4161A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm - - BRD4162A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4163A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm, - 868MHz@19dBm - - BRD4164A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm - - BRD4166A / SLTB004A / Thunderboard Sense 2 / 2.4GHz@10dBm - - BRD4170A / SLWSTK6000B / Multiband Wireless Starter Kit / 2.4GHz@19dBm, - 915MHz@19dBm - - BRD4304A / SLWSTK6000B / MGM12P Module / 2.4GHz@19dBm - - MG21 boards: Currently not supported due to RAM limitation. - - - BRD4180A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - - MG24 boards : - - - BRD2601B / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD2703A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4186A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4186C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4187A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - - BRD4187C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - * Build the example application: cd ~/connectedhomeip - ./scripts/examples/gn_efr32_example.sh ./examples/light-switch-app/efr32/ ./out/light-switch-app BRD4161A + ./scripts/examples/gn_efr32_example.sh ./examples/light-switch-app/silabs/SiWx917/ ./out/light-switch-app BRD4325A --wifi rs911x - To delete generated executable, libraries and object files use: $ cd ~/connectedhomeip $ rm -rf ./out/ - OR use GN/Ninja directly - - $ cd ~/connectedhomeip/examples/light-switch-app/efr32 - $ git submodule update --init - $ source third_party/connectedhomeip/scripts/activate.sh - $ export EFR32_BOARD=BRD4161A - $ gn gen out/debug - $ ninja -C out/debug - -- To delete generated executable, libraries and object files use: - - $ cd ~/connectedhomeip/examples/light-switch-app/efr32 - $ rm -rf out/ - -* Build the example with Matter shell - - ./scripts/examples/gn_efr32_example.sh examples/light-switch-app/efr32/ out/light-switch-app BRD4161A chip_build_libshell=true - -* Build the example as Sleepy End Device (SED) - - $ ./scripts/examples/gn_efr32_example.sh ./examples/light-switch-app/efr32/ ./out/light-switch-app_SED BRD4161A --sed - - or use gn as previously mentioned but adding the following arguments: - - $ gn gen out/debug '--args=silabs_board="BRD4161A" enable_sleepy_device=true chip_openthread_ftd=false chip_build_libshell=true' - -* Build the example with pigweed RCP - - $ ./scripts/examples/gn_efr32_example.sh examples/light-switch-app/efr32/ out/light-switch-app_rpc BRD4161A 'import("//with_pw_rpc.gni")' - - or use GN/Ninja Directly - - $ cd ~/connectedhomeip/examples/light-switch-app/efr32 - $ git submodule update --init - $ source third_party/connectedhomeip/scripts/activate.sh - $ export EFR32_BOARD=BRD4161A - $ gn gen out/debug --args='import("//with_pw_rpc.gni")' - $ ninja -C out/debug - - [Running Pigweed RPC console](#running-rpc-console) - -For more build options, help is provided when running the build script without -arguments - - ./scripts/examples/gn_efr32_example.sh + ## Flashing the Application -- On the command line: - - $ cd ~/connectedhomeip/examples/lighting-app/efr32 - $ python3 out/debug/chip-efr32-light-switch-example.flash.py - -- Or with the Ozone debugger, just load the .out file. +- Flashing requires the SiWx917 SoC device to be configured in the Ozone + Debugger. +- Once it's configured, it can be run with the Ozone Debugger by loading the + .out file. + - > For detailed instructions, please refer to + > [Running the Matter Demo on SiWx917 SoC](https://github.com/SiliconLabs/matter/blob/latest/docs/silabs/wifi/RUN_DEMO_SiWx917_SoC.md) + > in the Silicon Labs Matter Github Repo ## Viewing Logging Output -The example application is built to use the SEGGER Real Time Transfer (RTT) -facility for log output. RTT is a feature built-in to the J-Link Interface MCU -on the WSTK development board. It allows bi-directional communication with an -embedded application without the need for a dedicated UART. - -Using the RTT facility requires downloading and installing the _SEGGER J-Link -Software and Documentation Pack_ -([web site](https://www.segger.com/downloads/jlink#J-LinkSoftwareAndDocumentationPack)). - -Alternatively, SEGGER Ozone J-Link debugger can be used to view RTT logs too -after flashing the .out file. - -- Download the J-Link installer by navigating to the appropriate URL and - agreeing to the license agreement. - -- [JLink_Linux_x86_64.deb](https://www.segger.com/downloads/jlink/JLink_Linux_x86_64.deb) -- [JLink_MacOSX.pkg](https://www.segger.com/downloads/jlink/JLink_MacOSX.pkg) - -* Install the J-Link software - - $ cd ~/Downloads - $ sudo dpkg -i JLink_Linux_V*_x86_64.deb - -* In Linux, grant the logged in user the ability to talk to the development - hardware via the linux tty device (/dev/ttyACMx) by adding them to the - dialout group. - - $ sudo usermod -a -G dialout ${USER} - -Once the above is complete, log output can be viewed using the JLinkExe tool in -combination with JLinkRTTClient as follows: - -- Run the JLinkExe tool with arguments to autoconnect to the WSTK board: - - For MG12 use: - - $ JLinkExe -device EFR32MG12PXXXF1024 -if JTAG -speed 4000 -autoconnect 1 - - For MG21 use: - - $ JLinkExe -device EFR32MG21AXXXF1024 -if SWD -speed 4000 -autoconnect 1 - -- In a second terminal, run the JLinkRTTClient to view logs: - - $ JLinkRTTClient +The example application's logging output can be viewed in the Ozone Debugger. ## Running the Complete Example -- It is assumed here that you already have an OpenThread border router - configured and running. If not see the following guide - [Openthread_border_router](https://github.com/project-chip/connectedhomeip/blob/master/docs/guides/openthread_border_router_pi.md) - for more information on how to setup a border router on a raspberryPi. - - Take note that the RCP code is available directly through - [Simplicity Studio 5](https://www.silabs.com/products/development-tools/software/simplicity-studio/simplicity-studio-5) - under File->New->Project Wizard->Examples->Thread : ot-rcp - -- For this example to work, it is necessary to have a second efr32 device +- For this example to work, it is necessary to have a second SiWx917 device running the - [lighting app example](https://github.com/project-chip/connectedhomeip/blob/master/examples/lighting-app/efr32/README.md) - commissioned on the same openthread network - -- User interface : **LCD** The LCD on Silabs WSTK shows a QR Code. This QR - Code is be scanned by the CHIP Tool app For the Rendez-vous procedure over - BLE - - * On devices that do not have or support the LCD Display like the BRD4166A Thunderboard Sense 2, - a URL can be found in the RTT logs. - - [SVR] Copy/paste the below URL in a browser to see the QR Code: - [SVR] https://project-chip.github.io/connectedhomeip/qrcode.html?data=CH%3AI34NM%20-00%200C9SS0 - - **LED 0** shows the overall state of the device and its connectivity. The - following states are possible: - - - Short Flash On (50 ms on/950 ms off): The device is in the - unprovisioned (unpaired) state and is waiting for a commissioning - application to connect. - - - Rapid Even Flashing (100 ms on/100 ms off): The device is in the - unprovisioned state and a commissioning application is connected through - Bluetooth LE. - - - Short Flash Off (950ms on/50ms off): The device is fully - provisioned, but does not yet have full Thread network or service - connectivity. - - - Solid On: The device is fully provisioned and has full Thread - network and service connectivity. - - **Push Button 0** - - - _Press and Release_ : Start, or restart, BLE advertisement in fast mode. It will advertise in this mode - for 30 seconds. The device will then switch to a slower interval advertisement. - After 15 minutes, the advertisement stops. - - - _Pressed and hold for 6 s_ : Initiates the factory reset of the device. - Releasing the button within the 6-second window cancels the factory reset - procedure. **LEDs** blink in unison when the factory reset procedure is - initiated. - - **Push Button 1** + [lighting app example](https://github.com/project-chip/connectedhomeip/blob/master/examples/lighting-app/silabs/SiWx917/README.md) + commissioned on the same Wi-Fi network - - Sends a Toggle command to bound light app +* You can provision and control the Chip device using the + [chip-tool](https://github.com/project-chip/connectedhomeip/blob/master/examples/chip-tool/README.md) + standalone - **Matter shell** + Here is an example with the chip-tool for unicast commands only: - **_OnOff Cluster_** - - - 'switch onoff on' : Sends unicast On command to bound device - - 'switch onoff off' : Sends unicast Off command to bound device - - 'switch onoff toggle' : Sends unicast Toggle command to bound device - - - 'switch groups onoff on' : Sends On group command to bound group - - 'switch groups onoff off' : Sends On group command to bound group - - 'switch groups onoff toggle' : Sends On group command to bound group - - **_Binding Cluster_** - - - 'switch binding unicast ' : Creates a unicast binding - - 'switch binding group ' : Creates a group binding - -* You can provision and control the Chip device using the python controller, - [CHIPTool](https://github.com/project-chip/connectedhomeip/blob/master/examples/chip-tool/README.md) - standalone, Android or iOS app - - Here is an example with the CHIPTool for unicast commands only: + - > $SSID and $PSK are the SSID and passcode of your Wi-Fi Access Point. ``` - chip-tool pairing ble-thread 1 hex: 20202021 3840 + chip-tool pairing ble-wifi 1122 $SSID $PSK 20202021 3840 chip-tool accesscontrol write acl '[{"fabricIndex": 1, "privilege": 5, "authMode": 2, "subjects": [], "targets": null }{"fabricIndex": 1, "privilege": 3, "authMode": 2, "subjects": [1], "targets": null }]' 0 chip-tool binding write binding '[{"fabricIndex": 1, "node": , "endpoint": 1, "cluster":6}]' 1 1 ``` - Here is an example with the CHIPTool for groups commands only: + Here is an example with the chip-tool for groups commands only: ``` - chip-tool pairing ble-thread 1 hex: 20202021 3840 + chip-tool pairing ble-wifi 1122 $SSID $PSK 20202021 3840 chip-tool tests TestGroupDemoConfig --nodeId 1 @@ -359,68 +153,33 @@ combination with JLinkRTTClient as follows: ### Notes -- Depending on your network settings your router might not provide native ipv6 - addresses to your devices (Border router / PC). If this is the case, you - need to add a static ipv6 addresses on both device and then an ipv6 route to - the border router on your PC - -#### On Border Router: - -`$ sudo ip addr add dev 2002::2/64` +- Depending on your network settings your router might not provide native IPv6 + addresses to your devices (Router / PC). If this is the case, you need to + add a static IPv6 addresses on both devices and then an IPv6 route to the + border router on your PC #### On PC(Linux): `$ sudo ip addr add dev 2002::1/64` -#Add Ipv6 route on PC(Linux) \$ sudo ip route add /64 +#Add IPv6 route on PC(Linux) \$ sudo ip route add /64 via 2002::2 -## Running RPC console - -- As part of building the example with RPCs enabled the chip_rpc python - interactive console is installed into your venv. The python wheel files are - also created in the output folder: out/debug/chip_rpc_console_wheels. To - install the wheel files without rebuilding: - - `pip3 install out/debug/chip_rpc_console_wheels/*.whl` - -- To use the chip-rpc console after it has been installed run: - - `chip-console --device /dev/tty. -b 115200 -o //pw_log.out` - -- Then you can simulate a button press or release using the following command - where : idx = 0 or 1 for Button PB0 or PB1 action = 0 for PRESSED, 1 for - RELEASE Test toggling the LED with - - `rpcs.chip.rpc.Button.Event(idx=1, pushed=True)` - -- You can also Get and Set the light directly using the RPCs: - - `rpcs.chip.rpc.Lighting.Get()` - - `rpcs.chip.rpc.Lighting.Set(on=True, level=128, color=protos.chip.rpc.LightingColor(hue=5, saturation=5))` - ## Memory settings While most of the RAM usage in CHIP is static, allowing easier debugging and optimization with symbols analysis, we still need some HEAP for the crypto and -OpenThread. Size of the HEAP can be modified by changing the value of the +Wi-Fi stack. Size of the HEAP can be modified by changing the value of the `configTOTAL_HEAP_SIZE` define inside of the FreeRTOSConfig.h file of this -example. Please take note that a HEAP size smaller than 13k can and will cause a -Mbedtls failure during the BLE rendez-vous or CASE session +example. Please take note that a HEAP size smaller than 13k can and will cause +an Mbedtls failure during the BLE rendezvous or CASE session To track memory usage you can set `enable_heap_monitoring = true` either in the BUILD.gn file or pass it as a build argument to gn. This will print on the RTT console the RAM usage of each individual task and the number of Memory allocation and Free. While this is not extensive monitoring you're welcome to -modify `examples/platform/efr32/MemMonitoring.cpp` to add your own memory -tracking code inside the `trackAlloc` and `trackFree` function - -## OTA Software Update - -For the description of Software Update process with EFR32 example applications -see -[EFR32 OTA Software Update](../../../../docs/guides/silabs_efr32_software_update.md) +modify `examples/platform/silabs/SiWx917/MemMonitoring.cpp` to add your own +memory tracking code inside the `trackAlloc` and `trackFree` function ## Building options @@ -432,19 +191,19 @@ features can easily be toggled on or off. Here is a short list of options : chip_progress_logging, chip_detail_logging, chip_automation_logging - $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/efr32 ./out/lighting-app BRD4164A "chip_detail_logging=false chip_automation_logging=false chip_progress_logging=false" + $ ./scripts/examples/gn_efr32_example.sh ./examples/light-switch-app/silabs/SiWx917 ./out/light-switch-app BRD4325A "chip_detail_logging=false chip_automation_logging=false chip_progress_logging=false" --wifi rs911x ### Debug build / release build is_debug - $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/efr32 ./out/lighting-app BRD4164A "is_debug=false" + $ ./scripts/examples/gn_efr32_example.sh ./examples/light-switch-app/silabs/SiWx917 ./out/light-switch-app BRD4325A "is_debug=false" --wifi rs911x ### Disabling LCD show_qr_code - $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/efr32 ./out/lighting-app BRD4164A "show_qr_code=false" + $ ./scripts/examples/gn_efr32_example.sh ./examples/light-switch-app/silabs/SiWx917 ./out/light-switch-app BRD4325A "show_qr_code=false" --wifi rs911x ### KVS maximum entry count @@ -453,4 +212,4 @@ kvs_max_entries Set the maximum Kvs entries that can be stored in NVM (Default 75) Thresholds: 30 <= kvs_max_entries <= 255 - $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/efr32 ./out/lighting-app BRD4164A kvs_max_entries=50 + $ ./scripts/examples/gn_efr32_example.sh ./examples/light-switch-app/silabs/SiWx917 ./out/light-switch-app BRD4325A kvs_max_entries=50 --wifi rs911x diff --git a/examples/light-switch-app/silabs/SiWx917/src/AppTask.cpp b/examples/light-switch-app/silabs/SiWx917/src/AppTask.cpp index 9cba97f27dafc2..06a3dc734006ac 100644 --- a/examples/light-switch-app/silabs/SiWx917/src/AppTask.cpp +++ b/examples/light-switch-app/silabs/SiWx917/src/AppTask.cpp @@ -24,12 +24,14 @@ #include "AppTask.h" #include "AppConfig.h" #include "AppEvent.h" -#include "binding-handler.h" +#include "BindingHandler.h" #ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" #endif // ENABLE_WSTK_LEDS +#include "LightSwitchMgr.h" + #ifdef DISPLAY_ENABLED #include "lcd.h" #ifdef QR_CODE_ENABLED @@ -37,8 +39,10 @@ #endif // QR_CODE_ENABLED #endif // DISPLAY_ENABLED -#include -#include +#if defined(ENABLE_CHIP_SHELL) +#include "ShellCommands.h" +#endif // defined(ENABLE_CHIP_SHELL) + #include #include #include @@ -59,6 +63,13 @@ #define APP_FUNCTION_BUTTON &sl_button_btn0 #define APP_LIGHT_SWITCH &sl_button_btn1 +namespace { + +constexpr chip::EndpointId kLightSwitchEndpoint = 1; +constexpr chip::EndpointId kGenericSwitchEndpoint = 2; + +} // namespace + using namespace chip; using namespace ::chip::DeviceLayer; @@ -70,8 +81,6 @@ namespace { EmberAfIdentifyEffectIdentifier sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT; -bool mCurrentButtonState = false; - /********************************************************** * Identify Callbacks *********************************************************/ @@ -159,14 +168,17 @@ CHIP_ERROR AppTask::Init() appError(err); } - // Configure Bindings - TODO ERROR PROCESSING - err = InitBindingHandler(); + err = LightSwitchMgr::GetInstance().Init(kLightSwitchEndpoint, kGenericSwitchEndpoint); if (err != CHIP_NO_ERROR) { - SILABS_LOG("InitBindingHandler() failed"); + SILABS_LOG("LightSwitchMgr Init failed!"); appError(err); } +#if defined(ENABLE_CHIP_SHELL) + LightSwtichCommands::RegisterSwitchCommands(); +#endif // defined(ENABLE_CHIP_SHELL) + return err; } @@ -223,36 +235,32 @@ void AppTask::OnIdentifyStop(Identify * identify) void AppTask::SwitchActionEventHandler(AppEvent * aEvent) { - if (aEvent->Type == AppEvent::kEventType_Button) + VerifyOrReturn(aEvent->Type == AppEvent::kEventType_Button); + + static bool mCurrentButtonState = false; + + if (aEvent->ButtonEvent.Action == SL_SIMPLE_BUTTON_PRESSED) { - BindingCommandData * data = Platform::New(); - data->clusterId = chip::app::Clusters::OnOff::Id; + mCurrentButtonState = !mCurrentButtonState; + LightSwitchMgr::LightSwitchAction action = + mCurrentButtonState ? LightSwitchMgr::LightSwitchAction::On : LightSwitchMgr::LightSwitchAction::Off; - if (mCurrentButtonState) - { - mCurrentButtonState = false; - data->commandId = chip::app::Clusters::OnOff::Commands::Off::Id; - } - else - { - data->commandId = chip::app::Clusters::OnOff::Commands::On::Id; - mCurrentButtonState = true; - } + LightSwitchMgr::GetInstance().TriggerLightSwitchAction(action); + LightSwitchMgr::GetInstance().GenericSwitchOnInitialPress(); #ifdef DISPLAY_ENABLED sAppTask.GetLCD().WriteDemoUI(mCurrentButtonState); #endif - - DeviceLayer::PlatformMgr().ScheduleWork(SwitchWorkerFunction, reinterpret_cast(data)); + } + else if (aEvent->ButtonEvent.Action == SL_SIMPLE_BUTTON_RELEASED) + { + LightSwitchMgr::GetInstance().GenericSwitchOnShortRelease(); } } void AppTask::ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAction) { - if (buttonHandle == NULL) - { - return; - } + VerifyOrReturn(buttonHandle != NULL); AppEvent button_event = {}; button_event.Type = AppEvent::kEventType_Button; diff --git a/examples/light-switch-app/silabs/SiWx917/src/binding-handler.cpp b/examples/light-switch-app/silabs/SiWx917/src/binding-handler.cpp deleted file mode 100644 index 90a2463a088e33..00000000000000 --- a/examples/light-switch-app/silabs/SiWx917/src/binding-handler.cpp +++ /dev/null @@ -1,431 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "binding-handler.h" - -#include "AppConfig.h" -#include "app/CommandSender.h" -#include "app/clusters/bindings/BindingManager.h" -#include "app/server/Server.h" -#include "controller/InvokeInteraction.h" -#include "platform/CHIPDeviceLayer.h" -#include -#include - -#if defined(ENABLE_CHIP_SHELL) -#include "lib/shell/Engine.h" -#include "lib/shell/commands/Help.h" -#endif // ENABLE_CHIP_SHELL - -using namespace chip; -using namespace chip::app; - -#if defined(ENABLE_CHIP_SHELL) -using Shell::Engine; -using Shell::shell_command_t; -using Shell::streamer_get; -using Shell::streamer_printf; - -Engine sShellSwitchSubCommands; -Engine sShellSwitchOnOffSubCommands; - -Engine sShellSwitchGroupsSubCommands; -Engine sShellSwitchGroupsOnOffSubCommands; - -Engine sShellSwitchBindingSubCommands; -#endif // defined(ENABLE_CHIP_SHELL) - -namespace { - -void ProcessOnOffUnicastBindingCommand(CommandId commandId, const EmberBindingTableEntry & binding, - Messaging::ExchangeManager * exchangeMgr, const SessionHandle & sessionHandle) -{ - auto onSuccess = [](const ConcreteCommandPath & commandPath, const StatusIB & status, const auto & dataResponse) { - ChipLogProgress(NotSpecified, "OnOff command succeeds"); - }; - - auto onFailure = [](CHIP_ERROR error) { - ChipLogError(NotSpecified, "OnOff command failed: %" CHIP_ERROR_FORMAT, error.Format()); - }; - - switch (commandId) - { - case Clusters::OnOff::Commands::Toggle::Id: - Clusters::OnOff::Commands::Toggle::Type toggleCommand; - Controller::InvokeCommandRequest(exchangeMgr, sessionHandle, binding.remote, toggleCommand, onSuccess, onFailure); - break; - - case Clusters::OnOff::Commands::On::Id: - Clusters::OnOff::Commands::On::Type onCommand; - Controller::InvokeCommandRequest(exchangeMgr, sessionHandle, binding.remote, onCommand, onSuccess, onFailure); - break; - - case Clusters::OnOff::Commands::Off::Id: - Clusters::OnOff::Commands::Off::Type offCommand; - Controller::InvokeCommandRequest(exchangeMgr, sessionHandle, binding.remote, offCommand, onSuccess, onFailure); - break; - } -} - -void ProcessOnOffGroupBindingCommand(CommandId commandId, const EmberBindingTableEntry & binding) -{ - Messaging::ExchangeManager & exchangeMgr = Server::GetInstance().GetExchangeManager(); - - switch (commandId) - { - case Clusters::OnOff::Commands::Toggle::Id: - Clusters::OnOff::Commands::Toggle::Type toggleCommand; - Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, toggleCommand); - break; - - case Clusters::OnOff::Commands::On::Id: - Clusters::OnOff::Commands::On::Type onCommand; - Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, onCommand); - - break; - - case Clusters::OnOff::Commands::Off::Id: - Clusters::OnOff::Commands::Off::Type offCommand; - Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, offCommand); - break; - } -} - -void LightSwitchChangedHandler(const EmberBindingTableEntry & binding, OperationalDeviceProxy * peer_device, void * context) -{ - VerifyOrReturn(context != nullptr, ChipLogError(NotSpecified, "OnDeviceConnectedFn: context is null")); - BindingCommandData * data = static_cast(context); - - if (binding.type == EMBER_MULTICAST_BINDING && data->isGroup) - { - switch (data->clusterId) - { - case Clusters::OnOff::Id: - ProcessOnOffGroupBindingCommand(data->commandId, binding); - break; - } - } - else if (binding.type == EMBER_UNICAST_BINDING && !data->isGroup) - { - switch (data->clusterId) - { - case Clusters::OnOff::Id: - VerifyOrDie(peer_device != nullptr && peer_device->ConnectionReady()); - ProcessOnOffUnicastBindingCommand(data->commandId, binding, peer_device->GetExchangeManager(), - peer_device->GetSecureSession().Value()); - break; - } - } -} - -void LightSwitchContextReleaseHandler(void * context) -{ - VerifyOrReturn(context != nullptr, ChipLogError(NotSpecified, "LightSwitchContextReleaseHandler: context is null")); - - Platform::Delete(static_cast(context)); -} - -#ifdef ENABLE_CHIP_SHELL - -/******************************************************** - * Switch shell functions - *********************************************************/ - -CHIP_ERROR SwitchHelpHandler(int argc, char ** argv) -{ - sShellSwitchSubCommands.ForEachCommand(Shell::PrintCommandHelp, nullptr); - return CHIP_NO_ERROR; -} - -CHIP_ERROR SwitchCommandHandler(int argc, char ** argv) -{ - if (argc == 0) - { - return SwitchHelpHandler(argc, argv); - } - - return sShellSwitchSubCommands.ExecCommand(argc, argv); -} - -/******************************************************** - * OnOff switch shell functions - *********************************************************/ - -CHIP_ERROR OnOffHelpHandler(int argc, char ** argv) -{ - sShellSwitchOnOffSubCommands.ForEachCommand(Shell::PrintCommandHelp, nullptr); - return CHIP_NO_ERROR; -} - -CHIP_ERROR OnOffSwitchCommandHandler(int argc, char ** argv) -{ - if (argc == 0) - { - return OnOffHelpHandler(argc, argv); - } - - return sShellSwitchOnOffSubCommands.ExecCommand(argc, argv); -} - -CHIP_ERROR OnSwitchCommandHandler(int argc, char ** argv) -{ - BindingCommandData * data = Platform::New(); - data->commandId = Clusters::OnOff::Commands::On::Id; - data->clusterId = Clusters::OnOff::Id; - - DeviceLayer::PlatformMgr().ScheduleWork(SwitchWorkerFunction, reinterpret_cast(data)); - return CHIP_NO_ERROR; -} - -CHIP_ERROR OffSwitchCommandHandler(int argc, char ** argv) -{ - BindingCommandData * data = Platform::New(); - data->commandId = Clusters::OnOff::Commands::Off::Id; - data->clusterId = Clusters::OnOff::Id; - - DeviceLayer::PlatformMgr().ScheduleWork(SwitchWorkerFunction, reinterpret_cast(data)); - return CHIP_NO_ERROR; -} - -CHIP_ERROR ToggleSwitchCommandHandler(int argc, char ** argv) -{ - BindingCommandData * data = Platform::New(); - data->commandId = Clusters::OnOff::Commands::Toggle::Id; - data->clusterId = Clusters::OnOff::Id; - - DeviceLayer::PlatformMgr().ScheduleWork(SwitchWorkerFunction, reinterpret_cast(data)); - return CHIP_NO_ERROR; -} - -/******************************************************** - * bind switch shell functions - *********************************************************/ - -CHIP_ERROR BindingHelpHandler(int argc, char ** argv) -{ - sShellSwitchBindingSubCommands.ForEachCommand(Shell::PrintCommandHelp, nullptr); - return CHIP_NO_ERROR; -} - -CHIP_ERROR BindingSwitchCommandHandler(int argc, char ** argv) -{ - if (argc == 0) - { - return BindingHelpHandler(argc, argv); - } - - return sShellSwitchBindingSubCommands.ExecCommand(argc, argv); -} - -CHIP_ERROR BindingGroupBindCommandHandler(int argc, char ** argv) -{ - VerifyOrReturnError(argc == 2, CHIP_ERROR_INVALID_ARGUMENT); - - EmberBindingTableEntry * entry = Platform::New(); - entry->type = EMBER_MULTICAST_BINDING; - entry->fabricIndex = atoi(argv[0]); - entry->groupId = atoi(argv[1]); - entry->local = 1; // Hardcoded to endpoint 1 for now - entry->clusterId.SetValue(6); // Hardcoded to OnOff cluster for now - - DeviceLayer::PlatformMgr().ScheduleWork(BindingWorkerFunction, reinterpret_cast(entry)); - return CHIP_NO_ERROR; -} - -CHIP_ERROR BindingUnicastBindCommandHandler(int argc, char ** argv) -{ - VerifyOrReturnError(argc == 3, CHIP_ERROR_INVALID_ARGUMENT); - - EmberBindingTableEntry * entry = Platform::New(); - entry->type = EMBER_UNICAST_BINDING; - entry->fabricIndex = atoi(argv[0]); - entry->nodeId = atoi(argv[1]); - entry->local = 1; // Hardcoded to endpoint 1 for now - entry->remote = atoi(argv[2]); - entry->clusterId.SetValue(6); // Hardcode to OnOff cluster for now - - DeviceLayer::PlatformMgr().ScheduleWork(BindingWorkerFunction, reinterpret_cast(entry)); - return CHIP_NO_ERROR; -} - -/******************************************************** - * Groups switch shell functions - *********************************************************/ - -CHIP_ERROR GroupsHelpHandler(int argc, char ** argv) -{ - sShellSwitchGroupsSubCommands.ForEachCommand(Shell::PrintCommandHelp, nullptr); - return CHIP_NO_ERROR; -} - -CHIP_ERROR GroupsSwitchCommandHandler(int argc, char ** argv) -{ - if (argc == 0) - { - return GroupsHelpHandler(argc, argv); - } - - return sShellSwitchGroupsSubCommands.ExecCommand(argc, argv); -} - -/******************************************************** - * Groups OnOff switch shell functions - *********************************************************/ - -CHIP_ERROR GroupsOnOffHelpHandler(int argc, char ** argv) -{ - sShellSwitchGroupsOnOffSubCommands.ForEachCommand(Shell::PrintCommandHelp, nullptr); - return CHIP_NO_ERROR; -} - -CHIP_ERROR GroupsOnOffSwitchCommandHandler(int argc, char ** argv) -{ - if (argc == 0) - { - return GroupsOnOffHelpHandler(argc, argv); - } - - return sShellSwitchGroupsOnOffSubCommands.ExecCommand(argc, argv); -} - -CHIP_ERROR GroupOnSwitchCommandHandler(int argc, char ** argv) -{ - BindingCommandData * data = Platform::New(); - data->commandId = Clusters::OnOff::Commands::On::Id; - data->clusterId = Clusters::OnOff::Id; - data->isGroup = true; - - DeviceLayer::PlatformMgr().ScheduleWork(SwitchWorkerFunction, reinterpret_cast(data)); - return CHIP_NO_ERROR; -} - -CHIP_ERROR GroupOffSwitchCommandHandler(int argc, char ** argv) -{ - BindingCommandData * data = Platform::New(); - data->commandId = Clusters::OnOff::Commands::Off::Id; - data->clusterId = Clusters::OnOff::Id; - data->isGroup = true; - - DeviceLayer::PlatformMgr().ScheduleWork(SwitchWorkerFunction, reinterpret_cast(data)); - return CHIP_NO_ERROR; -} - -CHIP_ERROR GroupToggleSwitchCommandHandler(int argc, char ** argv) -{ - BindingCommandData * data = Platform::New(); - data->commandId = Clusters::OnOff::Commands::Toggle::Id; - data->clusterId = Clusters::OnOff::Id; - data->isGroup = true; - - DeviceLayer::PlatformMgr().ScheduleWork(SwitchWorkerFunction, reinterpret_cast(data)); - return CHIP_NO_ERROR; -} - -/** - * @brief configures switch matter shell - * - */ -static void RegisterSwitchCommands() -{ - static const shell_command_t sSwitchSubCommands[] = { - { &SwitchHelpHandler, "help", "Usage: switch " }, - { &OnOffSwitchCommandHandler, "onoff", " Usage: switch onoff " }, - { &GroupsSwitchCommandHandler, "groups", "Usage: switch groups " }, - { &BindingSwitchCommandHandler, "binding", "Usage: switch binding " } - }; - - static const shell_command_t sSwitchOnOffSubCommands[] = { - { &OnOffHelpHandler, "help", "Usage : switch ononff " }, - { &OnSwitchCommandHandler, "on", "Sends on command to bound lighting app" }, - { &OffSwitchCommandHandler, "off", "Sends off command to bound lighting app" }, - { &ToggleSwitchCommandHandler, "toggle", "Sends toggle command to bound lighting app" } - }; - - static const shell_command_t sSwitchGroupsSubCommands[] = { { &GroupsHelpHandler, "help", "Usage: switch groups " }, - { &GroupsOnOffSwitchCommandHandler, "onoff", - "Usage: switch groups onoff " } }; - - static const shell_command_t sSwitchGroupsOnOffSubCommands[] = { - { &GroupsOnOffHelpHandler, "help", "Usage: switch groups onoff " }, - { &GroupOnSwitchCommandHandler, "on", "Sends on command to bound group" }, - { &GroupOffSwitchCommandHandler, "off", "Sends off command to bound group" }, - { &GroupToggleSwitchCommandHandler, "toggle", "Sends toggle command to group" } - }; - - static const shell_command_t sSwitchBindingSubCommands[] = { - { &BindingHelpHandler, "help", "Usage: switch binding " }, - { &BindingGroupBindCommandHandler, "group", "Usage: switch binding group " }, - { &BindingUnicastBindCommandHandler, "unicast", "Usage: switch binding group " } - }; - - static const shell_command_t sSwitchCommand = { &SwitchCommandHandler, "switch", - "Light-switch commands. Usage: switch " }; - - sShellSwitchGroupsOnOffSubCommands.RegisterCommands(sSwitchGroupsOnOffSubCommands, ArraySize(sSwitchGroupsOnOffSubCommands)); - sShellSwitchOnOffSubCommands.RegisterCommands(sSwitchOnOffSubCommands, ArraySize(sSwitchOnOffSubCommands)); - sShellSwitchGroupsSubCommands.RegisterCommands(sSwitchGroupsSubCommands, ArraySize(sSwitchGroupsSubCommands)); - sShellSwitchBindingSubCommands.RegisterCommands(sSwitchBindingSubCommands, ArraySize(sSwitchBindingSubCommands)); - sShellSwitchSubCommands.RegisterCommands(sSwitchSubCommands, ArraySize(sSwitchSubCommands)); - - Engine::Root().RegisterCommands(&sSwitchCommand, 1); -} -#endif // ENABLE_CHIP_SHELL - -void InitBindingHandlerInternal(intptr_t arg) -{ - auto & server = chip::Server::GetInstance(); - chip::BindingManager::GetInstance().Init( - { &server.GetFabricTable(), server.GetCASESessionManager(), &server.GetPersistentStorage() }); - chip::BindingManager::GetInstance().RegisterBoundDeviceChangedHandler(LightSwitchChangedHandler); - chip::BindingManager::GetInstance().RegisterBoundDeviceContextReleaseHandler(LightSwitchContextReleaseHandler); -} - -} // namespace - -/******************************************************** - * Switch functions - *********************************************************/ - -void SwitchWorkerFunction(intptr_t context) -{ - VerifyOrReturn(context != 0, ChipLogError(NotSpecified, "SwitchWorkerFunction - Invalid work data")); - - BindingCommandData * data = reinterpret_cast(context); - BindingManager::GetInstance().NotifyBoundClusterChanged(data->localEndpointId, data->clusterId, static_cast(data)); -} - -void BindingWorkerFunction(intptr_t context) -{ - VerifyOrReturn(context != 0, ChipLogError(NotSpecified, "BindingWorkerFunction - Invalid work data")); - - EmberBindingTableEntry * entry = reinterpret_cast(context); - AddBindingEntry(*entry); - - Platform::Delete(entry); -} - -CHIP_ERROR InitBindingHandler() -{ - // The initialization of binding manager will try establishing connection with unicast peers - // so it requires the Server instance to be correctly initialized. Post the init function to - // the event queue so that everything is ready when initialization is conducted. - chip::DeviceLayer::PlatformMgr().ScheduleWork(InitBindingHandlerInternal); -#if defined(ENABLE_CHIP_SHELL) - RegisterSwitchCommands(); -#endif - return CHIP_NO_ERROR; -} diff --git a/examples/light-switch-app/silabs/common/BindingHandler.cpp b/examples/light-switch-app/silabs/common/BindingHandler.cpp new file mode 100644 index 00000000000000..3f75f79a60d82c --- /dev/null +++ b/examples/light-switch-app/silabs/common/BindingHandler.cpp @@ -0,0 +1,161 @@ +/* + * + * Copyright (c) 2020 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "BindingHandler.h" + +#include "AppConfig.h" +#include "app/CommandSender.h" +#include "app/clusters/bindings/BindingManager.h" +#include "app/server/Server.h" +#include "controller/InvokeInteraction.h" +#include "platform/CHIPDeviceLayer.h" +#include +#include + +using namespace chip; +using namespace chip::app; + +namespace { + +void ProcessOnOffUnicastBindingCommand(CommandId commandId, const EmberBindingTableEntry & binding, + Messaging::ExchangeManager * exchangeMgr, const SessionHandle & sessionHandle) +{ + auto onSuccess = [](const ConcreteCommandPath & commandPath, const StatusIB & status, const auto & dataResponse) { + ChipLogProgress(NotSpecified, "OnOff command succeeds"); + }; + + auto onFailure = [](CHIP_ERROR error) { + ChipLogError(NotSpecified, "OnOff command failed: %" CHIP_ERROR_FORMAT, error.Format()); + }; + + switch (commandId) + { + case Clusters::OnOff::Commands::Toggle::Id: + Clusters::OnOff::Commands::Toggle::Type toggleCommand; + Controller::InvokeCommandRequest(exchangeMgr, sessionHandle, binding.remote, toggleCommand, onSuccess, onFailure); + break; + + case Clusters::OnOff::Commands::On::Id: + Clusters::OnOff::Commands::On::Type onCommand; + Controller::InvokeCommandRequest(exchangeMgr, sessionHandle, binding.remote, onCommand, onSuccess, onFailure); + break; + + case Clusters::OnOff::Commands::Off::Id: + Clusters::OnOff::Commands::Off::Type offCommand; + Controller::InvokeCommandRequest(exchangeMgr, sessionHandle, binding.remote, offCommand, onSuccess, onFailure); + break; + } +} + +void ProcessOnOffGroupBindingCommand(CommandId commandId, const EmberBindingTableEntry & binding) +{ + Messaging::ExchangeManager & exchangeMgr = Server::GetInstance().GetExchangeManager(); + + switch (commandId) + { + case Clusters::OnOff::Commands::Toggle::Id: + Clusters::OnOff::Commands::Toggle::Type toggleCommand; + Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, toggleCommand); + break; + + case Clusters::OnOff::Commands::On::Id: + Clusters::OnOff::Commands::On::Type onCommand; + Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, onCommand); + + break; + + case Clusters::OnOff::Commands::Off::Id: + Clusters::OnOff::Commands::Off::Type offCommand; + Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, offCommand); + break; + } +} + +void LightSwitchChangedHandler(const EmberBindingTableEntry & binding, OperationalDeviceProxy * peer_device, void * context) +{ + VerifyOrReturn(context != nullptr, ChipLogError(NotSpecified, "OnDeviceConnectedFn: context is null")); + BindingCommandData * data = static_cast(context); + + if (binding.type == EMBER_MULTICAST_BINDING && data->isGroup) + { + switch (data->clusterId) + { + case Clusters::OnOff::Id: + ProcessOnOffGroupBindingCommand(data->commandId, binding); + break; + } + } + else if (binding.type == EMBER_UNICAST_BINDING && !data->isGroup) + { + switch (data->clusterId) + { + case Clusters::OnOff::Id: + VerifyOrDie(peer_device != nullptr && peer_device->ConnectionReady()); + ProcessOnOffUnicastBindingCommand(data->commandId, binding, peer_device->GetExchangeManager(), + peer_device->GetSecureSession().Value()); + break; + } + } +} + +void LightSwitchContextReleaseHandler(void * context) +{ + VerifyOrReturn(context != nullptr, ChipLogError(NotSpecified, "LightSwitchContextReleaseHandler: context is null")); + Platform::Delete(static_cast(context)); +} + +void InitBindingHandlerInternal(intptr_t arg) +{ + auto & server = chip::Server::GetInstance(); + chip::BindingManager::GetInstance().Init( + { &server.GetFabricTable(), server.GetCASESessionManager(), &server.GetPersistentStorage() }); + chip::BindingManager::GetInstance().RegisterBoundDeviceChangedHandler(LightSwitchChangedHandler); + chip::BindingManager::GetInstance().RegisterBoundDeviceContextReleaseHandler(LightSwitchContextReleaseHandler); +} + +} // namespace + +/******************************************************** + * Switch functions + *********************************************************/ + +void SwitchWorkerFunction(intptr_t context) +{ + VerifyOrReturn(context != 0, ChipLogError(NotSpecified, "SwitchWorkerFunction - Invalid work data")); + + BindingCommandData * data = reinterpret_cast(context); + BindingManager::GetInstance().NotifyBoundClusterChanged(data->localEndpointId, data->clusterId, static_cast(data)); +} + +void BindingWorkerFunction(intptr_t context) +{ + VerifyOrReturn(context != 0, ChipLogError(NotSpecified, "BindingWorkerFunction - Invalid work data")); + + EmberBindingTableEntry * entry = reinterpret_cast(context); + AddBindingEntry(*entry); + + Platform::Delete(entry); +} + +CHIP_ERROR InitBindingHandler() +{ + // The initialization of binding manager will try establishing connection with unicast peers + // so it requires the Server instance to be correctly initialized. Post the init function to + // the event queue so that everything is ready when initialization is conducted. + chip::DeviceLayer::PlatformMgr().ScheduleWork(InitBindingHandlerInternal); + return CHIP_NO_ERROR; +} diff --git a/examples/light-switch-app/silabs/SiWx917/include/binding-handler.h b/examples/light-switch-app/silabs/common/BindingHandler.h similarity index 100% rename from examples/light-switch-app/silabs/SiWx917/include/binding-handler.h rename to examples/light-switch-app/silabs/common/BindingHandler.h diff --git a/examples/light-switch-app/silabs/common/LightSwitchMgr.cpp b/examples/light-switch-app/silabs/common/LightSwitchMgr.cpp new file mode 100644 index 00000000000000..dddff2fc047616 --- /dev/null +++ b/examples/light-switch-app/silabs/common/LightSwitchMgr.cpp @@ -0,0 +1,161 @@ +/* + * + * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2018 Nest Labs, Inc. + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "LightSwitchMgr.h" +#include "BindingHandler.h" + +#if defined(ENABLE_CHIP_SHELL) +#include "ShellCommands.h" +#endif // defined(ENABLE_CHIP_SHELL) + +#include "AppConfig.h" +#include "AppEvent.h" + +#include +#include +#include +#include + +using namespace chip; +using namespace chip::app; +using namespace chip::app::Clusters; + +LightSwitchMgr LightSwitchMgr::sSwitch; + +/** + * @brief Configures LightSwitchMgr + * This function needs to be call before using the LightSwitchMgr + * + * @param lightSwitchEndpoint endpoint for the light switch device type + * @param genericSwitchEndpoint endpoint for the generic switch device type + */ +CHIP_ERROR LightSwitchMgr::Init(EndpointId lightSwitchEndpoint, chip::EndpointId genericSwitchEndpoint) +{ + VerifyOrReturnError(lightSwitchEndpoint != kInvalidEndpointId, CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrReturnError(genericSwitchEndpoint != kInvalidEndpointId, CHIP_ERROR_INVALID_ARGUMENT); + + mLightSwitchEndpoint = lightSwitchEndpoint; + mGenericSwitchEndpoint = genericSwitchEndpoint; + + // Configure Bindings + CHIP_ERROR error = InitBindingHandler(); + if (error != CHIP_NO_ERROR) + { + SILABS_LOG("InitBindingHandler() failed!"); + appError(error); + } + +#if defined(ENABLE_CHIP_SHELL) + LightSwtichCommands::RegisterSwitchCommands(); +#endif // defined(ENABLE_CHIP_SHELL) + + return error; +} + +/** + * @brief Function that triggers a generic switch OnInitialPress event + */ +void LightSwitchMgr::GenericSwitchOnInitialPress() +{ + GenericSwitchEventData * data = Platform::New(); + + data->endpoint = mGenericSwitchEndpoint; + data->event = Switch::Events::InitialPress::Id; + + DeviceLayer::PlatformMgr().ScheduleWork(GenericSwitchWorkerFunction, reinterpret_cast(data)); +} + +/** + * @brief Function that triggers a generic switch OnShortRelease event + */ +void LightSwitchMgr::GenericSwitchOnShortRelease() +{ + GenericSwitchEventData * data = Platform::New(); + + data->endpoint = mGenericSwitchEndpoint; + data->event = Switch::Events::ShortRelease::Id; + + DeviceLayer::PlatformMgr().ScheduleWork(GenericSwitchWorkerFunction, reinterpret_cast(data)); +} + +void LightSwitchMgr::TriggerLightSwitchAction(LightSwitchAction action, bool isGroupCommand) +{ + BindingCommandData * data = Platform::New(); + + data->clusterId = chip::app::Clusters::OnOff::Id; + data->isGroup = isGroupCommand; + + switch (action) + { + case LightSwitchAction::Toggle: + data->commandId = OnOff::Commands::Toggle::Id; + + break; + + case LightSwitchAction::On: + data->commandId = OnOff::Commands::On::Id; + break; + + case LightSwitchAction::Off: + data->commandId = OnOff::Commands::Off::Id; + break; + + default: + Platform::Delete(data); + return; + break; + } + + DeviceLayer::PlatformMgr().ScheduleWork(SwitchWorkerFunction, reinterpret_cast(data)); +} + +void LightSwitchMgr::GenericSwitchWorkerFunction(intptr_t context) +{ + + GenericSwitchEventData * data = reinterpret_cast(context); + + switch (data->event) + { + case Switch::Events::InitialPress::Id: { + uint8_t currentPosition = 1; + + // Set new attribute value + Clusters::Switch::Attributes::CurrentPosition::Set(data->endpoint, currentPosition); + + // Trigger event + Clusters::SwitchServer::Instance().OnInitialPress(data->endpoint, currentPosition); + break; + } + case Switch::Events::ShortRelease::Id: { + uint8_t previousPosition = 1; + uint8_t currentPosition = 0; + + // Set new attribute value + Clusters::Switch::Attributes::CurrentPosition::Set(data->endpoint, currentPosition); + + // Trigger event + Clusters::SwitchServer::Instance().OnShortRelease(data->endpoint, previousPosition); + break; + } + default: + break; + } + + Platform::Delete(data); +} diff --git a/examples/light-switch-app/silabs/common/LightSwitchMgr.h b/examples/light-switch-app/silabs/common/LightSwitchMgr.h new file mode 100644 index 00000000000000..adfe75fda9512e --- /dev/null +++ b/examples/light-switch-app/silabs/common/LightSwitchMgr.h @@ -0,0 +1,58 @@ +/* + * + * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2018 Nest Labs, Inc. + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include +#include + +class LightSwitchMgr +{ +public: + enum class LightSwitchAction : uint8_t + { + Toggle, // Triggers an toggle command + On, // Triggers an On command + Off // Trigger an Off command + }; + + struct GenericSwitchEventData + { + chip::EndpointId endpoint; + chip::EventId event; + }; + + CHIP_ERROR Init(chip::EndpointId lightSwitchEndpoint, chip::EndpointId genericSwitchEndpoint); + + void GenericSwitchOnInitialPress(); + void GenericSwitchOnShortRelease(); + + void TriggerLightSwitchAction(LightSwitchAction action, bool isGroupCommand = false); + + static LightSwitchMgr & GetInstance() { return sSwitch; } + +private: + static LightSwitchMgr sSwitch; + + static void GenericSwitchWorkerFunction(intptr_t context); + + chip::EndpointId mLightSwitchEndpoint = chip::kInvalidEndpointId; + chip::EndpointId mGenericSwitchEndpoint = chip::kInvalidEndpointId; +}; diff --git a/examples/light-switch-app/silabs/efr32/src/binding-handler.cpp b/examples/light-switch-app/silabs/common/ShellCommands.cpp similarity index 64% rename from examples/light-switch-app/silabs/efr32/src/binding-handler.cpp rename to examples/light-switch-app/silabs/common/ShellCommands.cpp index 90a2463a088e33..daac5078501858 100644 --- a/examples/light-switch-app/silabs/efr32/src/binding-handler.cpp +++ b/examples/light-switch-app/silabs/common/ShellCommands.cpp @@ -1,6 +1,8 @@ /* * * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2018 Nest Labs, Inc. + * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,27 +16,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#if defined(ENABLE_CHIP_SHELL) -#include "binding-handler.h" +#include "ShellCommands.h" +#include "BindingHandler.h" -#include "AppConfig.h" -#include "app/CommandSender.h" -#include "app/clusters/bindings/BindingManager.h" -#include "app/server/Server.h" -#include "controller/InvokeInteraction.h" -#include "platform/CHIPDeviceLayer.h" #include -#include - -#if defined(ENABLE_CHIP_SHELL) -#include "lib/shell/Engine.h" -#include "lib/shell/commands/Help.h" -#endif // ENABLE_CHIP_SHELL +#include +#include +#include using namespace chip; using namespace chip::app; -#if defined(ENABLE_CHIP_SHELL) +namespace LightSwtichCommands { + using Shell::Engine; using Shell::shell_command_t; using Shell::streamer_get; @@ -47,99 +43,6 @@ Engine sShellSwitchGroupsSubCommands; Engine sShellSwitchGroupsOnOffSubCommands; Engine sShellSwitchBindingSubCommands; -#endif // defined(ENABLE_CHIP_SHELL) - -namespace { - -void ProcessOnOffUnicastBindingCommand(CommandId commandId, const EmberBindingTableEntry & binding, - Messaging::ExchangeManager * exchangeMgr, const SessionHandle & sessionHandle) -{ - auto onSuccess = [](const ConcreteCommandPath & commandPath, const StatusIB & status, const auto & dataResponse) { - ChipLogProgress(NotSpecified, "OnOff command succeeds"); - }; - - auto onFailure = [](CHIP_ERROR error) { - ChipLogError(NotSpecified, "OnOff command failed: %" CHIP_ERROR_FORMAT, error.Format()); - }; - - switch (commandId) - { - case Clusters::OnOff::Commands::Toggle::Id: - Clusters::OnOff::Commands::Toggle::Type toggleCommand; - Controller::InvokeCommandRequest(exchangeMgr, sessionHandle, binding.remote, toggleCommand, onSuccess, onFailure); - break; - - case Clusters::OnOff::Commands::On::Id: - Clusters::OnOff::Commands::On::Type onCommand; - Controller::InvokeCommandRequest(exchangeMgr, sessionHandle, binding.remote, onCommand, onSuccess, onFailure); - break; - - case Clusters::OnOff::Commands::Off::Id: - Clusters::OnOff::Commands::Off::Type offCommand; - Controller::InvokeCommandRequest(exchangeMgr, sessionHandle, binding.remote, offCommand, onSuccess, onFailure); - break; - } -} - -void ProcessOnOffGroupBindingCommand(CommandId commandId, const EmberBindingTableEntry & binding) -{ - Messaging::ExchangeManager & exchangeMgr = Server::GetInstance().GetExchangeManager(); - - switch (commandId) - { - case Clusters::OnOff::Commands::Toggle::Id: - Clusters::OnOff::Commands::Toggle::Type toggleCommand; - Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, toggleCommand); - break; - - case Clusters::OnOff::Commands::On::Id: - Clusters::OnOff::Commands::On::Type onCommand; - Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, onCommand); - - break; - - case Clusters::OnOff::Commands::Off::Id: - Clusters::OnOff::Commands::Off::Type offCommand; - Controller::InvokeGroupCommandRequest(&exchangeMgr, binding.fabricIndex, binding.groupId, offCommand); - break; - } -} - -void LightSwitchChangedHandler(const EmberBindingTableEntry & binding, OperationalDeviceProxy * peer_device, void * context) -{ - VerifyOrReturn(context != nullptr, ChipLogError(NotSpecified, "OnDeviceConnectedFn: context is null")); - BindingCommandData * data = static_cast(context); - - if (binding.type == EMBER_MULTICAST_BINDING && data->isGroup) - { - switch (data->clusterId) - { - case Clusters::OnOff::Id: - ProcessOnOffGroupBindingCommand(data->commandId, binding); - break; - } - } - else if (binding.type == EMBER_UNICAST_BINDING && !data->isGroup) - { - switch (data->clusterId) - { - case Clusters::OnOff::Id: - VerifyOrDie(peer_device != nullptr && peer_device->ConnectionReady()); - ProcessOnOffUnicastBindingCommand(data->commandId, binding, peer_device->GetExchangeManager(), - peer_device->GetSecureSession().Value()); - break; - } - } -} - -void LightSwitchContextReleaseHandler(void * context) -{ - VerifyOrReturn(context != nullptr, ChipLogError(NotSpecified, "LightSwitchContextReleaseHandler: context is null")); - - Platform::Delete(static_cast(context)); -} - -#ifdef ENABLE_CHIP_SHELL /******************************************************** * Switch shell functions @@ -337,9 +240,8 @@ CHIP_ERROR GroupToggleSwitchCommandHandler(int argc, char ** argv) /** * @brief configures switch matter shell - * */ -static void RegisterSwitchCommands() +void RegisterSwitchCommands() { static const shell_command_t sSwitchSubCommands[] = { { &SwitchHelpHandler, "help", "Usage: switch " }, @@ -383,49 +285,7 @@ static void RegisterSwitchCommands() Engine::Root().RegisterCommands(&sSwitchCommand, 1); } -#endif // ENABLE_CHIP_SHELL - -void InitBindingHandlerInternal(intptr_t arg) -{ - auto & server = chip::Server::GetInstance(); - chip::BindingManager::GetInstance().Init( - { &server.GetFabricTable(), server.GetCASESessionManager(), &server.GetPersistentStorage() }); - chip::BindingManager::GetInstance().RegisterBoundDeviceChangedHandler(LightSwitchChangedHandler); - chip::BindingManager::GetInstance().RegisterBoundDeviceContextReleaseHandler(LightSwitchContextReleaseHandler); -} - -} // namespace - -/******************************************************** - * Switch functions - *********************************************************/ - -void SwitchWorkerFunction(intptr_t context) -{ - VerifyOrReturn(context != 0, ChipLogError(NotSpecified, "SwitchWorkerFunction - Invalid work data")); - - BindingCommandData * data = reinterpret_cast(context); - BindingManager::GetInstance().NotifyBoundClusterChanged(data->localEndpointId, data->clusterId, static_cast(data)); -} - -void BindingWorkerFunction(intptr_t context) -{ - VerifyOrReturn(context != 0, ChipLogError(NotSpecified, "BindingWorkerFunction - Invalid work data")); - EmberBindingTableEntry * entry = reinterpret_cast(context); - AddBindingEntry(*entry); +} // namespace LightSwtichCommands - Platform::Delete(entry); -} - -CHIP_ERROR InitBindingHandler() -{ - // The initialization of binding manager will try establishing connection with unicast peers - // so it requires the Server instance to be correctly initialized. Post the init function to - // the event queue so that everything is ready when initialization is conducted. - chip::DeviceLayer::PlatformMgr().ScheduleWork(InitBindingHandlerInternal); -#if defined(ENABLE_CHIP_SHELL) - RegisterSwitchCommands(); -#endif - return CHIP_NO_ERROR; -} +#endif // ENABLE_CHIP_SHELL diff --git a/examples/light-switch-app/silabs/efr32/include/binding-handler.h b/examples/light-switch-app/silabs/common/ShellCommands.h similarity index 61% rename from examples/light-switch-app/silabs/efr32/include/binding-handler.h rename to examples/light-switch-app/silabs/common/ShellCommands.h index aed08be25eb5bc..576ad5235ffd6b 100644 --- a/examples/light-switch-app/silabs/efr32/include/binding-handler.h +++ b/examples/light-switch-app/silabs/common/ShellCommands.h @@ -1,6 +1,8 @@ /* * * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2018 Nest Labs, Inc. + * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,20 +16,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #pragma once -#include "app-common/zap-generated/ids/Clusters.h" -#include "app-common/zap-generated/ids/Commands.h" -#include "lib/core/CHIPError.h" +#if defined(ENABLE_CHIP_SHELL) + +namespace LightSwtichCommands { + +void RegisterSwitchCommands(); -CHIP_ERROR InitBindingHandler(); -void SwitchWorkerFunction(intptr_t context); -void BindingWorkerFunction(intptr_t context); +} // namespace LightSwtichCommands -struct BindingCommandData -{ - chip::EndpointId localEndpointId = 1; - chip::CommandId commandId; - chip::ClusterId clusterId; - bool isGroup = false; -}; +#endif // defined(ENABLE_CHIP_SHELL) diff --git a/examples/light-switch-app/silabs/efr32/BUILD.gn b/examples/light-switch-app/silabs/efr32/BUILD.gn index 823f733273b9eb..0d49e7c354149d 100644 --- a/examples/light-switch-app/silabs/efr32/BUILD.gn +++ b/examples/light-switch-app/silabs/efr32/BUILD.gn @@ -35,114 +35,11 @@ efr32_project_dir = "${chip_root}/examples/light-switch-app/silabs/efr32" examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32" examples_common_plat_dir = "${chip_root}/examples/platform/silabs" +import("${examples_plat_dir}/args.gni") + declare_args() { # Dump memory usage at link time. chip_print_memory_usage = false - - # Monitor & log memory usage at runtime. - enable_heap_monitoring = false - - # Enable Sleepy end device - enable_sleepy_device = false - - # OTA timeout in seconds - OTA_periodic_query_timeout = 86400 - - # Wifi related stuff - they are overridden by gn -args="use_wf200=true" - use_wf200 = false - use_rs911x = false - use_rs911x_sockets = false - sl_wfx_config_softap = false - sl_wfx_config_scan = true - - # Disable LCD on supported devices - disable_lcd = false - - # Argument to Disable IPv4 for wifi(rs911) - chip_enable_wifi_ipv4 = false - - # Argument to force enable WPA3 security - rs91x_wpa3_only = false - - #default WiFi SSID - chip_default_wifi_ssid = "" - - #default Wifi Password - chip_default_wifi_psk = "" -} - -declare_args() { - # Enables LCD Qr Code on supported devices - show_qr_code = !disable_lcd -} - -# qr code cannot be true if lcd is disabled -assert(!(disable_lcd && show_qr_code)) - -# Sanity check -assert(!(chip_enable_wifi && chip_enable_openthread)) -assert(!(use_rs911x && chip_enable_openthread)) -assert(!(use_wf200 && chip_enable_openthread)) -if (chip_enable_wifi) { - assert(use_rs911x || use_wf200) - enable_openthread_cli = false - import("${chip_root}/src/platform/silabs/EFR32/wifi_args.gni") -} - -# ThunderBoards, Explorer Kit and MGM240L do not support LCD (No LCD) -if (silabs_board == "BRD4166A" || silabs_board == "BRD2601B" || - silabs_board == "BRD2703A" || silabs_board == "BRD4319A") { - show_qr_code = false - disable_lcd = true -} - -defines = [] - -# WiFi settings -if (chip_enable_wifi) { - if (chip_default_wifi_ssid != "") { - defines += [ - "CHIP_ONNETWORK_PAIRING=1", - "CHIP_WIFI_SSID=\"${chip_default_wifi_ssid}\"", - ] - } - if (chip_default_wifi_psk != "") { - assert(chip_default_wifi_ssid != "", - "ssid can't be null if psk is provided") - defines += [ "CHIP_WIFI_PSK=\"${chip_default_wifi_psk}\"" ] - } - wifi_sdk_dir = "${chip_root}/src/platform/silabs/EFR32/wifi" - efr32_lwip_defs = [ "LWIP_NETIF_API=1" ] - if (lwip_ipv4) { - efr32_lwip_defs += [ - "LWIP_IPV4=1", - - # adds following options to provide - # them to .cpp source files - # flags ported from lwipopts file - # TODO: move lwipopts to one location - "LWIP_ARP=1", - "LWIP_ICMP=1", - "LWIP_IGMP=1", - "LWIP_DHCP=1", - "LWIP_DNS=0", - ] - } else { - efr32_lwip_defs += [ "LWIP_IPV4=0" ] - } - if (lwip_ipv6) { - efr32_lwip_defs += [ "LWIP_IPV6=1" ] - } else { - efr32_lwip_defs += [ "LWIP_IPV6=0" ] - } - - if (use_rs911x) { - wiseconnect_sdk_root = - "${chip_root}/third_party/silabs/wiseconnect-wifi-bt-sdk" - import("${examples_plat_dir}/rs911x/rs911x.gni") - } else { - import("${examples_plat_dir}/wf200/wf200.gni") - } } efr32_sdk("sdk") { @@ -152,6 +49,7 @@ efr32_sdk("sdk") { ] include_dirs = [ + "${chip_root}/examples/light-switch-app/silabs/common", "${chip_root}/src/platform/silabs/EFR32", "${efr32_project_dir}/include", "${examples_plat_dir}", @@ -159,43 +57,18 @@ efr32_sdk("sdk") { "${examples_common_plat_dir}", ] - defines += [ - "BOARD_ID=${silabs_board}", - "OTA_PERIODIC_TIMEOUT=${OTA_periodic_query_timeout}", - ] + if (use_wf200) { + # TODO efr32_sdk should not need a header from this location + include_dirs += [ "${examples_plat_dir}/wf200" ] + } + defines = [] if (chip_enable_pw_rpc) { defines += [ "HAL_VCOM_ENABLE=1", "PW_RPC_ENABLED", ] } - - # WiFi Settings - if (chip_enable_wifi) { - if (use_rs911x) { - defines += rs911x_defs - include_dirs += rs911x_plat_incs - } else if (use_wf200) { - defines += wf200_defs - include_dirs += wf200_plat_incs - } - - if (use_rs911x_sockets) { - include_dirs += [ "${examples_plat_dir}/wifi/rsi-sockets" ] - defines += rs911x_sock_defs - } else { - # Using LWIP instead of the native TCP/IP stack - defines += efr32_lwip_defs - } - - if (sl_wfx_config_softap) { - defines += [ "SL_WFX_CONFIG_SOFTAP" ] - } - if (sl_wfx_config_scan) { - defines += [ "SL_WFX_CONFIG_SCAN" ] - } - } } efr32_executable("light_switch_app") { @@ -205,110 +78,23 @@ efr32_executable("light_switch_app") { defines = [] sources = [ - "${examples_common_plat_dir}/heap_4_silabs.c", - "${examples_plat_dir}/BaseApplication.cpp", - "${examples_plat_dir}/efr32_utils.cpp", - "${examples_plat_dir}/init_efrPlatform.cpp", - "${examples_plat_dir}/matter_config.cpp", + "${chip_root}/examples/light-switch-app/silabs/common/BindingHandler.cpp", + "${chip_root}/examples/light-switch-app/silabs/common/LightSwitchMgr.cpp", "src/AppTask.cpp", "src/ZclCallbacks.cpp", - "src/binding-handler.cpp", "src/main.cpp", ] - if (use_wstk_leds) { - sources += [ "${examples_plat_dir}/LEDWidget.cpp" ] - } - - if (chip_enable_pw_rpc || chip_build_libshell || enable_openthread_cli || - use_wf200 || use_rs911x) { - sources += [ "${examples_plat_dir}/uart.cpp" ] - } - deps = [ ":sdk", - "${chip_root}/examples/light-switch-app/light-switch-common", - "${chip_root}/examples/providers:device_info_provider", - "${chip_root}/src/lib", - "${chip_root}/src/setup_payload", + "${examples_plat_dir}:efr32-common", + app_data_model, ] - # OpenThread Settings - if (chip_enable_openthread) { - deps += [ - "${chip_root}/third_party/openthread:openthread", - "${chip_root}/third_party/openthread:openthread-platform", - "${examples_plat_dir}:efr-matter-shell", - ] - } - - # Attestation Credentials - if (chip_build_platform_attestation_credentials_provider) { - deps += [ "${examples_plat_dir}:efr32-attestation-credentials" ] - } - - # Factory Data Provider - if (use_efr32_factory_data_provider) { - deps += [ "${examples_plat_dir}:efr32-factory-data-provider" ] - } - - if (chip_enable_ota_requestor) { - defines += [ "EFR32_OTA_ENABLED" ] - sources += [ "${examples_plat_dir}/OTAConfig.cpp" ] - } - - # WiFi Settings - if (chip_enable_wifi) { - if (use_rs911x) { - sources += rs911x_src_plat - - # All the stuff from wiseconnect - sources += rs911x_src_sapi - - # Apparently - the rsi library needs this (though we may not use use it) - sources += rs911x_src_sock - include_dirs += rs911x_inc_plat - - if (use_rs911x_sockets) { - # - # Using native sockets inside RS911x - # - include_dirs += rs911x_sock_inc - } else { - # - # We use LWIP - not built-in sockets - # - sources += rs911x_src_lwip - } - } else if (use_wf200) { - sources += wf200_plat_src - include_dirs += wf200_plat_incs - } - - if (chip_enable_wifi_ipv4) { - defines += [ "CHIP_DEVICE_CONFIG_ENABLE_IPV4" ] - } - - if (rs91x_wpa3_only) { - # TODO: Change this macro once WF200 support is provided - defines += [ "WIFI_ENABLE_SECURITY_WPA3=1" ] - } - } - - if (!disable_lcd) { + if (chip_build_libshell) { sources += [ - "${examples_plat_dir}/display/demo-ui.c", - "${examples_plat_dir}/display/lcd.cpp", + "${chip_root}/examples/light-switch-app/silabs/common/ShellCommands.cpp", ] - include_dirs += [ "${examples_plat_dir}/display" ] - defines += [ - "DISPLAY_ENABLED", - "IS_DEMO_SWITCH=1", - ] - if (show_qr_code) { - defines += [ "QR_CODE_ENABLED" ] - deps += [ "${chip_root}/examples/common/QRCode" ] - } } if (chip_enable_pw_rpc) { @@ -348,11 +134,6 @@ efr32_executable("light_switch_app") { ] } - if (enable_heap_monitoring) { - sources += [ "${examples_common_plat_dir}/MemMonitoring.cpp" ] - defines += [ "HEAP_MONITORING" ] - } - ldscript = "${examples_plat_dir}/ldscripts/${silabs_family}.ld" inputs = [ ldscript ] diff --git a/examples/light-switch-app/silabs/efr32/README.md b/examples/light-switch-app/silabs/efr32/README.md index d79ab2895cbf91..7d1eceee613bcf 100644 --- a/examples/light-switch-app/silabs/efr32/README.md +++ b/examples/light-switch-app/silabs/efr32/README.md @@ -103,35 +103,10 @@ Silicon Labs platform. - BRD4187A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - BRD4187C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - MG12 boards: - - - BRD4161A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm - - BRD4162A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4163A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm, - 868MHz@19dBm - - BRD4164A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm - - BRD4166A / SLTB004A / Thunderboard Sense 2 / 2.4GHz@10dBm - - BRD4170A / SLWSTK6000B / Multiband Wireless Starter Kit / 2.4GHz@19dBm, - 915MHz@19dBm - - BRD4304A / SLWSTK6000B / MGM12P Module / 2.4GHz@19dBm - - MG21 boards: Currently not supported due to RAM limitation. - - - BRD4180A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - - MG24 boards : - - - BRD2601B / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD2703A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4186A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4186C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4187A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - - BRD4187C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - * Build the example application: cd ~/connectedhomeip - ./scripts/examples/gn_efr32_example.sh ./examples/light-switch-app/efr32/ ./out/light-switch-app BRD4161A + ./scripts/examples/gn_efr32_example.sh ./examples/light-switch-app/silabs/efr32/ ./out/light-switch-app BRD4161A - To delete generated executable, libraries and object files use: @@ -140,7 +115,7 @@ Silicon Labs platform. OR use GN/Ninja directly - $ cd ~/connectedhomeip/examples/light-switch-app/efr32 + $ cd ~/connectedhomeip/examples/light-switch-app/silabs/efr32 $ git submodule update --init $ source third_party/connectedhomeip/scripts/activate.sh $ export EFR32_BOARD=BRD4161A @@ -149,16 +124,16 @@ Silicon Labs platform. - To delete generated executable, libraries and object files use: - $ cd ~/connectedhomeip/examples/light-switch-app/efr32 + $ cd ~/connectedhomeip/examples/light-switch-app/silabs/efr32 $ rm -rf out/ * Build the example with Matter shell - ./scripts/examples/gn_efr32_example.sh examples/light-switch-app/efr32/ out/light-switch-app BRD4161A chip_build_libshell=true + ./scripts/examples/gn_efr32_example.sh examples/light-switch-app/silabs/efr32/ out/light-switch-app BRD4161A chip_build_libshell=true * Build the example as Sleepy End Device (SED) - $ ./scripts/examples/gn_efr32_example.sh ./examples/light-switch-app/efr32/ ./out/light-switch-app_SED BRD4161A --sed + $ ./scripts/examples/gn_efr32_example.sh ./examples/light-switch-app/silabs/efr32/ ./out/light-switch-app_SED BRD4161A --sed or use gn as previously mentioned but adding the following arguments: @@ -166,11 +141,11 @@ Silicon Labs platform. * Build the example with pigweed RCP - $ ./scripts/examples/gn_efr32_example.sh examples/light-switch-app/efr32/ out/light-switch-app_rpc BRD4161A 'import("//with_pw_rpc.gni")' + $ ./scripts/examples/gn_efr32_example.sh examples/light-switch-app/silabs/efr32/ out/light-switch-app_rpc BRD4161A 'import("//with_pw_rpc.gni")' or use GN/Ninja Directly - $ cd ~/connectedhomeip/examples/light-switch-app/efr32 + $ cd ~/connectedhomeip/examples/light-switch-app/silabs/efr32 $ git submodule update --init $ source third_party/connectedhomeip/scripts/activate.sh $ export EFR32_BOARD=BRD4161A @@ -186,7 +161,7 @@ arguments - On the command line: - $ cd ~/connectedhomeip/examples/lighting-app/efr32 + $ cd ~/connectedhomeip/examples/light-switch-app/silabs/efr32 $ python3 out/debug/chip-efr32-light-switch-example.flash.py - Or with the Ozone debugger, just load the .out file. @@ -252,7 +227,7 @@ combination with JLinkRTTClient as follows: - For this example to work, it is necessary to have a second efr32 device running the - [lighting app example](https://github.com/project-chip/connectedhomeip/blob/master/examples/lighting-app/efr32/README.md) + [lighting app example](https://github.com/project-chip/connectedhomeip/blob/master/examples/lighting-app/silabs/efr32/README.md) commissioned on the same openthread network - User interface : **LCD** The LCD on Silabs WSTK shows a QR Code. This QR @@ -411,7 +386,7 @@ To track memory usage you can set `enable_heap_monitoring = true` either in the BUILD.gn file or pass it as a build argument to gn. This will print on the RTT console the RAM usage of each individual task and the number of Memory allocation and Free. While this is not extensive monitoring you're welcome to -modify `examples/platform/efr32/MemMonitoring.cpp` to add your own memory +modify `examples/platform/silabs/efr32/MemMonitoring.cpp` to add your own memory tracking code inside the `trackAlloc` and `trackFree` function ## OTA Software Update @@ -430,19 +405,19 @@ features can easily be toggled on or off. Here is a short list of options : chip_progress_logging, chip_detail_logging, chip_automation_logging - $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/efr32 ./out/lighting-app BRD4164A "chip_detail_logging=false chip_automation_logging=false chip_progress_logging=false" + $ ./scripts/examples/gn_efr32_example.sh ./examples/light-switch-app/silabs/efr32 ./out/light-switch-app BRD4164A "chip_detail_logging=false chip_automation_logging=false chip_progress_logging=false" ### Debug build / release build is_debug - $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/efr32 ./out/lighting-app BRD4164A "is_debug=false" + $ ./scripts/examples/gn_efr32_example.sh ./examples/light-switch-app/silabs/efr32 ./out/light-switch-app BRD4164A "is_debug=false" ### Disabling LCD show_qr_code - $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/efr32 ./out/lighting-app BRD4164A "show_qr_code=false" + $ ./scripts/examples/gn_efr32_example.sh ./examples/light-switch-app/silabs/efr32 ./out/light-switch-app BRD4164A "show_qr_code=false" ### KVS maximum entry count @@ -451,4 +426,4 @@ kvs_max_entries Set the maximum Kvs entries that can be stored in NVM (Default 75) Thresholds: 30 <= kvs_max_entries <= 255 - $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/efr32 ./out/lighting-app BRD4164A kvs_max_entries=50 + $ ./scripts/examples/gn_efr32_example.sh ./examples/light-switch-app/silabs/efr32 ./out/light-switch-app BRD4164A kvs_max_entries=50 diff --git a/examples/light-switch-app/silabs/efr32/args.gni b/examples/light-switch-app/silabs/efr32/args.gni index c7b087a4ee4f49..5ca79b0919f47b 100644 --- a/examples/light-switch-app/silabs/efr32/args.gni +++ b/examples/light-switch-app/silabs/efr32/args.gni @@ -18,6 +18,7 @@ import("${chip_root}/src/platform/silabs/EFR32/args.gni") efr32_sdk_target = get_label_info(":sdk", "label_no_toolchain") +app_data_model = "${chip_root}/examples/light-switch-app/light-switch-common" chip_enable_ota_requestor = true chip_enable_openthread = true openthread_external_platform = diff --git a/examples/light-switch-app/silabs/efr32/build_for_wifi_args.gni b/examples/light-switch-app/silabs/efr32/build_for_wifi_args.gni index 86d8a19bbc36ce..7069bd4823a499 100644 --- a/examples/light-switch-app/silabs/efr32/build_for_wifi_args.gni +++ b/examples/light-switch-app/silabs/efr32/build_for_wifi_args.gni @@ -19,3 +19,4 @@ chip_enable_openthread = false import("${chip_root}/src/platform/silabs/EFR32/wifi_args.gni") chip_enable_ota_requestor = true +app_data_model = "${chip_root}/examples/light-switch-app/light-switch-common" diff --git a/examples/light-switch-app/silabs/efr32/include/AppConfig.h b/examples/light-switch-app/silabs/efr32/include/AppConfig.h index a936fe1d8abaeb..5b0d0a461072d5 100644 --- a/examples/light-switch-app/silabs/efr32/include/AppConfig.h +++ b/examples/light-switch-app/silabs/efr32/include/AppConfig.h @@ -27,6 +27,63 @@ // state to another. #define ACTUATOR_MOVEMENT_PERIOS_MS 10 +// APP Logo, boolean only. must be 64x64 +#define ON_DEMO_BITMAP \ + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, \ + 0x3F, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, \ + 0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, \ + 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0xC0, 0xFF, 0xFF, 0x03, 0xF8, 0xFF, 0xFF, 0x1F, 0xE0, 0xFF, 0xFF, \ + 0x07, 0xF8, 0xFF, 0xFF, 0x1F, 0xE0, 0xFF, 0xFF, 0x07, 0xF8, 0xFF, 0xFF, 0x1F, 0xE0, 0xFF, 0xFF, 0x07, 0xF8, 0xFF, 0xFF, \ + 0x1F, 0xE0, 0xFF, 0xFF, 0x07, 0xF8, 0xFF, 0xFF, 0x1F, 0xE0, 0xFF, 0xFF, 0x07, 0xF8, 0xFF, 0xFF, 0x1F, 0xE0, 0xFF, 0xFF, \ + 0x07, 0xF8, 0xFF, 0xFF, 0x1F, 0xE0, 0xFF, 0xFF, 0x07, 0xF8, 0xFF, 0xFF, 0x1F, 0xE0, 0xFF, 0xFF, 0x07, 0xF8, 0xFF, 0xFF, \ + 0x1F, 0xC0, 0xFF, 0xFF, 0x03, 0xF8, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, \ + 0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, \ + 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, \ + 0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, \ + 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, \ + 0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, \ + 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, \ + 0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, \ + 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, \ + 0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, \ + 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, \ + 0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, \ + 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, \ + 0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, \ + 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x00, \ + 0x00, 0xFC, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, \ + 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF + +#define OFF_DEMO_BITMAP \ + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x80, 0xFF, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, \ + 0x3F, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x00, \ + 0x00, 0xFC, 0xFF, 0xFF, 0x3F, 0xF8, 0xFF, 0xFF, 0x1F, 0xFC, 0xFF, 0xFF, 0x3F, 0xF8, 0xFF, 0xFF, 0x1F, 0xFC, 0xFF, 0xFF, \ + 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, \ + 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, \ + 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, \ + 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, \ + 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, \ + 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, \ + 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, \ + 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, \ + 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, \ + 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, \ + 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, \ + 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, \ + 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, \ + 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0x3C, 0x00, 0x00, 0x3C, 0xFC, 0xFF, 0xFF, 0x3F, 0x3C, 0x00, 0x00, 0x3C, 0xFC, 0xFF, 0xFF, \ + 0x3F, 0x3C, 0x00, 0x00, 0x3C, 0xFC, 0xFF, 0xFF, 0x3F, 0x3C, 0x00, 0x00, 0x3C, 0xFC, 0xFF, 0xFF, 0x3F, 0x3C, 0x00, 0x00, \ + 0x3C, 0xFC, 0xFF, 0xFF, 0x3F, 0x3C, 0x00, 0x00, 0x3C, 0xFC, 0xFF, 0xFF, 0x3F, 0x3C, 0x00, 0x00, 0x3C, 0xFC, 0xFF, 0xFF, \ + 0x3F, 0x3C, 0x00, 0x00, 0x3C, 0xFC, 0xFF, 0xFF, 0x3F, 0x3C, 0x00, 0x00, 0x3C, 0xFC, 0xFF, 0xFF, 0x3F, 0x3C, 0x00, 0x00, \ + 0x3C, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xFC, 0xFF, 0xFF, 0x3F, 0xF8, 0xFF, 0xFF, 0x1F, 0xFC, 0xFF, 0xFF, \ + 0x3F, 0xF8, 0xFF, 0xFF, 0x1F, 0xFC, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x00, \ + 0x00, 0xFC, 0xFF, 0xFF, 0x3F, 0x00, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFF, 0xFF, \ + 0xFF, 0x01, 0x00, 0x00, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF + // EFR Logging #ifdef __cplusplus extern "C" { diff --git a/examples/light-switch-app/silabs/efr32/src/AppTask.cpp b/examples/light-switch-app/silabs/efr32/src/AppTask.cpp index e1bbc8d782c888..4f2aca11f0712b 100644 --- a/examples/light-switch-app/silabs/efr32/src/AppTask.cpp +++ b/examples/light-switch-app/silabs/efr32/src/AppTask.cpp @@ -24,13 +24,15 @@ #include "AppTask.h" #include "AppConfig.h" #include "AppEvent.h" -#include "binding-handler.h" +#include "BindingHandler.h" #ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" #include "sl_simple_led_instances.h" #endif // ENABLE_WSTK_LEDS +#include "LightSwitchMgr.h" + #ifdef DISPLAY_ENABLED #include "lcd.h" #ifdef QR_CODE_ENABLED @@ -38,8 +40,6 @@ #endif // QR_CODE_ENABLED #endif // DISPLAY_ENABLED -#include -#include #include #include #include @@ -60,6 +60,13 @@ #define APP_FUNCTION_BUTTON &sl_button_btn0 #define APP_LIGHT_SWITCH &sl_button_btn1 +namespace { + +constexpr chip::EndpointId kLightSwitchEndpoint = 1; +constexpr chip::EndpointId kGenericSwitchEndpoint = 2; + +} // namespace + using namespace chip; using namespace ::chip::DeviceLayer; @@ -71,8 +78,6 @@ namespace { EmberAfIdentifyEffectIdentifier sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT; -bool mCurrentButtonState = false; - /********************************************************** * Identify Callbacks *********************************************************/ @@ -160,11 +165,10 @@ CHIP_ERROR AppTask::Init() appError(err); } - // Configure Bindings - TODO ERROR PROCESSING - err = InitBindingHandler(); + err = LightSwitchMgr::GetInstance().Init(kLightSwitchEndpoint, kGenericSwitchEndpoint); if (err != CHIP_NO_ERROR) { - SILABS_LOG("InitBindingHandler() failed"); + SILABS_LOG("LightSwitchMgr Init failed!"); appError(err); } @@ -224,42 +228,38 @@ void AppTask::OnIdentifyStop(Identify * identify) void AppTask::SwitchActionEventHandler(AppEvent * aEvent) { - if (aEvent->Type == AppEvent::kEventType_Button) + VerifyOrReturn(aEvent->Type == AppEvent::kEventType_Button); + + static bool mCurrentButtonState = false; + + if (aEvent->ButtonEvent.Action == SL_SIMPLE_BUTTON_PRESSED) { - BindingCommandData * data = Platform::New(); - data->clusterId = chip::app::Clusters::OnOff::Id; + mCurrentButtonState = !mCurrentButtonState; + LightSwitchMgr::LightSwitchAction action = + mCurrentButtonState ? LightSwitchMgr::LightSwitchAction::On : LightSwitchMgr::LightSwitchAction::Off; - if (mCurrentButtonState) - { - mCurrentButtonState = false; - data->commandId = chip::app::Clusters::OnOff::Commands::Off::Id; - } - else - { - data->commandId = chip::app::Clusters::OnOff::Commands::On::Id; - mCurrentButtonState = true; - } + LightSwitchMgr::GetInstance().TriggerLightSwitchAction(action); + LightSwitchMgr::GetInstance().GenericSwitchOnInitialPress(); #ifdef DISPLAY_ENABLED sAppTask.GetLCD().WriteDemoUI(mCurrentButtonState); #endif - - DeviceLayer::PlatformMgr().ScheduleWork(SwitchWorkerFunction, reinterpret_cast(data)); + } + else if (aEvent->ButtonEvent.Action == SL_SIMPLE_BUTTON_RELEASED) + { + LightSwitchMgr::GetInstance().GenericSwitchOnShortRelease(); } } void AppTask::ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAction) { - if (buttonHandle == NULL) - { - return; - } + VerifyOrReturn(buttonHandle != NULL); AppEvent button_event = {}; button_event.Type = AppEvent::kEventType_Button; button_event.ButtonEvent.Action = btnAction; - if (buttonHandle == APP_LIGHT_SWITCH && btnAction == SL_SIMPLE_BUTTON_PRESSED) + if (buttonHandle == APP_LIGHT_SWITCH) { button_event.Handler = SwitchActionEventHandler; sAppTask.PostEvent(&button_event); diff --git a/examples/light-switch-app/telink/CMakeLists.txt b/examples/light-switch-app/telink/CMakeLists.txt index 3f67e533375932..af48b2eb688c3e 100755 --- a/examples/light-switch-app/telink/CMakeLists.txt +++ b/examples/light-switch-app/telink/CMakeLists.txt @@ -52,7 +52,8 @@ target_sources(app PRIVATE src/binding-handler.cpp ${TELINK_COMMON}/util/src/LEDWidget.cpp ${TELINK_COMMON}/util/src/ButtonManager.cpp - ${TELINK_COMMON}/util/src/ThreadUtil.cpp) + ${TELINK_COMMON}/util/src/ThreadUtil.cpp + ${TELINK_COMMON}/util/src/PWMDevice.cpp) chip_configure_data_model(app INCLUDE_SERVER diff --git a/examples/light-switch-app/telink/README.md b/examples/light-switch-app/telink/README.md index 2c5aa4a940f687..a150047a5ec4d0 100755 --- a/examples/light-switch-app/telink/README.md +++ b/examples/light-switch-app/telink/README.md @@ -69,14 +69,31 @@ The following buttons are available on **tlsr9518adk80d** board: ### LEDs -**Red** LED indicates current state of Thread network. It ables to be in +#### Indicate current state of Thread network + +**Red** LED indicates current state of Thread network. It is able to be in following states: | State | Description | | :-------------------------- | :--------------------------------------------------------------------------- | | Blinks with short pulses | Device is not commissioned to Thread, Thread is disabled | -| Blinls with frequent pulses | Device is commissioned, Thread enabled. Device trying to JOIN thread network | -| Blinks with whde pulses | Device commissioned and joined to thread network as CHILD | +| Blinks with frequent pulses | Device is commissioned, Thread enabled. Device trying to JOIN thread network | +| Blinks with wide pulses | Device commissioned and joined to thread network as CHILD | + +#### Indicate identify of device + +**Green** LED used to identify the device. The LED starts blinking when the +Identify command of the Identify cluster is received. The command's argument can +be used to specify the the effect. It is able to be in following effects: + +| Effect | Description | +| :------------------------------ | :------------------------------------------------------------------- | +| Blinks (200 ms on/200 ms off) | Blink (EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK) | +| Breathe (during 1000 ms) | Breathe (EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE) | +| Blinks (50 ms on/950 ms off) | Okay (EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY) | +| Blinks (1000 ms on/1000 ms off) | Channel Change (EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE) | +| Blinks (950 ms on/50 ms off) | Finish (EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_FINISH_EFFECT) | +| LED off | Stop (EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT) | ### CHIP tool commands diff --git a/examples/light-switch-app/telink/include/AppConfig.h b/examples/light-switch-app/telink/include/AppConfig.h index 6155133e1d0278..688d848ea520ae 100755 --- a/examples/light-switch-app/telink/include/AppConfig.h +++ b/examples/light-switch-app/telink/include/AppConfig.h @@ -29,10 +29,6 @@ #define BUTTON_PIN_2 0 // LEDs config -// System led config -#define SYSTEM_STATE_LED_PORT DEVICE_DT_GET(DT_NODELABEL(gpiob)) -#define SYSTEM_STATE_LED_PIN 7 - -// Lighting LED config -#define LIGHTING_PWM_DEVICE DEVICE_DT_GET(DT_PWMS_CTLR(DT_ALIAS(pwm_led0))) -#define LIGHTING_PWM_CHANNEL DT_PWMS_CHANNEL(DT_ALIAS(pwm_led0)) +#define LEDS_PORT DEVICE_DT_GET(DT_NODELABEL(gpiob)) +#define SYSTEM_STATE_LED 7 +#define LIGHTING_PWM_SPEC_IDENTIFY_GREEN PWM_DT_SPEC_GET(DT_ALIAS(pwm_led3)) diff --git a/examples/light-switch-app/telink/include/AppEvent.h b/examples/light-switch-app/telink/include/AppEvent.h index 9a6fd3060c1685..72554b4bb54b5a 100755 --- a/examples/light-switch-app/telink/include/AppEvent.h +++ b/examples/light-switch-app/telink/include/AppEvent.h @@ -32,6 +32,8 @@ struct AppEvent kEventType_Button = 0, kEventType_Timer, kEventType_UpdateLedState, + kEventType_IdentifyStart, + kEventType_IdentifyStop, kEventType_Lighting, kEventType_Install, }; diff --git a/examples/light-switch-app/telink/include/AppTask.h b/examples/light-switch-app/telink/include/AppTask.h old mode 100755 new mode 100644 index 6509613e3741b8..8226505fcc2ccc --- a/examples/light-switch-app/telink/include/AppTask.h +++ b/examples/light-switch-app/telink/include/AppTask.h @@ -20,6 +20,7 @@ #include "AppEvent.h" #include "LEDWidget.h" +#include "PWMDevice.h" #include @@ -32,6 +33,7 @@ #include struct k_timer; +struct Identify; class AppTask { @@ -50,13 +52,16 @@ class AppTask void PostLightingActionRequest(Action_t aAction); void PostEvent(AppEvent * event); void UpdateClusterState(); + static void IdentifyEffectHandler(EmberAfIdentifyEffectIdentifier aEffect); private: friend AppTask & GetAppTask(void); - CHIP_ERROR Init(); + + CHIP_ERROR Init(void); static void ActionInitiated(AppTask::Action_t aAction, int32_t aActor); static void ActionCompleted(AppTask::Action_t aAction, int32_t aActor); + static void ActionIdentifyStateUpdateHandler(k_timer * timer); void DispatchEvent(AppEvent * event); @@ -77,12 +82,14 @@ class AppTask static void SwitchActionEventHandler(AppEvent * aEvent); static void StartBleAdvHandler(AppEvent * aEvent); static void UpdateLedStateEventHandler(AppEvent * aEvent); + static void UpdateIdentifyStateEventHandler(AppEvent * aEvent); static void InitButtons(void); static void ThreadProvisioningHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg); static AppTask sAppTask; + PWMDevice mPwmIdentifyLed; #if CONFIG_CHIP_FACTORY_DATA // chip::DeviceLayer::FactoryDataProvider mFactoryDataProvider; diff --git a/examples/light-switch-app/telink/src/AppTask.cpp b/examples/light-switch-app/telink/src/AppTask.cpp index 5b7817831ed68a..9cf419a884e5c5 100644 --- a/examples/light-switch-app/telink/src/AppTask.cpp +++ b/examples/light-switch-app/telink/src/AppTask.cpp @@ -26,8 +26,6 @@ #include "ThreadUtil.h" #include -#include -#include #include #include #include @@ -45,7 +43,25 @@ #include -LOG_MODULE_DECLARE(app); +#if CONFIG_CHIP_LIB_SHELL +#include +#include + +static int cmd_telink_reboot(const struct shell * shell, size_t argc, char ** argv) +{ + ARG_UNUSED(argc); + ARG_UNUSED(argv); + + shell_print(shell, "Performing board reboot..."); + sys_reboot(); +} + +SHELL_STATIC_SUBCMD_SET_CREATE(sub_telink, SHELL_CMD(reboot, NULL, "Reboot board command", cmd_telink_reboot), + SHELL_SUBCMD_SET_END); +SHELL_CMD_REGISTER(telink, &sub_telink, "Telink commands", NULL); +#endif // CONFIG_CHIP_LIB_SHELL + +LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL); using namespace ::chip; using namespace ::chip::app; @@ -53,15 +69,28 @@ using namespace ::chip::Credentials; using namespace ::chip::DeviceLayer; namespace { -constexpr int kFactoryResetTriggerTimeout = 2000; -constexpr int kAppEventQueueSize = 10; -constexpr uint8_t kButtonPushEvent = 1; -constexpr uint8_t kButtonReleaseEvent = 0; +constexpr int kFactoryResetTriggerTimeout = 2000; +constexpr int kAppEventQueueSize = 10; +constexpr uint8_t kButtonPushEvent = 1; +constexpr uint8_t kButtonReleaseEvent = 0; +constexpr EndpointId kEndpointId = 1; +constexpr uint8_t kDefaultMinLevel = 0; +constexpr uint8_t kDefaultMaxLevel = 254; +constexpr uint32_t kIdentifyBlinkRateMs = 200; +constexpr uint32_t kIdentifyOkayOnRateMs = 50; +constexpr uint32_t kIdentifyOkayOffRateMs = 950; +constexpr uint32_t kIdentifyFinishOnRateMs = 950; +constexpr uint32_t kIdentifyFinishOffRateMs = 50; +constexpr uint32_t kIdentifyChannelChangeRateMs = 1000; +constexpr uint32_t kIdentifyBreatheRateMs = 1000; + +const struct pwm_dt_spec sPwmIdentifySpecGreenLed = LIGHTING_PWM_SPEC_IDENTIFY_GREEN; +#if CONFIG_CHIP_FACTORY_DATA // NOTE! This key is for test/certification only and should not be available in production devices! -// If CONFIG_CHIP_FACTORY_DATA is enabled, this value is read from the factory data. uint8_t sTestEventTriggerEnableKey[TestEventTriggerDelegate::kEnableKeyLength] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }; +#endif K_MSGQ_DEFINE(sAppEventQueue, sizeof(AppEvent), kAppEventQueueSize, alignof(AppEvent)); k_timer sFactoryResetTimer; @@ -83,29 +112,11 @@ chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; void OnIdentifyTriggerEffect(Identify * identify) { - switch (identify->mCurrentEffectIdentifier) - { - case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK: - ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK"); - break; - case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE: - ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE"); - break; - case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY: - ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY"); - break; - case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE: - ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE"); - break; - default: - ChipLogProgress(Zcl, "No identifier effect"); - break; - } - return; + AppTask::IdentifyEffectHandler(identify->mCurrentEffectIdentifier); } Identify sIdentify = { - chip::EndpointId{ 1 }, + kEndpointId, [](Identify *) { ChipLogProgress(Zcl, "OnIdentifyStart"); }, [](Identify *) { ChipLogProgress(Zcl, "OnIdentifyStop"); }, EMBER_ZCL_IDENTIFY_IDENTIFY_TYPE_VISIBLE_LED, @@ -127,16 +138,14 @@ class AppFabricTableDelegate : public FabricTable::Delegate } }; -CHIP_ERROR AppTask::Init() +CHIP_ERROR AppTask::Init(void) { - CHIP_ERROR err; - LOG_INF("SW Version: %u, %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION, CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING); // Initialize status LED - LEDWidget::InitGpio(SYSTEM_STATE_LED_PORT); + LEDWidget::InitGpio(LEDS_PORT); LEDWidget::SetStateUpdateCallback(LEDStateUpdateHandler); - sStatusLED.Init(SYSTEM_STATE_LED_PIN); + sStatusLED.Init(SYSTEM_STATE_LED); UpdateStatusLED(); @@ -146,6 +155,16 @@ CHIP_ERROR AppTask::Init() k_timer_init(&sFactoryResetTimer, &AppTask::FactoryResetTimerTimeoutCallback, nullptr); k_timer_user_data_set(&sFactoryResetTimer, this); + // Initialize PWM Identify led + CHIP_ERROR err = sAppTask.mPwmIdentifyLed.Init(&sPwmIdentifySpecGreenLed, kDefaultMinLevel, kDefaultMaxLevel, kDefaultMaxLevel); + if (err != CHIP_NO_ERROR) + { + LOG_ERR("Green IDENTIFY PWM Device Init fail"); + return err; + } + + sAppTask.mPwmIdentifyLed.SetCallbacks(nullptr, nullptr, ActionIdentifyStateUpdateHandler); + // Initialize CHIP server #if CONFIG_CHIP_FACTORY_DATA ReturnErrorOnFailure(mFactoryDataProvider.Init()); @@ -210,7 +229,7 @@ CHIP_ERROR AppTask::Init() return CHIP_NO_ERROR; } -CHIP_ERROR AppTask::StartApp() +CHIP_ERROR AppTask::StartApp(void) { CHIP_ERROR err = Init(); @@ -234,6 +253,56 @@ CHIP_ERROR AppTask::StartApp() } } +void AppTask::IdentifyEffectHandler(EmberAfIdentifyEffectIdentifier aEffect) +{ + AppEvent event; + event.Type = AppEvent::kEventType_IdentifyStart; + + switch (aEffect) + { + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK: + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK"); + event.Handler = [](AppEvent *) { + sAppTask.mPwmIdentifyLed.InitiateBlinkAction(kIdentifyBlinkRateMs, kIdentifyBlinkRateMs); + }; + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE: + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE"); + event.Handler = [](AppEvent *) { + sAppTask.mPwmIdentifyLed.InitiateBreatheAction(PWMDevice::kBreatheType_Both, kIdentifyBreatheRateMs); + }; + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY: + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY"); + event.Handler = [](AppEvent *) { + sAppTask.mPwmIdentifyLed.InitiateBlinkAction(kIdentifyOkayOnRateMs, kIdentifyOkayOffRateMs); + }; + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE: + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE"); + event.Handler = [](AppEvent *) { + sAppTask.mPwmIdentifyLed.InitiateBlinkAction(kIdentifyChannelChangeRateMs, kIdentifyChannelChangeRateMs); + }; + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_FINISH_EFFECT: + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_FINISH_EFFECT"); + event.Handler = [](AppEvent *) { + sAppTask.mPwmIdentifyLed.InitiateBlinkAction(kIdentifyFinishOnRateMs, kIdentifyFinishOffRateMs); + }; + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT: + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT"); + event.Handler = [](AppEvent *) { sAppTask.mPwmIdentifyLed.StopAction(); }; + event.Type = AppEvent::kEventType_IdentifyStop; + break; + default: + ChipLogProgress(Zcl, "No identifier effect"); + return; + } + + sAppTask.PostEvent(&event); +} + void AppTask::SwitchActionButtonEventHandler(void) { AppEvent event; @@ -356,7 +425,7 @@ void AppTask::LEDStateUpdateHandler(LEDWidget * ledWidget) sAppTask.PostEvent(&event); } -void AppTask::UpdateStatusLED() +void AppTask::UpdateStatusLED(void) { if (sIsThreadProvisioned && sIsThreadEnabled) { @@ -402,6 +471,19 @@ void AppTask::ChipEventHandler(const ChipDeviceEvent * event, intptr_t /* arg */ } } +void AppTask::ActionIdentifyStateUpdateHandler(k_timer * timer) +{ + AppEvent event; + event.Type = AppEvent::kEventType_UpdateLedState; + event.Handler = UpdateIdentifyStateEventHandler; + sAppTask.PostEvent(&event); +} + +void AppTask::UpdateIdentifyStateEventHandler(AppEvent * aEvent) +{ + sAppTask.mPwmIdentifyLed.UpdateAction(); +} + void AppTask::ActionInitiated(AppTask::Action_t aAction, int32_t aActor) {} void AppTask::ActionCompleted(AppTask::Action_t aAction, int32_t aActor) diff --git a/examples/light-switch-app/telink/src/ZclCallbacks.cpp b/examples/light-switch-app/telink/src/ZclCallbacks.cpp index cb2b2ab490b48a..e7edb8514e7a18 100644 --- a/examples/light-switch-app/telink/src/ZclCallbacks.cpp +++ b/examples/light-switch-app/telink/src/ZclCallbacks.cpp @@ -23,6 +23,8 @@ #include #include +LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL); + using namespace chip; using namespace chip::app::Clusters; diff --git a/examples/light-switch-app/telink/src/binding-handler.cpp b/examples/light-switch-app/telink/src/binding-handler.cpp index ed6b07f8df467e..f982266828c583 100755 --- a/examples/light-switch-app/telink/src/binding-handler.cpp +++ b/examples/light-switch-app/telink/src/binding-handler.cpp @@ -26,15 +26,17 @@ #include #include -#if defined(ENABLE_CHIP_SHELL) +#if defined(CONFIG_CHIP_LIB_SHELL) #include "lib/shell/Engine.h" #include "lib/shell/commands/Help.h" -#endif // ENABLE_CHIP_SHELL +#endif // CONFIG_CHIP_LIB_SHELL + +LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL); using namespace chip; using namespace chip::app; -#if defined(ENABLE_CHIP_SHELL) +#if defined(CONFIG_CHIP_LIB_SHELL) using Shell::Engine; using Shell::shell_command_t; using Shell::streamer_get; @@ -47,7 +49,7 @@ Engine sShellSwitchGroupsSubCommands; Engine sShellSwitchGroupsOnOffSubCommands; Engine sShellSwitchBindingSubCommands; -#endif // defined(ENABLE_CHIP_SHELL) +#endif // defined(CONFIG_CHIP_LIB_SHELL) namespace { @@ -140,7 +142,7 @@ void LightSwitchContextReleaseHandler(void * context) Platform::Delete(static_cast(context)); } -#ifdef ENABLE_CHIP_SHELL +#ifdef CONFIG_CHIP_LIB_SHELL /******************************************************** * Switch shell functions @@ -384,7 +386,7 @@ static void RegisterSwitchCommands() Engine::Root().RegisterCommands(&sSwitchCommand, 1); } -#endif // ENABLE_CHIP_SHELL +#endif // CONFIG_CHIP_LIB_SHELL void InitBindingHandlerInternal(intptr_t arg) { @@ -439,7 +441,7 @@ CHIP_ERROR InitBindingHandler() // so it requires the Server instance to be correctly initialized. Post the init function to // the event queue so that everything is ready when initialization is conducted. chip::DeviceLayer::PlatformMgr().ScheduleWork(InitBindingHandlerInternal); -#if defined(ENABLE_CHIP_SHELL) +#if defined(CONFIG_CHIP_LIB_SHELL) RegisterSwitchCommands(); #endif return CHIP_NO_ERROR; diff --git a/examples/light-switch-app/telink/src/main.cpp b/examples/light-switch-app/telink/src/main.cpp index e71632de12fddb..9dd145f55ba0c9 100755 --- a/examples/light-switch-app/telink/src/main.cpp +++ b/examples/light-switch-app/telink/src/main.cpp @@ -23,7 +23,7 @@ #include -LOG_MODULE_REGISTER(app); +LOG_MODULE_REGISTER(app, CONFIG_CHIP_APP_LOG_LEVEL); using namespace ::chip; using namespace ::chip::Inet; diff --git a/examples/lighting-app/ameba/main/CHIPDeviceManager.cpp b/examples/lighting-app/ameba/main/CHIPDeviceManager.cpp index 951b4033e33077..98c148f505ed31 100644 --- a/examples/lighting-app/ameba/main/CHIPDeviceManager.cpp +++ b/examples/lighting-app/ameba/main/CHIPDeviceManager.cpp @@ -33,9 +33,8 @@ #include "Globals.h" #include "LEDWidget.h" -#include #include -#include +#include #include #include #include @@ -98,7 +97,7 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & if (clusterId == app::Clusters::OnOff::Id) { - if (attributeId != ZCL_ON_OFF_ATTRIBUTE_ID) + if (attributeId != app::Clusters::OnOff::Attributes::OnOff::Id) { ChipLogProgress(Zcl, "Unknown attribute ID: %" PRIx32, attributeId); return; @@ -108,7 +107,7 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & } else if (clusterId == app::Clusters::LevelControl::Id) { - if (attributeId != ZCL_CURRENT_LEVEL_ATTRIBUTE_ID) + if (attributeId != app::Clusters::LevelControl::Attributes::CurrentLevel::Id) { ChipLogProgress(Zcl, "Unknown attribute ID: %" PRIx32, attributeId); return; @@ -124,38 +123,37 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & } else if (clusterId == app::Clusters::ColorControl::Id) { + using namespace app::Clusters::ColorControl::Attributes; + uint8_t hue, saturation; - if ((attributeId != ZCL_COLOR_CONTROL_CURRENT_HUE_ATTRIBUTE_ID) && - (attributeId != ZCL_COLOR_CONTROL_CURRENT_SATURATION_ATTRIBUTE_ID)) + if ((attributeId != CurrentHue::Id) && (attributeId != CurrentSaturation::Id)) { ChipLogProgress(Zcl, "Unknown attribute ID: %" PRIx32, attributeId); return; } - if (attributeId == ZCL_COLOR_CONTROL_CURRENT_HUE_ATTRIBUTE_ID) + if (attributeId == CurrentHue::Id) { hue = *value; - emberAfReadServerAttribute(endpointId, app::Clusters::ColorControl::Id, - ZCL_COLOR_CONTROL_CURRENT_SATURATION_ATTRIBUTE_ID, &saturation, sizeof(uint8_t)); + CurrentSaturation::Get(endpointId, &saturation); } - if (attributeId == ZCL_COLOR_CONTROL_CURRENT_SATURATION_ATTRIBUTE_ID) + if (attributeId == CurrentSaturation::Id) { saturation = *value; - emberAfReadServerAttribute(endpointId, app::Clusters::ColorControl::Id, ZCL_COLOR_CONTROL_CURRENT_HUE_ATTRIBUTE_ID, - &hue, sizeof(uint8_t)); + CurrentHue::Get(endpointId, &hue); } ChipLogProgress(Zcl, "New hue: %d, New saturation: %d ", hue, saturation); } else if (clusterId == app::Clusters::Identify::Id) { - if (attributeId == ZCL_IDENTIFY_TIME_ATTRIBUTE_ID) + if (attributeId == app::Clusters::Identify::Attributes::IdentifyTime::Id) { if (cb != nullptr) { cb->PostAttributeChangeCallback(endpointId, clusterId, attributeId, type, size, value); } - ChipLogProgress(Zcl, "ZCL_IDENTIFY_TIME_ATTRIBUTE_ID value: %u ", *value); + ChipLogProgress(Zcl, "IdentifyTime value: %u ", *value); } } else diff --git a/examples/lighting-app/ameba/main/DeviceCallbacks.cpp b/examples/lighting-app/ameba/main/DeviceCallbacks.cpp index d2f99168e97515..4ae9c49f1c88e6 100644 --- a/examples/lighting-app/ameba/main/DeviceCallbacks.cpp +++ b/examples/lighting-app/ameba/main/DeviceCallbacks.cpp @@ -25,7 +25,7 @@ #include "DeviceCallbacks.h" #include "CHIPDeviceManager.h" -#include +#include #include #include #include @@ -147,7 +147,7 @@ void IdentifyTimerHandler(Layer * systemLayer, void * appState) void DeviceCallbacks::OnIdentifyPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { - VerifyOrExit(attributeId == ZCL_IDENTIFY_TIME_ATTRIBUTE_ID, + VerifyOrExit(attributeId == app::Clusters::Identify::Attributes::IdentifyTime::Id, ChipLogError(DeviceLayer, "[%s] Unhandled Attribute ID: '0x%04x", TAG, attributeId)); VerifyOrExit(endpointId == 1, ChipLogError(DeviceLayer, "[%s] Unexpected EndPoint ID: `0x%02x'", TAG, endpointId)); diff --git a/examples/lighting-app/beken/main/DeviceCallbacks.cpp b/examples/lighting-app/beken/main/DeviceCallbacks.cpp index 52da67d1253ecf..e2dc0d4e0e32ad 100644 --- a/examples/lighting-app/beken/main/DeviceCallbacks.cpp +++ b/examples/lighting-app/beken/main/DeviceCallbacks.cpp @@ -27,7 +27,6 @@ #include -#include #include #include #include @@ -72,8 +71,8 @@ void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Clus void AppDeviceCallbacks::OnOnOffPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { - VerifyOrExit(attributeId == ZCL_ON_OFF_ATTRIBUTE_ID, - ChipLogError(DeviceLayer, TAG, "Unhandled Attribute ID: '0x%04x", attributeId)); + VerifyOrExit(attributeId == app::Clusters::OnOff + : Attributes::OnOff::Id, ChipLogError(DeviceLayer, TAG, "Unhandled Attribute ID: '0x%04x", attributeId)); VerifyOrExit(endpointId == 1 || endpointId == 2, ChipLogError(DeviceLayer, TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); @@ -98,7 +97,7 @@ void IdentifyTimerHandler(Layer * systemLayer, void * appState) void AppDeviceCallbacks::OnIdentifyPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { - VerifyOrExit(attributeId == ZCL_IDENTIFY_TIME_ATTRIBUTE_ID, + VerifyOrExit(attributeId == app::Clusters::Identify::Attributes::IdentifyTime::Id, ChipLogError(DeviceLayer, "[%s] Unhandled Attribute ID: '0x%04x", TAG, attributeId)); VerifyOrExit(endpointId == 1, ChipLogError(DeviceLayer, "[%s] Unexpected EndPoint ID: `0x%02x'", TAG, endpointId)); diff --git a/examples/lighting-app/bouffalolab/bl602/BUILD.gn b/examples/lighting-app/bouffalolab/bl602/BUILD.gn index 0b341d50c32675..7389d3b0e17b07 100644 --- a/examples/lighting-app/bouffalolab/bl602/BUILD.gn +++ b/examples/lighting-app/bouffalolab/bl602/BUILD.gn @@ -110,6 +110,7 @@ bouffalolab_executable("lighting_app") { "${examples_plat_common_dir}/plat/aos_task.c", "${examples_plat_common_dir}/plat/demo_pwm.c", "${examples_plat_common_dir}/plat/main.cpp", + "${examples_plat_common_dir}/plat/platform.cpp", "${examples_plat_common_dir}/plat/uart.c", ] diff --git a/examples/lighting-app/bouffalolab/bl602/CHIPProjectConfig.h b/examples/lighting-app/bouffalolab/bl602/CHIPProjectConfig.h index 9e9934c227c465..3e1a577917a089 100644 --- a/examples/lighting-app/bouffalolab/bl602/CHIPProjectConfig.h +++ b/examples/lighting-app/bouffalolab/bl602/CHIPProjectConfig.h @@ -146,3 +146,5 @@ #define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1 #define CHIP_SYSTEM_CRYPTO_HEADER_RESERVE_SIZE 128 + +#define CHIP_BLE_DEVICE_NAME "MatterLight" diff --git a/examples/lighting-app/bouffalolab/bl702/BUILD.gn b/examples/lighting-app/bouffalolab/bl702/BUILD.gn index 65822676f89e04..6812d95f6de9c1 100644 --- a/examples/lighting-app/bouffalolab/bl702/BUILD.gn +++ b/examples/lighting-app/bouffalolab/bl702/BUILD.gn @@ -56,6 +56,7 @@ declare_args() { bl_iot_sdk("sdk") { include_dirs = [ + "${chip_root}/src/platform/bouffalolab/BL702", "${example_dir}", "${example_common_dir}", ] @@ -121,6 +122,7 @@ bouffalolab_executable("lighting_app") { "${examples_plat_common_dir}/plat/LEDWidget.cpp", "${examples_plat_common_dir}/plat/demo_pwm.c", "${examples_plat_common_dir}/plat/main.cpp", + "${examples_plat_common_dir}/plat/platform.cpp", "${examples_plat_common_dir}/plat/uart.c", ] diff --git a/examples/lighting-app/bouffalolab/bl702/CHIPProjectConfig.h b/examples/lighting-app/bouffalolab/bl702/CHIPProjectConfig.h index e83ec45117296f..eb7eab038c9baa 100644 --- a/examples/lighting-app/bouffalolab/bl702/CHIPProjectConfig.h +++ b/examples/lighting-app/bouffalolab/bl702/CHIPProjectConfig.h @@ -133,3 +133,5 @@ #define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1 #define CHIP_CONFIG_MAX_DEVICE_ADMINS 4 // 3 fabrics + 1 for rotation slack + +#define CHIP_BLE_DEVICE_NAME "MatterLight" diff --git a/examples/lighting-app/bouffalolab/common/AppConfig.h b/examples/lighting-app/bouffalolab/common/AppConfig.h deleted file mode 100644 index 2c35d9bdd4677b..00000000000000 --- a/examples/lighting-app/bouffalolab/common/AppConfig.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2019 Google LLC. - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -// ---- Lighting Example App Config ---- - -#define APP_TASK_NAME "APP" - -#define APP_BUTTON_PRESS_JITTER 50 -#define APP_BUTTON_PRESS_SHORT 1000 -#define APP_BUTTON_PRESS_LONG 4000 - -#define APP_TASK_PRIORITY 15 -#define EXT_DISCOVERY_TIMEOUT_SECS 20 -#define APP_LIGHT_ENDPOINT_ID 1 -#define APP_REBOOT_RESET_COUNT 3 -#define APP_REBOOT_RESET_COUNT_KEY "app_reset_cnt" - -#ifdef __cplusplus -extern "C" { -#endif - -#define BL_LOG(...) printf(__VA_ARGS__); -void appError(int err); - -#ifdef __cplusplus -} - -#include -void appError(CHIP_ERROR error); -#endif diff --git a/examples/lighting-app/bouffalolab/common/AppTask.cpp b/examples/lighting-app/bouffalolab/common/AppTask.cpp index 2fe2a403357717..90fdc87299082a 100644 --- a/examples/lighting-app/bouffalolab/common/AppTask.cpp +++ b/examples/lighting-app/bouffalolab/common/AppTask.cpp @@ -17,11 +17,9 @@ * limitations under the License. */ -#include "AppConfig.h" -#include "LEDWidget.h" +#include +#include -#include -#include #include #include #include @@ -42,10 +40,8 @@ #if CHIP_DEVICE_CONFIG_ENABLE_WIFI #include -#include #include #endif -#include #if HEAP_MONITORING #include "MemMonitoring.h" @@ -58,20 +54,11 @@ #include #endif -#if PW_RPC_ENABLED -#include "PigweedLogger.h" -#include "Rpc.h" -#endif - #if CONFIG_ENABLE_CHIP_SHELL #include #include #endif -#if CONFIG_ENABLE_CHIP_SHELL || PW_RPC_ENABLED -#include "uart.h" -#endif - extern "C" { #include "board.h" #include @@ -84,11 +71,6 @@ extern "C" { namespace { -#if CHIP_DEVICE_CONFIG_ENABLE_WIFI -chip::app::Clusters::NetworkCommissioning::Instance - sWiFiNetworkCommissioningInstance(0 /* Endpoint Id */, &(NetworkCommissioning::BLWiFiDriver::GetInstance())); -#endif - #if defined(BL706_NIGHT_LIGHT) || defined(BL602_NIGHT_LIGHT) ColorLEDWidget sLightLED; #else @@ -117,116 +99,6 @@ AppTask AppTask::sAppTask; StackType_t AppTask::appStack[APP_TASK_STACK_SIZE / sizeof(StackType_t)]; StaticTask_t AppTask::appTaskStruct; -void PlatformManagerImpl::PlatformInit(void) -{ -#if CONFIG_ENABLE_CHIP_SHELL || PW_RPC_ENABLED - uartInit(); -#endif - -#if PW_RPC_ENABLED - PigweedLogger::pw_init(); -#elif CONFIG_ENABLE_CHIP_SHELL - AppTask::StartAppShellTask(); -#endif - -#if HEAP_MONITORING - MemMonitoring::startHeapMonitoring(); -#endif - - ChipLogProgress(NotSpecified, "Initializing CHIP stack"); - CHIP_ERROR ret = PlatformMgr().InitChipStack(); - if (ret != CHIP_NO_ERROR) - { - ChipLogError(NotSpecified, "PlatformMgr().InitChipStack() failed"); - appError(ret); - } - - chip::DeviceLayer::ConnectivityMgr().SetBLEDeviceName("MatterLight"); - -#if CHIP_ENABLE_OPENTHREAD -#if CONFIG_ENABLE_CHIP_SHELL - cmd_otcli_init(); -#endif - - ChipLogProgress(NotSpecified, "Initializing OpenThread stack"); - ret = ThreadStackMgr().InitThreadStack(); - if (ret != CHIP_NO_ERROR) - { - ChipLogError(NotSpecified, "ThreadStackMgr().InitThreadStack() failed"); - appError(ret); - } - -#if CHIP_DEVICE_CONFIG_THREAD_FTD - ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router); -#else - ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice); -#endif - if (ret != CHIP_NO_ERROR) - { - ChipLogError(NotSpecified, "ConnectivityMgr().SetThreadDeviceType() failed"); - appError(ret); - } -#elif CHIP_DEVICE_CONFIG_ENABLE_WIFI - - ret = sWiFiNetworkCommissioningInstance.Init(); - if (CHIP_NO_ERROR != ret) - { - ChipLogError(NotSpecified, "sWiFiNetworkCommissioningInstance.Init() failed"); - } -#endif - - chip::DeviceLayer::PlatformMgr().LockChipStack(); - - // Initialize device attestation config - SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); - -#if CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY - chip::app::DnssdServer::Instance().SetExtendedDiscoveryTimeoutSecs(EXT_DISCOVERY_TIMEOUT_SECS); -#endif - - // Init ZCL Data Model - static chip::CommonCaseDeviceServerInitParams initParams; - (void) initParams.InitializeStaticResourcesBeforeServerInit(); - - ret = chip::Server::GetInstance().Init(initParams); - if (ret != CHIP_NO_ERROR) - { - ChipLogError(NotSpecified, "chip::Server::GetInstance().Init(initParams) failed"); - appError(ret); - } - chip::DeviceLayer::PlatformMgr().UnlockChipStack(); - -#if CHIP_ENABLE_OPENTHREAD - ChipLogProgress(NotSpecified, "Starting OpenThread task"); - // Start OpenThread task - ret = ThreadStackMgrImpl().StartThreadTask(); - if (ret != CHIP_NO_ERROR) - { - ChipLogError(NotSpecified, "ThreadStackMgr().StartThreadTask() failed"); - appError(ret); - } -#endif - - ConfigurationMgr().LogDeviceConfig(); - - PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE)); - PlatformMgr().AddEventHandler(AppTask::ChipEventHandler, 0); - -#ifdef OTA_ENABLED - chip::DeviceLayer::PlatformMgr().LockChipStack(); - OTAConfig::Init(); - chip::DeviceLayer::PlatformMgr().UnlockChipStack(); -#endif // OTA_ENABLED - -#if PW_RPC_ENABLED - chip::rpc::Init(); -#endif - - GetAppTask().PostEvent(AppTask::APP_EVENT_TIMER); - - vTaskResume(GetAppTask().sAppTaskHandle); -} - void StartAppTask(void) { GetAppTask().sAppTaskHandle = xTaskCreateStatic(GetAppTask().AppTaskMain, APP_TASK_NAME, ArraySize(GetAppTask().appStack), NULL, @@ -296,6 +168,8 @@ void AppTask::AppTaskMain(void * pvParameter) ChipLogError(NotSpecified, "PlatformMgr().StartEventLoopTask() failed"); appError(ret); } + + GetAppTask().PostEvent(AppTask::APP_EVENT_TIMER); vTaskSuspend(NULL); #ifndef LED_BTN_RESET @@ -464,46 +338,48 @@ void AppTask::ChipEventHandler(const ChipDeviceEvent * event, intptr_t arg) void AppTask::LightingUpdate(app_event_t event) { - uint8_t v, onoff, hue, sat; + uint8_t hue, sat; + bool onoff; + DataModel::Nullable v; EndpointId endpoint = GetAppTask().GetEndpointId(); do { - if (EMBER_ZCL_STATUS_SUCCESS != - emberAfReadAttribute(endpoint, Clusters::OnOff::Id, ZCL_ON_OFF_ATTRIBUTE_ID, &onoff, sizeof(onoff))) + if (EMBER_ZCL_STATUS_SUCCESS != Clusters::OnOff::Attributes::OnOff::Get(endpoint, &onoff)) { break; } - if (EMBER_ZCL_STATUS_SUCCESS != - emberAfReadAttribute(endpoint, Clusters::LevelControl::Id, ZCL_CURRENT_LEVEL_ATTRIBUTE_ID, &v, sizeof(v))) + if (EMBER_ZCL_STATUS_SUCCESS != Clusters::LevelControl::Attributes::CurrentLevel::Get(endpoint, v)) { break; } - if (EMBER_ZCL_STATUS_SUCCESS != - emberAfReadAttribute(endpoint, Clusters::ColorControl::Id, ZCL_COLOR_CONTROL_CURRENT_HUE_ATTRIBUTE_ID, &hue, sizeof(v))) + if (EMBER_ZCL_STATUS_SUCCESS != Clusters::ColorControl::Attributes::CurrentHue::Get(endpoint, &hue)) { break; } - if (EMBER_ZCL_STATUS_SUCCESS != - emberAfReadAttribute(endpoint, Clusters::ColorControl::Id, ZCL_COLOR_CONTROL_CURRENT_SATURATION_ATTRIBUTE_ID, &sat, - sizeof(v))) + if (EMBER_ZCL_STATUS_SUCCESS != Clusters::ColorControl::Attributes::CurrentSaturation::Get(endpoint, &sat)) { break; } - if (0 == onoff) + if (!onoff) { sLightLED.SetLevel(0); } else { + if (v.IsNull()) + { + // Just pick something. + v.SetNonNull(254); + } #if defined(BL706_NIGHT_LIGHT) || defined(BL602_NIGHT_LIGHT) - sLightLED.SetColor(v, hue, sat); + sLightLED.SetColor(v.Value(), hue, sat); #else - sLightLED.SetLevel(v); + sLightLED.SetLevel(v.Value()); #endif } @@ -516,36 +392,31 @@ void AppTask::LightingSetOnoff(uint8_t bonoff) EndpointId endpoint = GetAppTask().GetEndpointId(); // write the new on/off value - emberAfWriteAttribute(endpoint, Clusters::OnOff::Id, ZCL_ON_OFF_ATTRIBUTE_ID, (uint8_t *) &newValue, - ZCL_BOOLEAN_ATTRIBUTE_TYPE); + Clusters::OnOff::Attributes::OnOff::Set(endpoint, newValue); newValue = 254; - emberAfWriteAttribute(endpoint, Clusters::LevelControl::Id, ZCL_CURRENT_LEVEL_ATTRIBUTE_ID, (uint8_t *) &newValue, - ZCL_INT8U_ATTRIBUTE_TYPE); + Clusters::LevelControl::Attributes::CurrentLevel::Set(endpoint, newValue); } void AppTask::LightingSetStatus(app_event_t status) { - uint8_t onoff = 1, level, hue, sat; + uint8_t level, hue, sat; + bool onoff = true; EndpointId endpoint = GetAppTask().GetEndpointId(); static bool isProvisioned = false; if (APP_EVENT_SYS_LIGHT_TOGGLE == status) { - emberAfReadAttribute(endpoint, Clusters::OnOff::Id, ZCL_ON_OFF_ATTRIBUTE_ID, (uint8_t *) &onoff, - ZCL_BOOLEAN_ATTRIBUTE_TYPE); - onoff = 1 - onoff; + Clusters::OnOff::Attributes::OnOff::Get(endpoint, &onoff); + onoff = !onoff; } else if (APP_EVENT_SYS_BLE_ADV == status) { hue = 35; - emberAfWriteAttribute(endpoint, Clusters::ColorControl::Id, ZCL_COLOR_CONTROL_CURRENT_HUE_ATTRIBUTE_ID, (uint8_t *) &hue, - ZCL_INT8U_ATTRIBUTE_TYPE); + Clusters::ColorControl::Attributes::CurrentHue::Set(endpoint, hue); sat = 254; - emberAfWriteAttribute(endpoint, Clusters::ColorControl::Id, ZCL_COLOR_CONTROL_CURRENT_SATURATION_ATTRIBUTE_ID, - (uint8_t *) &sat, ZCL_INT8U_ATTRIBUTE_TYPE); + Clusters::ColorControl::Attributes::CurrentSaturation::Set(endpoint, sat); level = 254; - emberAfWriteAttribute(endpoint, Clusters::LevelControl::Id, ZCL_CURRENT_LEVEL_ATTRIBUTE_ID, (uint8_t *) &level, - ZCL_INT8U_ATTRIBUTE_TYPE); + Clusters::LevelControl::Attributes::CurrentLevel::Set(endpoint, level); isProvisioned = false; } @@ -557,14 +428,12 @@ void AppTask::LightingSetStatus(app_event_t status) } isProvisioned = true; sat = 0; - emberAfWriteAttribute(endpoint, Clusters::ColorControl::Id, ZCL_COLOR_CONTROL_CURRENT_SATURATION_ATTRIBUTE_ID, - (uint8_t *) &sat, ZCL_INT8U_ATTRIBUTE_TYPE); + Clusters::ColorControl::Attributes::CurrentSaturation::Set(endpoint, sat); level = 254; - emberAfWriteAttribute(endpoint, Clusters::LevelControl::Id, ZCL_CURRENT_LEVEL_ATTRIBUTE_ID, (uint8_t *) &level, - ZCL_INT8U_ATTRIBUTE_TYPE); + Clusters::LevelControl::Attributes::CurrentLevel::Set(endpoint, level); } - emberAfWriteAttribute(endpoint, Clusters::OnOff::Id, ZCL_ON_OFF_ATTRIBUTE_ID, (uint8_t *) &onoff, ZCL_BOOLEAN_ATTRIBUTE_TYPE); + Clusters::OnOff::Attributes::OnOff::Set(endpoint, onoff); } bool AppTask::StartTimer(void) diff --git a/examples/lighting-app/bouffalolab/common/AppTask.h b/examples/lighting-app/bouffalolab/common/AppTask.h index 3aeb06085f1f48..622c1e93ed0001 100644 --- a/examples/lighting-app/bouffalolab/common/AppTask.h +++ b/examples/lighting-app/bouffalolab/common/AppTask.h @@ -1,7 +1,6 @@ /* * * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2019 Google LLC. * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -31,6 +30,14 @@ using namespace ::chip; using namespace ::chip::DeviceLayer; +#define APP_BUTTON_PRESS_JITTER 50 +#define APP_BUTTON_PRESS_SHORT 1000 +#define APP_BUTTON_PRESS_LONG 4000 + +#define APP_LIGHT_ENDPOINT_ID 1 +#define APP_REBOOT_RESET_COUNT 3 +#define APP_REBOOT_RESET_COUNT_KEY "app_reset_cnt" + // Application-defined error codes in the CHIP_ERROR space. #define APP_ERROR_EVENT_QUEUE_FAILED CHIP_APPLICATION_ERROR(0x01) #define APP_ERROR_CREATE_TASK_FAILED CHIP_APPLICATION_ERROR(0x02) diff --git a/examples/lighting-app/bouffalolab/common/ZclCallbacks.cpp b/examples/lighting-app/bouffalolab/common/ZclCallbacks.cpp index 963c169c062912..e987fcbd325112 100644 --- a/examples/lighting-app/bouffalolab/common/ZclCallbacks.cpp +++ b/examples/lighting-app/bouffalolab/common/ZclCallbacks.cpp @@ -20,7 +20,7 @@ * This file implements the handler for data model messages. */ -#include "AppConfig.h" +#include #include #include diff --git a/examples/lighting-app/esp32/CMakeLists.txt b/examples/lighting-app/esp32/CMakeLists.txt index 746f70379ef1c1..92f2a10fec2f0b 100644 --- a/examples/lighting-app/esp32/CMakeLists.txt +++ b/examples/lighting-app/esp32/CMakeLists.txt @@ -27,7 +27,6 @@ include(${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common/cm set(EXTRA_COMPONENT_DIRS "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/config/esp32/components" "${CMAKE_CURRENT_LIST_DIR}/third_party/connectedhomeip/examples/common/QRCode" - "${IDF_PATH}/examples/common_components/led_strip" ) project(chip-lighting-app) diff --git a/examples/lighting-app/esp32/main/AppTask.cpp b/examples/lighting-app/esp32/main/AppTask.cpp index 434d98396efc64..91f91340e37bca 100644 --- a/examples/lighting-app/esp32/main/AppTask.cpp +++ b/examples/lighting-app/esp32/main/AppTask.cpp @@ -20,8 +20,6 @@ #include "esp_log.h" #include "freertos/FreeRTOS.h" -#include -#include #include #define APP_TASK_NAME "APP" diff --git a/examples/lighting-app/esp32/main/CMakeLists.txt b/examples/lighting-app/esp32/main/CMakeLists.txt index c1f1e30767e455..8b7a6e916f38a5 100644 --- a/examples/lighting-app/esp32/main/CMakeLists.txt +++ b/examples/lighting-app/esp32/main/CMakeLists.txt @@ -28,7 +28,6 @@ set(SRC_DIRS_LIST "${CMAKE_CURRENT_LIST_DIR}" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated/attributes" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/lighting-app/zap-generated" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/providers" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/lighting-app/lighting-common/src" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/ota" @@ -68,7 +67,7 @@ set(SRC_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/group-key-mgmt-server" ) -set(PRIV_REQUIRES_LIST chip QRCode bt led_strip app_update openthread driver nvs_flash) +set(PRIV_REQUIRES_LIST chip QRCode bt led_strip app_update openthread driver nvs_flash spi_flash) if (CONFIG_ENABLE_PW_RPC) # Append additional directories for RPC build diff --git a/examples/lighting-app/esp32/main/DeviceCallbacks.cpp b/examples/lighting-app/esp32/main/DeviceCallbacks.cpp index bc1174f4676358..c61c3d3d5054b5 100644 --- a/examples/lighting-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/lighting-app/esp32/main/DeviceCallbacks.cpp @@ -47,8 +47,9 @@ using namespace chip::app::Clusters; void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, ClusterId clusterId, AttributeId attributeId, uint8_t type, uint16_t size, uint8_t * value) { - ESP_LOGI(TAG, "PostAttributeChangeCallback - Cluster ID: '0x%04x', EndPoint ID: '0x%02x', Attribute ID: '0x%04x'", clusterId, - endpointId, attributeId); + ESP_LOGI(TAG, + "PostAttributeChangeCallback - Cluster ID: '0x%04" PRIx32 "', EndPoint ID: '0x%02x', Attribute ID: '0x%04" PRIx32 "'", + clusterId, endpointId, attributeId); switch (clusterId) { @@ -67,7 +68,7 @@ void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Clus #endif default: - ESP_LOGI(TAG, "Unhandled cluster ID: %d", clusterId); + ESP_LOGI(TAG, "Unhandled cluster ID: %" PRIu32, clusterId); break; } @@ -76,7 +77,8 @@ void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Clus void AppDeviceCallbacks::OnOnOffPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { - VerifyOrExit(attributeId == OnOff::Attributes::OnOff::Id, ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04x", attributeId)); + VerifyOrExit(attributeId == OnOff::Attributes::OnOff::Id, + ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04" PRIx32 "'", attributeId)); VerifyOrExit(endpointId == 1, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); AppLED.Set(*value); @@ -88,7 +90,7 @@ void AppDeviceCallbacks::OnOnOffPostAttributeChangeCallback(EndpointId endpointI void AppDeviceCallbacks::OnLevelControlAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { VerifyOrExit(attributeId == LevelControl::Attributes::CurrentLevel::Id, - ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04x", attributeId)); + ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04" PRIx32 "'", attributeId)); VerifyOrExit(endpointId == 1, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); AppLED.SetBrightness(*value); @@ -105,7 +107,7 @@ void AppDeviceCallbacks::OnColorControlAttributeChangeCallback(EndpointId endpoi VerifyOrExit(attributeId == ColorControl::Attributes::CurrentHue::Id || attributeId == ColorControl::Attributes::CurrentSaturation::Id, - ESP_LOGI(TAG, "Unhandled AttributeId ID: '0x%04x", attributeId)); + ESP_LOGI(TAG, "Unhandled AttributeId ID: '0x%04" PRIx32 "'", attributeId)); VerifyOrExit(endpointId == 1, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); if (attributeId == ColorControl::Attributes::CurrentHue::Id) diff --git a/examples/lighting-app/esp32/main/Kconfig.projbuild b/examples/lighting-app/esp32/main/Kconfig.projbuild index 43d7d9f0e75381..b41b4ef0e4fb81 100644 --- a/examples/lighting-app/esp32/main/Kconfig.projbuild +++ b/examples/lighting-app/esp32/main/Kconfig.projbuild @@ -25,6 +25,7 @@ menu "Demo" default DEVICE_TYPE_ESP32_DEVKITC if IDF_TARGET_ESP32 default DEVICE_TYPE_ESP32_C3_DEVKITM if IDF_TARGET_ESP32C3 default DEVICE_TYPE_ESP32_S3_DEVKITM if IDF_TARGET_ESP32S3 + default DEVICE_TYPE_ESP32_C2_DEVKITM if IDF_TARGET_ESP32C2 help Specifies the type of ESP32 device. @@ -46,6 +47,9 @@ menu "Demo" config DEVICE_TYPE_ESP32H2_DEVKITC bool "ESP32H2-DevKitC" depends on IDF_TARGET_ESP32H2 + config DEVICE_TYPE_ESP32_C2_DEVKITM + bool "ESP32C2-DevKitM" + depends on IDF_TARGET_ESP32C2 endchoice choice LED_TYPE @@ -76,7 +80,7 @@ menu "Demo" int "LED GPIO number" range 0 48 default 26 if DEVICE_TYPE_ESP32_WROVER_KIT - default 8 if DEVICE_TYPE_ESP32_C3_DEVKITM || DEVICE_TYPE_ESP32H2_DEVKITC + default 8 if DEVICE_TYPE_ESP32_C3_DEVKITM || DEVICE_TYPE_ESP32H2_DEVKITC || DEVICE_TYPE_ESP32_C2_DEVKITM default 48 if DEVICE_TYPE_ESP32_S3_DEVKITM default 5 help diff --git a/examples/lighting-app/esp32/main/LEDWidget.cpp b/examples/lighting-app/esp32/main/LEDWidget.cpp index bf2221b26446c9..6e65bec7c0c1e5 100644 --- a/examples/lighting-app/esp32/main/LEDWidget.cpp +++ b/examples/lighting-app/esp32/main/LEDWidget.cpp @@ -27,14 +27,6 @@ void LEDWidget::Init(void) mBrightness = UINT8_MAX; #if CONFIG_LED_TYPE_RMT -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) - led_strip_config_t strip_config = { - .strip_gpio_num = CONFIG_LED_GPIO, - .max_leds = 1, - }; - - led_strip_new_rmt_device(&strip_config, &mStrip); -#else rmt_config_t config = RMT_DEFAULT_CONFIG_TX((gpio_num_t) CONFIG_LED_GPIO, (rmt_channel_t) CONFIG_LED_RMT_CHANNEL); led_strip_config_t strip_config = LED_STRIP_DEFAULT_CONFIG(1, (led_strip_dev_t) config.channel); @@ -42,8 +34,7 @@ void LEDWidget::Init(void) rmt_config(&config); rmt_driver_install(config.channel, 0, 0); - mStrip = led_strip_new_rmt_ws2812(&strip_config); -#endif + mStrip = led_strip_new_rmt_ws2812(&strip_config); mHue = 0; mSaturation = 0; #else @@ -131,13 +122,8 @@ void LEDWidget::DoSet(void) { HsvColor_t hsv = { mHue, mSaturation, brightness }; RgbColor_t rgb = HsvToRgb(hsv); -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) - led_strip_set_pixel(mStrip, 0, rgb.r, rgb.g, rgb.b); - led_strip_refresh(mStrip); -#else mStrip->set_pixel(mStrip, 0, rgb.r, rgb.g, rgb.b); mStrip->refresh(mStrip, 100); -#endif } #else ESP_LOGI(TAG, "DoSet to GPIO number %d", mGPIONum); diff --git a/examples/lighting-app/esp32/main/idf_component.yml b/examples/lighting-app/esp32/main/idf_component.yml new file mode 100644 index 00000000000000..1c539b8eb57668 --- /dev/null +++ b/examples/lighting-app/esp32/main/idf_component.yml @@ -0,0 +1,2 @@ +dependencies: + espressif/led_strip: "^1.0.0-alpha" diff --git a/examples/lighting-app/esp32/main/include/LEDWidget.h b/examples/lighting-app/esp32/main/include/LEDWidget.h index f9d00a2b6882a9..c390d63ac1024f 100644 --- a/examples/lighting-app/esp32/main/include/LEDWidget.h +++ b/examples/lighting-app/esp32/main/include/LEDWidget.h @@ -50,11 +50,7 @@ class LEDWidget #if CONFIG_LED_TYPE_RMT uint8_t mHue; uint8_t mSaturation; -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) - led_strip_handle_t mStrip; -#else led_strip_t * mStrip; -#endif #else gpio_num_t mGPIONum; #endif diff --git a/examples/lighting-app/esp32/sdkconfig.defaults b/examples/lighting-app/esp32/sdkconfig.defaults index 64623b292bfdd3..bb74fc99f423d7 100644 --- a/examples/lighting-app/esp32/sdkconfig.defaults +++ b/examples/lighting-app/esp32/sdkconfig.defaults @@ -52,3 +52,6 @@ CONFIG_ESPTOOLPY_FLASHSIZE="4MB" # Disable softap support by default CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n +# This example uses the older version of RMT driver to work with both +# idf-v4.4.3 and idf-v5.0, so supressing the warnings by setting below option +CONFIG_RMT_SUPPRESS_DEPRECATE_WARN=y diff --git a/examples/lighting-app/esp32/sdkconfig.defaults.esp32c2 b/examples/lighting-app/esp32/sdkconfig.defaults.esp32c2 new file mode 100644 index 00000000000000..6cb90db4f55b9d --- /dev/null +++ b/examples/lighting-app/esp32/sdkconfig.defaults.esp32c2 @@ -0,0 +1,19 @@ +# Disable chip shell +CONFIG_ENABLE_CHIP_SHELL=n + +# CONFIG_ESP32_WIFI_IRAM_OPT is not set +# CONFIG_ESP32_WIFI_RX_IRAM_OPT is not set +CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y +CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH=y + +CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE=y + +CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=16 +CONFIG_LWIP_TCP_RECVMBOX_SIZE=8 + +CONFIG_BT_NIMBLE_ROLE_CENTRAL=n +CONFIG_BT_NIMBLE_ROLE_OBSERVER=n + +CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=4 +CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=8 +CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=16 diff --git a/examples/lighting-app/genio/src/AppTask.cpp b/examples/lighting-app/genio/src/AppTask.cpp index 3542e1adca1381..6a121673a002a6 100644 --- a/examples/lighting-app/genio/src/AppTask.cpp +++ b/examples/lighting-app/genio/src/AppTask.cpp @@ -25,8 +25,6 @@ #include "qrcodegen.h" -#include -#include #include #include #include diff --git a/examples/lighting-app/infineon/cyw30739/src/LightingManager.cpp b/examples/lighting-app/infineon/cyw30739/src/LightingManager.cpp index f8719aa64850ec..fbb88faa5ef00c 100644 --- a/examples/lighting-app/infineon/cyw30739/src/LightingManager.cpp +++ b/examples/lighting-app/infineon/cyw30739/src/LightingManager.cpp @@ -19,8 +19,6 @@ #include "LightingManager.h" #include -#include -#include #include #include #include diff --git a/examples/lighting-app/infineon/psoc6/src/AppTask.cpp b/examples/lighting-app/infineon/psoc6/src/AppTask.cpp index 6bbc62708117cf..bcbb79461dd4a2 100644 --- a/examples/lighting-app/infineon/psoc6/src/AppTask.cpp +++ b/examples/lighting-app/infineon/psoc6/src/AppTask.cpp @@ -22,8 +22,8 @@ #include "AppEvent.h" #include "ButtonHandler.h" #include "LEDWidget.h" -#include -#include +#include +#include #include #include #include @@ -554,8 +554,7 @@ void AppTask::UpdateClusterState(intptr_t context) uint8_t newValue = LightMgr().IsLightOn(); // write the new on/off value - EmberAfStatus status = emberAfWriteAttribute(1, app::Clusters::OnOff::Id, ZCL_ON_OFF_ATTRIBUTE_ID, (uint8_t *) &newValue, - ZCL_BOOLEAN_ATTRIBUTE_TYPE); + EmberAfStatus status = app::Clusters::OnOff::Attributes::OnOff::Set(1, newValue); if (status != EMBER_ZCL_STATUS_SUCCESS) { P6_LOG("ERR: updating on/off %x", status); diff --git a/examples/lighting-app/lighting-common/lighting-app.matter b/examples/lighting-app/lighting-common/lighting-app.matter index 623877d919bb3c..64eba579efc7f0 100644 --- a/examples/lighting-app/lighting-common/lighting-app.matter +++ b/examples/lighting-app/lighting-common/lighting-app.matter @@ -137,10 +137,6 @@ server cluster OnOff = 6 { kLighting = 0x1; } - bitmap SceneFeatures : BITMAP32 { - kSceneNames = 0x1; - } - readonly attribute boolean onOff = 0; readonly attribute boolean globalSceneControl = 16384; attribute int16u onTime = 16385; @@ -802,7 +798,7 @@ server cluster GeneralDiagnostics = 51 { kSoftwareReset = 6; } - enum HardwareFault : ENUM8 { + enum HardwareFaultEnum : ENUM8 { kUnspecified = 0; kRadio = 1; kSensor = 2; @@ -816,7 +812,7 @@ server cluster GeneralDiagnostics = 51 { kTamperDetected = 10; } - enum InterfaceType : ENUM8 { + enum InterfaceTypeEnum : ENUM8 { kUnspecified = 0; kWiFi = 1; kEthernet = 2; @@ -824,14 +820,14 @@ server cluster GeneralDiagnostics = 51 { kThread = 4; } - enum NetworkFaultType : ENUM8 { + enum NetworkFaultEnum : ENUM8 { kUnspecified = 0; kHardwareFailure = 1; kNetworkJammed = 2; kConnectionFailed = 3; } - enum RadioFault : ENUM8 { + enum RadioFaultEnum : ENUM8 { kUnspecified = 0; kWiFiFault = 1; kCellularFault = 2; @@ -849,22 +845,22 @@ server cluster GeneralDiagnostics = 51 { octet_string<8> hardwareAddress = 4; octet_string IPv4Addresses[] = 5; octet_string IPv6Addresses[] = 6; - InterfaceType type = 7; + InterfaceTypeEnum type = 7; } critical event HardwareFaultChange = 0 { - HardwareFault current[] = 0; - HardwareFault previous[] = 1; + HardwareFaultEnum current[] = 0; + HardwareFaultEnum previous[] = 1; } critical event RadioFaultChange = 1 { - RadioFault current[] = 0; - RadioFault previous[] = 1; + RadioFaultEnum current[] = 0; + RadioFaultEnum previous[] = 1; } critical event NetworkFaultChange = 2 { - NetworkFaultType current[] = 0; - NetworkFaultType previous[] = 1; + NetworkFaultEnum current[] = 0; + NetworkFaultEnum previous[] = 1; } critical event BootReason = 3 { @@ -876,9 +872,9 @@ server cluster GeneralDiagnostics = 51 { readonly attribute int64u upTime = 2; readonly attribute int32u totalOperationalHours = 3; readonly attribute BootReasonEnum bootReason = 4; - readonly attribute HardwareFault activeHardwareFaults[] = 5; - readonly attribute RadioFault activeRadioFaults[] = 6; - readonly attribute NetworkFaultType activeNetworkFaults[] = 7; + readonly attribute HardwareFaultEnum activeHardwareFaults[] = 5; + readonly attribute RadioFaultEnum activeRadioFaults[] = 6; + readonly attribute NetworkFaultEnum activeNetworkFaults[] = 7; readonly attribute boolean testEventTriggersEnabled = 8; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -1109,6 +1105,11 @@ server cluster WiFiNetworkDiagnostics = 54 { kAx = 5; } + bitmap WiFiNetworkDiagnosticsFeature : BITMAP32 { + kPacketCounts = 0x1; + kErrorCounts = 0x2; + } + info event Disconnection = 0 { INT16U reasonCode = 0; } @@ -1142,7 +1143,7 @@ server cluster WiFiNetworkDiagnostics = 54 { } server cluster EthernetNetworkDiagnostics = 55 { - enum PHYRate : ENUM8 { + enum PHYRateEnum : ENUM8 { kRate10M = 0; kRate100M = 1; kRate1G = 2; @@ -1155,7 +1156,12 @@ server cluster EthernetNetworkDiagnostics = 55 { kRate400G = 9; } - readonly attribute nullable PHYRate PHYRate = 0; + bitmap EthernetNetworkDiagnosticsFeature : BITMAP32 { + kPacketCounts = 0x1; + kErrorCounts = 0x2; + } + + readonly attribute nullable PHYRateEnum PHYRate = 0; readonly attribute nullable boolean fullDuplex = 1; readonly attribute int64u packetRxCount = 2; readonly attribute int64u packetTxCount = 3; @@ -1214,7 +1220,7 @@ server cluster Switch = 59 { } server cluster AdministratorCommissioning = 60 { - enum CommissioningWindowStatus : ENUM8 { + enum CommissioningWindowStatusEnum : ENUM8 { kWindowNotOpen = 0; kEnhancedWindowOpen = 1; kBasicWindowOpen = 2; @@ -1226,7 +1232,7 @@ server cluster AdministratorCommissioning = 60 { kWindowNotOpen = 4; } - readonly attribute CommissioningWindowStatus windowStatus = 0; + readonly attribute CommissioningWindowStatusEnum windowStatus = 0; readonly attribute nullable fabric_idx adminFabricIndex = 1; readonly attribute nullable int16u adminVendorId = 2; readonly attribute bitmap32 featureMap = 65532; @@ -1250,8 +1256,13 @@ server cluster AdministratorCommissioning = 60 { } server cluster OperationalCredentials = 62 { - enum OperationalCertStatus : ENUM8 { - kSuccess = 0; + enum CertificateChainTypeEnum : ENUM8 { + kDACCertificate = 1; + kPAICertificate = 2; + } + + enum NodeOperationalCertStatusEnum : ENUM8 { + kOk = 0; kInvalidPublicKey = 1; kInvalidNodeOpId = 2; kInvalidNOC = 3; @@ -1269,17 +1280,17 @@ server cluster OperationalCredentials = 62 { fabric_idx fabricIndex = 254; } - fabric_scoped struct FabricDescriptor { + fabric_scoped struct FabricDescriptorStruct { octet_string<65> rootPublicKey = 1; - vendor_id vendorId = 2; - fabric_id fabricId = 3; - node_id nodeId = 4; + vendor_id vendorID = 2; + fabric_id fabricID = 3; + node_id nodeID = 4; char_string<32> label = 5; fabric_idx fabricIndex = 254; } readonly attribute access(read: administer) NOCStruct NOCs[] = 0; - readonly attribute FabricDescriptor fabrics[] = 1; + readonly attribute FabricDescriptorStruct fabrics[] = 1; readonly attribute int8u supportedFabrics = 2; readonly attribute int8u commissionedFabrics = 3; readonly attribute OCTET_STRING trustedRootCertificates[] = 4; @@ -1292,7 +1303,7 @@ server cluster OperationalCredentials = 62 { } request struct CertificateChainRequestRequest { - INT8U certificateType = 0; + CertificateChainTypeEnum certificateType = 0; } request struct CSRRequestRequest { @@ -1322,12 +1333,12 @@ server cluster OperationalCredentials = 62 { } request struct AddTrustedRootCertificateRequest { - OCTET_STRING rootCertificate = 0; + OCTET_STRING rootCACertificate = 0; } response struct AttestationResponse = 1 { OCTET_STRING attestationElements = 0; - OCTET_STRING signature = 1; + OCTET_STRING attestationSignature = 1; } response struct CertificateChainResponse = 3 { @@ -1340,7 +1351,7 @@ server cluster OperationalCredentials = 62 { } response struct NOCResponse = 8 { - OperationalCertStatus statusCode = 0; + NodeOperationalCertStatusEnum statusCode = 0; optional fabric_idx fabricIndex = 1; optional CHAR_STRING debugText = 2; } @@ -1605,7 +1616,7 @@ server cluster ColorControl = 768 { } request struct MoveToColorTemperatureRequest { - INT16U colorTemperature = 0; + INT16U colorTemperatureMireds = 0; INT16U transitionTime = 1; BITMAP8 optionsMask = 2; BITMAP8 optionsOverride = 3; @@ -1729,7 +1740,7 @@ endpoint 0 { callback attribute extension; callback attribute subjectsPerAccessControlEntry default = 4; callback attribute targetsPerAccessControlEntry default = 3; - callback attribute accessControlEntriesPerFabric default = 3; + callback attribute accessControlEntriesPerFabric default = 4; callback attribute attributeList; ram attribute featureMap; ram attribute clusterRevision default = 1; diff --git a/examples/lighting-app/lighting-common/lighting-app.zap b/examples/lighting-app/lighting-common/lighting-app.zap index 5ac03a82c1ec7b..98ff42499eac14 100644 --- a/examples/lighting-app/lighting-common/lighting-app.zap +++ b/examples/lighting-app/lighting-common/lighting-app.zap @@ -1076,7 +1076,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "4", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -4361,7 +4361,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "PHYRate", + "type": "PHYRateEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -4585,7 +4585,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4637,7 +4637,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4649,7 +4649,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "CommissioningWindowStatus", + "type": "CommissioningWindowStatusEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -8091,7 +8091,7 @@ "enabled": 1, "attributes": [ { - "name": "occupancy", + "name": "Occupancy", "code": 0, "mfgCode": null, "side": "server", @@ -8107,7 +8107,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type", + "name": "OccupancySensorType", "code": 1, "mfgCode": null, "side": "server", @@ -8123,7 +8123,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type bitmap", + "name": "OccupancySensorTypeBitmap", "code": 2, "mfgCode": null, "side": "server", diff --git a/examples/lighting-app/mbed/main/AppTask.cpp b/examples/lighting-app/mbed/main/AppTask.cpp index 3cdf03a03edcec..fdbe8ea0cce291 100644 --- a/examples/lighting-app/mbed/main/AppTask.cpp +++ b/examples/lighting-app/mbed/main/AppTask.cpp @@ -33,8 +33,7 @@ #include "events/EventQueue.h" // ZAP -- ZCL Advanced Platform -#include -#include +#include #include #include @@ -463,8 +462,7 @@ void AppTask::UpdateClusterState() uint8_t onoff = LightingMgr().IsTurnedOn(); // write the new on/off value - EmberAfStatus status = - emberAfWriteServerAttribute(1, app::Clusters::OnOff::Id, ZCL_ON_OFF_ATTRIBUTE_ID, &onoff, ZCL_BOOLEAN_ATTRIBUTE_TYPE); + EmberAfStatus status = app::Clusters::OnOff::Attributes::OnOff::Set(1, onoff); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "Updating on/off cluster failed: %x", status); @@ -472,8 +470,7 @@ void AppTask::UpdateClusterState() uint8_t level = LightingMgr().GetLevel(); - status = emberAfWriteServerAttribute(1, app::Clusters::LevelControl::Id, ZCL_CURRENT_LEVEL_ATTRIBUTE_ID, &level, - ZCL_INT8U_ATTRIBUTE_TYPE); + status = app::Clusters::LevelControl::Attributes::CurrentLevel::Set(1, level); if (status != EMBER_ZCL_STATUS_SUCCESS) { diff --git a/examples/lighting-app/nrfconnect/main/AppTask.cpp b/examples/lighting-app/nrfconnect/main/AppTask.cpp index 390a6718c8ea77..8948ae1d3b3d33 100644 --- a/examples/lighting-app/nrfconnect/main/AppTask.cpp +++ b/examples/lighting-app/nrfconnect/main/AppTask.cpp @@ -24,8 +24,6 @@ #include "PWMDevice.h" #include -#include -#include #include #include #include @@ -158,7 +156,13 @@ CHIP_ERROR AppTask::Init() return err; } +#if CONFIG_CHIP_THREAD_SSED + err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SynchronizedSleepyEndDevice); +#elif CONFIG_OPENTHREAD_MTD_SED + err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SleepyEndDevice); +#else err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router); +#endif if (err != CHIP_NO_ERROR) { @@ -195,7 +199,7 @@ CHIP_ERROR AppTask::Init() #ifdef CONFIG_MCUMGR_SMP_BT // Initialize DFU over SMP - GetDFUOverSMP().Init(RequestSMPAdvertisingStart); + GetDFUOverSMP().Init(); GetDFUOverSMP().ConfirmNewImage(); #endif @@ -443,16 +447,6 @@ void AppTask::FunctionTimerEventHandler(const AppEvent & event) } } -#ifdef CONFIG_MCUMGR_SMP_BT -void AppTask::RequestSMPAdvertisingStart(void) -{ - AppEvent event; - event.Type = AppEventType::StartSMPAdvertising; - event.Handler = [](const AppEvent &) { GetDFUOverSMP().StartBLEAdvertising(); }; - PostEvent(event); -} -#endif - void AppTask::FunctionHandler(const AppEvent & event) { if (event.ButtonEvent.PinNo != FUNCTION_BUTTON) diff --git a/examples/lighting-app/nrfconnect/main/include/AppEvent.h b/examples/lighting-app/nrfconnect/main/include/AppEvent.h index 19e8cede4dab5a..49c92cc03af5a6 100644 --- a/examples/lighting-app/nrfconnect/main/include/AppEvent.h +++ b/examples/lighting-app/nrfconnect/main/include/AppEvent.h @@ -35,7 +35,6 @@ enum class AppEventType : uint8_t Lighting, IdentifyStart, IdentifyStop, - StartSMPAdvertising }; enum class FunctionEvent : uint8_t diff --git a/examples/lighting-app/nrfconnect/main/include/AppTask.h b/examples/lighting-app/nrfconnect/main/include/AppTask.h index 461981e44835f7..874be7d759b5a8 100644 --- a/examples/lighting-app/nrfconnect/main/include/AppTask.h +++ b/examples/lighting-app/nrfconnect/main/include/AppTask.h @@ -86,10 +86,6 @@ class AppTask static void FunctionHandler(const AppEvent & event); static void StartBLEAdvertisementAndLightActionEventHandler(const AppEvent & event); -#ifdef CONFIG_MCUMGR_SMP_BT - static void RequestSMPAdvertisingStart(void); -#endif - FunctionEvent mFunction = FunctionEvent::NoneSelected; bool mFunctionTimerActive = false; PWMDevice mPWMDevice; diff --git a/examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp b/examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp index 4e45106161348e..18b9896475115b 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp +++ b/examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp @@ -30,8 +30,7 @@ #include #include -#include -#include +#include #include #include @@ -922,8 +921,7 @@ void AppTask::UpdateClusterStateInternal(intptr_t arg) uint8_t newValue = !LightingMgr().IsTurnedOff(); // write the new on/off value - EmberAfStatus status = emberAfWriteAttribute(1, app::Clusters::OnOff::Id, ZCL_ON_OFF_ATTRIBUTE_ID, (uint8_t *) &newValue, - ZCL_BOOLEAN_ATTRIBUTE_TYPE); + EmberAfStatus status = app::Clusters::OnOff::Attributes::OnOff::Set(1, newValue); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: updating on/off %x", status); @@ -940,7 +938,7 @@ void AppTask::UpdateDeviceStateInternal(intptr_t arg) bool onoffAttrValue = 0; /* get onoff attribute value */ - (void) emberAfReadAttribute(1, app::Clusters::OnOff::Id, ZCL_ON_OFF_ATTRIBUTE_ID, (uint8_t *) &onoffAttrValue, 1); + (void) app::Clusters::OnOff::Attributes::OnOff::Get(1, &onoffAttrValue); /* set the device state */ sLightLED.Set(onoffAttrValue); diff --git a/examples/lighting-app/nxp/zap/lighting-on-off.matter b/examples/lighting-app/nxp/zap/lighting-on-off.matter index df1e83a77a9e4a..fc856bc275acd2 100644 --- a/examples/lighting-app/nxp/zap/lighting-on-off.matter +++ b/examples/lighting-app/nxp/zap/lighting-on-off.matter @@ -138,10 +138,6 @@ server cluster OnOff = 6 { kLighting = 0x1; } - bitmap SceneFeatures : BITMAP32 { - kSceneNames = 0x1; - } - readonly nosubscribe attribute boolean onOff = 0; readonly attribute boolean globalSceneControl = 16384; attribute int16u onTime = 16385; @@ -717,7 +713,7 @@ server cluster GeneralDiagnostics = 51 { kSoftwareReset = 6; } - enum HardwareFault : ENUM8 { + enum HardwareFaultEnum : ENUM8 { kUnspecified = 0; kRadio = 1; kSensor = 2; @@ -731,7 +727,7 @@ server cluster GeneralDiagnostics = 51 { kTamperDetected = 10; } - enum InterfaceType : ENUM8 { + enum InterfaceTypeEnum : ENUM8 { kUnspecified = 0; kWiFi = 1; kEthernet = 2; @@ -739,14 +735,14 @@ server cluster GeneralDiagnostics = 51 { kThread = 4; } - enum NetworkFaultType : ENUM8 { + enum NetworkFaultEnum : ENUM8 { kUnspecified = 0; kHardwareFailure = 1; kNetworkJammed = 2; kConnectionFailed = 3; } - enum RadioFault : ENUM8 { + enum RadioFaultEnum : ENUM8 { kUnspecified = 0; kWiFiFault = 1; kCellularFault = 2; @@ -764,22 +760,22 @@ server cluster GeneralDiagnostics = 51 { octet_string<8> hardwareAddress = 4; octet_string IPv4Addresses[] = 5; octet_string IPv6Addresses[] = 6; - InterfaceType type = 7; + InterfaceTypeEnum type = 7; } critical event HardwareFaultChange = 0 { - HardwareFault current[] = 0; - HardwareFault previous[] = 1; + HardwareFaultEnum current[] = 0; + HardwareFaultEnum previous[] = 1; } critical event RadioFaultChange = 1 { - RadioFault current[] = 0; - RadioFault previous[] = 1; + RadioFaultEnum current[] = 0; + RadioFaultEnum previous[] = 1; } critical event NetworkFaultChange = 2 { - NetworkFaultType current[] = 0; - NetworkFaultType previous[] = 1; + NetworkFaultEnum current[] = 0; + NetworkFaultEnum previous[] = 1; } critical event BootReason = 3 { @@ -985,7 +981,7 @@ server cluster ThreadNetworkDiagnostics = 53 { } server cluster AdministratorCommissioning = 60 { - enum CommissioningWindowStatus : ENUM8 { + enum CommissioningWindowStatusEnum : ENUM8 { kWindowNotOpen = 0; kEnhancedWindowOpen = 1; kBasicWindowOpen = 2; @@ -997,7 +993,7 @@ server cluster AdministratorCommissioning = 60 { kWindowNotOpen = 4; } - readonly attribute CommissioningWindowStatus windowStatus = 0; + readonly attribute CommissioningWindowStatusEnum windowStatus = 0; readonly attribute nullable fabric_idx adminFabricIndex = 1; readonly attribute nullable int16u adminVendorId = 2; readonly attribute bitmap32 featureMap = 65532; @@ -1016,8 +1012,13 @@ server cluster AdministratorCommissioning = 60 { } server cluster OperationalCredentials = 62 { - enum OperationalCertStatus : ENUM8 { - kSuccess = 0; + enum CertificateChainTypeEnum : ENUM8 { + kDACCertificate = 1; + kPAICertificate = 2; + } + + enum NodeOperationalCertStatusEnum : ENUM8 { + kOk = 0; kInvalidPublicKey = 1; kInvalidNodeOpId = 2; kInvalidNOC = 3; @@ -1035,17 +1036,17 @@ server cluster OperationalCredentials = 62 { fabric_idx fabricIndex = 254; } - fabric_scoped struct FabricDescriptor { + fabric_scoped struct FabricDescriptorStruct { octet_string<65> rootPublicKey = 1; - vendor_id vendorId = 2; - fabric_id fabricId = 3; - node_id nodeId = 4; + vendor_id vendorID = 2; + fabric_id fabricID = 3; + node_id nodeID = 4; char_string<32> label = 5; fabric_idx fabricIndex = 254; } readonly attribute access(read: administer) NOCStruct NOCs[] = 0; - readonly attribute FabricDescriptor fabrics[] = 1; + readonly attribute FabricDescriptorStruct fabrics[] = 1; readonly attribute int8u supportedFabrics = 2; readonly attribute int8u commissionedFabrics = 3; readonly attribute OCTET_STRING trustedRootCertificates[] = 4; @@ -1058,7 +1059,7 @@ server cluster OperationalCredentials = 62 { } request struct CertificateChainRequestRequest { - INT8U certificateType = 0; + CertificateChainTypeEnum certificateType = 0; } request struct CSRRequestRequest { @@ -1088,12 +1089,12 @@ server cluster OperationalCredentials = 62 { } request struct AddTrustedRootCertificateRequest { - OCTET_STRING rootCertificate = 0; + OCTET_STRING rootCACertificate = 0; } response struct AttestationResponse = 1 { OCTET_STRING attestationElements = 0; - OCTET_STRING signature = 1; + OCTET_STRING attestationSignature = 1; } response struct CertificateChainResponse = 3 { @@ -1106,7 +1107,7 @@ server cluster OperationalCredentials = 62 { } response struct NOCResponse = 8 { - OperationalCertStatus statusCode = 0; + NodeOperationalCertStatusEnum statusCode = 0; optional fabric_idx fabricIndex = 1; optional CHAR_STRING debugText = 2; } @@ -1205,7 +1206,7 @@ endpoint 0 { callback attribute acl; callback attribute subjectsPerAccessControlEntry default = 4; callback attribute targetsPerAccessControlEntry default = 3; - callback attribute accessControlEntriesPerFabric default = 3; + callback attribute accessControlEntriesPerFabric default = 4; callback attribute attributeList; ram attribute featureMap; ram attribute clusterRevision default = 1; diff --git a/examples/lighting-app/nxp/zap/lighting-on-off.zap b/examples/lighting-app/nxp/zap/lighting-on-off.zap index a4e9f8af670a4f..20a29e2484faea 100644 --- a/examples/lighting-app/nxp/zap/lighting-on-off.zap +++ b/examples/lighting-app/nxp/zap/lighting-on-off.zap @@ -1076,7 +1076,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "4", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -4556,7 +4556,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "PHYRate", + "type": "PHYRateEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -4780,7 +4780,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4832,7 +4832,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4844,7 +4844,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "CommissioningWindowStatus", + "type": "CommissioningWindowStatusEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -8818,7 +8818,7 @@ "enabled": 0, "attributes": [ { - "name": "occupancy", + "name": "Occupancy", "code": 0, "mfgCode": null, "side": "server", @@ -8834,7 +8834,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type", + "name": "OccupancySensorType", "code": 1, "mfgCode": null, "side": "server", @@ -8850,7 +8850,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type bitmap", + "name": "OccupancySensorTypeBitmap", "code": 2, "mfgCode": null, "side": "server", @@ -8866,7 +8866,7 @@ "reportableChange": 0 }, { - "name": "PIR occupied to unoccupied delay", + "name": "PIROccupiedToUnoccupiedDelay", "code": 16, "mfgCode": null, "side": "server", @@ -8882,7 +8882,7 @@ "reportableChange": 0 }, { - "name": "PIR unoccupied to occupied delay", + "name": "PIRUnoccupiedToOccupiedDelay", "code": 17, "mfgCode": null, "side": "server", @@ -8898,7 +8898,7 @@ "reportableChange": 0 }, { - "name": "PIR unoccupied to occupied threshold", + "name": "PIRUnoccupiedToOccupiedThreshold", "code": 18, "mfgCode": null, "side": "server", @@ -8914,7 +8914,7 @@ "reportableChange": 0 }, { - "name": "ultrasonic occupied to unoccupied delay", + "name": "UltrasonicOccupiedToUnoccupiedDelay", "code": 32, "mfgCode": null, "side": "server", @@ -8930,7 +8930,7 @@ "reportableChange": 0 }, { - "name": "ultrasonic unoccupied to occupied delay", + "name": "UltrasonicUnoccupiedToOccupiedDelay", "code": 33, "mfgCode": null, "side": "server", @@ -8946,7 +8946,7 @@ "reportableChange": 0 }, { - "name": "ultrasonic unoccupied to occupied threshold", + "name": "UltrasonicUnoccupiedToOccupiedThreshold", "code": 34, "mfgCode": null, "side": "server", @@ -8962,7 +8962,7 @@ "reportableChange": 0 }, { - "name": "physical contact occupied to unoccupied delay", + "name": "PhysicalContactOccupiedToUnoccupiedDelay", "code": 48, "mfgCode": null, "side": "server", @@ -8978,7 +8978,7 @@ "reportableChange": 0 }, { - "name": "physical contact unoccupied to occupied delay", + "name": "PhysicalContactUnoccupiedToOccupiedDelay", "code": 49, "mfgCode": null, "side": "server", @@ -8994,7 +8994,7 @@ "reportableChange": 0 }, { - "name": "physical contact unoccupied to occupied threshold", + "name": "PhysicalContactUnoccupiedToOccupiedThreshold", "code": 50, "mfgCode": null, "side": "server", diff --git a/examples/lighting-app/qpg/src/AppTask.cpp b/examples/lighting-app/qpg/src/AppTask.cpp index b2878cfd371ea9..216409c6570565 100644 --- a/examples/lighting-app/qpg/src/AppTask.cpp +++ b/examples/lighting-app/qpg/src/AppTask.cpp @@ -32,8 +32,6 @@ #include -#include -#include #include #include #include diff --git a/examples/lighting-app/silabs/SiWx917/BUILD.gn b/examples/lighting-app/silabs/SiWx917/BUILD.gn index dbedc37a233b5c..8abb554a67c3be 100644 --- a/examples/lighting-app/silabs/SiWx917/BUILD.gn +++ b/examples/lighting-app/silabs/SiWx917/BUILD.gn @@ -49,15 +49,9 @@ declare_args() { OTA_periodic_query_timeout = 86400 # Wifi related stuff - they are overridden by gn -args="use_wf200=true" - use_wf200 = false - use_rs911x = false - use_rs911x_sockets = false sl_wfx_config_softap = false sl_wfx_config_scan = true - # Disable LCD on supported devices - disable_lcd = true - # Argument to Disable IPv4 for wifi(rs911) chip_enable_wifi_ipv4 = false @@ -71,14 +65,6 @@ declare_args() { psk = "" } -declare_args() { - # Enables LCD Qr Code on supported devices - show_qr_code = !disable_lcd -} - -# qr code cannot be true if lcd is disabled -assert(!(disable_lcd && show_qr_code)) - # Sanity check assert(!(chip_enable_wifi && chip_enable_openthread)) assert(!(use_rs911x && chip_enable_openthread)) diff --git a/examples/lighting-app/silabs/SiWx917/README.md b/examples/lighting-app/silabs/SiWx917/README.md index 6ec100ade5d46a..58c449ad116be1 100644 --- a/examples/lighting-app/silabs/SiWx917/README.md +++ b/examples/lighting-app/silabs/SiWx917/README.md @@ -1,20 +1,17 @@ -# Matter EFR32 Lighting Example +# Matter SiWx917 Lighting Example -An example showing the use of CHIP on the Silicon Labs EFR32 MG12 and MG24. +An example showing the use of CHIP on the Silicon Labs SiWx917.
-- [Matter EFR32 Lighting Example](#matter-efr32-lighting-example) +- [Matter SiWx917 Lighting Example](#matter-siwx917-lighting-example) - [Introduction](#introduction) - [Building](#building) - [Flashing the Application](#flashing-the-application) - [Viewing Logging Output](#viewing-logging-output) - [Running the Complete Example](#running-the-complete-example) - - [Notes](#notes) - - [Running RPC console](#running-rpc-console) - - [Device Tracing](#device-tracing) + - [Notes](#notes) - [Memory settings](#memory-settings) - - [OTA Software Update](#ota-software-update) - [Group Communication (Multicast)](#group-communication-multicast) - [Building options](#building-options) - [Disabling logging](#disabling-logging) @@ -30,25 +27,30 @@ An example showing the use of CHIP on the Silicon Labs EFR32 MG12 and MG24. > release with added tools and documentation. > [Silabs Matter Github](https://github.com/SiliconLabs/matter/releases) + + ## Introduction -The EFR32 lighting example provides a baseline demonstration of a Light control -device, built using Matter and the Silicon Labs gecko SDK. It can be controlled -by a Chip controller over an Openthread or Wifi network.. +The SiWx917 lighting example provides a baseline demonstration of a Light +control device, built using Matter, the Silicon Labs Gecko SDK, and the Silicon +Labs WiseMCU SDK. It can be controlled by a Chip controller over a Wi-Fi +network. -The EFR32 device can be commissioned over Bluetooth Low Energy where the device -and the Chip controller will exchange security information with the Rendez-vous -procedure. If using Thread, Thread Network credentials are then provided to the -EFR32 device which will then join the Thread network. +The SiWx917 device can be commissioned over Bluetooth Low Energy where the +device and the Chip controller will exchange security information with the +rendezvous procedure. Wi-Fi Network credentials are then provided to the SiWx917 +device which will then join the Wi-Fi network. If the LCD is enabled, the LCD on the Silabs WSTK shows a QR Code containing the needed commissioning information for the BLE connection and starting the -Rendez-vous procedure. +rendezvous procedure. The lighting example is intended to serve both as a means to explore the workings of Matter as well as a template for creating real products based on the Silicon Labs platform. + + ## Building - Download the @@ -72,284 +74,69 @@ Silicon Labs platform. > [Hardware Requirements](https://github.com/SiliconLabs/matter/blob/latest/docs/silabs/general/HARDWARE_REQUIREMENTS.md) > in the Silicon Labs Matter Github Repo - MG12 boards: - - - BRD4161A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm - - BRD4162A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4163A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm, - 868MHz@19dBm - - BRD4164A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm - - BRD4166A / SLTB004A / Thunderboard Sense 2 / 2.4GHz@10dBm - - BRD4170A / SLWSTK6000B / Multiband Wireless Starter Kit / 2.4GHz@19dBm, - 915MHz@19dBm - - BRD4304A / SLWSTK6000B / MGM12P Module / 2.4GHz@19dBm - - MG21 boards: Currently not supported due to RAM limitation. - - - BRD4180A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - - MG24 boards : - - - BRD2601B / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD2703A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4186A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4186C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4187A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - - BRD4187C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - - MG12 boards: - - - BRD4161A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm - - BRD4162A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4163A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm, - 868MHz@19dBm - - BRD4164A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm - - BRD4166A / SLTB004A / Thunderboard Sense 2 / 2.4GHz@10dBm - - BRD4170A / SLWSTK6000B / Multiband Wireless Starter Kit / 2.4GHz@19dBm, - 915MHz@19dBm - - BRD4304A / SLWSTK6000B / MGM12P Module / 2.4GHz@19dBm - - MG21 boards: Currently not supported due to RAM limitation. - - - BRD4180A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - - MG24 boards : - - - BRD2601B / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD2703A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4186A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4186C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4187A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - - BRD4187C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - * Build the example application: cd ~/connectedhomeip - ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/efr32/ ./out/lighting-app BRD4161A + ./scripts/examples/gn_efr32_example.sh examples/lighting-app/silabs/SiWx917/ out/test BRD4325A --wifi rs911x - To delete generated executable, libraries and object files use: $ cd ~/connectedhomeip $ rm -rf ./out/ - OR use GN/Ninja directly - - $ cd ~/connectedhomeip/examples/lighting-app/efr32 - $ git submodule update --init - $ source third_party/connectedhomeip/scripts/activate.sh - $ export EFR32_BOARD=BRD4161A - $ gn gen out/debug - $ ninja -C out/debug - -- To delete generated executable, libraries and object files use: - - $ cd ~/connectedhomeip/examples/lighting-app/efr32 - $ rm -rf out/ - -* Build the example as Sleepy End Device (SED) - - $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/efr32/ ./out/lighting-app_SED BRD4161A --sed - - or use gn as previously mentioned but adding the following arguments: - - $ gn gen out/debug '--args=silabs_board="BRD4161A" enable_sleepy_device=true chip_openthread_ftd=false' - -* Build the example with pigweed RPC - - $ ./scripts/examples/gn_efr32_example.sh examples/lighting-app/efr32/ out/lighting_app_rpc BRD4161A 'import("//with_pw_rpc.gni")' - - or use GN/Ninja Directly - - $ cd ~/connectedhomeip/examples/lighting-app/efr32 - $ git submodule update --init - $ source third_party/connectedhomeip/scripts/activate.sh - $ export EFR32_BOARD=BRD4161A - $ gn gen out/debug --args='import("//with_pw_rpc.gni")' - $ ninja -C out/debug - -For more build options, help is provided when running the build script without -arguments - - ./scripts/examples/gn_efr32_example.sh + ## Flashing the Application -- On the command line: - - $ cd ~/connectedhomeip/examples/lighting-app/efr32 - $ python3 out/debug/chip-efr32-lighting-example.flash.py +- Flashing requires the SiWx917 SoC device to be configured in the Ozone + Debugger. +- Once it's configured, it can be run with the Ozone Debugger by loading the + .out file. + - > For detailed instructions, please refer to + > [Running the Matter Demo on SiWx917 SoC](https://github.com/SiliconLabs/matter/blob/latest/docs/silabs/wifi/RUN_DEMO_SiWx917_SoC.md) + > in the Silicon Labs Matter Github Repo -- Or with the Ozone debugger, just load the .out file. + ## Viewing Logging Output -The example application is built to use the SEGGER Real Time Transfer (RTT) -facility for log output. RTT is a feature built-in to the J-Link Interface MCU -on the WSTK development board. It allows bi-directional communication with an -embedded application without the need for a dedicated UART. - -Using the RTT facility requires downloading and installing the _SEGGER J-Link -Software and Documentation Pack_ -([web site](https://www.segger.com/downloads/jlink#J-LinkSoftwareAndDocumentationPack)). - -Alternatively, SEGGER Ozone J-Link debugger can be used to view RTT logs too -after flashing the .out file. - -- Download the J-Link installer by navigating to the appropriate URL and - agreeing to the license agreement. - -- [JLink_Linux_x86_64.deb](https://www.segger.com/downloads/jlink/JLink_Linux_x86_64.deb) -- [JLink_MacOSX.pkg](https://www.segger.com/downloads/jlink/JLink_MacOSX.pkg) - -* Install the J-Link software - - $ cd ~/Downloads - $ sudo dpkg -i JLink_Linux_V*_x86_64.deb - -* In Linux, grant the logged in user the ability to talk to the development - hardware via the linux tty device (/dev/ttyACMx) by adding them to the - dialout group. +The example application's logging output can be viewed in the Ozone Debugger. - $ sudo usermod -a -G dialout ${USER} - -Once the above is complete, log output can be viewed using the JLinkExe tool in -combination with JLinkRTTClient as follows: - -- Run the JLinkExe tool with arguments to autoconnect to the WSTK board: - - For MG12 use: - - $ JLinkExe -device EFR32MG12PXXXF1024 -if JTAG -speed 4000 -autoconnect 1 - - For MG21 use: - - $ JLinkExe -device EFR32MG21AXXXF1024 -if SWD -speed 4000 -autoconnect 1 - -- In a second terminal, run the JLinkRTTClient to view logs: - - $ JLinkRTTClient + ## Running the Complete Example -- It is assumed here that you already have an OpenThread border router - configured and running. If not see the following guide - [Openthread_border_router](https://github.com/project-chip/connectedhomeip/blob/master/docs/guides/openthread_border_router_pi.md) - for more information on how to setup a border router on a raspberryPi. - - Take note that the RCP code is available directly through - [Simplicity Studio 5](https://www.silabs.com/products/development-tools/software/simplicity-studio/simplicity-studio-5) - under File->New->Project Wizard->Examples->Thread : ot-rcp - -- User interface : **LCD** The LCD on Silabs WSTK shows a QR Code. This QR - Code is be scanned by the CHIP Tool app For the Rendez-vous procedure over - BLE - - * On devices that do not have or support the LCD Display like the BRD4166A Thunderboard Sense 2, - a URL can be found in the RTT logs. - - [SVR] Copy/paste the below URL in a browser to see the QR Code: - [SVR] https://project-chip.github.io/connectedhomeip/qrcode.html?data=CH%3AI34NM%20-00%200C9SS0 - - **LED 0** shows the overall state of the device and its connectivity. The - following states are possible: - - - _Short Flash On (50 ms on/950 ms off)_ ; The device is in the - unprovisioned (unpaired) state and is waiting for a commissioning - application to connect. - - - _Rapid Even Flashing_ ; (100 ms on/100 ms off)_ — The device is in the - unprovisioned state and a commissioning application is connected through - Bluetooth LE. - - - _Short Flash Off_ ; (950ms on/50ms off)_ — The device is fully - provisioned, but does not yet have full Thread network or service - connectivity. - - - _Solid On_ ; The device is fully provisioned and has full Thread - network and service connectivity. - - **LED 1** Simulates the Light The following states are possible: - - - _Solid On_ ; Light is on - - _Off_ ; Light is off +- You can provision and control the Chip device using the chip-tool standalone - **Push Button 0** + [chip-tool](https://github.com/project-chip/connectedhomeip/blob/master/examples/chip-tool/README.md) - - _Press and Release_ : Start, or restart, BLE advertisement in fast mode. It will advertise in this mode - for 30 seconds. The device will then switch to a slower interval advertisement. - After 15 minutes, the advertisement stops. + Here is an example with the chip-tool: - - _Pressed and hold for 6 s_ : Initiates the factory reset of the device. - Releasing the button within the 6-second window cancels the factory reset - procedure. **LEDs** blink in unison when the factory reset procedure is - initiated. + - > $SSID and $PSK are the SSID and passcode of your Wi-Fi Access Point. - **Push Button 1** Toggles the light state On/Off - -* You can provision and control the Chip device using the python controller, - Chip tool standalone, Android or iOS app - -* You can provision and control the Chip device using the python controller, - Chip tool standalone, Android or iOS app - - [CHIPTool](https://github.com/project-chip/connectedhomeip/blob/master/examples/chip-tool/README.md) - - Here is an example with the CHIPTool: - - chip-tool pairing ble-thread 1 hex: 20202021 3840 + ``` + chip-tool pairing ble-wifi 1122 $SSID $PSK 20202021 3840 chip-tool onoff on 1 1 + ``` ### Notes -- Depending on your network settings your router might not provide native ipv6 - addresses to your devices (Border router / PC). If this is the case, you - need to add a static ipv6 addresses on both device and then an ipv6 route to - the border router on your PC - - - On Border Router: `sudo ip addr add dev 2002::2/64` +- Depending on your network settings your router might not provide native IPv6 + addresses to your devices (Router / PC). If this is the case, you need to + add a static IPv6 addresses on both devices and then an IPv6 route to your + router on your PC - On PC(Linux): `sudo ip addr add dev 2002::1/64` - - Add Ipv6 route on PC(Linux) - `sudo ip route add /64 via 2002::2` - -## Running RPC console - -- As part of building the example with RPCs enabled the chip_rpc python - interactive console is installed into your venv. The python wheel files are - also created in the output folder: out/debug/chip_rpc_console_wheels. To - install the wheel files without rebuilding: - `pip3 install out/debug/chip_rpc_console_wheels/*.whl` - -- To use the chip-rpc console after it has been installed run: - `chip-console --device /dev/tty. -b 115200 -o //pw_log.out` - -- Then you can simulate a button press or release using the following command - where : idx = 0 or 1 for Button PB0 or PB1 action = 0 for PRESSED, 1 for - RELEASE Test toggling the LED with - `rpcs.chip.rpc.Button.Event(idx=1, pushed=True)` - -- You can also Get and Set the light directly using the RPCs: - `rpcs.chip.rpc.Lighting.Get()` - - `rpcs.chip.rpc.Lighting.Set(on=True, level=128, color=protos.chip.rpc.LightingColor(hue=5, saturation=5))` - -## Device Tracing - -Device tracing is available to analyze the device performance. To turn on -tracing, build with RPC enabled. See Build the example with pigweed RPC. - -Obtain tracing json file. - - $ ./{PIGWEED_REPO}/pw_trace_tokenized/py/pw_trace_tokenized/get_trace.py -d {PORT} -o {OUTPUT_FILE} \ - -t {ELF_FILE} {PIGWEED_REPO}/pw_trace_tokenized/pw_trace_protos/trace_rpc.proto + - Add IPv6 route on PC(Linux) + `sudo ip route add /64 via 2002::2` ## Memory settings While most of the RAM usage in CHIP is static, allowing easier debugging and optimization with symbols analysis, we still need some HEAP for the crypto and -OpenThread. Size of the HEAP can be modified by changing the value of the +Wi-Fi stack. Size of the HEAP can be modified by changing the value of the `configTOTAL_HEAP_SIZE` define inside of the FreeRTOSConfig.h file of this example. Please take note that a HEAP size smaller than 13k can and will cause a Mbedtls failure during the BLE rendez-vous or CASE session @@ -358,14 +145,8 @@ To track memory usage you can set `enable_heap_monitoring = true` either in the BUILD.gn file or pass it as a build argument to gn. This will print on the RTT console the RAM usage of each individual task and the number of Memory allocation and Free. While this is not extensive monitoring you're welcome to -modify `examples/platform/efr32/MemMonitoring.cpp` to add your own memory -tracking code inside the `trackAlloc` and `trackFree` function - -## OTA Software Update - -For the description of Software Update process with EFR32 example applications -see -[EFR32 OTA Software Update](../../../../docs/guides/silabs_efr32_software_update.md) +modify `examples/platform/silabs/SiWx917/MemMonitoring.cpp` to add your own +memory tracking code inside the `trackAlloc` and `trackFree` function ## Group Communication (Multicast) @@ -386,19 +167,19 @@ passed to the build scripts. `chip_progress_logging, chip_detail_logging, chip_automation_logging` - $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/efr32 ./out/lighting-app BRD4164A "chip_detail_logging=false chip_automation_logging=false chip_progress_logging=false" + $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/silabs/SiWx917 ./out/lighting-app BRD4325A "chip_detail_logging=false chip_automation_logging=false chip_progress_logging=false" --wifi rs911x ### Debug build / release build `is_debug` - $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/efr32 ./out/lighting-app BRD4164A "is_debug=false" + $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/silabs/SiWx917 ./out/lighting-app BRD4325A "is_debug=false" --wifi rs911x ### Disabling LCD `show_qr_code` - $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/efr32 ./out/lighting-app BRD4164A "show_qr_code=false" + $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/silabs/SiWx917 ./out/lighting-app BRD4325A "show_qr_code=false" --wifi rs911x ### KVS maximum entry count @@ -407,4 +188,4 @@ passed to the build scripts. Set the maximum Kvs entries that can be stored in NVM (Default 75) Thresholds: 30 <= kvs_max_entries <= 255 - $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/efr32 ./out/lighting-app BRD4164A kvs_max_entries=50 + $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/silabs/SiWx917 ./out/lighting-app BRD4325A kvs_max_entries=50 --wifi rs911x diff --git a/examples/lighting-app/silabs/SiWx917/src/AppTask.cpp b/examples/lighting-app/silabs/SiWx917/src/AppTask.cpp index 22cab2f3ed1e5f..06665ad695743c 100644 --- a/examples/lighting-app/silabs/SiWx917/src/AppTask.cpp +++ b/examples/lighting-app/silabs/SiWx917/src/AppTask.cpp @@ -21,8 +21,6 @@ #include "AppConfig.h" #include "AppEvent.h" -#include -#include #include #include #include diff --git a/examples/lighting-app/silabs/efr32/BUILD.gn b/examples/lighting-app/silabs/efr32/BUILD.gn index fdcadf1feb5732..f2103d5bde63b2 100644 --- a/examples/lighting-app/silabs/efr32/BUILD.gn +++ b/examples/lighting-app/silabs/efr32/BUILD.gn @@ -35,114 +35,11 @@ efr32_project_dir = "${chip_root}/examples/lighting-app/silabs/efr32" examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32" examples_common_plat_dir = "${chip_root}/examples/platform/silabs" +import("${examples_plat_dir}/args.gni") + declare_args() { # Dump memory usage at link time. chip_print_memory_usage = false - - # Monitor & log memory usage at runtime. - enable_heap_monitoring = false - - # Enable Sleepy end device - enable_sleepy_device = false - - # OTA timeout in seconds - OTA_periodic_query_timeout = 86400 - - # Wifi related stuff - they are overridden by gn -args="use_wf200=true" - use_wf200 = false - use_rs911x = false - use_rs911x_sockets = false - sl_wfx_config_softap = false - sl_wfx_config_scan = true - - # Disable LCD on supported devices - disable_lcd = false - - # Argument to Disable IPv4 for wifi(rs911) - chip_enable_wifi_ipv4 = false - - # Argument to force enable WPA3 security on rs91x - rs91x_wpa3_only = false - - #default WiFi SSID - chip_default_wifi_ssid = "" - - #default Wifi Password - chip_default_wifi_psk = "" -} - -declare_args() { - # Enables LCD Qr Code on supported devices - show_qr_code = !disable_lcd -} - -# qr code cannot be true if lcd is disabled -assert(!(disable_lcd && show_qr_code)) - -# Sanity check -assert(!(chip_enable_wifi && chip_enable_openthread)) -assert(!(use_rs911x && chip_enable_openthread)) -assert(!(use_wf200 && chip_enable_openthread)) -if (chip_enable_wifi) { - assert(use_rs911x || use_wf200) - enable_openthread_cli = false - import("${chip_root}/src/platform/silabs/EFR32/wifi_args.gni") -} - -# ThunderBoards, Explorer Kit and MGM240L do not support LCD (No LCD) -if (silabs_board == "BRD4166A" || silabs_board == "BRD2601B" || - silabs_board == "BRD2703A" || silabs_board == "BRD4319A") { - show_qr_code = false - disable_lcd = true -} - -defines = [] - -# WiFi settings -if (chip_enable_wifi) { - if (chip_default_wifi_ssid != "") { - defines += [ - "CHIP_ONNETWORK_PAIRING=1", - "CHIP_WIFI_SSID=\"${chip_default_wifi_ssid}\"", - ] - } - if (chip_default_wifi_psk != "") { - assert(chip_default_wifi_ssid != "", - "ssid can't be null if psk is provided") - defines += [ "CHIP_WIFI_PSK=\"${chip_default_wifi_psk}\"" ] - } - wifi_sdk_dir = "${chip_root}/src/platform/silabs/EFR32/wifi" - efr32_lwip_defs = [ "LWIP_NETIF_API=1" ] - if (lwip_ipv4) { - efr32_lwip_defs += [ - "LWIP_IPV4=1", - - # adds following options to provide - # them to .cpp source files - # flags ported from lwipopts file - # TODO: move lwipopts to one location - "LWIP_ARP=1", - "LWIP_ICMP=1", - "LWIP_IGMP=1", - "LWIP_DHCP=1", - "LWIP_DNS=0", - ] - } else { - efr32_lwip_defs += [ "LWIP_IPV4=0" ] - } - if (lwip_ipv6) { - efr32_lwip_defs += [ "LWIP_IPV6=1" ] - } else { - efr32_lwip_defs += [ "LWIP_IPV6=0" ] - } - - if (use_rs911x) { - wiseconnect_sdk_root = - "${chip_root}/third_party/silabs/wiseconnect-wifi-bt-sdk" - import("${examples_plat_dir}/rs911x/rs911x.gni") - } else { - import("${examples_plat_dir}/wf200/wf200.gni") - } } efr32_sdk("sdk") { @@ -159,47 +56,18 @@ efr32_sdk("sdk") { "${examples_common_plat_dir}", ] - defines += [ - "BOARD_ID=${silabs_board}", - "OTA_PERIODIC_TIMEOUT=${OTA_periodic_query_timeout}", - ] - - if (enable_heap_monitoring) { - defines += [ "HEAP_MONITORING" ] + if (use_wf200) { + # TODO efr32_sdk should not need a header from this location + include_dirs += [ "${examples_plat_dir}/wf200" ] } + defines = [] if (chip_enable_pw_rpc) { defines += [ "HAL_VCOM_ENABLE=1", "PW_RPC_ENABLED", ] } - - # WiFi Settings - if (chip_enable_wifi) { - if (use_rs911x) { - defines += rs911x_defs - include_dirs += rs911x_plat_incs - } else if (use_wf200) { - defines += wf200_defs - include_dirs += wf200_plat_incs - } - - if (use_rs911x_sockets) { - include_dirs += [ "${examples_plat_dir}/wifi/rsi-sockets" ] - defines += rs911x_sock_defs - } else { - # Using LWIP instead of the native TCP/IP stack - defines += efr32_lwip_defs - } - - if (sl_wfx_config_softap) { - defines += [ "SL_WFX_CONFIG_SOFTAP" ] - } - if (sl_wfx_config_scan) { - defines += [ "SL_WFX_CONFIG_SCAN" ] - } - } } efr32_executable("lighting_app") { @@ -208,105 +76,23 @@ efr32_executable("lighting_app") { include_dirs = [ "include" ] defines = [] + if (silabs_board == "BRD2704A") { + defines += [ "SL_STATUS_LED=0" ] + } + sources = [ - "${examples_common_plat_dir}/heap_4_silabs.c", - "${examples_plat_dir}/BaseApplication.cpp", - "${examples_plat_dir}/efr32_utils.cpp", - "${examples_plat_dir}/init_efrPlatform.cpp", - "${examples_plat_dir}/matter_config.cpp", "src/AppTask.cpp", "src/LightingManager.cpp", "src/ZclCallbacks.cpp", "src/main.cpp", ] - if (use_wstk_leds) { - sources += [ "${examples_plat_dir}/LEDWidget.cpp" ] - } - - if (chip_enable_pw_rpc || chip_build_libshell || enable_openthread_cli || - use_wf200 || use_rs911x) { - sources += [ "${examples_plat_dir}/uart.cpp" ] - } - deps = [ ":sdk", - "${chip_root}/examples/lighting-app/lighting-common", - "${chip_root}/examples/providers:device_info_provider", - "${chip_root}/src/lib", - "${chip_root}/src/setup_payload", + "${examples_plat_dir}:efr32-common", + app_data_model, ] - # OpenThread Settings - if (chip_enable_openthread) { - deps += [ - "${chip_root}/third_party/openthread:openthread", - "${chip_root}/third_party/openthread:openthread-platform", - "${examples_plat_dir}:efr-matter-shell", - ] - } - - if (chip_enable_ota_requestor) { - defines += [ "EFR32_OTA_ENABLED" ] - sources += [ "${examples_plat_dir}/OTAConfig.cpp" ] - } - - # WiFi Settings - if (chip_enable_wifi) { - if (use_rs911x) { - sources += rs911x_src_plat - - # All the stuff from wiseconnect - sources += rs911x_src_sapi - - # Apparently - the rsi library needs this (though we may not use use it) - sources += rs911x_src_sock - include_dirs += rs911x_inc_plat - - if (use_rs911x_sockets) { - # - # Using native sockets inside RS911x - # - include_dirs += rs911x_sock_inc - } else { - # - # We use LWIP - not built-in sockets - # - sources += rs911x_src_lwip - } - } else if (use_wf200) { - sources += wf200_plat_src - include_dirs += wf200_plat_incs - } - - if (chip_enable_wifi_ipv4) { - defines += [ "CHIP_DEVICE_CONFIG_ENABLE_IPV4" ] - } - - if (rs91x_wpa3_only) { - # TODO: Change this macro once WF200 support is provided - defines += [ "WIFI_ENABLE_SECURITY_WPA3=1" ] - } - } - - if (!disable_lcd) { - sources += [ - "${examples_plat_dir}/display/demo-ui.c", - "${examples_plat_dir}/display/lcd.cpp", - ] - - include_dirs += [ "${examples_plat_dir}/display" ] - defines += [ - "DISPLAY_ENABLED", - "IS_DEMO_LIGHT=1", - ] - if (show_qr_code) { - defines += [ "QR_CODE_ENABLED" ] - - deps += [ "${chip_root}/examples/common/QRCode" ] - } - } - if (chip_enable_pw_rpc) { defines += [ "PW_RPC_ENABLED", @@ -352,11 +138,6 @@ efr32_executable("lighting_app") { ] } - if (enable_heap_monitoring) { - sources += [ "${examples_common_plat_dir}/MemMonitoring.cpp" ] - defines += [ "HEAP_MONITORING" ] - } - ldscript = "${examples_plat_dir}/ldscripts/${silabs_family}.ld" inputs = [ ldscript ] @@ -378,16 +159,6 @@ efr32_executable("lighting_app") { ] } - # Attestation Credentials - if (chip_build_platform_attestation_credentials_provider) { - deps += [ "${examples_plat_dir}:efr32-attestation-credentials" ] - } - - # Factory Data Provider - if (use_efr32_factory_data_provider) { - deps += [ "${examples_plat_dir}:efr32-factory-data-provider" ] - } - output_dir = root_out_dir } diff --git a/examples/lighting-app/silabs/efr32/README.md b/examples/lighting-app/silabs/efr32/README.md index 26027fc6ad108e..92aeb9f5d1897d 100644 --- a/examples/lighting-app/silabs/efr32/README.md +++ b/examples/lighting-app/silabs/efr32/README.md @@ -97,31 +97,6 @@ Silicon Labs platform. - BRD4187A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - BRD4187C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - MG12 boards: - - - BRD4161A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm - - BRD4162A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4163A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm, - 868MHz@19dBm - - BRD4164A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm - - BRD4166A / SLTB004A / Thunderboard Sense 2 / 2.4GHz@10dBm - - BRD4170A / SLWSTK6000B / Multiband Wireless Starter Kit / 2.4GHz@19dBm, - 915MHz@19dBm - - BRD4304A / SLWSTK6000B / MGM12P Module / 2.4GHz@19dBm - - MG21 boards: Currently not supported due to RAM limitation. - - - BRD4180A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - - MG24 boards : - - - BRD2601B / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD2703A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4186A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4186C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4187A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - - BRD4187C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - * Build the example application: cd ~/connectedhomeip @@ -134,7 +109,7 @@ Silicon Labs platform. OR use GN/Ninja directly - $ cd ~/connectedhomeip/examples/lighting-app/efr32 + $ cd ~/connectedhomeip/examples/lighting-app/silabs/efr32 $ git submodule update --init $ source third_party/connectedhomeip/scripts/activate.sh $ export silabs_board=BRD4161A @@ -143,7 +118,7 @@ Silicon Labs platform. - To delete generated executable, libraries and object files use: - $ cd ~/connectedhomeip/examples/lighting-app/efr32 + $ cd ~/connectedhomeip/examples/lighting-app/silabs/efr32 $ rm -rf out/ * Build the example as Sleepy End Device (SED) @@ -156,11 +131,11 @@ Silicon Labs platform. * Build the example with pigweed RPC - $ ./scripts/examples/gn_efr32_example.sh examples/lighting-app/efr32/ out/lighting_app_rpc BRD4161A 'import("//with_pw_rpc.gni")' + $ ./scripts/examples/gn_efr32_example.sh examples/lighting-app/silabs/efr32/ out/lighting_app_rpc BRD4161A 'import("//with_pw_rpc.gni")' or use GN/Ninja Directly - $ cd ~/connectedhomeip/examples/lighting-app/efr32 + $ cd ~/connectedhomeip/examples/lighting-app/silabs/efr32 $ git submodule update --init $ source third_party/connectedhomeip/scripts/activate.sh $ export silabs_board=BRD4161A @@ -178,7 +153,7 @@ arguments - On the command line: - $ cd ~/connectedhomeip/examples/lighting-app/efr32 + $ cd ~/connectedhomeip/examples/lighting-app/silabs/efr32 $ python3 out/debug/chip-efr32-lighting-example.flash.py - Or with the Ozone debugger, just load the .out file. @@ -360,7 +335,7 @@ To track memory usage you can set `enable_heap_monitoring = true` either in the BUILD.gn file or pass it as a build argument to gn. This will print on the RTT console the RAM usage of each individual task and the number of Memory allocation and Free. While this is not extensive monitoring you're welcome to -modify `examples/platform/efr32/MemMonitoring.cpp` to add your own memory +modify `examples/platform/silabs/efr32/MemMonitoring.cpp` to add your own memory tracking code inside the `trackAlloc` and `trackFree` function ## OTA Software Update diff --git a/examples/lighting-app/silabs/efr32/args.gni b/examples/lighting-app/silabs/efr32/args.gni index 6b0d9a8e2eb8a6..75b21eaef170aa 100644 --- a/examples/lighting-app/silabs/efr32/args.gni +++ b/examples/lighting-app/silabs/efr32/args.gni @@ -18,6 +18,7 @@ import("${chip_root}/src/platform/silabs/EFR32/args.gni") efr32_sdk_target = get_label_info(":sdk", "label_no_toolchain") +app_data_model = "${chip_root}/examples/lighting-app/lighting-common" chip_enable_ota_requestor = true chip_enable_openthread = true diff --git a/examples/lighting-app/silabs/efr32/build_for_wifi_args.gni b/examples/lighting-app/silabs/efr32/build_for_wifi_args.gni index 86d8a19bbc36ce..a1e4b995d96b1a 100644 --- a/examples/lighting-app/silabs/efr32/build_for_wifi_args.gni +++ b/examples/lighting-app/silabs/efr32/build_for_wifi_args.gni @@ -19,3 +19,4 @@ chip_enable_openthread = false import("${chip_root}/src/platform/silabs/EFR32/wifi_args.gni") chip_enable_ota_requestor = true +app_data_model = "${chip_root}/examples/lighting-app/lighting-common" diff --git a/examples/lighting-app/silabs/efr32/include/AppConfig.h b/examples/lighting-app/silabs/efr32/include/AppConfig.h index ffadaf9706cd2e..349f28d7c466d6 100644 --- a/examples/lighting-app/silabs/efr32/include/AppConfig.h +++ b/examples/lighting-app/silabs/efr32/include/AppConfig.h @@ -28,3 +28,59 @@ // Time it takes in ms for the simulated actuator to move from one // state to another. #define ACTUATOR_MOVEMENT_PERIOS_MS 10 + +#define ON_DEMO_BITMAP \ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfc, \ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfc, 0xff, 0xff, 0xff, 0xff, \ + 0xff, 0xff, 0x7f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfc, \ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xcf, 0xff, 0xff, 0xff, 0xff, 0xf3, 0xff, 0xff, \ + 0x8f, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xff, 0xff, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xf0, 0xff, 0xff, 0x1f, 0xfe, 0x07, 0xe0, \ + 0x7f, 0xf8, 0xff, 0xff, 0x3f, 0xfc, 0x00, 0x00, 0x3f, 0xfc, 0xff, 0xff, 0x7f, 0x3c, 0xe0, 0x07, 0x3c, 0xfe, 0xff, 0xff, \ + 0xff, 0x1f, 0xfe, 0x7f, 0xf8, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xff, 0xff, \ + 0xe3, 0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xff, 0xc7, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xff, 0xff, 0x8f, 0xff, 0xff, 0xff, \ + 0xff, 0xf1, 0xff, 0xff, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0x7f, 0xfc, 0xff, 0xff, \ + 0x3f, 0xfe, 0xff, 0xff, 0x7f, 0xfc, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0x7f, 0xfc, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, \ + 0x7f, 0xfe, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0x7f, 0xfc, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, \ + 0x7f, 0xfc, 0xff, 0x0f, 0x38, 0xfe, 0xff, 0xff, 0x7f, 0x1c, 0xf0, 0x0f, 0x38, 0xfe, 0x03, 0xc0, 0x7f, 0x1c, 0xf0, 0x0f, \ + 0x38, 0xfe, 0x27, 0xe9, 0x7f, 0x1c, 0xf0, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0x7f, 0xfc, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, \ + 0x7f, 0xfc, 0xff, 0xff, 0x3f, 0xfe, 0xe7, 0xe7, 0x7f, 0xfc, 0xff, 0xff, 0x7f, 0xfe, 0xef, 0xf7, 0x7f, 0xfe, 0xff, 0xff, \ + 0x7f, 0xfc, 0xef, 0xf7, 0x3f, 0xfe, 0xff, 0xff, 0xff, 0xfc, 0xef, 0xf3, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xcf, 0xf3, \ + 0x1f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xdf, 0xfb, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xdf, 0xfb, 0x8f, 0xff, 0xff, 0xff, \ + 0xff, 0xe3, 0x9f, 0xf9, 0xc7, 0xff, 0xff, 0xff, 0xff, 0xc3, 0x9f, 0xf9, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xc7, 0x9f, 0xfd, \ + 0xe3, 0xff, 0xff, 0xff, 0xff, 0x8f, 0xbf, 0xfd, 0xf1, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x3f, 0xfc, 0xf8, 0xff, 0xff, 0xff, \ + 0xff, 0x3f, 0x3e, 0x7c, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfc, 0x3f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfc, 0x3f, \ + 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, \ + 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x1f, \ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, \ + 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1, 0x8f, \ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0xff, 0xff, \ + 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff + +#define OFF_DEMO_BITMAP \ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xe0, \ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xe0, 0x07, 0xfc, 0xff, 0xff, 0xff, \ + 0xff, 0x1f, 0xfe, 0x7f, 0xf8, 0xff, 0xff, 0xff, 0xff, 0x0f, 0xff, 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xff, 0xff, \ + 0xe3, 0xff, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xff, 0xc7, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xff, 0xff, 0x8f, 0xff, 0xff, 0xff, \ + 0xff, 0xf1, 0xff, 0xff, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0x7f, 0xfc, 0xff, 0xff, \ + 0x3f, 0xfe, 0xff, 0xff, 0x7f, 0xfc, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0x7f, 0xfc, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, \ + 0x7f, 0xfe, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0x7f, 0xfc, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, \ + 0x7f, 0xfc, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0x7f, 0xfc, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0x7f, 0xfc, 0xff, 0xff, \ + 0x3f, 0xfe, 0xff, 0xff, 0x7f, 0xfc, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0x7f, 0xfc, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, \ + 0x7f, 0xfc, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0x7f, 0xfc, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, \ + 0x7f, 0xfc, 0xff, 0xff, 0x3f, 0xfe, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff, \ + 0x1f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xff, 0xff, 0x8f, 0xff, 0xff, 0xff, \ + 0xff, 0xe3, 0xff, 0xff, 0xc7, 0xff, 0xff, 0xff, 0xff, 0xc3, 0xff, 0xff, 0xc3, 0xff, 0xff, 0xff, 0xff, 0xc7, 0xff, 0xff, \ + 0xe3, 0xff, 0xff, 0xff, 0xff, 0x8f, 0xff, 0xff, 0xf1, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xff, \ + 0xff, 0x3f, 0xfe, 0x7f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfc, 0x3f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfc, 0x3f, \ + 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, \ + 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x1f, \ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, \ + 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1, 0x8f, \ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0xff, 0xff, \ + 0xff, 0xff, 0x3f, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, \ + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff diff --git a/examples/lighting-app/silabs/efr32/include/AppTask.h b/examples/lighting-app/silabs/efr32/include/AppTask.h index df80995592fd95..cc76b02e8b293d 100644 --- a/examples/lighting-app/silabs/efr32/include/AppTask.h +++ b/examples/lighting-app/silabs/efr32/include/AppTask.h @@ -30,7 +30,9 @@ #include "BaseApplication.h" #include "FreeRTOS.h" #include "LightingManager.h" +#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT #include "sl_simple_button_instances.h" +#endif #include "timers.h" // provides FreeRTOS timer support #include #include @@ -69,7 +71,7 @@ class AppTask : public BaseApplication static void AppTaskMain(void * pvParameter); CHIP_ERROR StartAppTask(); - +#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT /** * @brief Event handler when a button is pressed * Function posts an event for button processing @@ -79,7 +81,7 @@ class AppTask : public BaseApplication * SL_SIMPLE_BUTTON_RELEASED or SL_SIMPLE_BUTTON_DISABLED */ void ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAction) override; - +#endif /** * @brief Callback called by the identify-server when an identify command is received * diff --git a/examples/lighting-app/silabs/efr32/src/AppTask.cpp b/examples/lighting-app/silabs/efr32/src/AppTask.cpp old mode 100644 new mode 100755 index ccd77060e755d1..1169e09619eb32 --- a/examples/lighting-app/silabs/efr32/src/AppTask.cpp +++ b/examples/lighting-app/silabs/efr32/src/AppTask.cpp @@ -26,8 +26,6 @@ #include "sl_simple_led_instances.h" #endif // ENABLE_WSTK_LEDS -#include -#include #include #include #include @@ -44,12 +42,18 @@ #include #ifdef ENABLE_WSTK_LEDS -#define SYSTEM_STATE_LED &sl_led_led0 +#if defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT) #define LIGHT_LED &sl_led_led1 +#else +#define LIGHT_LED &sl_led_led0 +#endif #endif // ENABLE_WSTK_LEDS +#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT + #define APP_FUNCTION_BUTTON &sl_button_btn0 #define APP_LIGHT_SWITCH &sl_button_btn1 +#endif using namespace chip; using namespace ::chip::DeviceLayer; @@ -158,6 +162,21 @@ CHIP_ERROR AppTask::Init() sLightLED.Set(LightMgr().IsLightOn()); #endif // ENABLE_WSTK_LEDS +// Update the LCD with the Stored value. Show QR Code if not provisioned +#ifdef DISPLAY_ENABLED + GetLCD().WriteDemoUI(LightMgr().IsLightOn()); +#ifdef QR_CODE_ENABLED +#ifdef SL_WIFI + if (!ConnectivityMgr().IsWiFiStationProvisioned()) +#else + if (!ConnectivityMgr().IsThreadProvisioned()) +#endif /* !SL_WIFI */ + { + GetLCD().ShowQRCode(true, true); + } +#endif // QR_CODE_ENABLED +#endif + return err; } @@ -225,11 +244,13 @@ void AppTask::LightActionEventHandler(AppEvent * aEvent) action = static_cast(aEvent->LightEvent.Action); actor = aEvent->LightEvent.Actor; } +#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT else if (aEvent->Type == AppEvent::kEventType_Button) { action = (LightMgr().IsLightOn()) ? LightingManager::OFF_ACTION : LightingManager::ON_ACTION; actor = AppEvent::kEventType_Button; } +#endif else { err = APP_ERROR_UNHANDLED_EVENT; @@ -245,7 +266,7 @@ void AppTask::LightActionEventHandler(AppEvent * aEvent) } } } - +#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT void AppTask::ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAction) { if (buttonHandle == NULL) @@ -269,6 +290,8 @@ void AppTask::ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAc } } +#endif + void AppTask::ActionInitiated(LightingManager::Action_t aAction, int32_t aActor) { // Action initiated, update the light led @@ -282,11 +305,12 @@ void AppTask::ActionInitiated(LightingManager::Action_t aAction, int32_t aActor) #ifdef DISPLAY_ENABLED sAppTask.GetLCD().WriteDemoUI(lightOn); #endif - +#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT if (aActor == AppEvent::kEventType_Button) { sAppTask.mSyncClusterToButtonAction = true; } +#endif } void AppTask::ActionCompleted(LightingManager::Action_t aAction) @@ -300,12 +324,13 @@ void AppTask::ActionCompleted(LightingManager::Action_t aAction) { SILABS_LOG("Light OFF") } - +#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT if (sAppTask.mSyncClusterToButtonAction) { chip::DeviceLayer::PlatformMgr().ScheduleWork(UpdateClusterState, reinterpret_cast(nullptr)); sAppTask.mSyncClusterToButtonAction = false; } +#endif } void AppTask::PostLightActionRequest(int32_t aActor, LightingManager::Action_t aAction) diff --git a/examples/lighting-app/silabs/efr32/src/main.cpp b/examples/lighting-app/silabs/efr32/src/main.cpp index 2594f6f9216e78..9f447b972678b6 100644 --- a/examples/lighting-app/silabs/efr32/src/main.cpp +++ b/examples/lighting-app/silabs/efr32/src/main.cpp @@ -21,7 +21,9 @@ #include "AppConfig.h" #include "init_efrPlatform.h" +#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT #include "sl_simple_button_instances.h" +#endif #include "sl_system_kernel.h" #include #include @@ -78,7 +80,9 @@ int main(void) appError(CHIP_ERROR_INTERNAL); } +#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT void sl_button_on_change(const sl_button_t * handle) { AppTask::GetAppTask().ButtonEventHandler(handle, sl_button_get_state(handle)); } +#endif diff --git a/examples/lighting-app/silabs/efr32/with_pw_rpc.gni b/examples/lighting-app/silabs/efr32/with_pw_rpc.gni index 40a8bb79d84b6a..3ee366c51ad498 100644 --- a/examples/lighting-app/silabs/efr32/with_pw_rpc.gni +++ b/examples/lighting-app/silabs/efr32/with_pw_rpc.gni @@ -21,6 +21,7 @@ import("${chip_root}/examples/platform/silabs/efr32/args.gni") efr32_sdk_target = get_label_info(":sdk", "label_no_toolchain") +app_data_model = "${chip_root}/examples/lighting-app/lighting-common" chip_enable_pw_rpc = true chip_enable_openthread = true chip_build_pw_trace_lib = true diff --git a/examples/lighting-app/telink/CMakeLists.txt b/examples/lighting-app/telink/CMakeLists.txt index a917c8d6ea6b36..628e10410e816c 100644 --- a/examples/lighting-app/telink/CMakeLists.txt +++ b/examples/lighting-app/telink/CMakeLists.txt @@ -47,12 +47,13 @@ add_definitions( target_sources(app PRIVATE src/AppTask.cpp - src/LightingManager.cpp src/main.cpp src/ZclCallbacks.cpp ${TELINK_COMMON}/util/src/LEDWidget.cpp ${TELINK_COMMON}/util/src/ButtonManager.cpp - ${TELINK_COMMON}/util/src/ThreadUtil.cpp) + ${TELINK_COMMON}/util/src/ThreadUtil.cpp + ${TELINK_COMMON}/util/src/PWMDevice.cpp + ${TELINK_COMMON}/util/src/ColorFormat.cpp) chip_configure_data_model(app INCLUDE_SERVER diff --git a/examples/lighting-app/telink/README.md b/examples/lighting-app/telink/README.md index d6ace813c0df75..11594c9091855e 100644 --- a/examples/lighting-app/telink/README.md +++ b/examples/lighting-app/telink/README.md @@ -67,16 +67,55 @@ The following buttons are available on **tlsr9518adk80d** board: ### LEDs -**Red** LED indicates current state of Thread network. It ables to be in +#### Indicate current state of Thread network + +**Red** LED indicates current state of Thread network. It is able to be in following states: | State | Description | | :-------------------------- | :--------------------------------------------------------------------------- | | Blinks with short pulses | Device is not commissioned to Thread, Thread is disabled | -| Blinls with frequent pulses | Device is commissioned, Thread enabled. Device trying to JOIN thread network | -| Blinks with whde pulses | Device commissioned and joined to thread network as CHILD | +| Blinks with frequent pulses | Device is commissioned, Thread enabled. Device trying to JOIN thread network | +| Blinks with wide pulses | Device commissioned and joined to thread network as CHILD | + +#### Indicate identify of device + +**Green** LED used to identify the device. The LED starts blinking when the +Identify command of the Identify cluster is received. The command's argument can +be used to specify the the effect. It is able to be in following effects: + +| Effect | Description | +| :------------------------------ | :------------------------------------------------------------------- | +| Blinks (200 ms on/200 ms off) | Blink (EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK) | +| Breathe (during 1000 ms) | Breathe (EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE) | +| Blinks (50 ms on/950 ms off) | Okay (EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY) | +| Blinks (1000 ms on/1000 ms off) | Channel Change (EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE) | +| Blinks (950 ms on/50 ms off) | Finish (EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_FINISH_EFFECT) | +| LED off | Stop (EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT) | + +#### Indicate current state of lightbulb + +By default, only **Blue** LED is used to show current state of lightbulb (only +for lightning-app). + +To enable RGB functionality in Your application set this config: + +In Matter examples/lighting-app/telink/include/**AppConfig.h**, set the define +`USE_RGB_PWM`: + +```bash + define USE_RGB_PWM 1 +``` + +To get current state of lightbulb in RGB mode, connect 3-color LED module to +following pins: -**Blue** LED shows current state of lightbulb +| Name | Pin | +| :---: | :-----------------: | +| Red | PE2 (pin 8 of J34) | +| Green | PE0 (pin 5 of J34) | +| Blue | PB4 (pin 20 of J34) | +| GND | GND (pin 24 of J50) | ### CHIP tool commands diff --git a/examples/lighting-app/telink/include/AppConfig.h b/examples/lighting-app/telink/include/AppConfig.h index 2d7aec52b295d2..531cca82215120 100644 --- a/examples/lighting-app/telink/include/AppConfig.h +++ b/examples/lighting-app/telink/include/AppConfig.h @@ -29,10 +29,15 @@ #define BUTTON_PIN_2 0 // LEDs config -// System led config -#define SYSTEM_STATE_LED_PORT DEVICE_DT_GET(DT_NODELABEL(gpiob)) -#define SYSTEM_STATE_LED_PIN 7 +#define LEDS_PORT DEVICE_DT_GET(DT_NODELABEL(gpiob)) +#define SYSTEM_STATE_LED 7 // Lighting LED config -#define LIGHTING_PWM_DEVICE DEVICE_DT_GET(DT_PWMS_CTLR(DT_ALIAS(pwm_led0))) -#define LIGHTING_PWM_CHANNEL DT_PWMS_CHANNEL(DT_ALIAS(pwm_led0)) +#define USE_RGB_PWM 0 + +#define LIGHTING_PWM_SPEC_RGB_BLUE PWM_DT_SPEC_GET(DT_ALIAS(pwm_led0)) +#if USE_RGB_PWM +#define LIGHTING_PWM_SPEC_RGB_GREEN PWM_DT_SPEC_GET(DT_ALIAS(pwm_led1)) +#define LIGHTING_PWM_SPEC_RGB_RED PWM_DT_SPEC_GET(DT_ALIAS(pwm_led2)) +#endif +#define LIGHTING_PWM_SPEC_IDENTIFY_GREEN PWM_DT_SPEC_GET(DT_ALIAS(pwm_led3)) diff --git a/examples/lighting-app/telink/include/AppEvent.h b/examples/lighting-app/telink/include/AppEvent.h index 1766b5d77577a1..72554b4bb54b5a 100644 --- a/examples/lighting-app/telink/include/AppEvent.h +++ b/examples/lighting-app/telink/include/AppEvent.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2021 Project CHIP Authors + * Copyright (c) 2022 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -32,6 +32,8 @@ struct AppEvent kEventType_Button = 0, kEventType_Timer, kEventType_UpdateLedState, + kEventType_IdentifyStart, + kEventType_IdentifyStop, kEventType_Lighting, kEventType_Install, }; diff --git a/examples/lighting-app/telink/include/AppTask.h b/examples/lighting-app/telink/include/AppTask.h index 26575805d70a5d..f0a175a4d9f9c1 100644 --- a/examples/lighting-app/telink/include/AppTask.h +++ b/examples/lighting-app/telink/include/AppTask.h @@ -18,9 +18,10 @@ #pragma once +#include "AppConfig.h" #include "AppEvent.h" #include "LEDWidget.h" -#include "LightingManager.h" +#include "PWMDevice.h" #include #if CONFIG_CHIP_FACTORY_DATA @@ -34,15 +35,17 @@ #include struct k_timer; +struct Identify; class AppTask { public: - CHIP_ERROR StartApp(); + CHIP_ERROR StartApp(void); - void PostLightingActionRequest(LightingManager::Action_t aAction); - void PostEvent(AppEvent * event); - void UpdateClusterState(); + void SetInitiateAction(PWMDevice::Action_t aAction, int32_t aActor, uint8_t * value); + void PostEvent(AppEvent * aEvent); + void UpdateClusterState(void); + PWMDevice & GetPWMDevice(void) { return mPwmRgbBlueLed; } enum ButtonId_t { @@ -52,19 +55,22 @@ class AppTask kButtonId_StartBleAdv } ButtonId; + static void IdentifyEffectHandler(EmberAfIdentifyEffectIdentifier aEffect); + private: #ifdef CONFIG_CHIP_PW_RPC friend class chip::rpc::TelinkButton; #endif friend AppTask & GetAppTask(void); - CHIP_ERROR Init(); + CHIP_ERROR Init(void); - static void ActionInitiated(LightingManager::Action_t aAction, int32_t aActor); - static void ActionCompleted(LightingManager::Action_t aAction, int32_t aActor); + static void ActionInitiated(PWMDevice::Action_t aAction, int32_t aActor); + static void ActionCompleted(PWMDevice::Action_t aAction, int32_t aActor); + static void ActionIdentifyStateUpdateHandler(k_timer * timer); void DispatchEvent(AppEvent * event); - static void UpdateStatusLED(); + static void UpdateStatusLED(void); static void LEDStateUpdateHandler(LEDWidget * ledWidget); static void LightingActionButtonEventHandler(void); static void FactoryResetButtonEventHandler(void); @@ -81,6 +87,7 @@ class AppTask static void LightingActionEventHandler(AppEvent * aEvent); static void StartBleAdvHandler(AppEvent * aEvent); static void UpdateLedStateEventHandler(AppEvent * aEvent); + static void UpdateIdentifyStateEventHandler(AppEvent * aEvent); static void ButtonEventHandler(ButtonId_t btnId, bool btnPressed); static void InitButtons(void); @@ -88,6 +95,12 @@ class AppTask static void ThreadProvisioningHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg); static AppTask sAppTask; + PWMDevice mPwmRgbBlueLed; +#if USE_RGB_PWM + PWMDevice mPwmRgbGreenLed; + PWMDevice mPwmRgbRedLed; +#endif + PWMDevice mPwmIdentifyLed; #if CONFIG_CHIP_FACTORY_DATA // chip::DeviceLayer::FactoryDataProvider mFactoryDataProvider; diff --git a/examples/lighting-app/telink/include/LightingManager.h b/examples/lighting-app/telink/include/LightingManager.h deleted file mode 100644 index 5ac8187f001e7f..00000000000000 --- a/examples/lighting-app/telink/include/LightingManager.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "AppEvent.h" - -#include - -#include -#include - -class LightingManager -{ -public: - enum Action_t : uint8_t - { - ON_ACTION = 0, - OFF_ACTION, - LEVEL_ACTION, - - INVALID_ACTION - }; - - enum State_t : uint8_t - { - kState_On = 0, - kState_Off, - }; - - using LightingCallback_fn = void (*)(Action_t, int32_t); - - CHIP_ERROR Init(const device * pwmDevice, uint32_t pwmChannel, uint8_t aMinLevel, uint8_t aMaxLevel, uint8_t aDefaultLevel = 0); - void Set(bool aOn); - bool IsTurnedOn() const { return mState == kState_On; } - uint8_t GetLevel() const { return mLevel; } - uint8_t GetMinLevel() const { return mMinLevel; } - uint8_t GetMaxLevel() const { return mMaxLevel; } - bool InitiateAction(Action_t aAction, int32_t aActor, uint8_t size, uint8_t * value); - void SetCallbacks(LightingCallback_fn aActionInitiated_CB, LightingCallback_fn aActionCompleted_CB); - -private: - friend LightingManager & LightingMgr(); - State_t mState; - uint8_t mMinLevel; - uint8_t mMaxLevel; - uint8_t mLevel; - const device * mPwmDevice; - uint32_t mPwmChannel; - - LightingCallback_fn mActionInitiated_CB; - LightingCallback_fn mActionCompleted_CB; - - void SetLevel(uint8_t aLevel); - void UpdateLight(); - - static LightingManager sLight; -}; - -inline LightingManager & LightingMgr(void) -{ - return LightingManager::sLight; -} diff --git a/examples/lighting-app/telink/src/AppTask.cpp b/examples/lighting-app/telink/src/AppTask.cpp index f7866db456c370..41a3cfcc57f373 100644 --- a/examples/lighting-app/telink/src/AppTask.cpp +++ b/examples/lighting-app/telink/src/AppTask.cpp @@ -21,12 +21,11 @@ #include "AppConfig.h" #include "AppEvent.h" #include "ButtonManager.h" +#include "ColorFormat.h" #include "ThreadUtil.h" #include -#include -#include #include #include #include @@ -45,7 +44,25 @@ #include -LOG_MODULE_DECLARE(app); +#if CONFIG_CHIP_LIB_SHELL +#include +#include + +static int cmd_telink_reboot(const struct shell * shell, size_t argc, char ** argv) +{ + ARG_UNUSED(argc); + ARG_UNUSED(argv); + + shell_print(shell, "Performing board reboot..."); + sys_reboot(); +} + +SHELL_STATIC_SUBCMD_SET_CREATE(sub_telink, SHELL_CMD(reboot, NULL, "Reboot board command", cmd_telink_reboot), + SHELL_SUBCMD_SET_END); +SHELL_CMD_REGISTER(telink, &sub_telink, "Telink commands", NULL); +#endif // CONFIG_CHIP_LIB_SHELL + +LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL); using namespace ::chip; using namespace ::chip::app; @@ -53,22 +70,45 @@ using namespace ::chip::Credentials; using namespace ::chip::DeviceLayer; namespace { -constexpr int kFactoryResetTriggerTimeout = 2000; -constexpr int kAppEventQueueSize = 10; -constexpr uint8_t kButtonPushEvent = 1; -constexpr uint8_t kButtonReleaseEvent = 0; -constexpr uint8_t kDefaultMinLevel = 0; -constexpr uint8_t kDefaultMaxLevel = 254; +constexpr int kFactoryResetTriggerTimeout = 2000; +constexpr int kAppEventQueueSize = 10; +constexpr uint8_t kButtonPushEvent = 1; +constexpr uint8_t kButtonReleaseEvent = 0; +constexpr EndpointId kLightEndpointId = 1; +constexpr uint8_t kDefaultMinLevel = 0; +constexpr uint8_t kDefaultMaxLevel = 254; +constexpr uint32_t kIdentifyBlinkRateMs = 200; +constexpr uint32_t kIdentifyOkayOnRateMs = 50; +constexpr uint32_t kIdentifyOkayOffRateMs = 950; +constexpr uint32_t kIdentifyFinishOnRateMs = 950; +constexpr uint32_t kIdentifyFinishOffRateMs = 50; +constexpr uint32_t kIdentifyChannelChangeRateMs = 1000; +constexpr uint32_t kIdentifyBreatheRateMs = 1000; + +const struct pwm_dt_spec sPwmRgbSpecBlueLed = LIGHTING_PWM_SPEC_RGB_BLUE; +#if USE_RGB_PWM +const struct pwm_dt_spec sPwmRgbSpecGreenLed = LIGHTING_PWM_SPEC_RGB_GREEN; +const struct pwm_dt_spec sPwmRgbSpecRedLed = LIGHTING_PWM_SPEC_RGB_RED; +#endif +const struct pwm_dt_spec sPwmIdentifySpecGreenLed = LIGHTING_PWM_SPEC_IDENTIFY_GREEN; +#if CONFIG_CHIP_FACTORY_DATA // NOTE! This key is for test/certification only and should not be available in production devices! -// If CONFIG_CHIP_FACTORY_DATA is enabled, this value is read from the factory data. uint8_t sTestEventTriggerEnableKey[TestEventTriggerDelegate::kEnableKeyLength] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }; +#endif K_MSGQ_DEFINE(sAppEventQueue, sizeof(AppEvent), kAppEventQueueSize, alignof(AppEvent)); k_timer sFactoryResetTimer; LEDWidget sStatusLED; +#if USE_RGB_PWM +uint8_t sBrightness; +PWMDevice::Action_t sColorAction = PWMDevice::INVALID_ACTION; +XyColor_t sXY; +HsvColor_t sHSV; +CtColor_t sCT; +#endif Button sFactoryResetButton; Button sLightingButton; @@ -85,29 +125,11 @@ chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; void OnIdentifyTriggerEffect(Identify * identify) { - switch (identify->mCurrentEffectIdentifier) - { - case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK: - ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK"); - break; - case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE: - ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE"); - break; - case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY: - ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY"); - break; - case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE: - ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE"); - break; - default: - ChipLogProgress(Zcl, "No identifier effect"); - break; - } - return; + AppTask::IdentifyEffectHandler(identify->mCurrentEffectIdentifier); } Identify sIdentify = { - chip::EndpointId{ 1 }, + kLightEndpointId, [](Identify *) { ChipLogProgress(Zcl, "OnIdentifyStart"); }, [](Identify *) { ChipLogProgress(Zcl, "OnIdentifyStop"); }, EMBER_ZCL_IDENTIFY_IDENTIFY_TYPE_VISIBLE_LED, @@ -129,14 +151,15 @@ class AppFabricTableDelegate : public FabricTable::Delegate } }; -CHIP_ERROR AppTask::Init() +CHIP_ERROR AppTask::Init(void) { LOG_INF("SW Version: %u, %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION, CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING); - // Initialize status LED - LEDWidget::InitGpio(SYSTEM_STATE_LED_PORT); + // Initialize LEDs + LEDWidget::InitGpio(LEDS_PORT); LEDWidget::SetStateUpdateCallback(LEDStateUpdateHandler); - sStatusLED.Init(SYSTEM_STATE_LED_PIN); + + sStatusLED.Init(SYSTEM_STATE_LED); UpdateStatusLED(); @@ -148,18 +171,42 @@ CHIP_ERROR AppTask::Init() // Init lighting manager uint8_t minLightLevel = kDefaultMinLevel; - Clusters::LevelControl::Attributes::MinLevel::Get(1, &minLightLevel); + Clusters::LevelControl::Attributes::MinLevel::Get(kLightEndpointId, &minLightLevel); uint8_t maxLightLevel = kDefaultMaxLevel; - Clusters::LevelControl::Attributes::MaxLevel::Get(1, &maxLightLevel); + Clusters::LevelControl::Attributes::MaxLevel::Get(kLightEndpointId, &maxLightLevel); - CHIP_ERROR err = LightingMgr().Init(LIGHTING_PWM_DEVICE, LIGHTING_PWM_CHANNEL, minLightLevel, maxLightLevel, maxLightLevel); + // Initialize PWM LEDs + CHIP_ERROR err = sAppTask.mPwmIdentifyLed.Init(&sPwmIdentifySpecGreenLed, kDefaultMinLevel, kDefaultMaxLevel, kDefaultMaxLevel); if (err != CHIP_NO_ERROR) { - LOG_ERR("LightingMgr Init fail"); + LOG_ERR("Green IDENTIFY PWM Device Init fail"); return err; } - LightingMgr().SetCallbacks(ActionInitiated, ActionCompleted); + + err = sAppTask.mPwmRgbBlueLed.Init(&sPwmRgbSpecBlueLed, minLightLevel, maxLightLevel, maxLightLevel); + if (err != CHIP_NO_ERROR) + { + LOG_ERR("Blue RGB PWM Device Init fail"); + return err; + } +#if USE_RGB_PWM + err = sAppTask.mPwmRgbRedLed.Init(&sPwmRgbSpecRedLed, minLightLevel, maxLightLevel, maxLightLevel); + if (err != CHIP_NO_ERROR) + { + LOG_ERR("Red RGB PWM Device Init fail"); + return err; + } + + err = sAppTask.mPwmRgbGreenLed.Init(&sPwmRgbSpecGreenLed, minLightLevel, maxLightLevel, maxLightLevel); + if (err != CHIP_NO_ERROR) + { + LOG_ERR("Green RGB PWM Device Init fail"); + return err; + } +#endif + sAppTask.mPwmRgbBlueLed.SetCallbacks(ActionInitiated, ActionCompleted, nullptr); + sAppTask.mPwmIdentifyLed.SetCallbacks(nullptr, nullptr, ActionIdentifyStateUpdateHandler); // Initialize CHIP server #if CONFIG_CHIP_FACTORY_DATA @@ -217,7 +264,7 @@ CHIP_ERROR AppTask::Init() return CHIP_NO_ERROR; } -CHIP_ERROR AppTask::StartApp() +CHIP_ERROR AppTask::StartApp(void) { CHIP_ERROR err = Init(); @@ -253,26 +300,93 @@ void AppTask::LightingActionButtonEventHandler(void) void AppTask::LightingActionEventHandler(AppEvent * aEvent) { - LightingManager::Action_t action = LightingManager::INVALID_ACTION; - int32_t actor = 0; + PWMDevice::Action_t action = PWMDevice::INVALID_ACTION; + int32_t actor = 0; if (aEvent->Type == AppEvent::kEventType_Lighting) { - action = static_cast(aEvent->LightingEvent.Action); + action = static_cast(aEvent->LightingEvent.Action); actor = aEvent->LightingEvent.Actor; } else if (aEvent->Type == AppEvent::kEventType_Button) { - action = LightingMgr().IsTurnedOn() ? LightingManager::OFF_ACTION : LightingManager::ON_ACTION; - actor = AppEvent::kEventType_Button; +#if USE_RGB_PWM + if (sAppTask.mPwmRgbRedLed.IsTurnedOn() || sAppTask.mPwmRgbGreenLed.IsTurnedOn() || sAppTask.mPwmRgbBlueLed.IsTurnedOn()) + { + action = PWMDevice::OFF_ACTION; + } + else + { + action = PWMDevice::ON_ACTION; + } +#else + action = sAppTask.mPwmRgbBlueLed.IsTurnedOn() ? PWMDevice::OFF_ACTION : PWMDevice::ON_ACTION; +#endif + actor = AppEvent::kEventType_Button; } - if (action != LightingManager::INVALID_ACTION && !LightingMgr().InitiateAction(action, actor, 0, NULL)) + if (action != PWMDevice::INVALID_ACTION && + ( +#if USE_RGB_PWM + !sAppTask.mPwmRgbRedLed.InitiateAction(action, actor, NULL) || + !sAppTask.mPwmRgbGreenLed.InitiateAction(action, actor, NULL) || +#endif + !sAppTask.mPwmRgbBlueLed.InitiateAction(action, actor, NULL))) { LOG_INF("Action is in progress or active"); } } +void AppTask::IdentifyEffectHandler(EmberAfIdentifyEffectIdentifier aEffect) +{ + AppEvent event; + event.Type = AppEvent::kEventType_IdentifyStart; + + switch (aEffect) + { + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK: + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK"); + event.Handler = [](AppEvent *) { + sAppTask.mPwmIdentifyLed.InitiateBlinkAction(kIdentifyBlinkRateMs, kIdentifyBlinkRateMs); + }; + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE: + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE"); + event.Handler = [](AppEvent *) { + sAppTask.mPwmIdentifyLed.InitiateBreatheAction(PWMDevice::kBreatheType_Both, kIdentifyBreatheRateMs); + }; + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY: + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY"); + event.Handler = [](AppEvent *) { + sAppTask.mPwmIdentifyLed.InitiateBlinkAction(kIdentifyOkayOnRateMs, kIdentifyOkayOffRateMs); + }; + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE: + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE"); + event.Handler = [](AppEvent *) { + sAppTask.mPwmIdentifyLed.InitiateBlinkAction(kIdentifyChannelChangeRateMs, kIdentifyChannelChangeRateMs); + }; + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_FINISH_EFFECT: + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_FINISH_EFFECT"); + event.Handler = [](AppEvent *) { + sAppTask.mPwmIdentifyLed.InitiateBlinkAction(kIdentifyFinishOnRateMs, kIdentifyFinishOffRateMs); + }; + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT: + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT"); + event.Handler = [](AppEvent *) { sAppTask.mPwmIdentifyLed.StopAction(); }; + event.Type = AppEvent::kEventType_IdentifyStop; + break; + default: + ChipLogProgress(Zcl, "No identifier effect"); + return; + } + + sAppTask.PostEvent(&event); +} + void AppTask::FactoryResetButtonEventHandler(void) { AppEvent event; @@ -373,7 +487,7 @@ void AppTask::LEDStateUpdateHandler(LEDWidget * ledWidget) sAppTask.PostEvent(&event); } -void AppTask::UpdateStatusLED() +void AppTask::UpdateStatusLED(void) { if (sIsThreadProvisioned && sIsThreadEnabled) { @@ -419,35 +533,48 @@ void AppTask::ChipEventHandler(const ChipDeviceEvent * event, intptr_t /* arg */ } } -void AppTask::ActionInitiated(LightingManager::Action_t aAction, int32_t aActor) +void AppTask::ActionIdentifyStateUpdateHandler(k_timer * timer) +{ + AppEvent event; + event.Type = AppEvent::kEventType_UpdateLedState; + event.Handler = UpdateIdentifyStateEventHandler; + sAppTask.PostEvent(&event); +} + +void AppTask::UpdateIdentifyStateEventHandler(AppEvent * aEvent) { - if (aAction == LightingManager::ON_ACTION) + sAppTask.mPwmIdentifyLed.UpdateAction(); +} + +void AppTask::ActionInitiated(PWMDevice::Action_t aAction, int32_t aActor) +{ + if (aAction == PWMDevice::ON_ACTION) { - LOG_INF("ON_ACTION initiated"); + LOG_DBG("ON_ACTION initiated"); } - else if (aAction == LightingManager::OFF_ACTION) + else if (aAction == PWMDevice::OFF_ACTION) { - LOG_INF("OFF_ACTION initiated"); + LOG_DBG("OFF_ACTION initiated"); } - else if (aAction == LightingManager::LEVEL_ACTION) + else if (aAction == PWMDevice::LEVEL_ACTION) { - LOG_INF("LEVEL_ACTION initiated"); + LOG_DBG("LEVEL_ACTION initiated"); } } -void AppTask::ActionCompleted(LightingManager::Action_t aAction, int32_t aActor) +void AppTask::ActionCompleted(PWMDevice::Action_t aAction, int32_t aActor) { - if (aAction == LightingManager::ON_ACTION) + if (aAction == PWMDevice::ON_ACTION) { - LOG_INF("ON_ACTION completed"); + LOG_DBG("ON_ACTION completed"); } - else if (aAction == LightingManager::OFF_ACTION) + else if (aAction == PWMDevice::OFF_ACTION) { - LOG_INF("OFF_ACTION completed"); + LOG_DBG("OFF_ACTION completed"); } - else if (aAction == LightingManager::LEVEL_ACTION) + else if (aAction == PWMDevice::LEVEL_ACTION) { - LOG_INF("LEVEL_ACTION completed"); + LOG_DBG("LEVEL_ACTION completed"); } if (aActor == AppEvent::kEventType_Button) @@ -456,15 +583,6 @@ void AppTask::ActionCompleted(LightingManager::Action_t aAction, int32_t aActor) } } -void AppTask::PostLightingActionRequest(LightingManager::Action_t aAction) -{ - AppEvent event; - event.Type = AppEvent::kEventType_Lighting; - event.LightingEvent.Action = aAction; - event.Handler = LightingActionEventHandler; - PostEvent(&event); -} - void AppTask::PostEvent(AppEvent * aEvent) { if (k_msgq_put(&sAppEventQueue, aEvent, K_NO_WAIT) != 0) @@ -485,18 +603,37 @@ void AppTask::DispatchEvent(AppEvent * aEvent) } } -void AppTask::UpdateClusterState() +void AppTask::UpdateClusterState(void) { +#if USE_RGB_PWM + bool isTurnedOn = + sAppTask.mPwmRgbRedLed.IsTurnedOn() || sAppTask.mPwmRgbGreenLed.IsTurnedOn() || sAppTask.mPwmRgbBlueLed.IsTurnedOn(); +#else + bool isTurnedOn = sAppTask.mPwmRgbBlueLed.IsTurnedOn(); +#endif // write the new on/off value - EmberAfStatus status = Clusters::OnOff::Attributes::OnOff::Set(1, LightingMgr().IsTurnedOn()); + EmberAfStatus status = Clusters::OnOff::Attributes::OnOff::Set(kLightEndpointId, isTurnedOn); if (status != EMBER_ZCL_STATUS_SUCCESS) { LOG_ERR("Update OnOff fail: %x", status); } - status = Clusters::LevelControl::Attributes::CurrentLevel::Set(1, LightingMgr().GetLevel()); - +#if USE_RGB_PWM + uint8_t setLevel; + if (sColorAction == PWMDevice::COLOR_ACTION_XY || sColorAction == PWMDevice::COLOR_ACTION_HSV || + sColorAction == PWMDevice::COLOR_ACTION_CT) + { + setLevel = sBrightness; + } + else + { + setLevel = sAppTask.mPwmRgbBlueLed.GetLevel(); + } +#else + uint8_t setLevel = sAppTask.mPwmRgbBlueLed.GetLevel(); +#endif + status = Clusters::LevelControl::Attributes::CurrentLevel::Set(kLightEndpointId, setLevel); if (status != EMBER_ZCL_STATUS_SUCCESS) { LOG_ERR("Update CurrentLevel fail: %x", status); @@ -564,3 +701,87 @@ void AppTask::InitButtons(void) ButtonManagerInst().AddButton(sThreadStartButton); ButtonManagerInst().AddButton(sBleAdvStartButton); } + +void AppTask::SetInitiateAction(PWMDevice::Action_t aAction, int32_t aActor, uint8_t * value) +{ +#if USE_RGB_PWM + bool setRgbAction = false; + RgbColor_t rgb; +#endif + + if (aAction == PWMDevice::ON_ACTION || aAction == PWMDevice::OFF_ACTION) + { + sAppTask.mPwmRgbBlueLed.InitiateAction(aAction, aActor, value); +#if USE_RGB_PWM + sAppTask.mPwmRgbRedLed.InitiateAction(aAction, aActor, value); + sAppTask.mPwmRgbGreenLed.InitiateAction(aAction, aActor, value); +#endif + } + else if (aAction == PWMDevice::LEVEL_ACTION) + { +#if USE_RGB_PWM + // Save a new brightness for ColorControl + sBrightness = *value; + + if (sColorAction == PWMDevice::COLOR_ACTION_XY) + { + rgb = XYToRgb(sBrightness, sXY.x, sXY.y); + } + else if (sColorAction == PWMDevice::COLOR_ACTION_HSV) + { + sHSV.v = sBrightness; + rgb = HsvToRgb(sHSV); + } + else + { + rgb.r = sBrightness; + rgb.g = sBrightness; + rgb.b = sBrightness; + } + + ChipLogProgress(Zcl, "New brightness: %u | R: %u, G: %u, B: %u", sBrightness, rgb.r, rgb.g, rgb.b); + setRgbAction = true; +#else + sAppTask.mPwmRgbBlueLed.InitiateAction(aAction, aActor, value); +#endif + } + +#if USE_RGB_PWM + else if (aAction == PWMDevice::COLOR_ACTION_XY) + { + sXY = *reinterpret_cast(value); + rgb = XYToRgb(sBrightness, sXY.x, sXY.y); + ChipLogProgress(Zcl, "XY to RGB: X: %u, Y: %u, Level: %u | R: %u, G: %u, B: %u", sXY.x, sXY.y, sBrightness, rgb.r, rgb.g, + rgb.b); + setRgbAction = true; + sColorAction = PWMDevice::COLOR_ACTION_XY; + } + else if (aAction == PWMDevice::COLOR_ACTION_HSV) + { + sHSV = *reinterpret_cast(value); + sHSV.v = sBrightness; + rgb = HsvToRgb(sHSV); + ChipLogProgress(Zcl, "HSV to RGB: H: %u, S: %u, V: %u | R: %u, G: %u, B: %u", sHSV.h, sHSV.s, sHSV.v, rgb.r, rgb.g, rgb.b); + setRgbAction = true; + sColorAction = PWMDevice::COLOR_ACTION_HSV; + } + else if (aAction == PWMDevice::COLOR_ACTION_CT) + { + sCT = *reinterpret_cast(value); + if (sCT.ctMireds) + { + rgb = CTToRgb(sCT); + ChipLogProgress(Zcl, "ColorTemp to RGB: CT: %u | R: %u, G: %u, B: %u", sCT.ctMireds, rgb.r, rgb.g, rgb.b); + setRgbAction = true; + sColorAction = PWMDevice::COLOR_ACTION_CT; + } + } + + if (setRgbAction) + { + sAppTask.mPwmRgbRedLed.InitiateAction(aAction, aActor, &rgb.r); + sAppTask.mPwmRgbGreenLed.InitiateAction(aAction, aActor, &rgb.g); + sAppTask.mPwmRgbBlueLed.InitiateAction(aAction, aActor, &rgb.b); + } +#endif +} diff --git a/examples/lighting-app/telink/src/LightingManager.cpp b/examples/lighting-app/telink/src/LightingManager.cpp deleted file mode 100644 index 1c0cea74bb5cce..00000000000000 --- a/examples/lighting-app/telink/src/LightingManager.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "LightingManager.h" - -#include "AppConfig.h" - -#include - -#include -#include -#include - -LOG_MODULE_DECLARE(app); - -LightingManager LightingManager::sLight; - -CHIP_ERROR LightingManager::Init(const device * pwmDevice, uint32_t pwmChannel, uint8_t aMinLevel, uint8_t aMaxLevel, - uint8_t aDefaultLevel) -{ - // We use a gpioPin instead of a LEDWidget here because we want to use PWM - // and other features instead of just on/off. - - mState = kState_On; - mMinLevel = aMinLevel; - mMaxLevel = aMaxLevel; - mLevel = aDefaultLevel; - mPwmDevice = pwmDevice; - mPwmChannel = pwmChannel; - - if (!device_is_ready(mPwmDevice)) - { - LOG_ERR("PWM device %s is not ready", mPwmDevice->name); - return CHIP_ERROR_INCORRECT_STATE; - } - - Set(false); - return CHIP_NO_ERROR; -} - -void LightingManager::SetCallbacks(LightingCallback_fn aActionInitiated_CB, LightingCallback_fn aActionCompleted_CB) -{ - mActionInitiated_CB = aActionInitiated_CB; - mActionCompleted_CB = aActionCompleted_CB; -} - -bool LightingManager::InitiateAction(Action_t aAction, int32_t aActor, uint8_t size, uint8_t * value) -{ - bool action_initiated = false; - State_t new_state; - - // Initiate On/Off Action only when the previous one is complete. - if (mState == kState_Off && aAction == ON_ACTION) - { - action_initiated = true; - new_state = kState_On; - } - else if (mState == kState_On && aAction == OFF_ACTION) - { - action_initiated = true; - new_state = kState_Off; - } - else if (aAction == LEVEL_ACTION && *value != mLevel) - { - action_initiated = true; - if (*value == 0) - { - new_state = kState_Off; - } - else - { - new_state = kState_On; - } - } - - if (action_initiated) - { - if (mActionInitiated_CB) - { - mActionInitiated_CB(aAction, aActor); - } - - if (aAction == ON_ACTION || aAction == OFF_ACTION) - { - Set(new_state == kState_On); - } - else if (aAction == LEVEL_ACTION) - { - SetLevel(*value); - } - - if (mActionCompleted_CB) - { - mActionCompleted_CB(aAction, aActor); - } - } - - return action_initiated; -} - -void LightingManager::SetLevel(uint8_t aLevel) -{ - LOG_INF("Setting brightness level to %u", aLevel); - mLevel = aLevel; - UpdateLight(); -} - -void LightingManager::Set(bool aOn) -{ - mState = aOn ? kState_On : kState_Off; - UpdateLight(); -} - -void LightingManager::UpdateLight() -{ - constexpr uint32_t kPwmWidthUs = 20000u; - const uint8_t maxEffectiveLevel = mMaxLevel - mMinLevel; - const uint8_t effectiveLevel = mState == kState_On ? chip::min(mLevel - mMinLevel, maxEffectiveLevel) : 0; - - pwm_set(mPwmDevice, mPwmChannel, PWM_USEC(kPwmWidthUs), PWM_USEC(kPwmWidthUs * effectiveLevel / maxEffectiveLevel), 0); -} diff --git a/examples/lighting-app/telink/src/ZclCallbacks.cpp b/examples/lighting-app/telink/src/ZclCallbacks.cpp index 83a5d7a0a67ba9..f25ae759db8150 100644 --- a/examples/lighting-app/telink/src/ZclCallbacks.cpp +++ b/examples/lighting-app/telink/src/ZclCallbacks.cpp @@ -17,7 +17,8 @@ */ #include "AppTask.h" -#include "LightingManager.h" +#include "ColorFormat.h" +#include "PWMDevice.h" #include #include @@ -25,6 +26,8 @@ #include #include +LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL); + using namespace chip; using namespace chip::app::Clusters; using namespace chip::app::Clusters::OnOff; @@ -32,28 +35,88 @@ using namespace chip::app::Clusters::OnOff; void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size, uint8_t * value) { + static HsvColor_t hsv; + static XyColor_t xy; ClusterId clusterId = attributePath.mClusterId; AttributeId attributeId = attributePath.mAttributeId; if (clusterId == OnOff::Id && attributeId == OnOff::Attributes::OnOff::Id) { - ChipLogProgress(Zcl, "Cluster OnOff: attribute OnOff set to %u", *value); - LightingMgr().InitiateAction(*value ? LightingManager::ON_ACTION : LightingManager::OFF_ACTION, - AppEvent::kEventType_Lighting, size, value); + ChipLogDetail(Zcl, "Cluster OnOff: attribute OnOff set to %u", *value); + GetAppTask().SetInitiateAction(*value ? PWMDevice::ON_ACTION : PWMDevice::OFF_ACTION, + static_cast(AppEvent::kEventType_Lighting), value); } else if (clusterId == LevelControl::Id && attributeId == LevelControl::Attributes::CurrentLevel::Id) { - ChipLogProgress(Zcl, "Cluster LevelControl: attribute CurrentLevel set to %u", *value); - - if (LightingMgr().IsTurnedOn()) + if (GetAppTask().GetPWMDevice().IsTurnedOn()) { - LightingMgr().InitiateAction(LightingManager::LEVEL_ACTION, AppEvent::kEventType_Lighting, size, value); + ChipLogDetail(Zcl, "Cluster LevelControl: attribute CurrentLevel set to %u", *value); + GetAppTask().SetInitiateAction(PWMDevice::LEVEL_ACTION, static_cast(AppEvent::kEventType_Lighting), value); } else { ChipLogDetail(Zcl, "LED is off. Try to use move-to-level-with-on-off instead of move-to-level"); } } + else if (clusterId == ColorControl::Id) + { + /* Ignore several attributes that are currently not processed */ + if ((attributeId == ColorControl::Attributes::RemainingTime::Id) || + (attributeId == ColorControl::Attributes::EnhancedColorMode::Id) || + (attributeId == ColorControl::Attributes::ColorMode::Id)) + { + return; + } + + /* XY color space */ + if (attributeId == ColorControl::Attributes::CurrentX::Id || attributeId == ColorControl::Attributes::CurrentY::Id) + { + if (attributeId == ColorControl::Attributes::CurrentX::Id) + { + xy.x = *reinterpret_cast(value); + } + else if (attributeId == ColorControl::Attributes::CurrentY::Id) + { + xy.y = *reinterpret_cast(value); + } + + ChipLogDetail(Zcl, "New XY color: %u|%u", xy.x, xy.y); + GetAppTask().SetInitiateAction(PWMDevice::COLOR_ACTION_XY, static_cast(AppEvent::kEventType_Lighting), + (uint8_t *) &xy); + } + /* HSV color space */ + else if (attributeId == ColorControl::Attributes::CurrentHue::Id || + attributeId == ColorControl::Attributes::CurrentSaturation::Id || + attributeId == ColorControl::Attributes::EnhancedCurrentHue::Id) + { + if (attributeId == ColorControl::Attributes::EnhancedCurrentHue::Id) + { + hsv.h = (uint8_t)(((*reinterpret_cast(value)) & 0xFF00) >> 8); + hsv.s = (uint8_t)((*reinterpret_cast(value)) & 0xFF); + } + else if (attributeId == ColorControl::Attributes::CurrentHue::Id) + { + hsv.h = *value; + } + else if (attributeId == ColorControl::Attributes::CurrentSaturation::Id) + { + hsv.s = *value; + } + ChipLogDetail(Zcl, "New HSV color: hue = %u| saturation = %u", hsv.h, hsv.s); + GetAppTask().SetInitiateAction(PWMDevice::COLOR_ACTION_HSV, static_cast(AppEvent::kEventType_Lighting), + (uint8_t *) &hsv); + } + /* Temperature Mireds color space */ + else if (attributeId == ColorControl::Attributes::ColorTemperatureMireds::Id) + { + ChipLogDetail(Zcl, "New Temperature Mireds color = %u", *(uint16_t *) value); + GetAppTask().SetInitiateAction(PWMDevice::COLOR_ACTION_CT, static_cast(AppEvent::kEventType_Lighting), value); + } + else + { + ChipLogDetail(Zcl, "Ignore ColorControl attribute (%u) that is not currently processed!", attributeId); + } + } } /** @brief OnOff Cluster Init @@ -75,7 +138,7 @@ void emberAfOnOffClusterInitCallback(EndpointId endpoint) if (status == EMBER_ZCL_STATUS_SUCCESS) { // Set actual state to stored before reboot - LightingMgr().Set(storedValue); + GetAppTask().GetPWMDevice().Set(storedValue); } GetAppTask().UpdateClusterState(); diff --git a/examples/lighting-app/telink/src/main.cpp b/examples/lighting-app/telink/src/main.cpp index 2e30e3cc52b6f9..ca6d59cbc9eae8 100644 --- a/examples/lighting-app/telink/src/main.cpp +++ b/examples/lighting-app/telink/src/main.cpp @@ -27,7 +27,7 @@ #include "Rpc.h" #endif -LOG_MODULE_REGISTER(app); +LOG_MODULE_REGISTER(app, CONFIG_CHIP_APP_LOG_LEVEL); using namespace ::chip; using namespace ::chip::Inet; diff --git a/examples/lock-app/cc32xx/main/AppTask.cpp b/examples/lock-app/cc32xx/main/AppTask.cpp index cff1e73bf8d0cf..a556fee7514f3d 100644 --- a/examples/lock-app/cc32xx/main/AppTask.cpp +++ b/examples/lock-app/cc32xx/main/AppTask.cpp @@ -20,7 +20,7 @@ #include "AppTask.h" #include "AppConfig.h" #include "AppEvent.h" -#include +#include #include #include #include @@ -263,7 +263,7 @@ void AppTask::ActionCompleted(BoltLockManager::Action_t aAction) LED_setOff(gLedRedHandle); state = 0; } - emberAfWriteAttribute(1, app::Clusters::OnOff::Id, ZCL_ON_OFF_ATTRIBUTE_ID, &state, ZCL_BOOLEAN_ATTRIBUTE_TYPE); + app::Clusters::OnOff::Attributes::OnOff::Set(1, state); } void AppTask::DispatchEvent(AppEvent * aEvent) diff --git a/examples/lock-app/esp32/main/AppTask.cpp b/examples/lock-app/esp32/main/AppTask.cpp index c7ebacf0f334f5..a9fc2c35cdbd86 100644 --- a/examples/lock-app/esp32/main/AppTask.cpp +++ b/examples/lock-app/esp32/main/AppTask.cpp @@ -16,19 +16,18 @@ */ #include "AppTask.h" -#include "AppConfig.h" -#include "AppEvent.h" #include "Button.h" #include "LEDWidget.h" #include "esp_log.h" -#include -#include +#include #include #include #include #include #include #include +#include +#include #include #include @@ -60,6 +59,7 @@ StackType_t appStack[APP_TASK_STACK_SIZE / sizeof(StackType_t)]; using namespace ::chip::DeviceLayer; using namespace ::chip::System; +// using namespace ESP32DoorLock::LockInitParams; AppTask AppTask::sAppTask; @@ -79,19 +79,14 @@ CHIP_ERROR AppTask::StartAppTask() CHIP_ERROR AppTask::Init() { - // Create FreeRTOS sw timer for Function Selection. + // Create FreeRTOS sw timer for Function Selection sFunctionTimer = xTimerCreate("FnTmr", // Just a text name, not used by the RTOS kernel 1, // == default timer period (mS) false, // no timer reload (==one-shot) (void *) this, // init timer id = app task obj context TimerEventHandler // timer callback handler ); - CHIP_ERROR err = BoltLockMgr().Init(); - if (err != CHIP_NO_ERROR) - { - ESP_LOGI(TAG, "BoltLockMgr().Init() failed"); - return err; - } + CHIP_ERROR err = BoltLockMgr().InitLockState(); BoltLockMgr().SetCallbacks(ActionInitiated, ActionCompleted); @@ -201,12 +196,12 @@ void AppTask::LockActionEventHandler(AppEvent * aEvent) int32_t actor; CHIP_ERROR err = CHIP_NO_ERROR; - if (aEvent->Type == AppEvent::kEventType_Lock) + if (aEvent->mType == AppEvent::kEventType_Lock) { - action = static_cast(aEvent->LockEvent.Action); - actor = aEvent->LockEvent.Actor; + action = static_cast(aEvent->mLockEvent.mAction); + actor = aEvent->mLockEvent.mActor; } - else if (aEvent->Type == AppEvent::kEventType_Button) + else if (aEvent->mType == AppEvent::kEventType_Button) { if (BoltLockMgr().IsUnlocked()) { @@ -241,19 +236,19 @@ void AppTask::ButtonEventHandler(uint8_t btnIdx, uint8_t btnAction) return; } - AppEvent button_event = {}; - button_event.Type = AppEvent::kEventType_Button; - button_event.ButtonEvent.PinNo = btnIdx; - button_event.ButtonEvent.Action = btnAction; + AppEvent button_event = {}; + button_event.mType = AppEvent::kEventType_Button; + button_event.mButtonEvent.mPinNo = btnIdx; + button_event.mButtonEvent.mAction = btnAction; if (btnIdx == APP_LOCK_BUTTON && btnAction == APP_BUTTON_PRESSED) { - button_event.Handler = LockActionEventHandler; + button_event.mHandler = LockActionEventHandler; sAppTask.PostEvent(&button_event); } else if (btnIdx == APP_FUNCTION_BUTTON) { - button_event.Handler = FunctionHandler; + button_event.mHandler = FunctionHandler; sAppTask.PostEvent(&button_event); } } @@ -261,15 +256,15 @@ void AppTask::ButtonEventHandler(uint8_t btnIdx, uint8_t btnAction) void AppTask::TimerEventHandler(TimerHandle_t xTimer) { AppEvent event; - event.Type = AppEvent::kEventType_Timer; - event.TimerEvent.Context = (void *) xTimer; - event.Handler = FunctionTimerEventHandler; + event.mType = AppEvent::kEventType_Timer; + event.mTimerEvent.mContext = (void *) xTimer; + event.mHandler = FunctionTimerEventHandler; sAppTask.PostEvent(&event); } void AppTask::FunctionTimerEventHandler(AppEvent * aEvent) { - if (aEvent->Type != AppEvent::kEventType_Timer) + if (aEvent->mType != AppEvent::kEventType_Timer) { return; } @@ -304,7 +299,7 @@ void AppTask::FunctionTimerEventHandler(AppEvent * aEvent) void AppTask::FunctionHandler(AppEvent * aEvent) { - if (aEvent->ButtonEvent.PinNo != APP_FUNCTION_BUTTON) + if (aEvent->mButtonEvent.mPinNo != APP_FUNCTION_BUTTON) { return; } @@ -316,7 +311,7 @@ void AppTask::FunctionHandler(AppEvent * aEvent) // FACTORY_RESET_TRIGGER_TIMEOUT to signal factory reset has been initiated. // To cancel factory reset: release the APP_FUNCTION_BUTTON once all LEDs // start blinking within the FACTORY_RESET_CANCEL_WINDOW_TIMEOUT - if (aEvent->ButtonEvent.Action == APP_BUTTON_PRESSED) + if (aEvent->mButtonEvent.mAction == APP_BUTTON_PRESSED) { if (!sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_NoneSelected) { @@ -431,10 +426,10 @@ void AppTask::ActionCompleted(BoltLockManager::Action_t aAction) void AppTask::PostLockActionRequest(int32_t aActor, BoltLockManager::Action_t aAction) { AppEvent event; - event.Type = AppEvent::kEventType_Lock; - event.LockEvent.Actor = aActor; - event.LockEvent.Action = aAction; - event.Handler = LockActionEventHandler; + event.mType = AppEvent::kEventType_Lock; + event.mLockEvent.mActor = aActor; + event.mLockEvent.mAction = aAction; + event.mHandler = LockActionEventHandler; PostEvent(&event); } @@ -451,9 +446,9 @@ void AppTask::PostEvent(const AppEvent * aEvent) void AppTask::DispatchEvent(AppEvent * aEvent) { - if (aEvent->Handler) + if (aEvent->mHandler) { - aEvent->Handler(aEvent); + aEvent->mHandler(aEvent); } else { @@ -467,8 +462,7 @@ void AppTask::UpdateClusterState(chip::System::Layer *, void * context) uint8_t newValue = !BoltLockMgr().IsUnlocked(); // write the new on/off value - EmberAfStatus status = emberAfWriteAttribute(1, chip::app::Clusters::OnOff::Id, ZCL_ON_OFF_ATTRIBUTE_ID, (uint8_t *) &newValue, - ZCL_BOOLEAN_ATTRIBUTE_TYPE); + EmberAfStatus status = chip::app::Clusters::OnOff::Attributes::OnOff::Set(1, newValue); if (status != EMBER_ZCL_STATUS_SUCCESS) { ESP_LOGI(TAG, "ERR: updating on/off %x", status); diff --git a/examples/lock-app/esp32/main/BoltLockManager.cpp b/examples/lock-app/esp32/main/BoltLockManager.cpp deleted file mode 100644 index d6cb59aaf54a3e..00000000000000 --- a/examples/lock-app/esp32/main/BoltLockManager.cpp +++ /dev/null @@ -1,217 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "BoltLockManager.h" - -#include "AppConfig.h" -#include "AppTask.h" -#include "esp_log.h" -#include -static const char * TAG = "BoltLockManager"; -BoltLockManager BoltLockManager::sLock; - -TimerHandle_t sLockTimer; - -CHIP_ERROR BoltLockManager::Init() -{ - // Create FreeRTOS sw timer for lock timer. - sLockTimer = xTimerCreate("lockTmr", // Just a text name, not used by the RTOS kernel - 1, // == default timer period (mS) - false, // no timer reload (==one-shot) - (void *) this, // init timer id = lock obj context - TimerEventHandler // timer callback handler - ); - - if (sLockTimer == NULL) - { - ESP_LOGE(TAG, "sLockTimer timer create failed"); - return APP_ERROR_CREATE_TIMER_FAILED; - } - - mState = kState_LockingCompleted; - mAutoLockTimerArmed = false; - mAutoRelock = false; - mAutoLockDuration = 0; - - return CHIP_NO_ERROR; -} - -void BoltLockManager::SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Callback_fn_completed aActionCompleted_CB) -{ - mActionInitiated_CB = aActionInitiated_CB; - mActionCompleted_CB = aActionCompleted_CB; -} - -bool BoltLockManager::IsActionInProgress() -{ - return (mState == kState_LockingInitiated || mState == kState_UnlockingInitiated); -} - -bool BoltLockManager::IsUnlocked() -{ - return (mState == kState_UnlockingCompleted); -} - -void BoltLockManager::SetAutoLockDuration(uint32_t aDurationInSecs) -{ - mAutoLockDuration = aDurationInSecs; -} - -bool BoltLockManager::InitiateAction(int32_t aActor, Action_t aAction) -{ - bool action_initiated = false; - State_t new_state; - // Initiate Lock/Unlock Action only when the previous one is complete. - if (mState == kState_LockingCompleted && aAction == UNLOCK_ACTION) - { - action_initiated = true; - - new_state = kState_UnlockingInitiated; - } - else if (mState == kState_UnlockingCompleted && aAction == LOCK_ACTION) - { - action_initiated = true; - - new_state = kState_LockingInitiated; - } - - if (action_initiated) - { - if (mAutoLockTimerArmed && new_state == kState_LockingInitiated) - { - // If auto lock timer has been armed and someone initiates locking, - // cancel the timer and continue as normal. - mAutoLockTimerArmed = false; - - CancelTimer(); - } - - StartTimer(ACTUATOR_MOVEMENT_PERIOS_MS); - - // Since the timer started successfully, update the state and trigger callback - mState = new_state; - - if (mActionInitiated_CB) - { - mActionInitiated_CB(aAction, aActor); - } - } - - return action_initiated; -} - -void BoltLockManager::StartTimer(uint32_t aTimeoutMs) -{ - if (xTimerIsTimerActive(sLockTimer)) - { - ESP_LOGI(TAG, "app timer already started!"); - CancelTimer(); - } - - // timer is not active, change its period to required value (== restart). - // FreeRTOS- Block for a maximum of 100 ticks if the change period command - // cannot immediately be sent to the timer command queue. - if (xTimerChangePeriod(sLockTimer, (aTimeoutMs / portTICK_PERIOD_MS), 100) != pdPASS) - { - ESP_LOGI(TAG, "sLockTimer timer start() failed"); - return; - } -} - -void BoltLockManager::CancelTimer(void) -{ - if (xTimerStop(sLockTimer, 0) == pdFAIL) - { - ESP_LOGI(TAG, "Lock timer timer stop() failed"); - return; - } -} -void BoltLockManager::TimerEventHandler(TimerHandle_t xTimer) -{ - // Get lock obj context from timer id. - BoltLockManager * lock = static_cast(pvTimerGetTimerID(xTimer)); - - // The timer event handler will be called in the context of the timer task - // once sLockTimer expires. Post an event to apptask queue with the actual handler - // so that the event can be handled in the context of the apptask. - AppEvent event; - event.Type = AppEvent::kEventType_Timer; - event.TimerEvent.Context = lock; - if (lock->mAutoLockTimerArmed) - { - event.Handler = AutoReLockTimerEventHandler; - } - else - { - event.Handler = ActuatorMovementTimerEventHandler; - } - GetAppTask().PostEvent(&event); -} - -void BoltLockManager::AutoReLockTimerEventHandler(AppEvent * aEvent) -{ - BoltLockManager * lock = static_cast(aEvent->TimerEvent.Context); - int32_t actor = 0; - - // Make sure auto lock timer is still armed. - if (!lock->mAutoLockTimerArmed) - { - return; - } - - lock->mAutoLockTimerArmed = false; - - ESP_LOGI(TAG, "Auto Re-Lock has been triggered!"); - - lock->InitiateAction(actor, LOCK_ACTION); -} - -void BoltLockManager::ActuatorMovementTimerEventHandler(AppEvent * aEvent) -{ - Action_t actionCompleted = INVALID_ACTION; - - BoltLockManager * lock = static_cast(aEvent->TimerEvent.Context); - - if (lock->mState == kState_LockingInitiated) - { - lock->mState = kState_LockingCompleted; - actionCompleted = LOCK_ACTION; - } - else if (lock->mState == kState_UnlockingInitiated) - { - lock->mState = kState_UnlockingCompleted; - actionCompleted = UNLOCK_ACTION; - } - - if (actionCompleted != INVALID_ACTION) - { - if (lock->mActionCompleted_CB) - { - lock->mActionCompleted_CB(actionCompleted); - } - - if (lock->mAutoRelock && actionCompleted == UNLOCK_ACTION) - { - // Start the timer for auto relock - lock->StartTimer(lock->mAutoLockDuration * 1000); - - lock->mAutoLockTimerArmed = true; - - ESP_LOGI(TAG, "Auto Re-lock enabled. Will be triggered in %u seconds", lock->mAutoLockDuration); - } - } -} diff --git a/examples/lock-app/esp32/main/Button.cpp b/examples/lock-app/esp32/main/Button.cpp index 698888440ecb65..301e62f92d7e08 100644 --- a/examples/lock-app/esp32/main/Button.cpp +++ b/examples/lock-app/esp32/main/Button.cpp @@ -18,7 +18,7 @@ #include "Button.h" #include "AppTask.h" -#include "AppConfig.h" +//#include esp_err_t Button::Init(gpio_num_t gpioNum, uint16_t debouncePeriod) { diff --git a/examples/lock-app/esp32/main/CMakeLists.txt b/examples/lock-app/esp32/main/CMakeLists.txt index 8dd4bc1dc0a774..e15ee62a79f53b 100644 --- a/examples/lock-app/esp32/main/CMakeLists.txt +++ b/examples/lock-app/esp32/main/CMakeLists.txt @@ -23,6 +23,7 @@ idf_component_register(INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/pw_sys_io/public" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/lock" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/providers" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/pigweed" @@ -40,7 +41,6 @@ idf_component_register(INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/common/pigweed/esp32" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated/attributes" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/lock-app/zap-generated" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/reporting" @@ -151,7 +151,6 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated/attributes" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/lock-app/zap-generated" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/providers" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/shell_extension" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/common" @@ -185,6 +184,7 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/door-lock-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/identify-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/groups-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/lock" PRIV_REQUIRES chip QRCode bt) add_dependencies(${COMPONENT_LIB} app-codegen) diff --git a/examples/lock-app/esp32/main/DeviceCallbacks.cpp b/examples/lock-app/esp32/main/DeviceCallbacks.cpp index 7a073be32e1e53..ba738c7acab4d1 100644 --- a/examples/lock-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/lock-app/esp32/main/DeviceCallbacks.cpp @@ -24,10 +24,9 @@ **/ #include "DeviceCallbacks.h" -#include "AppConfig.h" -#include "BoltLockManager.h" +#include +#include -#include #include static const char * TAG = "lock-devicecallbacks"; @@ -59,7 +58,8 @@ void AppDeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Clus void AppDeviceCallbacks::OnOnOffPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { - VerifyOrExit(attributeId == ZCL_ON_OFF_ATTRIBUTE_ID, ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04x", attributeId)); + VerifyOrExit(attributeId == app::Clusters::OnOff::Attributes::OnOff::Id, + ESP_LOGI(TAG, "Unhandled Attribute ID: '0x%04x", attributeId)); VerifyOrExit(endpointId == 1 || endpointId == 2, ESP_LOGE(TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); if (*value) { diff --git a/examples/lock-app/esp32/main/include/AppEvent.h b/examples/lock-app/esp32/main/include/AppEvent.h deleted file mode 100644 index 783d29ca6feb5d..00000000000000 --- a/examples/lock-app/esp32/main/include/AppEvent.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -struct AppEvent; -typedef void (*EventHandler)(AppEvent *); - -struct AppEvent -{ - enum AppEventTypes - { - kEventType_Button = 0, - kEventType_Timer, - kEventType_Lock, - kEventType_Install, - }; - - uint16_t Type; - - union - { - struct - { - uint8_t PinNo; - uint8_t Action; - } ButtonEvent; - struct - { - void * Context; - } TimerEvent; - struct - { - uint8_t Action; - int32_t Actor; - } LockEvent; - }; - - EventHandler Handler; -}; diff --git a/examples/lock-app/esp32/main/include/AppTask.h b/examples/lock-app/esp32/main/include/AppTask.h index ba7121b1554495..7a1aad3e221800 100644 --- a/examples/lock-app/esp32/main/include/AppTask.h +++ b/examples/lock-app/esp32/main/include/AppTask.h @@ -20,8 +20,8 @@ #include #include -#include "AppEvent.h" -#include "BoltLockManager.h" +#include +#include #include "freertos/FreeRTOS.h" #include @@ -35,6 +35,7 @@ #define APP_ERROR_CREATE_TIMER_FAILED CHIP_APPLICATION_ERROR(0x04) #define APP_ERROR_START_TIMER_FAILED CHIP_APPLICATION_ERROR(0x05) #define APP_ERROR_STOP_TIMER_FAILED CHIP_APPLICATION_ERROR(0x06) +#define APP_ERROR_ALLOCATION_FAILED CHIP_APPLICATION_ERROR(0x07) class AppTask { diff --git a/examples/lock-app/esp32/main/include/BoltLockManager.h b/examples/lock-app/esp32/main/include/BoltLockManager.h deleted file mode 100644 index 654da89ece435b..00000000000000 --- a/examples/lock-app/esp32/main/include/BoltLockManager.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef LOCK_MANAGER_H -#define LOCK_MANAGER_H - -#include -#include - -#include "AppEvent.h" - -#include - -#include "freertos/FreeRTOS.h" -#include "freertos/timers.h" // provides FreeRTOS timer support - -class BoltLockManager -{ -public: - enum Action_t - { - LOCK_ACTION = 0, - UNLOCK_ACTION, - - INVALID_ACTION - } Action; - - enum State_t - { - kState_LockingInitiated = 0, - kState_LockingCompleted, - kState_UnlockingInitiated, - kState_UnlockingCompleted, - } State; - - CHIP_ERROR Init(); - bool IsUnlocked(); - void EnableAutoRelock(bool aOn); - void SetAutoLockDuration(uint32_t aDurationInSecs); - bool IsActionInProgress(); - bool InitiateAction(int32_t aActor, Action_t aAction); - - typedef void (*Callback_fn_initiated)(Action_t, int32_t aActor); - typedef void (*Callback_fn_completed)(Action_t); - void SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Callback_fn_completed aActionCompleted_CB); - -private: - friend BoltLockManager & BoltLockMgr(void); - State_t mState; - - Callback_fn_initiated mActionInitiated_CB; - Callback_fn_completed mActionCompleted_CB; - - bool mAutoRelock; - uint32_t mAutoLockDuration; - bool mAutoLockTimerArmed; - - void CancelTimer(void); - void StartTimer(uint32_t aTimeoutMs); - - static void TimerEventHandler(TimerHandle_t xTimer); - static void AutoReLockTimerEventHandler(AppEvent * aEvent); - static void ActuatorMovementTimerEventHandler(AppEvent * aEvent); - - static BoltLockManager sLock; -}; - -inline BoltLockManager & BoltLockMgr(void) -{ - return BoltLockManager::sLock; -} - -#endif // LOCK_MANAGER_H diff --git a/examples/lock-app/esp32/main/include/Button.h b/examples/lock-app/esp32/main/include/Button.h index 53ae87884b2865..fc838f806a1061 100644 --- a/examples/lock-app/esp32/main/include/Button.h +++ b/examples/lock-app/esp32/main/include/Button.h @@ -17,11 +17,10 @@ #pragma once -#include - -#include "AppConfig.h" #include "AppTask.h" +#include "driver/gpio.h" #include "freertos/FreeRTOS.h" +#include class Button { diff --git a/examples/lock-app/genio/include/LockManager.h b/examples/lock-app/genio/include/LockManager.h old mode 100755 new mode 100644 index 084b77a029884d..6361706e11a5e8 --- a/examples/lock-app/genio/include/LockManager.h +++ b/examples/lock-app/genio/include/LockManager.h @@ -146,25 +146,26 @@ class LockManager typedef void (*Callback_fn_completed)(Action_t); void SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Callback_fn_completed aActionCompleted_CB); - bool Lock(chip::EndpointId endpointId, const Optional & pin, DlOperationError & err); - bool Unlock(chip::EndpointId endpointId, const Optional & pin, DlOperationError & err); + bool Lock(chip::EndpointId endpointId, const Optional & pin, OperationErrorEnum & err); + bool Unlock(chip::EndpointId endpointId, const Optional & pin, OperationErrorEnum & err); bool GetUser(chip::EndpointId endpointId, uint16_t userIndex, EmberAfPluginDoorLockUserInfo & user); bool SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - const chip::CharSpan & userName, uint32_t uniqueId, DlUserStatus userStatus, DlUserType usertype, - DlCredentialRule credentialRule, const DlCredential * credentials, size_t totalCredentials); + const chip::CharSpan & userName, uint32_t uniqueId, UserStatusEnum userStatus, UserTypeEnum usertype, + CredentialRuleEnum credentialRule, const CredentialStruct * credentials, size_t totalCredentials); - bool GetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, DlCredentialType credentialType, + bool GetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, CredentialTypeEnum credentialType, EmberAfPluginDoorLockCredentialInfo & credential); bool SetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - DlCredentialStatus credentialStatus, DlCredentialType credentialType, const chip::ByteSpan & credentialData); + DlCredentialStatus credentialStatus, CredentialTypeEnum credentialType, + const chip::ByteSpan & credentialData); DlStatus GetWeekdaySchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex, EmberAfPluginDoorLockWeekDaySchedule & schedule); DlStatus SetWeekdaySchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex, DlScheduleStatus status, - DlDaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute); + DaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute); DlStatus GetYeardaySchedule(chip::EndpointId endpointId, uint8_t yearDayIndex, uint16_t userIndex, EmberAfPluginDoorLockYearDaySchedule & schedule); @@ -175,16 +176,16 @@ class LockManager DlStatus GetHolidaySchedule(chip::EndpointId endpointId, uint8_t holidayIndex, EmberAfPluginDoorLockHolidaySchedule & schedule); DlStatus SetHolidaySchedule(chip::EndpointId endpointId, uint8_t holidayIndex, DlScheduleStatus status, uint32_t localStartTime, - uint32_t localEndTime, DlOperatingMode operatingMode); + uint32_t localEndTime, OperatingModeEnum operatingMode); bool IsValidUserIndex(uint16_t userIndex); - bool IsValidCredentialIndex(uint16_t credentialIndex, DlCredentialType type); + bool IsValidCredentialIndex(uint16_t credentialIndex, CredentialTypeEnum type); bool IsValidWeekdayScheduleIndex(uint8_t scheduleIndex); bool IsValidYeardayScheduleIndex(uint8_t scheduleIndex); bool IsValidHolidayScheduleIndex(uint8_t scheduleIndex); bool setLockState(chip::EndpointId endpointId, DlLockState lockState, const Optional & pin, - DlOperationError & err); + OperationErrorEnum & err); const char * lockStateToString(DlLockState lockState) const; bool ReadConfigValues(); @@ -212,7 +213,7 @@ class LockManager char mUserNames[ArraySize(mLockUsers)][DOOR_LOCK_MAX_USER_NAME_SIZE]; uint8_t mCredentialData[kMaxCredentials][kMaxCredentialSize]; - DlCredential mCredentials[kMaxUsers][kMaxCredentialsPerUser]; + CredentialStruct mCredentials[kMaxUsers][kMaxCredentialsPerUser]; static LockManager sLock; MT793XDoorLock::LockInitParams::LockParam LockParams; diff --git a/examples/lock-app/genio/src/AppTask.cpp b/examples/lock-app/genio/src/AppTask.cpp index 05455f579ad1d3..2b1db547997bc9 100644 --- a/examples/lock-app/genio/src/AppTask.cpp +++ b/examples/lock-app/genio/src/AppTask.cpp @@ -24,8 +24,6 @@ #include "qrcodegen.h" #include -#include -#include #include #include #include @@ -96,8 +94,8 @@ chip::app::Clusters::NetworkCommissioning::Instance sWiFiNetworkCommissioningIns } // namespace using chip::app::Clusters::DoorLock::DlLockState; -using chip::app::Clusters::DoorLock::DlOperationError; -using chip::app::Clusters::DoorLock::DlOperationSource; +using chip::app::Clusters::DoorLock::OperationErrorEnum; +using chip::app::Clusters::DoorLock::OperationSourceEnum; using namespace chip; using namespace ::chip::DeviceLayer; @@ -596,7 +594,7 @@ void AppTask::UpdateClusterState(intptr_t context) bool unlocked = LockMgr().NextState(); DlLockState newState = unlocked ? DlLockState::kUnlocked : DlLockState::kLocked; - DlOperationSource source = DlOperationSource::kUnspecified; + OperationSourceEnum source = OperationSourceEnum::kUnspecified; // write the new lock value EmberAfStatus status = diff --git a/examples/lock-app/genio/src/LockManager.cpp b/examples/lock-app/genio/src/LockManager.cpp index 9ae7e4288695ea..66e394bd00c744 100644 --- a/examples/lock-app/genio/src/LockManager.cpp +++ b/examples/lock-app/genio/src/LockManager.cpp @@ -104,9 +104,9 @@ bool LockManager::IsValidUserIndex(uint16_t userIndex) return (userIndex < kMaxUsers); } -bool LockManager::IsValidCredentialIndex(uint16_t credentialIndex, DlCredentialType type) +bool LockManager::IsValidCredentialIndex(uint16_t credentialIndex, CredentialTypeEnum type) { - if (DlCredentialType::kProgrammingPIN == type) + if (CredentialTypeEnum::kProgrammingPIN == type) { return (0 == credentialIndex); // 0 is required index for Programming PIN } @@ -144,7 +144,7 @@ bool LockManager::ReadConfigValues() sizeof(mCredentialData), outLen); MT793XConfig::ReadConfigValueBin(MT793XConfig::kConfigKey_UserCredentials, reinterpret_cast(mCredentials), - sizeof(DlCredential) * LockParams.numberOfUsers * LockParams.numberOfCredentialsPerUser, + sizeof(CredentialStruct) * LockParams.numberOfUsers * LockParams.numberOfCredentialsPerUser, outLen); MT793XConfig::ReadConfigValueBin(MT793XConfig::kConfigKey_WeekDaySchedules, reinterpret_cast(mWeekdaySchedule), @@ -283,12 +283,12 @@ void LockManager::ActuatorMovementTimerEventHandler(AppEvent * aEvent) } } -bool LockManager::Lock(chip::EndpointId endpointId, const Optional & pin, DlOperationError & err) +bool LockManager::Lock(chip::EndpointId endpointId, const Optional & pin, OperationErrorEnum & err) { return setLockState(endpointId, DlLockState::kLocked, pin, err); } -bool LockManager::Unlock(chip::EndpointId endpointId, const Optional & pin, DlOperationError & err) +bool LockManager::Unlock(chip::EndpointId endpointId, const Optional & pin, OperationErrorEnum & err) { return setLockState(endpointId, DlLockState::kUnlocked, pin, err); } @@ -306,14 +306,14 @@ bool LockManager::GetUser(chip::EndpointId endpointId, uint16_t userIndex, Ember const auto & userInDb = mLockUsers[userIndex]; user.userStatus = userInDb.userStatus; - if (DlUserStatus::kAvailable == user.userStatus) + if (UserStatusEnum::kAvailable == user.userStatus) { ChipLogDetail(Zcl, "Found unoccupied user [endpoint=%d]", endpointId); return true; } user.userName = chip::CharSpan(userInDb.userName.data(), userInDb.userName.size()); - user.credentials = chip::Span(mCredentials[userIndex], userInDb.credentials.size()); + user.credentials = chip::Span(mCredentials[userIndex], userInDb.credentials.size()); user.userUniqueId = userInDb.userUniqueId; user.userType = userInDb.userType; user.credentialRule = userInDb.credentialRule; @@ -336,8 +336,8 @@ bool LockManager::GetUser(chip::EndpointId endpointId, uint16_t userIndex, Ember } bool LockManager::SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - const chip::CharSpan & userName, uint32_t uniqueId, DlUserStatus userStatus, DlUserType usertype, - DlCredentialRule credentialRule, const DlCredential * credentials, size_t totalCredentials) + const chip::CharSpan & userName, uint32_t uniqueId, UserStatusEnum userStatus, UserTypeEnum usertype, + CredentialRuleEnum credentialRule, const CredentialStruct * credentials, size_t totalCredentials) { ChipLogProgress(Zcl, "Door Lock App: LockManager::SetUser " @@ -381,14 +381,14 @@ bool LockManager::SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip: mCredentials[userIndex][i] = credentials[i]; } - userInStorage.credentials = chip::Span(mCredentials[userIndex], totalCredentials); + userInStorage.credentials = chip::Span(mCredentials[userIndex], totalCredentials); // Save user information in NVM flash MT793XConfig::WriteConfigValueBin(MT793XConfig::kConfigKey_LockUser, reinterpret_cast(&mLockUsers), sizeof(EmberAfPluginDoorLockUserInfo) * LockParams.numberOfUsers); MT793XConfig::WriteConfigValueBin(MT793XConfig::kConfigKey_UserCredentials, reinterpret_cast(mCredentials), - sizeof(DlCredential) * LockParams.numberOfUsers * LockParams.numberOfCredentialsPerUser); + sizeof(CredentialStruct) * LockParams.numberOfUsers * LockParams.numberOfCredentialsPerUser); MT793XConfig::WriteConfigValueBin(MT793XConfig::kConfigKey_LockUserName, reinterpret_cast(mUserNames), sizeof(mUserNames)); @@ -398,11 +398,11 @@ bool LockManager::SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip: return true; } -bool LockManager::GetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, DlCredentialType credentialType, +bool LockManager::GetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, CredentialTypeEnum credentialType, EmberAfPluginDoorLockCredentialInfo & credential) { - if (DlCredentialType::kProgrammingPIN == credentialType) + if (CredentialTypeEnum::kProgrammingPIN == credentialType) { VerifyOrReturnValue(IsValidCredentialIndex(credentialIndex, credentialType), false); // programming pin index is only index allowed to contain 0 @@ -441,11 +441,11 @@ bool LockManager::GetCredential(chip::EndpointId endpointId, uint16_t credential } bool LockManager::SetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, chip::FabricIndex creator, - chip::FabricIndex modifier, DlCredentialStatus credentialStatus, DlCredentialType credentialType, + chip::FabricIndex modifier, DlCredentialStatus credentialStatus, CredentialTypeEnum credentialType, const chip::ByteSpan & credentialData) { - if (DlCredentialType::kProgrammingPIN == credentialType) + if (CredentialTypeEnum::kProgrammingPIN == credentialType) { VerifyOrReturnValue(IsValidCredentialIndex(credentialIndex, credentialType), false); // programming pin index is only index allowed to contain 0 @@ -507,7 +507,7 @@ DlStatus LockManager::GetWeekdaySchedule(chip::EndpointId endpointId, uint8_t we } DlStatus LockManager::SetWeekdaySchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex, - DlScheduleStatus status, DlDaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, + DlScheduleStatus status, DaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute) { @@ -607,7 +607,7 @@ DlStatus LockManager::GetHolidaySchedule(chip::EndpointId endpointId, uint8_t ho } DlStatus LockManager::SetHolidaySchedule(chip::EndpointId endpointId, uint8_t holidayIndex, DlScheduleStatus status, - uint32_t localStartTime, uint32_t localEndTime, DlOperatingMode operatingMode) + uint32_t localStartTime, uint32_t localEndTime, OperatingModeEnum operatingMode) { VerifyOrReturnValue(holidayIndex > 0, DlStatus::kFailure); // indices are one-indexed @@ -648,7 +648,7 @@ const char * LockManager::lockStateToString(DlLockState lockState) const } bool LockManager::setLockState(chip::EndpointId endpointId, DlLockState lockState, const Optional & pin, - DlOperationError & err) + OperationErrorEnum & err) { // Assume pin is required until told otherwise @@ -678,14 +678,14 @@ bool LockManager::setLockState(chip::EndpointId endpointId, DlLockState lockStat { for (uint8_t j = 0; j < kMaxCredentialsPerUser; j++) { - if (mLockCredentials[mCredentials[i][j].CredentialIndex - 1].credentialType != DlCredentialType::kPin || + if (mLockCredentials[mCredentials[i][j].CredentialIndex - 1].credentialType != CredentialTypeEnum::kPin || mLockCredentials[mCredentials[i][j].CredentialIndex - 1].status == DlCredentialStatus::kAvailable) { continue; } if (mLockCredentials[mCredentials[i][j].CredentialIndex - 1].credentialData.data_equal(pin.Value()) && - mLockUsers[i].userStatus != DlUserStatus::kOccupiedDisabled) + mLockUsers[i].userStatus != UserStatusEnum::kOccupiedDisabled) { ChipLogDetail( Zcl, "Lock App: specified PIN code was found in the database, setting lock state to \"%s\" [endpointId=%d]", @@ -702,6 +702,6 @@ bool LockManager::setLockState(chip::EndpointId endpointId, DlLockState lockStat "[endpointId=%d]", lockStateToString(lockState), mEndpointId); - err = DlOperationError::kInvalidCredential; + err = OperationErrorEnum::kInvalidCredential; return false; } diff --git a/examples/lock-app/genio/src/ZclCallbacks.cpp b/examples/lock-app/genio/src/ZclCallbacks.cpp index cca3ef947c9d86..91a867bc38c25e 100644 --- a/examples/lock-app/genio/src/ZclCallbacks.cpp +++ b/examples/lock-app/genio/src/ZclCallbacks.cpp @@ -92,7 +92,7 @@ void emberAfDoorLockClusterInitCallback(EndpointId endpoint) // Note: Due to current logic of credential, do not enable PIN and RFID // at the same time. - // Set FeatureMap to (kUsersManagement|kPINCredentials) + // Set FeatureMap to (kUser|kPinCredential) status = DoorLock::Attributes::FeatureMap::Set(endpoint, 0x101); if (status != EMBER_ZCL_STATUS_SUCCESS) { @@ -100,7 +100,8 @@ void emberAfDoorLockClusterInitCallback(EndpointId endpoint) } } -bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const Optional & pinCode, DlOperationError & err) +bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const Optional & pinCode, + OperationErrorEnum & err) { ChipLogProgress(Zcl, "Door Lock App: Lock Command endpoint=%d", endpointId); bool status = LockMgr().Lock(endpointId, pinCode, err); @@ -112,7 +113,7 @@ bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const O } bool emberAfPluginDoorLockOnDoorUnlockCommand(chip::EndpointId endpointId, const Optional & pinCode, - DlOperationError & err) + OperationErrorEnum & err) { ChipLogProgress(Zcl, "Door Lock App: Unlock Command endpoint=%d", endpointId); bool status = LockMgr().Unlock(endpointId, pinCode, err); @@ -124,7 +125,7 @@ bool emberAfPluginDoorLockOnDoorUnlockCommand(chip::EndpointId endpointId, const return status; } -bool emberAfPluginDoorLockGetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, DlCredentialType credentialType, +bool emberAfPluginDoorLockGetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, CredentialTypeEnum credentialType, EmberAfPluginDoorLockCredentialInfo & credential) { return LockMgr().GetCredential(endpointId, credentialIndex, credentialType, credential); @@ -132,7 +133,7 @@ bool emberAfPluginDoorLockGetCredential(chip::EndpointId endpointId, uint16_t cr bool emberAfPluginDoorLockSetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, chip::FabricIndex creator, chip::FabricIndex modifier, DlCredentialStatus credentialStatus, - DlCredentialType credentialType, const chip::ByteSpan & credentialData) + CredentialTypeEnum credentialType, const chip::ByteSpan & credentialData) { return LockMgr().SetCredential(endpointId, credentialIndex, creator, modifier, credentialStatus, credentialType, credentialData); @@ -145,8 +146,8 @@ bool emberAfPluginDoorLockGetUser(chip::EndpointId endpointId, uint16_t userInde bool emberAfPluginDoorLockSetUser(chip::EndpointId endpointId, uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, const chip::CharSpan & userName, uint32_t uniqueId, - DlUserStatus userStatus, DlUserType usertype, DlCredentialRule credentialRule, - const DlCredential * credentials, size_t totalCredentials) + UserStatusEnum userStatus, UserTypeEnum usertype, CredentialRuleEnum credentialRule, + const CredentialStruct * credentials, size_t totalCredentials) { return LockMgr().SetUser(endpointId, userIndex, creator, modifier, userName, uniqueId, userStatus, usertype, credentialRule, @@ -172,7 +173,7 @@ DlStatus emberAfPluginDoorLockGetSchedule(chip::EndpointId endpointId, uint8_t h } DlStatus emberAfPluginDoorLockSetSchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex, - DlScheduleStatus status, DlDaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, + DlScheduleStatus status, DaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute) { return LockMgr().SetWeekdaySchedule(endpointId, weekdayIndex, userIndex, status, daysMask, startHour, startMinute, endHour, @@ -186,7 +187,7 @@ DlStatus emberAfPluginDoorLockSetSchedule(chip::EndpointId endpointId, uint8_t y } DlStatus emberAfPluginDoorLockSetSchedule(chip::EndpointId endpointId, uint8_t holidayIndex, DlScheduleStatus status, - uint32_t localStartTime, uint32_t localEndTime, DlOperatingMode operatingMode) + uint32_t localStartTime, uint32_t localEndTime, OperatingModeEnum operatingMode) { return LockMgr().SetHolidaySchedule(endpointId, holidayIndex, status, localStartTime, localEndTime, operatingMode); } diff --git a/examples/lock-app/infineon/cyw30739/include/LockManager.h b/examples/lock-app/infineon/cyw30739/include/LockManager.h index 8f4cdf658d7375..19a336bb094fa9 100644 --- a/examples/lock-app/infineon/cyw30739/include/LockManager.h +++ b/examples/lock-app/infineon/cyw30739/include/LockManager.h @@ -142,29 +142,30 @@ class LockManager typedef void (*Callback_fn_completed)(Action_t); void SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Callback_fn_completed aActionCompleted_CB); - bool Lock(chip::EndpointId endpointId, const Optional & pin, DlOperationError & err); - bool Unlock(chip::EndpointId endpointId, const Optional & pin, DlOperationError & err); + bool Lock(chip::EndpointId endpointId, const Optional & pin, OperationErrorEnum & err); + bool Unlock(chip::EndpointId endpointId, const Optional & pin, OperationErrorEnum & err); bool GetUser(chip::EndpointId endpointId, uint16_t userIndex, EmberAfPluginDoorLockUserInfo & user); bool SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - const chip::CharSpan & userName, uint32_t uniqueId, DlUserStatus userStatus, DlUserType usertype, - DlCredentialRule credentialRule, const DlCredential * credentials, size_t totalCredentials); + const chip::CharSpan & userName, uint32_t uniqueId, UserStatusEnum userStatus, UserTypeEnum usertype, + CredentialRuleEnum credentialRule, const CredentialStruct * credentials, size_t totalCredentials); - bool SetDoorState(chip::EndpointId endpointId, DlDoorState newState); + bool SetDoorState(chip::EndpointId endpointId, DoorStateEnum newState); - DlDoorState GetDoorState() const; + DoorStateEnum GetDoorState() const; - bool GetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, DlCredentialType credentialType, + bool GetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, CredentialTypeEnum credentialType, EmberAfPluginDoorLockCredentialInfo & credential); bool SetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - DlCredentialStatus credentialStatus, DlCredentialType credentialType, const chip::ByteSpan & credentialData); + DlCredentialStatus credentialStatus, CredentialTypeEnum credentialType, + const chip::ByteSpan & credentialData); DlStatus GetWeekdaySchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex, EmberAfPluginDoorLockWeekDaySchedule & schedule); DlStatus SetWeekdaySchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex, DlScheduleStatus status, - DlDaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute); + DaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute); DlStatus GetYeardaySchedule(chip::EndpointId endpointId, uint8_t yearDayIndex, uint16_t userIndex, EmberAfPluginDoorLockYearDaySchedule & schedule); @@ -175,16 +176,16 @@ class LockManager DlStatus GetHolidaySchedule(chip::EndpointId endpointId, uint8_t holidayIndex, EmberAfPluginDoorLockHolidaySchedule & schedule); DlStatus SetHolidaySchedule(chip::EndpointId endpointId, uint8_t holidayIndex, DlScheduleStatus status, uint32_t localStartTime, - uint32_t localEndTime, DlOperatingMode operatingMode); + uint32_t localEndTime, OperatingModeEnum operatingMode); bool IsValidUserIndex(uint16_t userIndex); - bool IsValidCredentialIndex(uint16_t credentialIndex, DlCredentialType type); + bool IsValidCredentialIndex(uint16_t credentialIndex, CredentialTypeEnum type); bool IsValidWeekdayScheduleIndex(uint8_t scheduleIndex); bool IsValidYeardayScheduleIndex(uint8_t scheduleIndex); bool IsValidHolidayScheduleIndex(uint8_t scheduleIndex); bool setLockState(chip::EndpointId endpointId, DlLockState lockState, const Optional & pin, - DlOperationError & err); + OperationErrorEnum & err); const char * lockStateToString(DlLockState lockState) const; @@ -194,7 +195,7 @@ class LockManager friend LockManager & LockMgr(); chip::EndpointId mEndpointId; State_t mState; - DlDoorState mDoorState; + DoorStateEnum mDoorState; Callback_fn_initiated mActionInitiated_CB; Callback_fn_completed mActionCompleted_CB; @@ -212,7 +213,7 @@ class LockManager HolidayScheduleInfo mHolidaySchedule[kMaxHolidaySchedules]; char mUserNames[ArraySize(mLockUsers)][DOOR_LOCK_MAX_USER_NAME_SIZE]; uint8_t mCredentialData[kMaxCredentials][kMaxCredentialSize]; - DlCredential mCredentials[kMaxUsers][kMaxCredentialsPerUser]; + CredentialStruct mCredentials[kMaxUsers][kMaxCredentialsPerUser]; static LockManager sLock; CYW30739DoorLock::LockInitParams::LockParam LockParams; diff --git a/examples/lock-app/infineon/cyw30739/src/AppShellCommands.cpp b/examples/lock-app/infineon/cyw30739/src/AppShellCommands.cpp index bd5e301259e81d..3161272d070a17 100644 --- a/examples/lock-app/infineon/cyw30739/src/AppShellCommands.cpp +++ b/examples/lock-app/infineon/cyw30739/src/AppShellCommands.cpp @@ -90,12 +90,12 @@ CHIP_ERROR AppCommandLockHandler(int argc, char * argv[]) else if (strcmp(argv[0], "open") == 0) { streamer_printf(streamer_get(), "open ...\n"); - LockMgr().SetDoorState(endpointId, DlDoorState::kDoorOpen); + LockMgr().SetDoorState(endpointId, DoorStateEnum::kDoorOpen); } else if (strcmp(argv[0], "close") == 0) { streamer_printf(streamer_get(), "close ...\n"); - LockMgr().SetDoorState(endpointId, DlDoorState::kDoorClosed); + LockMgr().SetDoorState(endpointId, DoorStateEnum::kDoorClosed); } else { diff --git a/examples/lock-app/infineon/cyw30739/src/LockManager.cpp b/examples/lock-app/infineon/cyw30739/src/LockManager.cpp index 598e454f2e4d1a..bc11e6128291a2 100644 --- a/examples/lock-app/infineon/cyw30739/src/LockManager.cpp +++ b/examples/lock-app/infineon/cyw30739/src/LockManager.cpp @@ -98,10 +98,10 @@ bool LockManager::IsValidUserIndex(uint16_t userIndex) return (userIndex < kMaxUsers); } -bool LockManager::IsValidCredentialIndex(uint16_t credentialIndex, DlCredentialType type) +bool LockManager::IsValidCredentialIndex(uint16_t credentialIndex, CredentialTypeEnum type) { // appclusters, 5.2.6.3.1: 0 is allowed index for Programming PIN credential only - if (DlCredentialType::kProgrammingPIN == type) + if (CredentialTypeEnum::kProgrammingPIN == type) { return (0 == credentialIndex); } @@ -140,7 +140,7 @@ bool LockManager::ReadConfigValues() sizeof(mCredentialData), outLen); CYW30739Config::ReadConfigValueBin(CYW30739Config::kConfigKey_UserCredentials, reinterpret_cast(mCredentials), - sizeof(DlCredential) * LockParams.numberOfUsers * LockParams.numberOfCredentialsPerUser, + sizeof(CredentialStruct) * LockParams.numberOfUsers * LockParams.numberOfCredentialsPerUser, outLen); CYW30739Config::ReadConfigValueBin(CYW30739Config::kConfigKey_WeekDaySchedules, reinterpret_cast(mWeekdaySchedule), @@ -186,7 +186,7 @@ bool LockManager::InitiateAction(int32_t aActor, Action_t aAction) ChipLogProgress(Zcl, "Sending a lock jammed event"); /* Generating Door Lock Jammed event */ - DoorLockServer::Instance().SendLockAlarmEvent(1, DlAlarmCode::kLockJammed); + DoorLockServer::Instance().SendLockAlarmEvent(1, AlarmCodeEnum::kLockJammed); return true; } @@ -288,12 +288,12 @@ int LockManager::ActuatorMovementTimerEventHandler(void * data) return 0; } -bool LockManager::Lock(chip::EndpointId endpointId, const Optional & pin, DlOperationError & err) +bool LockManager::Lock(chip::EndpointId endpointId, const Optional & pin, OperationErrorEnum & err) { return setLockState(endpointId, DlLockState::kLocked, pin, err); } -bool LockManager::Unlock(chip::EndpointId endpointId, const Optional & pin, DlOperationError & err) +bool LockManager::Unlock(chip::EndpointId endpointId, const Optional & pin, OperationErrorEnum & err) { return setLockState(endpointId, DlLockState::kUnlocked, pin, err); } @@ -311,14 +311,14 @@ bool LockManager::GetUser(chip::EndpointId endpointId, uint16_t userIndex, Ember const auto & userInDb = mLockUsers[userIndex]; user.userStatus = userInDb.userStatus; - if (DlUserStatus::kAvailable == user.userStatus) + if (UserStatusEnum::kAvailable == user.userStatus) { ChipLogDetail(Zcl, "Found unoccupied user [endpoint=%d]", endpointId); return true; } user.userName = chip::CharSpan(userInDb.userName.data(), userInDb.userName.size()); - user.credentials = chip::Span(mCredentials[userIndex], userInDb.credentials.size()); + user.credentials = chip::Span(mCredentials[userIndex], userInDb.credentials.size()); user.userUniqueId = userInDb.userUniqueId; user.userType = userInDb.userType; user.credentialRule = userInDb.credentialRule; @@ -341,8 +341,8 @@ bool LockManager::GetUser(chip::EndpointId endpointId, uint16_t userIndex, Ember } bool LockManager::SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - const chip::CharSpan & userName, uint32_t uniqueId, DlUserStatus userStatus, DlUserType usertype, - DlCredentialRule credentialRule, const DlCredential * credentials, size_t totalCredentials) + const chip::CharSpan & userName, uint32_t uniqueId, UserStatusEnum userStatus, UserTypeEnum usertype, + CredentialRuleEnum credentialRule, const CredentialStruct * credentials, size_t totalCredentials) { ChipLogProgress(Zcl, "Door Lock App: LockManager::SetUser " @@ -388,14 +388,15 @@ bool LockManager::SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip: mCredentials[userIndex][i].CredentialIndex = i + 1; } - userInStorage.credentials = chip::Span(mCredentials[userIndex], totalCredentials); + userInStorage.credentials = chip::Span(mCredentials[userIndex], totalCredentials); // Save user information in NVM flash CYW30739Config::WriteConfigValueBin(CYW30739Config::kConfigKey_LockUser, reinterpret_cast(&mLockUsers), sizeof(EmberAfPluginDoorLockUserInfo) * LockParams.numberOfUsers); CYW30739Config::WriteConfigValueBin(CYW30739Config::kConfigKey_UserCredentials, reinterpret_cast(mCredentials), - sizeof(DlCredential) * LockParams.numberOfUsers * LockParams.numberOfCredentialsPerUser); + sizeof(CredentialStruct) * LockParams.numberOfUsers * + LockParams.numberOfCredentialsPerUser); CYW30739Config::WriteConfigValueBin(CYW30739Config::kConfigKey_LockUserName, reinterpret_cast(mUserNames), sizeof(mUserNames)); @@ -405,7 +406,7 @@ bool LockManager::SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip: return true; } -bool LockManager::GetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, DlCredentialType credentialType, +bool LockManager::GetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, CredentialTypeEnum credentialType, EmberAfPluginDoorLockCredentialInfo & credential) { @@ -418,7 +419,7 @@ bool LockManager::GetCredential(chip::EndpointId endpointId, uint16_t credential ChipLogProgress(Zcl, "Lock App: LockManager::GetCredential [credentialType=%u], credentialIndex=%d", to_underlying(credentialType), credentialIndex); - if (credentialType == DlCredentialType::kProgrammingPIN) + if (credentialType == CredentialTypeEnum::kProgrammingPIN) { ChipLogError(Zcl, "Programming user not supported [credentialType=%u], credentialIndex=%d", to_underlying(credentialType), credentialIndex); @@ -452,7 +453,7 @@ bool LockManager::GetCredential(chip::EndpointId endpointId, uint16_t credential } bool LockManager::SetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, chip::FabricIndex creator, - chip::FabricIndex modifier, DlCredentialStatus credentialStatus, DlCredentialType credentialType, + chip::FabricIndex modifier, DlCredentialStatus credentialStatus, CredentialTypeEnum credentialType, const chip::ByteSpan & credentialData) { VerifyOrReturnValue(credentialIndex > 0, false); // indices are one-indexed @@ -513,7 +514,7 @@ DlStatus LockManager::GetWeekdaySchedule(chip::EndpointId endpointId, uint8_t we } DlStatus LockManager::SetWeekdaySchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex, - DlScheduleStatus status, DlDaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, + DlScheduleStatus status, DaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute) { @@ -613,7 +614,7 @@ DlStatus LockManager::GetHolidaySchedule(chip::EndpointId endpointId, uint8_t ho } DlStatus LockManager::SetHolidaySchedule(chip::EndpointId endpointId, uint8_t holidayIndex, DlScheduleStatus status, - uint32_t localStartTime, uint32_t localEndTime, DlOperatingMode operatingMode) + uint32_t localStartTime, uint32_t localEndTime, OperatingModeEnum operatingMode) { VerifyOrReturnValue(holidayIndex > 0, DlStatus::kFailure); // indices are one-indexed @@ -654,7 +655,7 @@ const char * LockManager::lockStateToString(DlLockState lockState) const } bool LockManager::setLockState(chip::EndpointId endpointId, DlLockState lockState, const Optional & pin, - DlOperationError & err) + OperationErrorEnum & err) { // Assume pin is required until told otherwise bool requirePin = true; @@ -684,7 +685,7 @@ bool LockManager::setLockState(chip::EndpointId endpointId, DlLockState lockStat // Check the PIN code for (uint8_t i = 0; i < kMaxCredentials; i++) { - if (mLockCredentials[i].credentialType != DlCredentialType::kPin || + if (mLockCredentials[i].credentialType != CredentialTypeEnum::kPin || mLockCredentials[i].status == DlCredentialStatus::kAvailable) { continue; @@ -707,11 +708,11 @@ bool LockManager::setLockState(chip::EndpointId endpointId, DlLockState lockStat "[endpointId=%d]", lockStateToString(lockState), endpointId); - err = DlOperationError::kInvalidCredential; + err = OperationErrorEnum::kInvalidCredential; return false; } -bool LockManager::SetDoorState(chip::EndpointId endpointId, DlDoorState newState) +bool LockManager::SetDoorState(chip::EndpointId endpointId, DoorStateEnum newState) { if (mDoorState != newState) { diff --git a/examples/lock-app/infineon/cyw30739/src/ZclCallbacks.cpp b/examples/lock-app/infineon/cyw30739/src/ZclCallbacks.cpp index 1607c9e053ec91..d1efc819761bf4 100644 --- a/examples/lock-app/infineon/cyw30739/src/ZclCallbacks.cpp +++ b/examples/lock-app/infineon/cyw30739/src/ZclCallbacks.cpp @@ -54,7 +54,8 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & } } -bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const Optional & pinCode, DlOperationError & err) +bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const Optional & pinCode, + OperationErrorEnum & err) { ChipLogProgress(Zcl, "Door Lock App: Lock Command endpoint=%d", endpointId); bool status = LockMgr().Lock(endpointId, pinCode, err); @@ -66,7 +67,7 @@ bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const O } bool emberAfPluginDoorLockOnDoorUnlockCommand(chip::EndpointId endpointId, const Optional & pinCode, - DlOperationError & err) + OperationErrorEnum & err) { ChipLogProgress(Zcl, "Door Lock App: Unlock Command endpoint=%d", endpointId); bool status = LockMgr().Unlock(endpointId, pinCode, err); @@ -78,7 +79,7 @@ bool emberAfPluginDoorLockOnDoorUnlockCommand(chip::EndpointId endpointId, const return status; } -bool emberAfPluginDoorLockGetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, DlCredentialType credentialType, +bool emberAfPluginDoorLockGetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, CredentialTypeEnum credentialType, EmberAfPluginDoorLockCredentialInfo & credential) { return LockMgr().GetCredential(endpointId, credentialIndex, credentialType, credential); @@ -86,7 +87,7 @@ bool emberAfPluginDoorLockGetCredential(chip::EndpointId endpointId, uint16_t cr bool emberAfPluginDoorLockSetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, chip::FabricIndex creator, chip::FabricIndex modifier, DlCredentialStatus credentialStatus, - DlCredentialType credentialType, const chip::ByteSpan & credentialData) + CredentialTypeEnum credentialType, const chip::ByteSpan & credentialData) { return LockMgr().SetCredential(endpointId, credentialIndex, creator, modifier, credentialStatus, credentialType, credentialData); @@ -99,8 +100,8 @@ bool emberAfPluginDoorLockGetUser(chip::EndpointId endpointId, uint16_t userInde bool emberAfPluginDoorLockSetUser(chip::EndpointId endpointId, uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, const chip::CharSpan & userName, uint32_t uniqueId, - DlUserStatus userStatus, DlUserType usertype, DlCredentialRule credentialRule, - const DlCredential * credentials, size_t totalCredentials) + UserStatusEnum userStatus, UserTypeEnum usertype, CredentialRuleEnum credentialRule, + const CredentialStruct * credentials, size_t totalCredentials) { return LockMgr().SetUser(endpointId, userIndex, creator, modifier, userName, uniqueId, userStatus, usertype, credentialRule, @@ -126,7 +127,7 @@ DlStatus emberAfPluginDoorLockGetSchedule(chip::EndpointId endpointId, uint8_t h } DlStatus emberAfPluginDoorLockSetSchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex, - DlScheduleStatus status, DlDaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, + DlScheduleStatus status, DaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute) { return LockMgr().SetWeekdaySchedule(endpointId, weekdayIndex, userIndex, status, daysMask, startHour, startMinute, endHour, @@ -140,7 +141,7 @@ DlStatus emberAfPluginDoorLockSetSchedule(chip::EndpointId endpointId, uint8_t y } DlStatus emberAfPluginDoorLockSetSchedule(chip::EndpointId endpointId, uint8_t holidayIndex, DlScheduleStatus status, - uint32_t localStartTime, uint32_t localEndTime, DlOperatingMode operatingMode) + uint32_t localStartTime, uint32_t localEndTime, OperatingModeEnum operatingMode) { return LockMgr().SetHolidaySchedule(endpointId, holidayIndex, status, localStartTime, localEndTime, operatingMode); } diff --git a/examples/lock-app/infineon/cyw30739/src/main.cpp b/examples/lock-app/infineon/cyw30739/src/main.cpp index 7483536fa4fe15..be32b550205bf4 100644 --- a/examples/lock-app/infineon/cyw30739/src/main.cpp +++ b/examples/lock-app/infineon/cyw30739/src/main.cpp @@ -47,8 +47,8 @@ #include using chip::app::Clusters::DoorLock::DlLockState; -using chip::app::Clusters::DoorLock::DlOperationError; -using chip::app::Clusters::DoorLock::DlOperationSource; +using chip::app::Clusters::DoorLock::OperationErrorEnum; +using chip::app::Clusters::DoorLock::OperationSourceEnum; using namespace chip; using namespace ::chip::DeviceLayer::Internal; @@ -308,7 +308,7 @@ void UpdateClusterState(intptr_t context) bool unlocked = LockMgr().NextState(); DlLockState newState = unlocked ? DlLockState::kUnlocked : DlLockState::kLocked; - DlOperationSource source = DlOperationSource::kUnspecified; + OperationSourceEnum source = OperationSourceEnum::kUnspecified; // write the new lock value EmberAfStatus status = diff --git a/examples/lock-app/infineon/psoc6/include/AppTask.h b/examples/lock-app/infineon/psoc6/include/AppTask.h index f83ba6c1e42730..8d6ca18b1f8e8a 100644 --- a/examples/lock-app/infineon/psoc6/include/AppTask.h +++ b/examples/lock-app/infineon/psoc6/include/AppTask.h @@ -52,11 +52,12 @@ class AppTask void ButtonEventHandler(uint8_t btnIdx, uint8_t btnAction); void UpdateClusterState(void); void InitOTARequestor(); + void lockMgr_Init(); private: friend AppTask & GetAppTask(void); - CHIP_ERROR Init(); + void Init(); static void ActionInitiated(LockManager::Action_t aAction, int32_t aActor); static void ActionCompleted(LockManager::Action_t aAction); diff --git a/examples/lock-app/infineon/psoc6/include/LockManager.h b/examples/lock-app/infineon/psoc6/include/LockManager.h index 1dbdf58d85487e..ab3eb96c0a92c6 100644 --- a/examples/lock-app/infineon/psoc6/include/LockManager.h +++ b/examples/lock-app/infineon/psoc6/include/LockManager.h @@ -145,25 +145,26 @@ class LockManager typedef void (*Callback_fn_completed)(Action_t); void SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Callback_fn_completed aActionCompleted_CB); - bool Lock(chip::EndpointId endpointId, const Optional & pin, DlOperationError & err); - bool Unlock(chip::EndpointId endpointId, const Optional & pin, DlOperationError & err); + bool Lock(chip::EndpointId endpointId, const Optional & pin, OperationErrorEnum & err); + bool Unlock(chip::EndpointId endpointId, const Optional & pin, OperationErrorEnum & err); bool GetUser(chip::EndpointId endpointId, uint16_t userIndex, EmberAfPluginDoorLockUserInfo & user); bool SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - const chip::CharSpan & userName, uint32_t uniqueId, DlUserStatus userStatus, DlUserType usertype, - DlCredentialRule credentialRule, const DlCredential * credentials, size_t totalCredentials); + const chip::CharSpan & userName, uint32_t uniqueId, UserStatusEnum userStatus, UserTypeEnum usertype, + CredentialRuleEnum credentialRule, const CredentialStruct * credentials, size_t totalCredentials); - bool GetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, DlCredentialType credentialType, + bool GetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, CredentialTypeEnum credentialType, EmberAfPluginDoorLockCredentialInfo & credential); bool SetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - DlCredentialStatus credentialStatus, DlCredentialType credentialType, const chip::ByteSpan & credentialData); + DlCredentialStatus credentialStatus, CredentialTypeEnum credentialType, + const chip::ByteSpan & credentialData); DlStatus GetWeekdaySchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex, EmberAfPluginDoorLockWeekDaySchedule & schedule); DlStatus SetWeekdaySchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex, DlScheduleStatus status, - DlDaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute); + DaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute); DlStatus GetYeardaySchedule(chip::EndpointId endpointId, uint8_t yearDayIndex, uint16_t userIndex, EmberAfPluginDoorLockYearDaySchedule & schedule); @@ -174,16 +175,16 @@ class LockManager DlStatus GetHolidaySchedule(chip::EndpointId endpointId, uint8_t holidayIndex, EmberAfPluginDoorLockHolidaySchedule & schedule); DlStatus SetHolidaySchedule(chip::EndpointId endpointId, uint8_t holidayIndex, DlScheduleStatus status, uint32_t localStartTime, - uint32_t localEndTime, DlOperatingMode operatingMode); + uint32_t localEndTime, OperatingModeEnum operatingMode); bool IsValidUserIndex(uint16_t userIndex); - bool IsValidCredentialIndex(uint16_t credentialIndex, DlCredentialType type); + bool IsValidCredentialIndex(uint16_t credentialIndex, CredentialTypeEnum type); bool IsValidWeekdayScheduleIndex(uint8_t scheduleIndex); bool IsValidYeardayScheduleIndex(uint8_t scheduleIndex); bool IsValidHolidayScheduleIndex(uint8_t scheduleIndex); bool setLockState(chip::EndpointId endpointId, DlLockState lockState, const Optional & pin, - DlOperationError & err); + OperationErrorEnum & err); const char * lockStateToString(DlLockState lockState) const; bool ReadConfigValues(); @@ -211,7 +212,7 @@ class LockManager char mUserNames[ArraySize(mLockUsers)][DOOR_LOCK_MAX_USER_NAME_SIZE]; uint8_t mCredentialData[kMaxCredentials][kMaxCredentialSize]; - DlCredential mCredentials[kMaxUsers][kMaxCredentialsPerUser]; + CredentialStruct mCredentials[kMaxUsers][kMaxCredentialsPerUser]; static LockManager sLock; P6DoorLock::LockInitParams::LockParam LockParams; diff --git a/examples/lock-app/infineon/psoc6/src/AppTask.cpp b/examples/lock-app/infineon/psoc6/src/AppTask.cpp index a06f1ca687dca0..2120a10ace0393 100644 --- a/examples/lock-app/infineon/psoc6/src/AppTask.cpp +++ b/examples/lock-app/infineon/psoc6/src/AppTask.cpp @@ -22,8 +22,6 @@ #include "ButtonHandler.h" #include "LEDWidget.h" #include -#include -#include #include #include @@ -80,8 +78,8 @@ using namespace ::chip::System; #define APP_EVENT_QUEUE_SIZE 10 using chip::app::Clusters::DoorLock::DlLockState; -using chip::app::Clusters::DoorLock::DlOperationError; -using chip::app::Clusters::DoorLock::DlOperationSource; +using chip::app::Clusters::DoorLock::OperationErrorEnum; +using chip::app::Clusters::DoorLock::OperationSourceEnum; namespace { TimerHandle_t sFunctionTimer; // FreeRTOS app sw timer. @@ -162,6 +160,8 @@ static void InitServer(intptr_t context) #if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR GetAppTask().InitOTARequestor(); #endif + + GetAppTask().lockMgr_Init(); } CHIP_ERROR AppTask::StartAppTask() @@ -178,55 +178,15 @@ CHIP_ERROR AppTask::StartAppTask() return (sAppTaskHandle == nullptr) ? APP_ERROR_CREATE_TASK_FAILED : CHIP_NO_ERROR; } -CHIP_ERROR AppTask::Init() +void AppTask::lockMgr_Init() { CHIP_ERROR err = CHIP_NO_ERROR; -#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR - int rc = boot_set_confirmed(); - if (rc != 0) - { - P6_LOG("boot_set_confirmed failed"); - appError(CHIP_ERROR_WELL_UNINITIALIZED); - } -#endif - // Register the callback to init the MDNS server when connectivity is available - PlatformMgr().AddEventHandler( - [](const ChipDeviceEvent * event, intptr_t arg) { - // Restart the server whenever an ip address is renewed - if (event->Type == DeviceEventType::kInternetConnectivityChange) - { - if (event->InternetConnectivityChange.IPv4 == kConnectivity_Established || - event->InternetConnectivityChange.IPv6 == kConnectivity_Established) - { - chip::app::DnssdServer::Instance().StartServer(); - } - } - }, - 0); - chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast(nullptr)); - - // Initialise WSTK buttons PB0 and PB1 (including debounce). - ButtonHandler::Init(); - - // Create FreeRTOS sw timer for Function Selection. - sFunctionTimer = xTimerCreate("FnTmr", // Just a text name, not used by the RTOS kernel - 1, // == default timer period (mS) - false, // no timer reload (==one-shot) - (void *) this, // init timer id = app task obj context - TimerEventHandler // timer callback handler - ); - if (sFunctionTimer == NULL) - { - P6_LOG("funct timer create failed"); - appError(APP_ERROR_CREATE_TIMER_FAILED); - } NetWorkCommissioningInstInit(); P6_LOG("Current Software Version: %d", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION); // Initial lock state chip::app::DataModel::Nullable state; chip::EndpointId endpointId{ 1 }; - chip::DeviceLayer::PlatformMgr().LockChipStack(); chip::app::Clusters::DoorLock::Attributes::LockState::Get(endpointId, state); uint8_t numberOfCredentialsPerUser = 0; @@ -278,9 +238,6 @@ CHIP_ERROR AppTask::Init() numberOfHolidaySchedules = 10; } - chip::DeviceLayer::PlatformMgr().UnlockChipStack(); - - // err = LockMgr().Init(state, maxCredentialsPerUser, numberOfSupportedUsers); err = LockMgr().Init(state, ParamBuilder() .SetNumberOfUsers(numberOfUsers) @@ -294,11 +251,29 @@ CHIP_ERROR AppTask::Init() P6_LOG("LockMgr().Init() failed"); appError(err); } + + // Initialise WSTK buttons PB0 and PB1 (including debounce). + ButtonHandler::Init(); + + // Create FreeRTOS sw timer for Function Selection. + sFunctionTimer = xTimerCreate("FnTmr", // Just a text name, not used by the RTOS kernel + 1, // == default timer period (mS) + false, // no timer reload (==one-shot) + (void *) this, // init timer id = app task obj context + TimerEventHandler // timer callback handler + ); + if (sFunctionTimer == NULL) + { + P6_LOG("funct timer create failed"); + appError(APP_ERROR_CREATE_TIMER_FAILED); + } + LockMgr().SetCallbacks(ActionInitiated, ActionCompleted); // Initialize LEDs sStatusLED.Init(SYSTEM_STATE_LED); sLockLED.Init(LOCK_STATE_LED); + if (state.Value() == DlLockState::kUnlocked) { sLockLED.Set(false); @@ -312,21 +287,41 @@ CHIP_ERROR AppTask::Init() // Print setup info PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE)); +} - return err; +void AppTask::Init() +{ +#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR + int rc = boot_set_confirmed(); + if (rc != 0) + { + P6_LOG("boot_set_confirmed failed"); + appError(CHIP_ERROR_WELL_UNINITIALIZED); + } +#endif + // Register the callback to init the MDNS server when connectivity is available + PlatformMgr().AddEventHandler( + [](const ChipDeviceEvent * event, intptr_t arg) { + // Restart the server whenever an ip address is renewed + if (event->Type == DeviceEventType::kInternetConnectivityChange) + { + if (event->InternetConnectivityChange.IPv4 == kConnectivity_Established || + event->InternetConnectivityChange.IPv6 == kConnectivity_Established) + { + chip::app::DnssdServer::Instance().StartServer(); + } + } + }, + 0); + + chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast(nullptr)); } void AppTask::AppTaskMain(void * pvParameter) { AppEvent event; - CHIP_ERROR err = sAppTask.Init(); - if (err != CHIP_NO_ERROR) - { - P6_LOG("AppTask.Init() failed"); - appError(err); - } - + sAppTask.Init(); P6_LOG("App Task started"); // Users and credentials should be checked once from flash on boot @@ -407,7 +402,7 @@ void AppTask::LockActionEventHandler(AppEvent * event) P6_LOG("Sending a lock jammed event"); /* Generating Door Lock Jammed event */ - DoorLockServer::Instance().SendLockAlarmEvent(1 /* Endpoint Id */, DlAlarmCode::kLockJammed); + DoorLockServer::Instance().SendLockAlarmEvent(1 /* Endpoint Id */, AlarmCodeEnum::kLockJammed); return; } @@ -663,7 +658,7 @@ void AppTask::UpdateCluster(intptr_t context) bool unlocked = LockMgr().NextState(); DlLockState newState = unlocked ? DlLockState::kUnlocked : DlLockState::kLocked; - DlOperationSource source = DlOperationSource::kUnspecified; + OperationSourceEnum source = OperationSourceEnum::kUnspecified; // write the new lock value EmberAfStatus status = diff --git a/examples/lock-app/infineon/psoc6/src/ButtonHandler.cpp b/examples/lock-app/infineon/psoc6/src/ButtonHandler.cpp index 84aaac16ae3d41..551b97d39414fd 100644 --- a/examples/lock-app/infineon/psoc6/src/ButtonHandler.cpp +++ b/examples/lock-app/infineon/psoc6/src/ButtonHandler.cpp @@ -99,11 +99,7 @@ void ButtonHandler::TimerCallback(TimerHandle_t xTimer) timerId = (uint32_t) pvTimerGetTimerID(xTimer); if (timerId) { - buttonevent = cyhal_gpio_read(APP_FUNCTION_BUTTON); - if (buttonevent) - { - GetAppTask().ButtonEventHandler(timerId, APP_BUTTON_PRESSED); - } + GetAppTask().ButtonEventHandler(timerId, APP_BUTTON_PRESSED); } else { diff --git a/examples/lock-app/infineon/psoc6/src/LockManager.cpp b/examples/lock-app/infineon/psoc6/src/LockManager.cpp index 05db9aec0d5098..6d218073cc97be 100644 --- a/examples/lock-app/infineon/psoc6/src/LockManager.cpp +++ b/examples/lock-app/infineon/psoc6/src/LockManager.cpp @@ -107,10 +107,10 @@ bool LockManager::IsValidUserIndex(uint16_t userIndex) return (userIndex < kMaxUsers); } -bool LockManager::IsValidCredentialIndex(uint16_t credentialIndex, DlCredentialType type) +bool LockManager::IsValidCredentialIndex(uint16_t credentialIndex, CredentialTypeEnum type) { // appclusters, 5.2.6.3.1: 0 is allowed index for Programming PIN credential only - if (DlCredentialType::kProgrammingPIN == type) + if (CredentialTypeEnum::kProgrammingPIN == type) { return (0 == credentialIndex); } @@ -149,7 +149,8 @@ bool LockManager::ReadConfigValues() sizeof(mCredentialData), outLen); P6Config::ReadConfigValueBin(P6Config::kConfigKey_UserCredentials, reinterpret_cast(mCredentials), - sizeof(DlCredential) * LockParams.numberOfUsers * LockParams.numberOfCredentialsPerUser, outLen); + sizeof(CredentialStruct) * LockParams.numberOfUsers * LockParams.numberOfCredentialsPerUser, + outLen); P6Config::ReadConfigValueBin(P6Config::kConfigKey_WeekDaySchedules, reinterpret_cast(mWeekdaySchedule), sizeof(EmberAfPluginDoorLockWeekDaySchedule) * LockParams.numberOfWeekdaySchedulesPerUser * @@ -287,12 +288,12 @@ void LockManager::ActuatorMovementTimerEventHandler(AppEvent * aEvent) } } -bool LockManager::Lock(chip::EndpointId endpointId, const Optional & pin, DlOperationError & err) +bool LockManager::Lock(chip::EndpointId endpointId, const Optional & pin, OperationErrorEnum & err) { return setLockState(endpointId, DlLockState::kLocked, pin, err); } -bool LockManager::Unlock(chip::EndpointId endpointId, const Optional & pin, DlOperationError & err) +bool LockManager::Unlock(chip::EndpointId endpointId, const Optional & pin, OperationErrorEnum & err) { return setLockState(endpointId, DlLockState::kUnlocked, pin, err); } @@ -310,14 +311,14 @@ bool LockManager::GetUser(chip::EndpointId endpointId, uint16_t userIndex, Ember const auto & userInDb = mLockUsers[userIndex]; user.userStatus = userInDb.userStatus; - if (DlUserStatus::kAvailable == user.userStatus) + if (UserStatusEnum::kAvailable == user.userStatus) { ChipLogDetail(Zcl, "Found unoccupied user [endpoint=%d]", mEndpointId); return true; } user.userName = chip::CharSpan(userInDb.userName.data(), userInDb.userName.size()); - user.credentials = chip::Span(mCredentials[userIndex], userInDb.credentials.size()); + user.credentials = chip::Span(mCredentials[userIndex], userInDb.credentials.size()); user.userUniqueId = userInDb.userUniqueId; user.userType = userInDb.userType; user.credentialRule = userInDb.credentialRule; @@ -340,8 +341,8 @@ bool LockManager::GetUser(chip::EndpointId endpointId, uint16_t userIndex, Ember } bool LockManager::SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - const chip::CharSpan & userName, uint32_t uniqueId, DlUserStatus userStatus, DlUserType usertype, - DlCredentialRule credentialRule, const DlCredential * credentials, size_t totalCredentials) + const chip::CharSpan & userName, uint32_t uniqueId, UserStatusEnum userStatus, UserTypeEnum usertype, + CredentialRuleEnum credentialRule, const CredentialStruct * credentials, size_t totalCredentials) { ChipLogProgress(Zcl, "Door Lock App: LockManager::SetUser " @@ -387,14 +388,14 @@ bool LockManager::SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip: mCredentials[userIndex][i].CredentialIndex = i + 1; } - userInStorage.credentials = chip::Span(mCredentials[userIndex], totalCredentials); + userInStorage.credentials = chip::Span(mCredentials[userIndex], totalCredentials); // Save user information in NVM flash P6Config::WriteConfigValueBin(P6Config::kConfigKey_LockUser, reinterpret_cast(&mLockUsers), sizeof(EmberAfPluginDoorLockUserInfo) * LockParams.numberOfUsers); P6Config::WriteConfigValueBin(P6Config::kConfigKey_UserCredentials, reinterpret_cast(mCredentials), - sizeof(DlCredential) * LockParams.numberOfUsers * LockParams.numberOfCredentialsPerUser); + sizeof(CredentialStruct) * LockParams.numberOfUsers * LockParams.numberOfCredentialsPerUser); P6Config::WriteConfigValueBin(P6Config::kConfigKey_LockUserName, reinterpret_cast(mUserNames), sizeof(mUserNames)); @@ -404,7 +405,7 @@ bool LockManager::SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip: return true; } -bool LockManager::GetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, DlCredentialType credentialType, +bool LockManager::GetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, CredentialTypeEnum credentialType, EmberAfPluginDoorLockCredentialInfo & credential) { @@ -417,7 +418,7 @@ bool LockManager::GetCredential(chip::EndpointId endpointId, uint16_t credential ChipLogProgress(Zcl, "Lock App: LockManager::GetCredential [credentialType=%u], credentialIndex=%d", to_underlying(credentialType), credentialIndex); - if (credentialType == DlCredentialType::kProgrammingPIN) + if (credentialType == CredentialTypeEnum::kProgrammingPIN) { ChipLogError(Zcl, "Programming user not supported [credentialType=%u], credentialIndex=%d", to_underlying(credentialType), credentialIndex); @@ -451,7 +452,7 @@ bool LockManager::GetCredential(chip::EndpointId endpointId, uint16_t credential } bool LockManager::SetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, chip::FabricIndex creator, - chip::FabricIndex modifier, DlCredentialStatus credentialStatus, DlCredentialType credentialType, + chip::FabricIndex modifier, DlCredentialStatus credentialStatus, CredentialTypeEnum credentialType, const chip::ByteSpan & credentialData) { @@ -513,7 +514,7 @@ DlStatus LockManager::GetWeekdaySchedule(chip::EndpointId endpointId, uint8_t we } DlStatus LockManager::SetWeekdaySchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex, - DlScheduleStatus status, DlDaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, + DlScheduleStatus status, DaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute) { @@ -613,7 +614,7 @@ DlStatus LockManager::GetHolidaySchedule(chip::EndpointId endpointId, uint8_t ho } DlStatus LockManager::SetHolidaySchedule(chip::EndpointId endpointId, uint8_t holidayIndex, DlScheduleStatus status, - uint32_t localStartTime, uint32_t localEndTime, DlOperatingMode operatingMode) + uint32_t localStartTime, uint32_t localEndTime, OperatingModeEnum operatingMode) { VerifyOrReturnValue(holidayIndex > 0, DlStatus::kFailure); // indices are one-indexed @@ -653,7 +654,7 @@ const char * LockManager::lockStateToString(DlLockState lockState) const } bool LockManager::setLockState(chip::EndpointId endpointId, DlLockState lockState, const Optional & pin, - DlOperationError & err) + OperationErrorEnum & err) { // Assume pin is required until told otherwise @@ -684,7 +685,7 @@ bool LockManager::setLockState(chip::EndpointId endpointId, DlLockState lockStat // Check the PIN code for (uint8_t i = 0; i < kMaxCredentials; i++) { - if (mLockCredentials[i].credentialType != DlCredentialType::kPin || + if (mLockCredentials[i].credentialType != CredentialTypeEnum::kPin || mLockCredentials[i].status == DlCredentialStatus::kAvailable) { continue; @@ -707,6 +708,6 @@ bool LockManager::setLockState(chip::EndpointId endpointId, DlLockState lockStat "[endpointId=%d]", lockStateToString(lockState), endpointId); - err = DlOperationError::kInvalidCredential; + err = OperationErrorEnum::kInvalidCredential; return false; } diff --git a/examples/lock-app/infineon/psoc6/src/ZclCallbacks.cpp b/examples/lock-app/infineon/psoc6/src/ZclCallbacks.cpp index cdfd3a8d27e883..91936419d458a6 100644 --- a/examples/lock-app/infineon/psoc6/src/ZclCallbacks.cpp +++ b/examples/lock-app/infineon/psoc6/src/ZclCallbacks.cpp @@ -58,7 +58,8 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & */ void emberAfOnOffClusterInitCallback(EndpointId endpoint) {} -bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const Optional & pinCode, DlOperationError & err) +bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const Optional & pinCode, + OperationErrorEnum & err) { ChipLogProgress(Zcl, "Door Lock App: Lock Command endpoint=%d", endpointId); bool status = LockMgr().Lock(endpointId, pinCode, err); @@ -70,7 +71,7 @@ bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const O } bool emberAfPluginDoorLockOnDoorUnlockCommand(chip::EndpointId endpointId, const Optional & pinCode, - DlOperationError & err) + OperationErrorEnum & err) { ChipLogProgress(Zcl, "Door Lock App: Unlock Command endpoint=%d", endpointId); bool status = LockMgr().Unlock(endpointId, pinCode, err); @@ -82,7 +83,7 @@ bool emberAfPluginDoorLockOnDoorUnlockCommand(chip::EndpointId endpointId, const return status; } -bool emberAfPluginDoorLockGetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, DlCredentialType credentialType, +bool emberAfPluginDoorLockGetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, CredentialTypeEnum credentialType, EmberAfPluginDoorLockCredentialInfo & credential) { return LockMgr().GetCredential(endpointId, credentialIndex, credentialType, credential); @@ -90,7 +91,7 @@ bool emberAfPluginDoorLockGetCredential(chip::EndpointId endpointId, uint16_t cr bool emberAfPluginDoorLockSetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, chip::FabricIndex creator, chip::FabricIndex modifier, DlCredentialStatus credentialStatus, - DlCredentialType credentialType, const chip::ByteSpan & credentialData) + CredentialTypeEnum credentialType, const chip::ByteSpan & credentialData) { return LockMgr().SetCredential(endpointId, credentialIndex, creator, modifier, credentialStatus, credentialType, credentialData); @@ -103,8 +104,8 @@ bool emberAfPluginDoorLockGetUser(chip::EndpointId endpointId, uint16_t userInde bool emberAfPluginDoorLockSetUser(chip::EndpointId endpointId, uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, const chip::CharSpan & userName, uint32_t uniqueId, - DlUserStatus userStatus, DlUserType usertype, DlCredentialRule credentialRule, - const DlCredential * credentials, size_t totalCredentials) + UserStatusEnum userStatus, UserTypeEnum usertype, CredentialRuleEnum credentialRule, + const CredentialStruct * credentials, size_t totalCredentials) { return LockMgr().SetUser(endpointId, userIndex, creator, modifier, userName, uniqueId, userStatus, usertype, credentialRule, @@ -127,7 +128,7 @@ DlStatus emberAfPluginDoorLockGetSchedule(chip::EndpointId endpointId, uint8_t y } DlStatus emberAfPluginDoorLockSetSchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex, - DlScheduleStatus status, DlDaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, + DlScheduleStatus status, DaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute) { return LockMgr().SetWeekdaySchedule(endpointId, weekdayIndex, userIndex, status, daysMask, startHour, startMinute, endHour, @@ -150,7 +151,7 @@ DlStatus emberAfPluginDoorLockGetSchedule(chip::EndpointId endpointId, uint8_t h } DlStatus emberAfPluginDoorLockSetSchedule(chip::EndpointId endpointId, uint8_t holidayIndex, DlScheduleStatus status, - uint32_t localStartTime, uint32_t localEndTime, DlOperatingMode operatingMode) + uint32_t localStartTime, uint32_t localEndTime, OperatingModeEnum operatingMode) { return LockMgr().SetHolidaySchedule(endpointId, holidayIndex, status, localStartTime, localEndTime, operatingMode); // return DlStatus::kFailure; diff --git a/examples/lock-app/linux/include/LockEndpoint.h b/examples/lock-app/linux/include/LockEndpoint.h index 91a4b4f71b727d..7ba34d10d6c3cd 100644 --- a/examples/lock-app/linux/include/LockEndpoint.h +++ b/examples/lock-app/linux/include/LockEndpoint.h @@ -25,10 +25,10 @@ struct LockUserInfo { char userName[DOOR_LOCK_USER_NAME_BUFFER_SIZE]; uint32_t userUniqueId; - DlUserStatus userStatus; - DlUserType userType; - DlCredentialRule credentialRule; - std::vector credentials; + UserStatusEnum userStatus; + UserTypeEnum userType; + CredentialRuleEnum credentialRule; + std::vector credentials; chip::FabricIndex createdBy; chip::FabricIndex lastModifiedBy; }; @@ -39,6 +39,7 @@ struct YearDayScheduleInfo; struct HolidayScheduleInfo; static constexpr size_t DOOR_LOCK_CREDENTIAL_INFO_MAX_DATA_SIZE = 20; +static constexpr size_t DOOR_LOCK_CREDENTIAL_INFO_MAX_TYPES = 6; class LockEndpoint { @@ -47,8 +48,8 @@ class LockEndpoint uint8_t weekDaySchedulesPerUser, uint8_t yearDaySchedulesPerUser, uint8_t numberOfCredentialsPerUser, uint8_t numberOfHolidaySchedules) : mEndpointId{ endpointId }, - mLockState{ DlLockState::kLocked }, mDoorState{ DlDoorState::kDoorClosed }, mLockUsers(numberOfLockUsersSupported), - mLockCredentials(numberOfCredentialsSupported + 1), + mLockState{ DlLockState::kLocked }, mDoorState{ DoorStateEnum::kDoorClosed }, mLockUsers(numberOfLockUsersSupported), + mLockCredentials(DOOR_LOCK_CREDENTIAL_INFO_MAX_TYPES, std::vector(numberOfCredentialsSupported + 1)), mWeekDaySchedules(numberOfLockUsersSupported, std::vector(weekDaySchedulesPerUser)), mYearDaySchedules(numberOfLockUsersSupported, std::vector(yearDaySchedulesPerUser)), mHolidaySchedules(numberOfHolidaySchedules) @@ -63,39 +64,40 @@ class LockEndpoint inline chip::EndpointId GetEndpointId() const { return mEndpointId; } - bool Lock(const Optional & pin, DlOperationError & err); - bool Unlock(const Optional & pin, DlOperationError & err); + bool Lock(const Optional & pin, OperationErrorEnum & err); + bool Unlock(const Optional & pin, OperationErrorEnum & err); bool GetUser(uint16_t userIndex, EmberAfPluginDoorLockUserInfo & user) const; bool SetUser(uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, const chip::CharSpan & userName, - uint32_t uniqueId, DlUserStatus userStatus, DlUserType usertype, DlCredentialRule credentialRule, - const DlCredential * credentials, size_t totalCredentials); + uint32_t uniqueId, UserStatusEnum userStatus, UserTypeEnum usertype, CredentialRuleEnum credentialRule, + const CredentialStruct * credentials, size_t totalCredentials); - bool SetDoorState(DlDoorState newState); + bool SetDoorState(DoorStateEnum newState); - DlDoorState GetDoorState() const; + DoorStateEnum GetDoorState() const; - bool SendLockAlarm(DlAlarmCode alarmCode) const; + bool SendLockAlarm(AlarmCodeEnum alarmCode) const; - bool GetCredential(uint16_t credentialIndex, DlCredentialType credentialType, + bool GetCredential(uint16_t credentialIndex, CredentialTypeEnum credentialType, EmberAfPluginDoorLockCredentialInfo & credential) const; bool SetCredential(uint16_t credentialIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - DlCredentialStatus credentialStatus, DlCredentialType credentialType, const chip::ByteSpan & credentialData); + DlCredentialStatus credentialStatus, CredentialTypeEnum credentialType, + const chip::ByteSpan & credentialData); DlStatus GetSchedule(uint8_t weekDayIndex, uint16_t userIndex, EmberAfPluginDoorLockWeekDaySchedule & schedule); DlStatus GetSchedule(uint8_t yearDayIndex, uint16_t userIndex, EmberAfPluginDoorLockYearDaySchedule & schedule); DlStatus GetSchedule(uint8_t holidayIndex, EmberAfPluginDoorLockHolidaySchedule & schedule); - DlStatus SetSchedule(uint8_t weekDayIndex, uint16_t userIndex, DlScheduleStatus status, DlDaysMaskMap daysMask, - uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute); + DlStatus SetSchedule(uint8_t weekDayIndex, uint16_t userIndex, DlScheduleStatus status, DaysMaskMap daysMask, uint8_t startHour, + uint8_t startMinute, uint8_t endHour, uint8_t endMinute); DlStatus SetSchedule(uint8_t yearDayIndex, uint16_t userIndex, DlScheduleStatus status, uint32_t localStartTime, uint32_t localEndTime); DlStatus SetSchedule(uint8_t holidayIndex, DlScheduleStatus status, uint32_t localStartTime, uint32_t localEndTime, - DlOperatingMode operatingMode); + OperatingModeEnum operatingMode); private: - bool setLockState(DlLockState lockState, const Optional & pin, DlOperationError & err); + bool setLockState(DlLockState lockState, const Optional & pin, OperationErrorEnum & err); const char * lockStateToString(DlLockState lockState) const; bool weekDayScheduleInAction(uint16_t userIndex) const; @@ -103,12 +105,12 @@ class LockEndpoint chip::EndpointId mEndpointId; DlLockState mLockState; - DlDoorState mDoorState; + DoorStateEnum mDoorState; // This is very naive implementation of users/credentials/schedules database and by no means the best practice. Proper storage // of those items is out of scope of this example. std::vector mLockUsers; - std::vector mLockCredentials; + std::vector> mLockCredentials; std::vector> mWeekDaySchedules; std::vector> mYearDaySchedules; std::vector mHolidaySchedules; @@ -117,7 +119,7 @@ class LockEndpoint struct LockCredentialInfo { DlCredentialStatus status; - DlCredentialType credentialType; + CredentialTypeEnum credentialType; chip::FabricIndex createdBy; chip::FabricIndex modifiedBy; uint8_t credentialData[DOOR_LOCK_CREDENTIAL_INFO_MAX_DATA_SIZE]; diff --git a/examples/lock-app/linux/include/LockManager.h b/examples/lock-app/linux/include/LockManager.h index a517e07580af3a..07123df607bf46 100644 --- a/examples/lock-app/linux/include/LockManager.h +++ b/examples/lock-app/linux/include/LockManager.h @@ -31,23 +31,24 @@ class LockManager bool InitEndpoint(chip::EndpointId endpointId); - bool SetDoorState(chip::EndpointId endpointId, DlDoorState doorState); + bool SetDoorState(chip::EndpointId endpointId, DoorStateEnum doorState); - bool SendLockAlarm(chip::EndpointId endpointId, DlAlarmCode alarmCode); + bool SendLockAlarm(chip::EndpointId endpointId, AlarmCodeEnum alarmCode); - bool Lock(chip::EndpointId endpointId, const Optional & pin, DlOperationError & err); - bool Unlock(chip::EndpointId endpointId, const Optional & pin, DlOperationError & err); + bool Lock(chip::EndpointId endpointId, const Optional & pin, OperationErrorEnum & err); + bool Unlock(chip::EndpointId endpointId, const Optional & pin, OperationErrorEnum & err); bool GetUser(chip::EndpointId endpointId, uint16_t userIndex, EmberAfPluginDoorLockUserInfo & user); bool SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - const chip::CharSpan & userName, uint32_t uniqueId, DlUserStatus userStatus, DlUserType usertype, - DlCredentialRule credentialRule, const DlCredential * credentials, size_t totalCredentials); + const chip::CharSpan & userName, uint32_t uniqueId, UserStatusEnum userStatus, UserTypeEnum usertype, + CredentialRuleEnum credentialRule, const CredentialStruct * credentials, size_t totalCredentials); - bool GetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, DlCredentialType credentialType, + bool GetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, CredentialTypeEnum credentialType, EmberAfPluginDoorLockCredentialInfo & credential); bool SetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - DlCredentialStatus credentialStatus, DlCredentialType credentialType, const chip::ByteSpan & credentialData); + DlCredentialStatus credentialStatus, CredentialTypeEnum credentialType, + const chip::ByteSpan & credentialData); DlStatus GetSchedule(chip::EndpointId endpointId, uint8_t weekDayIndex, uint16_t userIndex, EmberAfPluginDoorLockWeekDaySchedule & schedule); @@ -56,11 +57,11 @@ class LockManager DlStatus GetSchedule(chip::EndpointId endpointId, uint8_t holidayIndex, EmberAfPluginDoorLockHolidaySchedule & schedule); DlStatus SetSchedule(chip::EndpointId endpointId, uint8_t weekDayIndex, uint16_t userIndex, DlScheduleStatus status, - DlDaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute); + DaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute); DlStatus SetSchedule(chip::EndpointId endpointId, uint8_t yearDayIndex, uint16_t userIndex, DlScheduleStatus status, uint32_t localStartTime, uint32_t localEndTime); DlStatus SetSchedule(chip::EndpointId endpointId, uint8_t holidayIndex, DlScheduleStatus status, uint32_t localStartTime, - uint32_t localEndTime, DlOperatingMode operatingMode); + uint32_t localEndTime, OperatingModeEnum operatingMode); static LockManager & Instance(); diff --git a/examples/lock-app/linux/src/LockAppCommandDelegate.cpp b/examples/lock-app/linux/src/LockAppCommandDelegate.cpp index 9268d37f4e9c3f..92602a70c022c2 100644 --- a/examples/lock-app/linux/src/LockAppCommandDelegate.cpp +++ b/examples/lock-app/linux/src/LockAppCommandDelegate.cpp @@ -107,11 +107,11 @@ void LockAppCommandHandler::HandleCommand(intptr_t context) ChipLogError(NotSpecified, "Lock App: Unable to execute command to set the door state: invalid type for DoorState")); auto doorState = params["DoorState"].asUInt(); - VerifyOrExit(doorState < to_underlying(DlDoorState::kUnknownEnumValue), + VerifyOrExit(doorState < to_underlying(DoorStateEnum::kUnknownEnumValue), ChipLogError(NotSpecified, "Lock App: Unable to execute command to set door state: DoorState is out of range [doorState=%u]", doorState)); - LockManager::Instance().SetDoorState(endpointId, static_cast(doorState)); + LockManager::Instance().SetDoorState(endpointId, static_cast(doorState)); } else if (self->mCommandName == "SendDoorLockAlarm") { @@ -125,11 +125,11 @@ void LockAppCommandHandler::HandleCommand(intptr_t context) auto alarmCode = params["AlarmCode"].asUInt(); VerifyOrExit( - alarmCode < to_underlying(DlAlarmCode::kUnknownEnumValue), + alarmCode < to_underlying(AlarmCodeEnum::kUnknownEnumValue), ChipLogError(NotSpecified, "Lock App: Unable to execute command to send lock alarm: AlarmCode is out of range [alarmCode=%u]", alarmCode)); - LockManager::Instance().SendLockAlarm(endpointId, static_cast(alarmCode)); + LockManager::Instance().SendLockAlarm(endpointId, static_cast(alarmCode)); } else { diff --git a/examples/lock-app/linux/src/LockEndpoint.cpp b/examples/lock-app/linux/src/LockEndpoint.cpp index c3d52c69a08603..672b2f32f9fb75 100644 --- a/examples/lock-app/linux/src/LockEndpoint.cpp +++ b/examples/lock-app/linux/src/LockEndpoint.cpp @@ -21,12 +21,12 @@ using chip::to_underlying; -bool LockEndpoint::Lock(const Optional & pin, DlOperationError & err) +bool LockEndpoint::Lock(const Optional & pin, OperationErrorEnum & err) { return setLockState(DlLockState::kLocked, pin, err); } -bool LockEndpoint::Unlock(const Optional & pin, DlOperationError & err) +bool LockEndpoint::Unlock(const Optional & pin, OperationErrorEnum & err) { return setLockState(DlLockState::kUnlocked, pin, err); } @@ -45,14 +45,14 @@ bool LockEndpoint::GetUser(uint16_t userIndex, EmberAfPluginDoorLockUserInfo & u const auto & userInDb = mLockUsers[adjustedUserIndex]; user.userStatus = userInDb.userStatus; - if (DlUserStatus::kAvailable == user.userStatus) + if (UserStatusEnum::kAvailable == user.userStatus) { ChipLogDetail(Zcl, "Found unoccupied user [endpoint=%d,adjustedIndex=%hu]", mEndpointId, adjustedUserIndex); return true; } user.userName = chip::CharSpan(userInDb.userName, strlen(userInDb.userName)); - user.credentials = chip::Span(userInDb.credentials.data(), userInDb.credentials.size()); + user.credentials = chip::Span(userInDb.credentials.data(), userInDb.credentials.size()); user.userUniqueId = userInDb.userUniqueId; user.userType = userInDb.userType; user.credentialRule = userInDb.credentialRule; @@ -75,8 +75,8 @@ bool LockEndpoint::GetUser(uint16_t userIndex, EmberAfPluginDoorLockUserInfo & u } bool LockEndpoint::SetUser(uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - const chip::CharSpan & userName, uint32_t uniqueId, DlUserStatus userStatus, DlUserType usertype, - DlCredentialRule credentialRule, const DlCredential * credentials, size_t totalCredentials) + const chip::CharSpan & userName, uint32_t uniqueId, UserStatusEnum userStatus, UserTypeEnum usertype, + CredentialRuleEnum credentialRule, const CredentialStruct * credentials, size_t totalCredentials) { ChipLogProgress(Zcl, "Lock App: LockEndpoint::SetUser " @@ -134,12 +134,12 @@ bool LockEndpoint::SetUser(uint16_t userIndex, chip::FabricIndex creator, chip:: return true; } -DlDoorState LockEndpoint::GetDoorState() const +DoorStateEnum LockEndpoint::GetDoorState() const { return mDoorState; } -bool LockEndpoint::SetDoorState(DlDoorState newState) +bool LockEndpoint::SetDoorState(DoorStateEnum newState) { if (mDoorState != newState) { @@ -152,25 +152,32 @@ bool LockEndpoint::SetDoorState(DlDoorState newState) return true; } -bool LockEndpoint::SendLockAlarm(DlAlarmCode alarmCode) const +bool LockEndpoint::SendLockAlarm(AlarmCodeEnum alarmCode) const { ChipLogProgress(Zcl, "Sending the LockAlarm event [endpointId=%d,alarmCode=%u]", mEndpointId, to_underlying(alarmCode)); return DoorLockServer::Instance().SendLockAlarmEvent(mEndpointId, alarmCode); } -bool LockEndpoint::GetCredential(uint16_t credentialIndex, DlCredentialType credentialType, +bool LockEndpoint::GetCredential(uint16_t credentialIndex, CredentialTypeEnum credentialType, EmberAfPluginDoorLockCredentialInfo & credential) const { ChipLogProgress(Zcl, "Lock App: LockEndpoint::GetCredential [endpoint=%d,credentialIndex=%u,credentialType=%u]", mEndpointId, credentialIndex, to_underlying(credentialType)); - if (credentialIndex >= mLockCredentials.size() || (0 == credentialIndex && DlCredentialType::kProgrammingPIN != credentialType)) + if (to_underlying(credentialType) >= mLockCredentials.size()) { ChipLogError(Zcl, "Cannot get the credential - index out of range [endpoint=%d,index=%d]", mEndpointId, credentialIndex); return false; } - const auto & credentialInStorage = mLockCredentials[credentialIndex]; + if (credentialIndex >= mLockCredentials.at(to_underlying(credentialType)).size() || + (0 == credentialIndex && CredentialTypeEnum::kProgrammingPIN != credentialType)) + { + ChipLogError(Zcl, "Cannot get the credential - index out of range [endpoint=%d,index=%d]", mEndpointId, credentialIndex); + return false; + } + + const auto & credentialInStorage = mLockCredentials[to_underlying(credentialType)][credentialIndex]; credential.status = credentialInStorage.status; if (DlCredentialStatus::kAvailable == credential.status) @@ -195,7 +202,7 @@ bool LockEndpoint::GetCredential(uint16_t credentialIndex, DlCredentialType cred } bool LockEndpoint::SetCredential(uint16_t credentialIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - DlCredentialStatus credentialStatus, DlCredentialType credentialType, + DlCredentialStatus credentialStatus, CredentialTypeEnum credentialType, const chip::ByteSpan & credentialData) { ChipLogProgress( @@ -205,13 +212,21 @@ bool LockEndpoint::SetCredential(uint16_t credentialIndex, chip::FabricIndex cre mEndpointId, credentialIndex, to_underlying(credentialStatus), to_underlying(credentialType), static_cast(credentialData.size()), creator, modifier); - if (credentialIndex >= mLockCredentials.size() || (0 == credentialIndex && DlCredentialType::kProgrammingPIN != credentialType)) + if (to_underlying(credentialType) >= mLockCredentials.capacity()) + { + ChipLogError(Zcl, "Cannot set the credential - type out of range [endpoint=%d,type=%d]", mEndpointId, + to_underlying(credentialType)); + return false; + } + + if (credentialIndex >= mLockCredentials.at(to_underlying(credentialType)).size() || + (0 == credentialIndex && CredentialTypeEnum::kProgrammingPIN != credentialType)) { ChipLogError(Zcl, "Cannot set the credential - index out of range [endpoint=%d,index=%d]", mEndpointId, credentialIndex); return false; } - auto & credentialInStorage = mLockCredentials[credentialIndex]; + auto & credentialInStorage = mLockCredentials[to_underlying(credentialType)][credentialIndex]; if (credentialData.size() > DOOR_LOCK_CREDENTIAL_INFO_MAX_DATA_SIZE) { ChipLogError(Zcl, @@ -258,7 +273,7 @@ DlStatus LockEndpoint::GetSchedule(uint8_t weekDayIndex, uint16_t userIndex, Emb return DlStatus::kSuccess; } -DlStatus LockEndpoint::SetSchedule(uint8_t weekDayIndex, uint16_t userIndex, DlScheduleStatus status, DlDaysMaskMap daysMask, +DlStatus LockEndpoint::SetSchedule(uint8_t weekDayIndex, uint16_t userIndex, DlScheduleStatus status, DaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute) { if (0 == userIndex || userIndex > mWeekDaySchedules.size()) @@ -345,7 +360,7 @@ DlStatus LockEndpoint::GetSchedule(uint8_t holidayIndex, EmberAfPluginDoorLockHo } DlStatus LockEndpoint::SetSchedule(uint8_t holidayIndex, DlScheduleStatus status, uint32_t localStartTime, uint32_t localEndTime, - DlOperatingMode operatingMode) + OperatingModeEnum operatingMode) { if (0 == holidayIndex || holidayIndex > mHolidaySchedules.size()) { @@ -361,7 +376,7 @@ DlStatus LockEndpoint::SetSchedule(uint8_t holidayIndex, DlScheduleStatus status return DlStatus::kSuccess; } -bool LockEndpoint::setLockState(DlLockState lockState, const Optional & pin, DlOperationError & err) +bool LockEndpoint::setLockState(DlLockState lockState, const Optional & pin, OperationErrorEnum & err) { // Assume pin is required until told otherwise bool requirePin = true; @@ -389,25 +404,26 @@ bool LockEndpoint::setLockState(DlLockState lockState, const Optional(credential - mLockCredentials.begin()); + auto credentialIndex = static_cast(credential - pinCredentials.begin()); auto user = std::find_if(mLockUsers.begin(), mLockUsers.end(), [credential, credentialIndex](const LockUserInfo & u) { - return std::any_of(u.credentials.begin(), u.credentials.end(), [&credential, credentialIndex](const DlCredential & c) { + return std::any_of(u.credentials.begin(), u.credentials.end(), [&credential, credentialIndex](const CredentialStruct & c) { return c.CredentialIndex == credentialIndex && c.CredentialType == to_underlying(credential->credentialType); }); }); @@ -422,17 +438,17 @@ bool LockEndpoint::setLockState(DlLockState lockState, const Optional(user - mLockUsers.begin()); // Check if schedules affect the user - if ((user->userType == DlUserType::kScheduleRestrictedUser || user->userType == DlUserType::kWeekDayScheduleUser) && + if ((user->userType == UserTypeEnum::kScheduleRestrictedUser || user->userType == UserTypeEnum::kWeekDayScheduleUser) && !weekDayScheduleInAction(userIndex)) { - if ((user->userType == DlUserType::kScheduleRestrictedUser || user->userType == DlUserType::kYearDayScheduleUser) && + if ((user->userType == UserTypeEnum::kScheduleRestrictedUser || user->userType == UserTypeEnum::kYearDayScheduleUser) && !yearDayScheduleInAction(userIndex)) { ChipLogDetail(Zcl, "Lock App: associated user is not allowed to operate the lock due to schedules" "[endpointId=%d,userIndex=%u]", mEndpointId, userIndex); - err = DlOperationError::kRestricted; + err = OperationErrorEnum::kRestricted; return false; } } @@ -450,7 +466,7 @@ bool LockEndpoint::setLockState(DlLockState lockState, const OptionalSetDoorState(doorState); } -bool LockManager::SendLockAlarm(chip::EndpointId endpointId, DlAlarmCode alarmCode) +bool LockManager::SendLockAlarm(chip::EndpointId endpointId, AlarmCodeEnum alarmCode) { auto lockEndpoint = getEndpoint(endpointId); if (nullptr == lockEndpoint) @@ -134,7 +134,7 @@ bool LockManager::SendLockAlarm(chip::EndpointId endpointId, DlAlarmCode alarmCo return lockEndpoint->SendLockAlarm(alarmCode); } -bool LockManager::Lock(chip::EndpointId endpointId, const Optional & pin, DlOperationError & err) +bool LockManager::Lock(chip::EndpointId endpointId, const Optional & pin, OperationErrorEnum & err) { auto lockEndpoint = getEndpoint(endpointId); if (nullptr == lockEndpoint) @@ -145,7 +145,7 @@ bool LockManager::Lock(chip::EndpointId endpointId, const OptionalLock(pin, err); } -bool LockManager::Unlock(chip::EndpointId endpointId, const Optional & pin, DlOperationError & err) +bool LockManager::Unlock(chip::EndpointId endpointId, const Optional & pin, OperationErrorEnum & err) { auto lockEndpoint = getEndpoint(endpointId); if (nullptr == lockEndpoint) @@ -168,8 +168,8 @@ bool LockManager::GetUser(chip::EndpointId endpointId, uint16_t userIndex, Ember } bool LockManager::SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - const chip::CharSpan & userName, uint32_t uniqueId, DlUserStatus userStatus, DlUserType usertype, - DlCredentialRule credentialRule, const DlCredential * credentials, size_t totalCredentials) + const chip::CharSpan & userName, uint32_t uniqueId, UserStatusEnum userStatus, UserTypeEnum usertype, + CredentialRuleEnum credentialRule, const CredentialStruct * credentials, size_t totalCredentials) { auto lockEndpoint = getEndpoint(endpointId); if (nullptr == lockEndpoint) @@ -181,7 +181,7 @@ bool LockManager::SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip: credentials, totalCredentials); } -bool LockManager::GetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, DlCredentialType credentialType, +bool LockManager::GetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, CredentialTypeEnum credentialType, EmberAfPluginDoorLockCredentialInfo & credential) { auto lockEndpoint = getEndpoint(endpointId); @@ -194,7 +194,7 @@ bool LockManager::GetCredential(chip::EndpointId endpointId, uint16_t credential } bool LockManager::SetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, chip::FabricIndex creator, - chip::FabricIndex modifier, DlCredentialStatus credentialStatus, DlCredentialType credentialType, + chip::FabricIndex modifier, DlCredentialStatus credentialStatus, CredentialTypeEnum credentialType, const chip::ByteSpan & credentialData) { auto lockEndpoint = getEndpoint(endpointId); @@ -220,8 +220,7 @@ DlStatus LockManager::GetSchedule(chip::EndpointId endpointId, uint8_t weekDayIn } DlStatus LockManager::SetSchedule(chip::EndpointId endpointId, uint8_t weekDayIndex, uint16_t userIndex, DlScheduleStatus status, - DlDaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, - uint8_t endMinute) + DaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute) { auto lockEndpoint = getEndpoint(endpointId); if (nullptr == lockEndpoint) @@ -273,7 +272,7 @@ DlStatus LockManager::GetSchedule(chip::EndpointId endpointId, uint8_t holidayIn } DlStatus LockManager::SetSchedule(chip::EndpointId endpointId, uint8_t holidayIndex, DlScheduleStatus status, - uint32_t localStartTime, uint32_t localEndTime, DlOperatingMode operatingMode) + uint32_t localStartTime, uint32_t localEndTime, OperatingModeEnum operatingMode) { auto lockEndpoint = getEndpoint(endpointId); if (nullptr == lockEndpoint) diff --git a/examples/lock-app/linux/src/ZCLDoorLockCallbacks.cpp b/examples/lock-app/linux/src/ZCLDoorLockCallbacks.cpp index fa7cc2dff164cf..a0670f2abf7f0c 100644 --- a/examples/lock-app/linux/src/ZCLDoorLockCallbacks.cpp +++ b/examples/lock-app/linux/src/ZCLDoorLockCallbacks.cpp @@ -10,13 +10,14 @@ using namespace chip::app::Clusters::DoorLock; // should wait for door to be locked on lock command and return success) but // door lock server should check pin before even calling the lock-door // callback. -bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const Optional & pinCode, DlOperationError & err) +bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const Optional & pinCode, + OperationErrorEnum & err) { return LockManager::Instance().Lock(endpointId, pinCode, err); } bool emberAfPluginDoorLockOnDoorUnlockCommand(chip::EndpointId endpointId, const Optional & pinCode, - DlOperationError & err) + OperationErrorEnum & err) { return LockManager::Instance().Unlock(endpointId, pinCode, err); } @@ -28,15 +29,15 @@ bool emberAfPluginDoorLockGetUser(chip::EndpointId endpointId, uint16_t userInde bool emberAfPluginDoorLockSetUser(chip::EndpointId endpointId, uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, const chip::CharSpan & userName, uint32_t uniqueId, - DlUserStatus userStatus, DlUserType usertype, DlCredentialRule credentialRule, - const DlCredential * credentials, size_t totalCredentials) + UserStatusEnum userStatus, UserTypeEnum usertype, CredentialRuleEnum credentialRule, + const CredentialStruct * credentials, size_t totalCredentials) { return LockManager::Instance().SetUser(endpointId, userIndex, creator, modifier, userName, uniqueId, userStatus, usertype, credentialRule, credentials, totalCredentials); } -bool emberAfPluginDoorLockGetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, DlCredentialType credentialType, +bool emberAfPluginDoorLockGetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, CredentialTypeEnum credentialType, EmberAfPluginDoorLockCredentialInfo & credential) { return LockManager::Instance().GetCredential(endpointId, credentialIndex, credentialType, credential); @@ -44,7 +45,7 @@ bool emberAfPluginDoorLockGetCredential(chip::EndpointId endpointId, uint16_t cr bool emberAfPluginDoorLockSetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, chip::FabricIndex creator, chip::FabricIndex modifier, DlCredentialStatus credentialStatus, - DlCredentialType credentialType, const chip::ByteSpan & credentialData) + CredentialTypeEnum credentialType, const chip::ByteSpan & credentialData) { return LockManager::Instance().SetCredential(endpointId, credentialIndex, creator, modifier, credentialStatus, credentialType, credentialData); @@ -63,7 +64,7 @@ DlStatus emberAfPluginDoorLockGetSchedule(chip::EndpointId endpointId, uint8_t h } DlStatus emberAfPluginDoorLockSetSchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex, - DlScheduleStatus status, DlDaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, + DlScheduleStatus status, DaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute) { return LockManager::Instance().SetSchedule(endpointId, weekdayIndex, userIndex, status, daysMask, startHour, startMinute, @@ -83,7 +84,7 @@ DlStatus emberAfPluginDoorLockGetSchedule(chip::EndpointId endpointId, uint8_t y } DlStatus emberAfPluginDoorLockSetSchedule(chip::EndpointId endpointId, uint8_t holidayIndex, DlScheduleStatus status, - uint32_t localStartTime, uint32_t localEndTime, DlOperatingMode operatingMode) + uint32_t localStartTime, uint32_t localEndTime, OperatingModeEnum operatingMode) { return LockManager::Instance().SetSchedule(endpointId, holidayIndex, status, localStartTime, localEndTime, operatingMode); } diff --git a/examples/lock-app/lock-common/lock-app.matter b/examples/lock-app/lock-common/lock-app.matter index 4813d33f6da103..f41c9e6b21284c 100644 --- a/examples/lock-app/lock-common/lock-app.matter +++ b/examples/lock-app/lock-common/lock-app.matter @@ -71,10 +71,6 @@ server cluster OnOff = 6 { kLighting = 0x1; } - bitmap SceneFeatures : BITMAP32 { - kSceneNames = 0x1; - } - readonly attribute boolean onOff = 0; readonly attribute boolean globalSceneControl = 16384; attribute int16u onTime = 16385; @@ -391,7 +387,7 @@ server cluster PowerSourceConfiguration = 46 { server cluster PowerSource = 47 { enum BatChargeFault : ENUM8 { - kUnspecfied = 0; + kUnspecified = 0; kAmbientTooHot = 1; kAmbientTooCold = 2; kBatteryTooHot = 3; @@ -431,7 +427,7 @@ server cluster PowerSource = 47 { } enum PowerSourceStatus : ENUM8 { - kUnspecfied = 0; + kUnspecified = 0; kActive = 1; kStandby = 2; kUnavailable = 3; @@ -718,7 +714,7 @@ server cluster GeneralDiagnostics = 51 { kSoftwareReset = 6; } - enum HardwareFault : ENUM8 { + enum HardwareFaultEnum : ENUM8 { kUnspecified = 0; kRadio = 1; kSensor = 2; @@ -732,7 +728,7 @@ server cluster GeneralDiagnostics = 51 { kTamperDetected = 10; } - enum InterfaceType : ENUM8 { + enum InterfaceTypeEnum : ENUM8 { kUnspecified = 0; kWiFi = 1; kEthernet = 2; @@ -740,14 +736,14 @@ server cluster GeneralDiagnostics = 51 { kThread = 4; } - enum NetworkFaultType : ENUM8 { + enum NetworkFaultEnum : ENUM8 { kUnspecified = 0; kHardwareFailure = 1; kNetworkJammed = 2; kConnectionFailed = 3; } - enum RadioFault : ENUM8 { + enum RadioFaultEnum : ENUM8 { kUnspecified = 0; kWiFiFault = 1; kCellularFault = 2; @@ -765,22 +761,22 @@ server cluster GeneralDiagnostics = 51 { octet_string<8> hardwareAddress = 4; octet_string IPv4Addresses[] = 5; octet_string IPv6Addresses[] = 6; - InterfaceType type = 7; + InterfaceTypeEnum type = 7; } critical event HardwareFaultChange = 0 { - HardwareFault current[] = 0; - HardwareFault previous[] = 1; + HardwareFaultEnum current[] = 0; + HardwareFaultEnum previous[] = 1; } critical event RadioFaultChange = 1 { - RadioFault current[] = 0; - RadioFault previous[] = 1; + RadioFaultEnum current[] = 0; + RadioFaultEnum previous[] = 1; } critical event NetworkFaultChange = 2 { - NetworkFaultType current[] = 0; - NetworkFaultType previous[] = 1; + NetworkFaultEnum current[] = 0; + NetworkFaultEnum previous[] = 1; } critical event BootReason = 3 { @@ -792,9 +788,9 @@ server cluster GeneralDiagnostics = 51 { readonly attribute int64u upTime = 2; readonly attribute int32u totalOperationalHours = 3; readonly attribute BootReasonEnum bootReason = 4; - readonly attribute HardwareFault activeHardwareFaults[] = 5; - readonly attribute RadioFault activeRadioFaults[] = 6; - readonly attribute NetworkFaultType activeNetworkFaults[] = 7; + readonly attribute HardwareFaultEnum activeHardwareFaults[] = 5; + readonly attribute RadioFaultEnum activeRadioFaults[] = 6; + readonly attribute NetworkFaultEnum activeNetworkFaults[] = 7; readonly attribute boolean testEventTriggersEnabled = 8; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -1025,6 +1021,11 @@ server cluster WiFiNetworkDiagnostics = 54 { kAx = 5; } + bitmap WiFiNetworkDiagnosticsFeature : BITMAP32 { + kPacketCounts = 0x1; + kErrorCounts = 0x2; + } + info event Disconnection = 0 { INT16U reasonCode = 0; } @@ -1058,7 +1059,7 @@ server cluster WiFiNetworkDiagnostics = 54 { } server cluster EthernetNetworkDiagnostics = 55 { - enum PHYRate : ENUM8 { + enum PHYRateEnum : ENUM8 { kRate10M = 0; kRate100M = 1; kRate1G = 2; @@ -1071,7 +1072,12 @@ server cluster EthernetNetworkDiagnostics = 55 { kRate400G = 9; } - readonly attribute nullable PHYRate PHYRate = 0; + bitmap EthernetNetworkDiagnosticsFeature : BITMAP32 { + kPacketCounts = 0x1; + kErrorCounts = 0x2; + } + + readonly attribute nullable PHYRateEnum PHYRate = 0; readonly attribute nullable boolean fullDuplex = 1; readonly attribute int64u packetRxCount = 2; readonly attribute int64u packetTxCount = 3; @@ -1087,7 +1093,7 @@ server cluster EthernetNetworkDiagnostics = 55 { } server cluster AdministratorCommissioning = 60 { - enum CommissioningWindowStatus : ENUM8 { + enum CommissioningWindowStatusEnum : ENUM8 { kWindowNotOpen = 0; kEnhancedWindowOpen = 1; kBasicWindowOpen = 2; @@ -1099,7 +1105,7 @@ server cluster AdministratorCommissioning = 60 { kWindowNotOpen = 4; } - readonly attribute CommissioningWindowStatus windowStatus = 0; + readonly attribute CommissioningWindowStatusEnum windowStatus = 0; readonly attribute nullable fabric_idx adminFabricIndex = 1; readonly attribute nullable int16u adminVendorId = 2; readonly attribute bitmap32 featureMap = 65532; @@ -1123,8 +1129,13 @@ server cluster AdministratorCommissioning = 60 { } server cluster OperationalCredentials = 62 { - enum OperationalCertStatus : ENUM8 { - kSuccess = 0; + enum CertificateChainTypeEnum : ENUM8 { + kDACCertificate = 1; + kPAICertificate = 2; + } + + enum NodeOperationalCertStatusEnum : ENUM8 { + kOk = 0; kInvalidPublicKey = 1; kInvalidNodeOpId = 2; kInvalidNOC = 3; @@ -1142,17 +1153,17 @@ server cluster OperationalCredentials = 62 { fabric_idx fabricIndex = 254; } - fabric_scoped struct FabricDescriptor { + fabric_scoped struct FabricDescriptorStruct { octet_string<65> rootPublicKey = 1; - vendor_id vendorId = 2; - fabric_id fabricId = 3; - node_id nodeId = 4; + vendor_id vendorID = 2; + fabric_id fabricID = 3; + node_id nodeID = 4; char_string<32> label = 5; fabric_idx fabricIndex = 254; } readonly attribute access(read: administer) NOCStruct NOCs[] = 0; - readonly attribute FabricDescriptor fabrics[] = 1; + readonly attribute FabricDescriptorStruct fabrics[] = 1; readonly attribute int8u supportedFabrics = 2; readonly attribute int8u commissionedFabrics = 3; readonly attribute OCTET_STRING trustedRootCertificates[] = 4; @@ -1165,7 +1176,7 @@ server cluster OperationalCredentials = 62 { } request struct CertificateChainRequestRequest { - INT8U certificateType = 0; + CertificateChainTypeEnum certificateType = 0; } request struct CSRRequestRequest { @@ -1195,12 +1206,12 @@ server cluster OperationalCredentials = 62 { } request struct AddTrustedRootCertificateRequest { - OCTET_STRING rootCertificate = 0; + OCTET_STRING rootCACertificate = 0; } response struct AttestationResponse = 1 { OCTET_STRING attestationElements = 0; - OCTET_STRING signature = 1; + OCTET_STRING attestationSignature = 1; } response struct CertificateChainResponse = 3 { @@ -1213,7 +1224,7 @@ server cluster OperationalCredentials = 62 { } response struct NOCResponse = 8 { - OperationalCertStatus statusCode = 0; + NodeOperationalCertStatusEnum statusCode = 0; optional fabric_idx fabricIndex = 1; optional CHAR_STRING debugText = 2; } @@ -1308,7 +1319,7 @@ server cluster UserLabel = 65 { } server cluster DoorLock = 257 { - enum DlAlarmCode : ENUM8 { + enum AlarmCodeEnum : ENUM8 { kLockJammed = 0; kLockFactoryReset = 1; kLockRadioPowerCycled = 3; @@ -1319,13 +1330,13 @@ server cluster DoorLock = 257 { kForcedUser = 8; } - enum DlCredentialRule : ENUM8 { + enum CredentialRuleEnum : ENUM8 { kSingle = 0; - kDouble = 1; + kDual = 1; kTri = 2; } - enum DlCredentialType : ENUM8 { + enum CredentialTypeEnum : ENUM8 { kProgrammingPIN = 0; kPin = 1; kRfid = 2; @@ -1334,40 +1345,12 @@ server cluster DoorLock = 257 { kFace = 5; } - enum DlDataOperationType : ENUM8 { + enum DataOperationTypeEnum : ENUM8 { kAdd = 0; kClear = 1; kModify = 2; } - enum DlDoorState : ENUM8 { - kDoorOpen = 0; - kDoorClosed = 1; - kDoorJammed = 2; - kDoorForcedOpen = 3; - kDoorUnspecifiedError = 4; - kDoorAjar = 5; - } - - enum DlLockDataType : ENUM8 { - kUnspecified = 0; - kProgrammingCode = 1; - kUserIndex = 2; - kWeekDaySchedule = 3; - kYearDaySchedule = 4; - kHolidaySchedule = 5; - kPin = 6; - kRfid = 7; - kFingerprint = 8; - } - - enum DlLockOperationType : ENUM8 { - kLock = 0; - kUnlock = 1; - kNonAccessUserEvent = 2; - kForcedUserEvent = 3; - } - enum DlLockState : ENUM8 { kNotFullyLocked = 0; kLocked = 1; @@ -1388,35 +1371,6 @@ server cluster DoorLock = 257 { kDoorFurniture = 10; } - enum DlOperatingMode : ENUM8 { - kNormal = 0; - kVacation = 1; - kPrivacy = 2; - kNoRemoteLockUnlock = 3; - kPassage = 4; - } - - enum DlOperationError : ENUM8 { - kUnspecified = 0; - kInvalidCredential = 1; - kDisabledUserDenied = 2; - kRestricted = 3; - kInsufficientBattery = 4; - } - - enum DlOperationSource : ENUM8 { - kUnspecified = 0; - kManual = 1; - kProprietaryRemote = 2; - kKeypad = 3; - kAuto = 4; - kButton = 5; - kSchedule = 6; - kRemote = 7; - kRfid = 8; - kBiometric = 9; - } - enum DlStatus : ENUM8 { kSuccess = 0; kFailure = 1; @@ -1427,25 +1381,6 @@ server cluster DoorLock = 257 { kNotFound = 139; } - enum DlUserStatus : ENUM8 { - kAvailable = 0; - kOccupiedEnabled = 1; - kOccupiedDisabled = 3; - } - - enum DlUserType : ENUM8 { - kUnrestrictedUser = 0; - kYearDayScheduleUser = 1; - kWeekDayScheduleUser = 2; - kProgrammingUser = 3; - kNonAccessUser = 4; - kForcedUser = 5; - kDisposableUser = 6; - kExpiringUser = 7; - kScheduleRestrictedUser = 8; - kRemoteOnlyUser = 9; - } - enum DoorLockOperationEventCode : ENUM8 { kUnknownOrMfgSpecific = 0; kLock = 1; @@ -1497,19 +1432,83 @@ server cluster DoorLock = 257 { kNotSupported = 255; } - bitmap DlCredentialRuleMask : BITMAP8 { - kSingle = 0x1; - kDual = 0x2; - kTri = 0x4; + enum DoorStateEnum : ENUM8 { + kDoorOpen = 0; + kDoorClosed = 1; + kDoorJammed = 2; + kDoorForcedOpen = 3; + kDoorUnspecifiedError = 4; + kDoorAjar = 5; } - bitmap DlCredentialRulesSupport : BITMAP8 { - kSingle = 0x1; - kDual = 0x2; - kTri = 0x4; + enum LockDataTypeEnum : ENUM8 { + kUnspecified = 0; + kProgrammingCode = 1; + kUserIndex = 2; + kWeekDaySchedule = 3; + kYearDaySchedule = 4; + kHolidaySchedule = 5; + kPin = 6; + kRfid = 7; + kFingerprint = 8; } - bitmap DlDaysMaskMap : BITMAP8 { + enum LockOperationTypeEnum : ENUM8 { + kLock = 0; + kUnlock = 1; + kNonAccessUserEvent = 2; + kForcedUserEvent = 3; + } + + enum OperatingModeEnum : ENUM8 { + kNormal = 0; + kVacation = 1; + kPrivacy = 2; + kNoRemoteLockUnlock = 3; + kPassage = 4; + } + + enum OperationErrorEnum : ENUM8 { + kUnspecified = 0; + kInvalidCredential = 1; + kDisabledUserDenied = 2; + kRestricted = 3; + kInsufficientBattery = 4; + } + + enum OperationSourceEnum : ENUM8 { + kUnspecified = 0; + kManual = 1; + kProprietaryRemote = 2; + kKeypad = 3; + kAuto = 4; + kButton = 5; + kSchedule = 6; + kRemote = 7; + kRfid = 8; + kBiometric = 9; + } + + enum UserStatusEnum : ENUM8 { + kAvailable = 0; + kOccupiedEnabled = 1; + kOccupiedDisabled = 3; + } + + enum UserTypeEnum : ENUM8 { + kUnrestrictedUser = 0; + kYearDayScheduleUser = 1; + kWeekDayScheduleUser = 2; + kProgrammingUser = 3; + kNonAccessUser = 4; + kForcedUser = 5; + kDisposableUser = 6; + kExpiringUser = 7; + kScheduleRestrictedUser = 8; + kRemoteOnlyUser = 9; + } + + bitmap DaysMaskMap : BITMAP8 { kSunday = 0x1; kMonday = 0x2; kTuesday = 0x4; @@ -1519,6 +1518,18 @@ server cluster DoorLock = 257 { kSaturday = 0x40; } + bitmap DlCredentialRuleMask : BITMAP8 { + kSingle = 0x1; + kDual = 0x2; + kTri = 0x4; + } + + bitmap DlCredentialRulesSupport : BITMAP8 { + kSingle = 0x1; + kDual = 0x2; + kTri = 0x4; + } + bitmap DlDefaultConfigurationRegister : BITMAP16 { kEnableLocalProgrammingEnabled = 0x1; kKeypadInterfaceDefaultAccessEnabled = 0x2; @@ -1623,56 +1634,56 @@ server cluster DoorLock = 257 { } bitmap DoorLockFeature : BITMAP32 { - kPINCredentials = 0x1; - kRFIDCredentials = 0x2; + kPinCredential = 0x1; + kRfidCredential = 0x2; kFingerCredentials = 0x4; kLogging = 0x8; - kWeekDaySchedules = 0x10; + kWeekDayAccessSchedules = 0x10; kDoorPositionSensor = 0x20; kFaceCredentials = 0x40; - kCredentialsOTA = 0x80; - kUsersManagement = 0x100; - kNotifications = 0x200; - kYearDaySchedules = 0x400; + kCredentialsOverTheAirAccess = 0x80; + kUser = 0x100; + kNotification = 0x200; + kYearDayAccessSchedules = 0x400; kHolidaySchedules = 0x800; } - struct DlCredential { - DlCredentialType credentialType = 0; + struct CredentialStruct { + CredentialTypeEnum credentialType = 0; int16u credentialIndex = 1; } critical event DoorLockAlarm = 0 { - DlAlarmCode alarmCode = 0; + AlarmCodeEnum alarmCode = 0; } critical event DoorStateChange = 1 { - DlDoorState doorState = 0; + DoorStateEnum doorState = 0; } critical event LockOperation = 2 { - DlLockOperationType lockOperationType = 0; - DlOperationSource operationSource = 1; + LockOperationTypeEnum lockOperationType = 0; + OperationSourceEnum operationSource = 1; nullable INT16U userIndex = 2; nullable fabric_idx fabricIndex = 3; nullable NODE_ID sourceNode = 4; - optional nullable DlCredential credentials[] = 5; + optional nullable CredentialStruct credentials[] = 5; } critical event LockOperationError = 3 { - DlLockOperationType lockOperationType = 0; - DlOperationSource operationSource = 1; - DlOperationError operationError = 2; + LockOperationTypeEnum lockOperationType = 0; + OperationSourceEnum operationSource = 1; + OperationErrorEnum operationError = 2; nullable INT16U userIndex = 3; nullable fabric_idx fabricIndex = 4; nullable NODE_ID sourceNode = 5; - optional nullable DlCredential credentials[] = 6; + optional nullable CredentialStruct credentials[] = 6; } info event LockUserChange = 4 { - DlLockDataType lockDataType = 0; - DlDataOperationType dataOperationType = 1; - DlOperationSource operationSource = 2; + LockDataTypeEnum lockDataType = 0; + DataOperationTypeEnum dataOperationType = 1; + OperationSourceEnum operationSource = 2; nullable INT16U userIndex = 3; nullable fabric_idx fabricIndex = 4; nullable NODE_ID sourceNode = 5; @@ -1682,7 +1693,7 @@ server cluster DoorLock = 257 { readonly attribute nullable DlLockState lockState = 0; readonly attribute DlLockType lockType = 1; readonly attribute boolean actuatorEnabled = 2; - readonly attribute nullable DlDoorState doorState = 3; + readonly attribute nullable DoorStateEnum doorState = 3; readonly attribute int16u numberOfTotalUsersSupported = 17; readonly attribute int16u numberOfPINUsersSupported = 18; readonly attribute int16u numberOfRFIDUsersSupported = 19; @@ -1698,7 +1709,7 @@ server cluster DoorLock = 257 { attribute access(write: manage) char_string<3> language = 33; attribute access(write: manage) int32u autoRelockTime = 35; attribute access(write: manage) int8u soundVolume = 36; - attribute access(write: manage) DlOperatingMode operatingMode = 37; + attribute access(write: manage) OperatingModeEnum operatingMode = 37; readonly attribute DlSupportedOperatingModes supportedOperatingModes = 38; attribute access(write: manage) boolean enableOneTouchLocking = 41; attribute access(write: manage) boolean enablePrivacyModeButton = 43; @@ -1709,22 +1720,22 @@ server cluster DoorLock = 257 { readonly attribute int16u clusterRevision = 65533; request struct LockDoorRequest { - optional OCTET_STRING pinCode = 0; + optional OCTET_STRING PINCode = 0; } request struct UnlockDoorRequest { - optional OCTET_STRING pinCode = 0; + optional OCTET_STRING PINCode = 0; } request struct UnlockWithTimeoutRequest { INT16U timeout = 0; - optional OCTET_STRING pinCode = 1; + optional OCTET_STRING PINCode = 1; } request struct SetWeekDayScheduleRequest { INT8U weekDayIndex = 0; INT16U userIndex = 1; - DlDaysMaskMap daysMask = 2; + DaysMaskMap daysMask = 2; INT8U startHour = 3; INT8U startMinute = 4; INT8U endHour = 5; @@ -1762,7 +1773,7 @@ server cluster DoorLock = 257 { INT8U holidayIndex = 0; epoch_s localStartTime = 1; epoch_s localEndTime = 2; - DlOperatingMode operatingMode = 3; + OperatingModeEnum operatingMode = 3; } request struct GetHolidayScheduleRequest { @@ -1774,13 +1785,13 @@ server cluster DoorLock = 257 { } request struct SetUserRequest { - DlDataOperationType operationType = 0; + DataOperationTypeEnum operationType = 0; INT16U userIndex = 1; nullable CHAR_STRING userName = 2; - nullable INT32U userUniqueId = 3; - nullable DlUserStatus userStatus = 4; - nullable DlUserType userType = 5; - nullable DlCredentialRule credentialRule = 6; + nullable INT32U userUniqueID = 3; + nullable UserStatusEnum userStatus = 4; + nullable UserTypeEnum userType = 5; + nullable CredentialRuleEnum credentialRule = 6; } request struct GetUserRequest { @@ -1792,27 +1803,27 @@ server cluster DoorLock = 257 { } request struct SetCredentialRequest { - DlDataOperationType operationType = 0; - DlCredential credential = 1; + DataOperationTypeEnum operationType = 0; + CredentialStruct credential = 1; LONG_OCTET_STRING credentialData = 2; nullable INT16U userIndex = 3; - nullable DlUserStatus userStatus = 4; - nullable DlUserType userType = 5; + nullable UserStatusEnum userStatus = 4; + nullable UserTypeEnum userType = 5; } request struct GetCredentialStatusRequest { - DlCredential credential = 0; + CredentialStruct credential = 0; } request struct ClearCredentialRequest { - nullable DlCredential credential = 0; + nullable CredentialStruct credential = 0; } response struct GetWeekDayScheduleResponse = 12 { INT8U weekDayIndex = 0; INT16U userIndex = 1; DlStatus status = 2; - optional DlDaysMaskMap daysMask = 3; + optional DaysMaskMap daysMask = 3; optional INT8U startHour = 4; optional INT8U startMinute = 5; optional INT8U endHour = 6; @@ -1832,17 +1843,17 @@ server cluster DoorLock = 257 { DlStatus status = 1; optional epoch_s localStartTime = 2; optional epoch_s localEndTime = 3; - optional DlOperatingMode operatingMode = 4; + optional OperatingModeEnum operatingMode = 4; } response struct GetUserResponse = 28 { INT16U userIndex = 0; nullable CHAR_STRING userName = 1; - nullable INT32U userUniqueId = 2; - nullable DlUserStatus userStatus = 3; - nullable DlUserType userType = 4; - nullable DlCredentialRule credentialRule = 5; - nullable DlCredential credentials[] = 6; + nullable INT32U userUniqueID = 2; + nullable UserStatusEnum userStatus = 3; + nullable UserTypeEnum userType = 4; + nullable CredentialRuleEnum credentialRule = 5; + nullable CredentialStruct credentials[] = 6; nullable fabric_idx creatorFabricIndex = 7; nullable fabric_idx lastModifiedFabricIndex = 8; nullable INT16U nextUserIndex = 9; @@ -1900,7 +1911,7 @@ endpoint 0 { callback attribute extension; callback attribute subjectsPerAccessControlEntry default = 4; callback attribute targetsPerAccessControlEntry default = 3; - callback attribute accessControlEntriesPerFabric default = 3; + callback attribute accessControlEntriesPerFabric default = 4; callback attribute attributeList; ram attribute featureMap; ram attribute clusterRevision default = 1; diff --git a/examples/lock-app/lock-common/lock-app.zap b/examples/lock-app/lock-common/lock-app.zap index 58cd06f776bd3f..3d19bfcfd7a655 100644 --- a/examples/lock-app/lock-common/lock-app.zap +++ b/examples/lock-app/lock-common/lock-app.zap @@ -824,7 +824,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "4", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -4289,7 +4289,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "PHYRate", + "type": "PHYRateEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -4463,7 +4463,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4515,7 +4515,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -4527,7 +4527,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "CommissioningWindowStatus", + "type": "CommissioningWindowStatusEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -5217,7 +5217,7 @@ "enabled": 0, "attributes": [ { - "name": "occupancy", + "name": "Occupancy", "code": 0, "mfgCode": null, "side": "server", @@ -5233,7 +5233,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type", + "name": "OccupancySensorType", "code": 1, "mfgCode": null, "side": "server", @@ -5249,7 +5249,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type bitmap", + "name": "OccupancySensorTypeBitmap", "code": 2, "mfgCode": null, "side": "server", @@ -7031,7 +7031,7 @@ "code": 3, "mfgCode": null, "side": "server", - "type": "DlDoorState", + "type": "DoorStateEnum", "included": 1, "storageOption": "RAM", "singleton": 0, @@ -7351,7 +7351,7 @@ "code": 37, "mfgCode": null, "side": "server", - "type": "DlOperatingMode", + "type": "OperatingModeEnum", "included": 1, "storageOption": "RAM", "singleton": 0, @@ -7671,7 +7671,7 @@ "enabled": 0, "attributes": [ { - "name": "occupancy", + "name": "Occupancy", "code": 0, "mfgCode": null, "side": "server", @@ -7687,7 +7687,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type", + "name": "OccupancySensorType", "code": 1, "mfgCode": null, "side": "server", @@ -7703,7 +7703,7 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type bitmap", + "name": "OccupancySensorTypeBitmap", "code": 2, "mfgCode": null, "side": "server", diff --git a/examples/lock-app/mbed/main/AppTask.cpp b/examples/lock-app/mbed/main/AppTask.cpp index 8e2b98dac5b3f2..4e1d0c70e943cc 100644 --- a/examples/lock-app/mbed/main/AppTask.cpp +++ b/examples/lock-app/mbed/main/AppTask.cpp @@ -33,8 +33,7 @@ #include "events/EventQueue.h" // ZAP -- ZCL Advanced Platform -#include -#include +#include #include #include @@ -462,8 +461,7 @@ void AppTask::UpdateClusterState() uint8_t newValue = !BoltLockMgr().IsUnlocked(); // write the new on/off value - EmberAfStatus status = - emberAfWriteAttribute(1, app::Clusters::OnOff::Id, ZCL_ON_OFF_ATTRIBUTE_ID, &newValue, ZCL_BOOLEAN_ATTRIBUTE_TYPE); + EmberAfStatus status = app::Clusters::OnOff::Attributes::OnOff::Set(1, newValue); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ZCL update failed: %lx", status); diff --git a/examples/lock-app/nrfconnect/main/AppTask.cpp b/examples/lock-app/nrfconnect/main/AppTask.cpp index 88b58c1a32fcd8..fc6c6bece1faf2 100644 --- a/examples/lock-app/nrfconnect/main/AppTask.cpp +++ b/examples/lock-app/nrfconnect/main/AppTask.cpp @@ -23,8 +23,6 @@ #include "LEDWidget.h" #include -#include -#include #include #include #include @@ -179,7 +177,7 @@ CHIP_ERROR AppTask::Init() #ifdef CONFIG_MCUMGR_SMP_BT // Initialize DFU over SMP - GetDFUOverSMP().Init(RequestSMPAdvertisingStart); + GetDFUOverSMP().Init(); GetDFUOverSMP().ConfirmNewImage(); #endif @@ -399,16 +397,6 @@ void AppTask::FunctionTimerEventHandler(const AppEvent & event) } } -#ifdef CONFIG_MCUMGR_SMP_BT -void AppTask::RequestSMPAdvertisingStart(void) -{ - AppEvent event; - event.Type = AppEventType::StartSMPAdvertising; - event.Handler = [](const AppEvent &) { GetDFUOverSMP().StartBLEAdvertising(); }; - PostEvent(event); -} -#endif - void AppTask::FunctionHandler(const AppEvent & event) { if (event.ButtonEvent.PinNo != FUNCTION_BUTTON) diff --git a/examples/lock-app/nrfconnect/main/BoltLockManager.cpp b/examples/lock-app/nrfconnect/main/BoltLockManager.cpp index 9f82f856063aa6..fc3d30bbbf93ef 100644 --- a/examples/lock-app/nrfconnect/main/BoltLockManager.cpp +++ b/examples/lock-app/nrfconnect/main/BoltLockManager.cpp @@ -41,14 +41,14 @@ bool BoltLockManager::GetUser(uint16_t userIndex, EmberAfPluginDoorLockUserInfo user = mUsers[userIndex - 1]; ChipLogProgress(Zcl, "Getting lock user %u: %s", static_cast(userIndex), - user.userStatus == DlUserStatus::kAvailable ? "available" : "occupied"); + user.userStatus == UserStatusEnum::kAvailable ? "available" : "occupied"); return true; } bool BoltLockManager::SetUser(uint16_t userIndex, FabricIndex creator, FabricIndex modifier, const CharSpan & userName, - uint32_t uniqueId, DlUserStatus userStatus, DlUserType userType, DlCredentialRule credentialRule, - const DlCredential * credentials, size_t totalCredentials) + uint32_t uniqueId, UserStatusEnum userStatus, UserTypeEnum userType, + CredentialRuleEnum credentialRule, const CredentialStruct * credentials, size_t totalCredentials) { // userIndex is guaranteed by the caller to be between 1 and CONFIG_LOCK_NUM_USERS UserData & userData = mUserData[userIndex - 1]; @@ -58,10 +58,10 @@ bool BoltLockManager::SetUser(uint16_t userIndex, FabricIndex creator, FabricInd VerifyOrReturnError(totalCredentials <= CONFIG_LOCK_NUM_CREDENTIALS_PER_USER, false); Platform::CopyString(userData.mName, userName); - memcpy(userData.mCredentials, credentials, totalCredentials * sizeof(DlCredential)); + memcpy(userData.mCredentials, credentials, totalCredentials * sizeof(CredentialStruct)); user.userName = CharSpan(userData.mName, userName.size()); - user.credentials = Span(userData.mCredentials, totalCredentials); + user.credentials = Span(userData.mCredentials, totalCredentials); user.userUniqueId = uniqueId; user.userStatus = userStatus; user.userType = userType; @@ -72,12 +72,12 @@ bool BoltLockManager::SetUser(uint16_t userIndex, FabricIndex creator, FabricInd user.lastModifiedBy = modifier; ChipLogProgress(Zcl, "Setting lock user %u: %s", static_cast(userIndex), - userStatus == DlUserStatus::kAvailable ? "available" : "occupied"); + userStatus == UserStatusEnum::kAvailable ? "available" : "occupied"); return true; } -bool BoltLockManager::GetCredential(uint16_t credentialIndex, DlCredentialType credentialType, +bool BoltLockManager::GetCredential(uint16_t credentialIndex, CredentialTypeEnum credentialType, EmberAfPluginDoorLockCredentialInfo & credential) const { VerifyOrReturnError(credentialIndex > 0 && credentialIndex <= CONFIG_LOCK_NUM_CREDENTIALS, false); @@ -91,7 +91,7 @@ bool BoltLockManager::GetCredential(uint16_t credentialIndex, DlCredentialType c } bool BoltLockManager::SetCredential(uint16_t credentialIndex, FabricIndex creator, FabricIndex modifier, - DlCredentialStatus credentialStatus, DlCredentialType credentialType, const ByteSpan & secret) + DlCredentialStatus credentialStatus, CredentialTypeEnum credentialType, const ByteSpan & secret) { VerifyOrReturnError(credentialIndex > 0 && credentialIndex <= CONFIG_LOCK_NUM_CREDENTIALS, false); VerifyOrReturnError(secret.size() <= kMaxCredentialLength, false); @@ -118,7 +118,7 @@ bool BoltLockManager::SetCredential(uint16_t credentialIndex, FabricIndex creato return true; } -bool BoltLockManager::ValidatePIN(const Optional & pinCode, DlOperationError & err) const +bool BoltLockManager::ValidatePIN(const Optional & pinCode, OperationErrorEnum & err) const { // Optionality of the PIN code is validated by the caller, so assume it is OK not to provide the PIN code. if (!pinCode.HasValue()) @@ -129,7 +129,7 @@ bool BoltLockManager::ValidatePIN(const Optional & pinCode, DlOperatio // Check the PIN code for (const auto & credential : mCredentials) { - if (credential.status == DlCredentialStatus::kAvailable || credential.credentialType != DlCredentialType::kPin) + if (credential.status == DlCredentialStatus::kAvailable || credential.credentialType != CredentialTypeEnum::kPin) { continue; } @@ -142,7 +142,7 @@ bool BoltLockManager::ValidatePIN(const Optional & pinCode, DlOperatio } ChipLogDetail(Zcl, "Invalid lock PIN code provided"); - err = DlOperationError::kInvalidCredential; + err = OperationErrorEnum::kInvalidCredential; return false; } diff --git a/examples/lock-app/nrfconnect/main/ZclCallbacks.cpp b/examples/lock-app/nrfconnect/main/ZclCallbacks.cpp index 48ab16bb839b7d..49cdbfb84e754a 100644 --- a/examples/lock-app/nrfconnect/main/ZclCallbacks.cpp +++ b/examples/lock-app/nrfconnect/main/ZclCallbacks.cpp @@ -55,27 +55,27 @@ bool emberAfPluginDoorLockGetUser(EndpointId endpointId, uint16_t userIndex, Emb } bool emberAfPluginDoorLockSetUser(EndpointId endpointId, uint16_t userIndex, FabricIndex creator, FabricIndex modifier, - const CharSpan & userName, uint32_t uniqueId, DlUserStatus userStatus, DlUserType userType, - DlCredentialRule credentialRule, const DlCredential * credentials, size_t totalCredentials) + const CharSpan & userName, uint32_t uniqueId, UserStatusEnum userStatus, UserTypeEnum userType, + CredentialRuleEnum credentialRule, const CredentialStruct * credentials, size_t totalCredentials) { return BoltLockMgr().SetUser(userIndex, creator, modifier, userName, uniqueId, userStatus, userType, credentialRule, credentials, totalCredentials); } -bool emberAfPluginDoorLockGetCredential(EndpointId endpointId, uint16_t credentialIndex, DlCredentialType credentialType, +bool emberAfPluginDoorLockGetCredential(EndpointId endpointId, uint16_t credentialIndex, CredentialTypeEnum credentialType, EmberAfPluginDoorLockCredentialInfo & credential) { return BoltLockMgr().GetCredential(credentialIndex, credentialType, credential); } bool emberAfPluginDoorLockSetCredential(EndpointId endpointId, uint16_t credentialIndex, FabricIndex creator, FabricIndex modifier, - DlCredentialStatus credentialStatus, DlCredentialType credentialType, + DlCredentialStatus credentialStatus, CredentialTypeEnum credentialType, const ByteSpan & secret) { return BoltLockMgr().SetCredential(credentialIndex, creator, modifier, credentialStatus, credentialType, secret); } -bool emberAfPluginDoorLockOnDoorLockCommand(EndpointId endpointId, const Optional & pinCode, DlOperationError & err) +bool emberAfPluginDoorLockOnDoorLockCommand(EndpointId endpointId, const Optional & pinCode, OperationErrorEnum & err) { bool result = BoltLockMgr().ValidatePIN(pinCode, err); @@ -88,7 +88,7 @@ bool emberAfPluginDoorLockOnDoorLockCommand(EndpointId endpointId, const Optiona return result; } -bool emberAfPluginDoorLockOnDoorUnlockCommand(EndpointId endpointId, const Optional & pinCode, DlOperationError & err) +bool emberAfPluginDoorLockOnDoorUnlockCommand(EndpointId endpointId, const Optional & pinCode, OperationErrorEnum & err) { bool result = BoltLockMgr().ValidatePIN(pinCode, err); @@ -119,8 +119,8 @@ void emberAfDoorLockClusterInitCallback(EndpointId endpoint) logOnFailure(DoorLock::Attributes::NumberOfCredentialsSupportedPerUser::Set(endpoint, CONFIG_LOCK_NUM_CREDENTIALS_PER_USER), "number of credentials per user"); - // Set FeatureMap to (kUsersManagement|kPINCredentials), default is: - // (kUsersManagement|kAccessSchedules|kRFIDCredentials|kPINCredentials) 0x113 + // Set FeatureMap to (kUser|kPinCredential), default is: + // (kUser|kAccessSchedules|kRfidCredential|kPinCredential) 0x113 logOnFailure(DoorLock::Attributes::FeatureMap::Set(endpoint, 0x101), "feature map"); AppTask::Instance().UpdateClusterState(BoltLockMgr().GetState(), BoltLockManager::OperationSource::kUnspecified); diff --git a/examples/lock-app/nrfconnect/main/include/AppEvent.h b/examples/lock-app/nrfconnect/main/include/AppEvent.h index f171149750e181..3189e78d848deb 100644 --- a/examples/lock-app/nrfconnect/main/include/AppEvent.h +++ b/examples/lock-app/nrfconnect/main/include/AppEvent.h @@ -34,7 +34,6 @@ enum class AppEventType : uint8_t UpdateLedState, IdentifyStart, IdentifyStop, - StartSMPAdvertising }; enum class FunctionEvent : uint8_t diff --git a/examples/lock-app/nrfconnect/main/include/AppTask.h b/examples/lock-app/nrfconnect/main/include/AppTask.h index a23ad0f64b4ad7..841362ed6ba8ce 100644 --- a/examples/lock-app/nrfconnect/main/include/AppTask.h +++ b/examples/lock-app/nrfconnect/main/include/AppTask.h @@ -76,10 +76,6 @@ class AppTask static void LockStateChanged(BoltLockManager::State state, BoltLockManager::OperationSource source); -#ifdef CONFIG_MCUMGR_SMP_BT - static void RequestSMPAdvertisingStart(void); -#endif - FunctionEvent mFunction = FunctionEvent::NoneSelected; bool mFunctionTimerActive = false; diff --git a/examples/lock-app/nrfconnect/main/include/BoltLockManager.h b/examples/lock-app/nrfconnect/main/include/BoltLockManager.h index b5b5b66b9b1aef..bd107f7f77626f 100644 --- a/examples/lock-app/nrfconnect/main/include/BoltLockManager.h +++ b/examples/lock-app/nrfconnect/main/include/BoltLockManager.h @@ -45,7 +45,7 @@ class BoltLockManager struct UserData { char mName[DOOR_LOCK_USER_NAME_BUFFER_SIZE]; - DlCredential mCredentials[CONFIG_LOCK_NUM_CREDENTIALS_PER_USER]; + CredentialStruct mCredentials[CONFIG_LOCK_NUM_CREDENTIALS_PER_USER]; }; struct CredentialData @@ -53,7 +53,7 @@ class BoltLockManager chip::Platform::ScopedMemoryBuffer mSecret; }; - using OperationSource = chip::app::Clusters::DoorLock::DlOperationSource; + using OperationSource = chip::app::Clusters::DoorLock::OperationSourceEnum; using StateChangeCallback = void (*)(State, OperationSource); static constexpr uint32_t kActuatorMovementTimeMs = 2000; @@ -65,15 +65,15 @@ class BoltLockManager bool GetUser(uint16_t userIndex, EmberAfPluginDoorLockUserInfo & user) const; bool SetUser(uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, const chip::CharSpan & userName, - uint32_t uniqueId, DlUserStatus userStatus, DlUserType userType, DlCredentialRule credentialRule, - const DlCredential * credentials, size_t totalCredentials); + uint32_t uniqueId, UserStatusEnum userStatus, UserTypeEnum userType, CredentialRuleEnum credentialRule, + const CredentialStruct * credentials, size_t totalCredentials); - bool GetCredential(uint16_t credentialIndex, DlCredentialType credentialType, + bool GetCredential(uint16_t credentialIndex, CredentialTypeEnum credentialType, EmberAfPluginDoorLockCredentialInfo & credential) const; bool SetCredential(uint16_t credentialIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - DlCredentialStatus credentialStatus, DlCredentialType credentialType, const chip::ByteSpan & secret); + DlCredentialStatus credentialStatus, CredentialTypeEnum credentialType, const chip::ByteSpan & secret); - bool ValidatePIN(const Optional & pinCode, DlOperationError & err) const; + bool ValidatePIN(const Optional & pinCode, OperationErrorEnum & err) const; void Lock(OperationSource source); void Unlock(OperationSource source); diff --git a/examples/lock-app/nxp/k32w/k32w0/main/AppTask.cpp b/examples/lock-app/nxp/k32w/k32w0/main/AppTask.cpp index deba6a5c63772d..5971c4ea7c28e0 100644 --- a/examples/lock-app/nxp/k32w/k32w0/main/AppTask.cpp +++ b/examples/lock-app/nxp/k32w/k32w0/main/AppTask.cpp @@ -30,8 +30,7 @@ #include #include -#include -#include +#include #include #include @@ -763,8 +762,7 @@ void AppTask::UpdateClusterStateInternal(intptr_t arg) uint8_t newValue = !BoltLockMgr().IsUnlocked(); // write the new on/off value - EmberAfStatus status = emberAfWriteAttribute(1, chip::app::Clusters::OnOff::Id, ZCL_ON_OFF_ATTRIBUTE_ID, (uint8_t *) &newValue, - ZCL_BOOLEAN_ATTRIBUTE_TYPE); + EmberAfStatus status = chip::app::Clusters::OnOff::Attributes::OnOff::Set(1, newValue); if (status != EMBER_ZCL_STATUS_SUCCESS) { ChipLogError(NotSpecified, "ERR: updating on/off %x", status); diff --git a/examples/lock-app/openiotsdk/CMakeLists.txt b/examples/lock-app/openiotsdk/CMakeLists.txt index 1e0125b99c0497..ec75b81afdf3d2 100644 --- a/examples/lock-app/openiotsdk/CMakeLists.txt +++ b/examples/lock-app/openiotsdk/CMakeLists.txt @@ -19,11 +19,15 @@ cmake_minimum_required(VERSION 3.21) get_filename_component(CHIP_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../.. REALPATH) get_filename_component(OPEN_IOT_SDK_CONFIG ${CHIP_ROOT}/config/openiotsdk REALPATH) get_filename_component(OPEN_IOT_SDK_EXAMPLE_COMMON ${CHIP_ROOT}/examples/platform/openiotsdk REALPATH) -get_filename_component(GEN_DIR ${CHIP_ROOT}/zzz_generated/ REALPATH) list(APPEND CMAKE_MODULE_PATH ${OPEN_IOT_SDK_CONFIG}/cmake) -set(APP_TARGET chip-openiotsdk-lock-app-example) +set(APP_TARGET chip-openiotsdk-lock-app-example_ns) + +set(TFM_SUPPORT YES) +set(TFM_PROJECT_CONFIG_HEADER_FILE "${CMAKE_CURRENT_SOURCE_DIR}/tf-m-config/TfmProjectConfig.h") +set(TFM_NS_APP_VERSION "0.0.1") +set(CONFIG_CHIP_OPEN_IOT_SDK_USE_PSA_PS YES) # Toolchain files need to exist before first call to project include(toolchain) @@ -55,16 +59,16 @@ include(chip) add_subdirectory(${OPEN_IOT_SDK_EXAMPLE_COMMON}/app ./app_build) -target_include_directories(${APP_TARGET} +chip_add_data_model(openiotsdk-app PUBLIC lock) + +target_include_directories(${APP_TARGET} PRIVATE main/include - ${GEN_DIR}/app-common - ${GEN_DIR}/lock-app ) -target_sources(${APP_TARGET} +target_sources(${APP_TARGET} PRIVATE - main/main.cpp + main/main_ns.cpp main/ZclCallbacks.cpp main/LockManager.cpp main/LockEndpoint.cpp @@ -74,11 +78,7 @@ target_link_libraries(${APP_TARGET} openiotsdk-app ) -include(${CHIP_ROOT}/src/app/chip_data_model.cmake) -chip_configure_data_model(${APP_TARGET} - INCLUDE_SERVER - ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../lock-common/lock-app.zap -) - include(linker) set_target_link(${APP_TARGET}) + +sdk_post_build(${APP_TARGET}) diff --git a/examples/lock-app/openiotsdk/cmsis-config/RTE_Components.h b/examples/lock-app/openiotsdk/cmsis-config/RTE_Components.h index 3921500daecafb..e86df2b4e44e06 100644 --- a/examples/lock-app/openiotsdk/cmsis-config/RTE_Components.h +++ b/examples/lock-app/openiotsdk/cmsis-config/RTE_Components.h @@ -19,6 +19,4 @@ #ifndef RTE_COMPONENTS_H #define RTE_COMPONENTS_H -#define OS_STACK_SIZE (4 * 1024) - #endif // RTE_COMPONENTS_H diff --git a/examples/lock-app/openiotsdk/freertos-config/FreeRTOSConfig.h b/examples/lock-app/openiotsdk/freertos-config/FreeRTOSConfig.h index c95af61db3c84d..bfcd8f09e9b4aa 100644 --- a/examples/lock-app/openiotsdk/freertos-config/FreeRTOSConfig.h +++ b/examples/lock-app/openiotsdk/freertos-config/FreeRTOSConfig.h @@ -190,7 +190,7 @@ extern uint32_t SystemCoreClock; // Use TrustZone Secure Side Only // This settings prevents FreeRTOS contex switch to Non-Secure side. // Enable this setting when FreeRTOS runs on the Secure side only. -#define configRUN_FREERTOS_SECURE_ONLY 1 +#define configRUN_FREERTOS_SECURE_ONLY CONFIG_RUN_FREERTOS_SECURE_ONLY // Use TrustZone Security Extension // Using TrustZone affects context handling. diff --git a/examples/lock-app/openiotsdk/main/LockEndpoint.cpp b/examples/lock-app/openiotsdk/main/LockEndpoint.cpp index 82e91a53aceb23..453520c6470cca 100644 --- a/examples/lock-app/openiotsdk/main/LockEndpoint.cpp +++ b/examples/lock-app/openiotsdk/main/LockEndpoint.cpp @@ -21,12 +21,12 @@ using chip::to_underlying; -bool LockEndpoint::Lock(const Optional & pin, DlOperationError & err) +bool LockEndpoint::Lock(const Optional & pin, OperationErrorEnum & err) { return setLockState(DlLockState::kLocked, pin, err); } -bool LockEndpoint::Unlock(const Optional & pin, DlOperationError & err) +bool LockEndpoint::Unlock(const Optional & pin, OperationErrorEnum & err) { return setLockState(DlLockState::kUnlocked, pin, err); } @@ -45,14 +45,14 @@ bool LockEndpoint::GetUser(uint16_t userIndex, EmberAfPluginDoorLockUserInfo & u const auto & userInDb = mLockUsers[adjustedUserIndex]; user.userStatus = userInDb.userStatus; - if (DlUserStatus::kAvailable == user.userStatus) + if (UserStatusEnum::kAvailable == user.userStatus) { ChipLogDetail(Zcl, "Found unoccupied user [endpoint=%d,adjustedIndex=%hu]", mEndpointId, adjustedUserIndex); return true; } user.userName = chip::CharSpan(userInDb.userName, strlen(userInDb.userName)); - user.credentials = chip::Span(userInDb.credentials.data(), userInDb.credentials.size()); + user.credentials = chip::Span(userInDb.credentials.data(), userInDb.credentials.size()); user.userUniqueId = userInDb.userUniqueId; user.userType = userInDb.userType; user.credentialRule = userInDb.credentialRule; @@ -71,8 +71,8 @@ bool LockEndpoint::GetUser(uint16_t userIndex, EmberAfPluginDoorLockUserInfo & u } bool LockEndpoint::SetUser(uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - const chip::CharSpan & userName, uint32_t uniqueId, DlUserStatus userStatus, DlUserType usertype, - DlCredentialRule credentialRule, const DlCredential * credentials, size_t totalCredentials) + const chip::CharSpan & userName, uint32_t uniqueId, UserStatusEnum userStatus, UserTypeEnum usertype, + CredentialRuleEnum credentialRule, const CredentialStruct * credentials, size_t totalCredentials) { ChipLogProgress(Zcl, "SetUser " @@ -130,13 +130,14 @@ bool LockEndpoint::SetUser(uint16_t userIndex, chip::FabricIndex creator, chip:: return true; } -bool LockEndpoint::GetCredential(uint16_t credentialIndex, DlCredentialType credentialType, +bool LockEndpoint::GetCredential(uint16_t credentialIndex, CredentialTypeEnum credentialType, EmberAfPluginDoorLockCredentialInfo & credential) const { ChipLogDetail(Zcl, "GetCredential [endpoint=%d,credentialIndex=%u,credentialType=%u]", mEndpointId, credentialIndex, to_underlying(credentialType)); - if (credentialIndex >= mLockCredentials.size() || (0 == credentialIndex && DlCredentialType::kProgrammingPIN != credentialType)) + if (credentialIndex >= mLockCredentials.size() || + (0 == credentialIndex && CredentialTypeEnum::kProgrammingPIN != credentialType)) { ChipLogError(Zcl, "Cannot get the credential - index out of range [endpoint=%d,index=%d]", mEndpointId, credentialIndex); return false; @@ -163,7 +164,7 @@ bool LockEndpoint::GetCredential(uint16_t credentialIndex, DlCredentialType cred } bool LockEndpoint::SetCredential(uint16_t credentialIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - DlCredentialStatus credentialStatus, DlCredentialType credentialType, + DlCredentialStatus credentialStatus, CredentialTypeEnum credentialType, const chip::ByteSpan & credentialData) { ChipLogDetail( @@ -173,7 +174,8 @@ bool LockEndpoint::SetCredential(uint16_t credentialIndex, chip::FabricIndex cre mEndpointId, credentialIndex, to_underlying(credentialStatus), to_underlying(credentialType), static_cast(credentialData.size()), creator, modifier); - if (credentialIndex >= mLockCredentials.size() || (0 == credentialIndex && DlCredentialType::kProgrammingPIN != credentialType)) + if (credentialIndex >= mLockCredentials.size() || + (0 == credentialIndex && CredentialTypeEnum::kProgrammingPIN != credentialType)) { ChipLogError(Zcl, "Cannot set the credential - index out of range [endpoint=%d,index=%d]", mEndpointId, credentialIndex); return false; @@ -226,7 +228,7 @@ DlStatus LockEndpoint::GetSchedule(uint8_t weekDayIndex, uint16_t userIndex, Emb return DlStatus::kSuccess; } -DlStatus LockEndpoint::SetSchedule(uint8_t weekDayIndex, uint16_t userIndex, DlScheduleStatus status, DlDaysMaskMap daysMask, +DlStatus LockEndpoint::SetSchedule(uint8_t weekDayIndex, uint16_t userIndex, DlScheduleStatus status, DaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute) { if (0 == userIndex || userIndex > mWeekDaySchedules.size()) @@ -295,7 +297,7 @@ DlStatus LockEndpoint::SetSchedule(uint8_t yearDayIndex, uint16_t userIndex, DlS return DlStatus::kSuccess; } -bool LockEndpoint::setLockState(DlLockState lockState, const Optional & pin, DlOperationError & err) +bool LockEndpoint::setLockState(DlLockState lockState, const Optional & pin, OperationErrorEnum & err) { if (!pin.HasValue()) { @@ -308,7 +310,7 @@ bool LockEndpoint::setLockState(DlLockState lockState, const Optional & pin, DlOperationError & err) +bool LockManager::Lock(chip::EndpointId endpointId, const Optional & pin, OperationErrorEnum & err) { auto lockEndpoint = getEndpoint(endpointId); if (nullptr == lockEndpoint) @@ -118,7 +118,7 @@ bool LockManager::Lock(chip::EndpointId endpointId, const Optional & pin, DlOperationError & err) +bool LockManager::Unlock(chip::EndpointId endpointId, const Optional & pin, OperationErrorEnum & err) { auto lockEndpoint = getEndpoint(endpointId); if (nullptr == lockEndpoint) @@ -144,8 +144,8 @@ bool LockManager::GetUser(chip::EndpointId endpointId, uint16_t userIndex, Ember } bool LockManager::SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - const chip::CharSpan & userName, uint32_t uniqueId, DlUserStatus userStatus, DlUserType usertype, - DlCredentialRule credentialRule, const DlCredential * credentials, size_t totalCredentials) + const chip::CharSpan & userName, uint32_t uniqueId, UserStatusEnum userStatus, UserTypeEnum usertype, + CredentialRuleEnum credentialRule, const CredentialStruct * credentials, size_t totalCredentials) { auto lockEndpoint = getEndpoint(endpointId); if (nullptr == lockEndpoint) @@ -157,7 +157,7 @@ bool LockManager::SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip: credentials, totalCredentials); } -bool LockManager::GetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, DlCredentialType credentialType, +bool LockManager::GetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, CredentialTypeEnum credentialType, EmberAfPluginDoorLockCredentialInfo & credential) { auto lockEndpoint = getEndpoint(endpointId); @@ -170,7 +170,7 @@ bool LockManager::GetCredential(chip::EndpointId endpointId, uint16_t credential } bool LockManager::SetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, chip::FabricIndex creator, - chip::FabricIndex modifier, DlCredentialStatus credentialStatus, DlCredentialType credentialType, + chip::FabricIndex modifier, DlCredentialStatus credentialStatus, CredentialTypeEnum credentialType, const chip::ByteSpan & credentialData) { auto lockEndpoint = getEndpoint(endpointId); @@ -196,8 +196,7 @@ DlStatus LockManager::GetSchedule(chip::EndpointId endpointId, uint8_t weekDayIn } DlStatus LockManager::SetSchedule(chip::EndpointId endpointId, uint8_t weekDayIndex, uint16_t userIndex, DlScheduleStatus status, - DlDaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, - uint8_t endMinute) + DaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute) { auto lockEndpoint = getEndpoint(endpointId); if (nullptr == lockEndpoint) diff --git a/examples/lock-app/openiotsdk/main/ZclCallbacks.cpp b/examples/lock-app/openiotsdk/main/ZclCallbacks.cpp index f383377cfd77f7..0ebcf686bbebcc 100644 --- a/examples/lock-app/openiotsdk/main/ZclCallbacks.cpp +++ b/examples/lock-app/openiotsdk/main/ZclCallbacks.cpp @@ -25,13 +25,14 @@ using namespace chip; using namespace chip::app::Clusters; using namespace chip::app::Clusters::DoorLock; -bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const Optional & pinCode, DlOperationError & err) +bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const Optional & pinCode, + OperationErrorEnum & err) { return LockManager::Instance().Lock(endpointId, pinCode, err); } bool emberAfPluginDoorLockOnDoorUnlockCommand(chip::EndpointId endpointId, const Optional & pinCode, - DlOperationError & err) + OperationErrorEnum & err) { return LockManager::Instance().Unlock(endpointId, pinCode, err); } @@ -43,15 +44,15 @@ bool emberAfPluginDoorLockGetUser(chip::EndpointId endpointId, uint16_t userInde bool emberAfPluginDoorLockSetUser(chip::EndpointId endpointId, uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, const chip::CharSpan & userName, uint32_t uniqueId, - DlUserStatus userStatus, DlUserType usertype, DlCredentialRule credentialRule, - const DlCredential * credentials, size_t totalCredentials) + UserStatusEnum userStatus, UserTypeEnum usertype, CredentialRuleEnum credentialRule, + const CredentialStruct * credentials, size_t totalCredentials) { return LockManager::Instance().SetUser(endpointId, userIndex, creator, modifier, userName, uniqueId, userStatus, usertype, credentialRule, credentials, totalCredentials); } -bool emberAfPluginDoorLockGetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, DlCredentialType credentialType, +bool emberAfPluginDoorLockGetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, CredentialTypeEnum credentialType, EmberAfPluginDoorLockCredentialInfo & credential) { return LockManager::Instance().GetCredential(endpointId, credentialIndex, credentialType, credential); @@ -59,7 +60,7 @@ bool emberAfPluginDoorLockGetCredential(chip::EndpointId endpointId, uint16_t cr bool emberAfPluginDoorLockSetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, chip::FabricIndex creator, chip::FabricIndex modifier, DlCredentialStatus credentialStatus, - DlCredentialType credentialType, const chip::ByteSpan & credentialData) + CredentialTypeEnum credentialType, const chip::ByteSpan & credentialData) { return LockManager::Instance().SetCredential(endpointId, credentialIndex, creator, modifier, credentialStatus, credentialType, credentialData); @@ -72,7 +73,7 @@ DlStatus emberAfPluginDoorLockGetSchedule(chip::EndpointId endpointId, uint8_t w } DlStatus emberAfPluginDoorLockSetSchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex, - DlScheduleStatus status, DlDaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, + DlScheduleStatus status, DaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute) { return LockManager::Instance().SetSchedule(endpointId, weekdayIndex, userIndex, status, daysMask, startHour, startMinute, diff --git a/examples/lock-app/openiotsdk/main/include/LockEndpoint.h b/examples/lock-app/openiotsdk/main/include/LockEndpoint.h index bee91e7265239f..069ab270707f1f 100644 --- a/examples/lock-app/openiotsdk/main/include/LockEndpoint.h +++ b/examples/lock-app/openiotsdk/main/include/LockEndpoint.h @@ -25,10 +25,10 @@ struct LockUserInfo { char userName[DOOR_LOCK_USER_NAME_BUFFER_SIZE]; uint32_t userUniqueId; - DlUserStatus userStatus; - DlUserType userType; - DlCredentialRule credentialRule; - std::vector credentials; + UserStatusEnum userStatus; + UserTypeEnum userType; + CredentialRuleEnum credentialRule; + std::vector credentials; chip::FabricIndex createdBy; chip::FabricIndex lastModifiedBy; }; @@ -58,29 +58,30 @@ class LockEndpoint inline chip::EndpointId GetEndpointId() const { return mEndpointId; } - bool Lock(const Optional & pin, DlOperationError & err); - bool Unlock(const Optional & pin, DlOperationError & err); + bool Lock(const Optional & pin, OperationErrorEnum & err); + bool Unlock(const Optional & pin, OperationErrorEnum & err); bool GetUser(uint16_t userIndex, EmberAfPluginDoorLockUserInfo & user) const; bool SetUser(uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, const chip::CharSpan & userName, - uint32_t uniqueId, DlUserStatus userStatus, DlUserType usertype, DlCredentialRule credentialRule, - const DlCredential * credentials, size_t totalCredentials); + uint32_t uniqueId, UserStatusEnum userStatus, UserTypeEnum usertype, CredentialRuleEnum credentialRule, + const CredentialStruct * credentials, size_t totalCredentials); - bool GetCredential(uint16_t credentialIndex, DlCredentialType credentialType, + bool GetCredential(uint16_t credentialIndex, CredentialTypeEnum credentialType, EmberAfPluginDoorLockCredentialInfo & credential) const; bool SetCredential(uint16_t credentialIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - DlCredentialStatus credentialStatus, DlCredentialType credentialType, const chip::ByteSpan & credentialData); + DlCredentialStatus credentialStatus, CredentialTypeEnum credentialType, + const chip::ByteSpan & credentialData); DlStatus GetSchedule(uint8_t weekDayIndex, uint16_t userIndex, EmberAfPluginDoorLockWeekDaySchedule & schedule); DlStatus GetSchedule(uint8_t yearDayIndex, uint16_t userIndex, EmberAfPluginDoorLockYearDaySchedule & schedule); - DlStatus SetSchedule(uint8_t weekDayIndex, uint16_t userIndex, DlScheduleStatus status, DlDaysMaskMap daysMask, - uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute); + DlStatus SetSchedule(uint8_t weekDayIndex, uint16_t userIndex, DlScheduleStatus status, DaysMaskMap daysMask, uint8_t startHour, + uint8_t startMinute, uint8_t endHour, uint8_t endMinute); DlStatus SetSchedule(uint8_t yearDayIndex, uint16_t userIndex, DlScheduleStatus status, uint32_t localStartTime, uint32_t localEndTime); private: - bool setLockState(DlLockState lockState, const Optional & pin, DlOperationError & err); + bool setLockState(DlLockState lockState, const Optional & pin, OperationErrorEnum & err); const char * lockStateToString(DlLockState lockState) const; chip::EndpointId mEndpointId; @@ -97,7 +98,7 @@ class LockEndpoint struct LockCredentialInfo { DlCredentialStatus status; - DlCredentialType credentialType; + CredentialTypeEnum credentialType; chip::FabricIndex createdBy; chip::FabricIndex modifiedBy; uint8_t credentialData[DOOR_LOCK_CREDENTIAL_INFO_MAX_DATA_SIZE]; diff --git a/examples/lock-app/openiotsdk/main/include/LockManager.h b/examples/lock-app/openiotsdk/main/include/LockManager.h index 2fccdc9745f7a7..349fee22adee8a 100644 --- a/examples/lock-app/openiotsdk/main/include/LockManager.h +++ b/examples/lock-app/openiotsdk/main/include/LockManager.h @@ -31,26 +31,27 @@ class LockManager bool InitEndpoint(chip::EndpointId endpointId); - bool Lock(chip::EndpointId endpointId, const Optional & pin, DlOperationError & err); - bool Unlock(chip::EndpointId endpointId, const Optional & pin, DlOperationError & err); + bool Lock(chip::EndpointId endpointId, const Optional & pin, OperationErrorEnum & err); + bool Unlock(chip::EndpointId endpointId, const Optional & pin, OperationErrorEnum & err); bool GetUser(chip::EndpointId endpointId, uint16_t userIndex, EmberAfPluginDoorLockUserInfo & user); bool SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - const chip::CharSpan & userName, uint32_t uniqueId, DlUserStatus userStatus, DlUserType usertype, - DlCredentialRule credentialRule, const DlCredential * credentials, size_t totalCredentials); + const chip::CharSpan & userName, uint32_t uniqueId, UserStatusEnum userStatus, UserTypeEnum usertype, + CredentialRuleEnum credentialRule, const CredentialStruct * credentials, size_t totalCredentials); - bool GetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, DlCredentialType credentialType, + bool GetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, CredentialTypeEnum credentialType, EmberAfPluginDoorLockCredentialInfo & credential); bool SetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - DlCredentialStatus credentialStatus, DlCredentialType credentialType, const chip::ByteSpan & credentialData); + DlCredentialStatus credentialStatus, CredentialTypeEnum credentialType, + const chip::ByteSpan & credentialData); DlStatus GetSchedule(chip::EndpointId endpointId, uint8_t weekDayIndex, uint16_t userIndex, EmberAfPluginDoorLockWeekDaySchedule & schedule); DlStatus GetSchedule(chip::EndpointId endpointId, uint8_t yearDayIndex, uint16_t userIndex, EmberAfPluginDoorLockYearDaySchedule & schedule); DlStatus SetSchedule(chip::EndpointId endpointId, uint8_t weekDayIndex, uint16_t userIndex, DlScheduleStatus status, - DlDaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute); + DaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute); DlStatus SetSchedule(chip::EndpointId endpointId, uint8_t yearDayIndex, uint16_t userIndex, DlScheduleStatus status, uint32_t localStartTime, uint32_t localEndTime); diff --git a/examples/lock-app/openiotsdk/main/main.cpp b/examples/lock-app/openiotsdk/main/main_ns.cpp similarity index 63% rename from examples/lock-app/openiotsdk/main/main.cpp rename to examples/lock-app/openiotsdk/main/main_ns.cpp index fbd72e0542fc85..2b6484b05180c2 100644 --- a/examples/lock-app/openiotsdk/main/main.cpp +++ b/examples/lock-app/openiotsdk/main/main_ns.cpp @@ -18,48 +18,23 @@ #include #include -#include #include -#include - -#include -#include -#include -#include #include "openiotsdk_platform.h" -using namespace ::chip; -using namespace ::chip::DeviceLayer; - static void app_thread(void * argument) { - CHIP_ERROR error; - if (openiotsdk_network_init(true)) { ChipLogError(NotSpecified, "Network initialization failed"); goto exit; } - // Init ZCL Data Model and start server - static chip::CommonCaseDeviceServerInitParams initParams; - (void) initParams.InitializeStaticResourcesBeforeServerInit(); - initParams.operationalServicePort = CHIP_PORT; - initParams.userDirectedCommissioningPort = CHIP_UDC_PORT; - - error = Server::GetInstance().Init(initParams); - SuccessOrExit(error); - - // Now that the server has started and we are done with our startup logging, - // log our discovery/onboarding information again so it's not lost in the - // noise. - ConfigurationMgr().LogDeviceConfig(); - - PrintOnboardingCodes(RendezvousInformationFlags(RendezvousInformationFlag::kOnNetwork)); - - // Initialize device attestation config - SetDeviceAttestationCredentialsProvider(Credentials::Examples::GetExampleDACProvider()); + if (openiotsdk_chip_run()) + { + ChipLogError(NotSpecified, "CHIP stack run failed"); + goto exit; + } ChipLogProgress(NotSpecified, "Open IoT SDK lock-app example application run"); @@ -69,7 +44,7 @@ static void app_thread(void * argument) osDelay(osWaitForever); } - Server::GetInstance().Shutdown(); + openiotsdk_chip_shutdown(); exit: osThreadTerminate(osThreadGetId()); diff --git a/examples/lock-app/openiotsdk/tf-m-config/TfmProjectConfig.h b/examples/lock-app/openiotsdk/tf-m-config/TfmProjectConfig.h new file mode 100644 index 00000000000000..a792f400bd2660 --- /dev/null +++ b/examples/lock-app/openiotsdk/tf-m-config/TfmProjectConfig.h @@ -0,0 +1,165 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef TFM_PROJECT_CONFIG_H +#define TFM_PROJECT_CONFIG_H + +/* Platform Partition Configs */ + +/* Size of input buffer in platform service */ +#define PLATFORM_SERVICE_INPUT_BUFFER_SIZE 64 + +/* Size of output buffer in platform service */ +#define PLATFORM_SERVICE_OUTPUT_BUFFER_SIZE 64 + +/* The stack size of the Platform Secure Partition */ +#define PLATFORM_SP_STACK_SIZE 0x500 + +/* Disable Non-volatile counter module */ +#define PLATFORM_NV_COUNTER_MODULE_DISABLED 0 + +/* Crypto Partition Configs */ + +/* + * Heap size for the crypto backend + * CRYPTO_ENGINE_BUF_SIZE needs to be >8KB for EC signing by attest module. + */ +#define CRYPTO_ENGINE_BUF_SIZE 0x2080 + +/* The max number of concurrent operations that can be active (allocated) at any time in Crypto */ +#define CRYPTO_CONC_OPER_NUM 8 + +/* Enable PSA Crypto random number generator module */ +#define CRYPTO_RNG_MODULE_ENABLED 1 + +/* Enable PSA Crypto Key module */ +#define CRYPTO_KEY_MODULE_ENABLED 1 + +/* Enable PSA Crypto AEAD module */ +#define CRYPTO_AEAD_MODULE_ENABLED 1 + +/* Enable PSA Crypto MAC module */ +#define CRYPTO_MAC_MODULE_ENABLED 1 + +/* Enable PSA Crypto Hash module */ +#define CRYPTO_HASH_MODULE_ENABLED 1 + +/* Enable PSA Crypto Cipher module */ +#define CRYPTO_CIPHER_MODULE_ENABLED 1 + +/* Enable PSA Crypto asymmetric key signature module */ +#define CRYPTO_ASYM_SIGN_MODULE_ENABLED 1 + +/* Enable PSA Crypto asymmetric key encryption module */ +#define CRYPTO_ASYM_ENCRYPT_MODULE_ENABLED 0 + +/* Enable PSA Crypto key derivation module */ +#define CRYPTO_KEY_DERIVATION_MODULE_ENABLED 1 + +/* Default size of the internal scratch buffer used for PSA FF IOVec allocations */ +#define CRYPTO_IOVEC_BUFFER_SIZE 5120 + +/* Use stored NV seed to provide entropy */ +#define CRYPTO_NV_SEED 1 + +/* + * Only enable multi-part operations in Hash, MAC, AEAD and symmetric ciphers, + * to optimize memory footprint in resource-constrained devices. + */ +#define CRYPTO_SINGLE_PART_FUNCS_DISABLED 0 + +/* The stack size of the Crypto Secure Partition */ +#define CRYPTO_STACK_SIZE 0x1B00 + +/* FWU Partition Configs */ + +/* Size of the FWU internal data transfer buffer */ +#define TFM_FWU_BUF_SIZE PSA_FWU_MAX_WRITE_SIZE + +/* The stack size of the Firmware Update Secure Partition */ +#define FWU_STACK_SIZE 0x600 + +/* Attest Partition Configs */ + +/* Include optional claims in initial attestation token */ +#define ATTEST_INCLUDE_OPTIONAL_CLAIMS 1 + +/* Include COSE key-id in initial attestation token */ +#define ATTEST_INCLUDE_COSE_KEY_ID 0 + +/* The stack size of the Initial Attestation Secure Partition */ +#define ATTEST_STACK_SIZE 0x700 + +/* Set the initial attestation token profile */ +#define ATTEST_TOKEN_PROFILE_PSA_IOT_1 1 + +/* ITS Partition Configs */ + +/* Create flash FS if it doesn't exist for Internal Trusted Storage partition */ +#define ITS_CREATE_FLASH_LAYOUT 1 + +/* Enable emulated RAM FS for platforms that don't have flash for Internal Trusted Storage partition */ +#define ITS_RAM_FS 0 + +/* Validate filesystem metadata every time it is read from flash */ +#define ITS_VALIDATE_METADATA_FROM_FLASH 1 + +/* The maximum asset size to be stored in the Internal Trusted Storage */ +#define ITS_MAX_ASSET_SIZE 512 + +/* Size of the ITS internal data transfer buffer */ +#define ITS_BUF_SIZE 32 + +/* The maximum number of assets to be stored in the Internal Trusted Storage */ +#define ITS_NUM_ASSETS 10 + +/* The stack size of the Internal Trusted Storage Secure Partition */ +#define ITS_STACK_SIZE 0x720 + +/* PS Partition Configs */ + +/* Create flash FS if it doesn't exist for Protected Storage partition */ +#define PS_CREATE_FLASH_LAYOUT 1 + +/* Enable emulated RAM FS for platforms that don't have flash for Protected Storage partition */ +#define PS_RAM_FS 0 + +/* Enable rollback protection for Protected Storage partition */ +#define PS_ROLLBACK_PROTECTION 1 + +/* Validate filesystem metadata every time it is read from flash */ +#define PS_VALIDATE_METADATA_FROM_FLASH 1 + +/* The maximum asset size to be stored in the Protected Storage */ +#define PS_MAX_ASSET_SIZE 2048 + +/* The maximum number of assets to be stored in the Protected Storage */ +#define PS_NUM_ASSETS 30 + +/* The stack size of the Protected Storage Secure Partition */ +#define PS_STACK_SIZE 0x700 + +/* SPM Partition Configs */ + +/* The maximal number of secure services that are connected or requested at the same time */ +#define CONFIG_TFM_CONN_HANDLE_MAX_NUM 8 + +/* Enable the doorbell APIs */ +#define CONFIG_TFM_DOORBELL_API 1 + +#endif /* TFM_PROJECT_CONFIG_H */ diff --git a/examples/lock-app/qpg/include/BoltLockManager.h b/examples/lock-app/qpg/include/BoltLockManager.h index 005dd8711b5161..c80e3555fc8d3d 100644 --- a/examples/lock-app/qpg/include/BoltLockManager.h +++ b/examples/lock-app/qpg/include/BoltLockManager.h @@ -55,7 +55,7 @@ class BoltLockManager struct UserData { char mName[DOOR_LOCK_USER_NAME_BUFFER_SIZE]; - DlCredential mCredentials[CONFIG_LOCK_NUM_CREDENTIALS_PER_USER]; + CredentialStruct mCredentials[CONFIG_LOCK_NUM_CREDENTIALS_PER_USER]; }; struct CredentialData @@ -75,15 +75,15 @@ class BoltLockManager void SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Callback_fn_completed aActionCompleted_CB); bool GetUser(uint16_t userIndex, EmberAfPluginDoorLockUserInfo & user) const; bool SetUser(uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, const chip::CharSpan & userName, - uint32_t uniqueId, DlUserStatus userStatus, DlUserType userType, DlCredentialRule credentialRule, - const DlCredential * credentials, size_t totalCredentials); + uint32_t uniqueId, UserStatusEnum userStatus, UserTypeEnum userType, CredentialRuleEnum credentialRule, + const CredentialStruct * credentials, size_t totalCredentials); - bool GetCredential(uint16_t credentialIndex, DlCredentialType credentialType, + bool GetCredential(uint16_t credentialIndex, CredentialTypeEnum credentialType, EmberAfPluginDoorLockCredentialInfo & credential) const; bool SetCredential(uint16_t credentialIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - DlCredentialStatus credentialStatus, DlCredentialType credentialType, const chip::ByteSpan & secret); + DlCredentialStatus credentialStatus, CredentialTypeEnum credentialType, const chip::ByteSpan & secret); - bool ValidatePIN(const Optional & pinCode, DlOperationError & err) const; + bool ValidatePIN(const Optional & pinCode, OperationErrorEnum & err) const; private: friend BoltLockManager & BoltLockMgr(void); diff --git a/examples/lock-app/qpg/src/AppTask.cpp b/examples/lock-app/qpg/src/AppTask.cpp index 09aca7a146589d..b5c5d73fb723c1 100644 --- a/examples/lock-app/qpg/src/AppTask.cpp +++ b/examples/lock-app/qpg/src/AppTask.cpp @@ -25,8 +25,6 @@ #include -#include -#include #include #include #include diff --git a/examples/lock-app/qpg/src/BoltLockManager.cpp b/examples/lock-app/qpg/src/BoltLockManager.cpp index f407648b4166a9..44bb81abaebdc8 100644 --- a/examples/lock-app/qpg/src/BoltLockManager.cpp +++ b/examples/lock-app/qpg/src/BoltLockManager.cpp @@ -97,14 +97,14 @@ bool BoltLockManager::GetUser(uint16_t userIndex, EmberAfPluginDoorLockUserInfo user = mUsers[userIndex - 1]; ChipLogProgress(Zcl, "Getting lock user %u: %s", static_cast(userIndex), - user.userStatus == DlUserStatus::kAvailable ? "available" : "occupied"); + user.userStatus == UserStatusEnum::kAvailable ? "available" : "occupied"); return true; } bool BoltLockManager::SetUser(uint16_t userIndex, FabricIndex creator, FabricIndex modifier, const CharSpan & userName, - uint32_t uniqueId, DlUserStatus userStatus, DlUserType userType, DlCredentialRule credentialRule, - const DlCredential * credentials, size_t totalCredentials) + uint32_t uniqueId, UserStatusEnum userStatus, UserTypeEnum userType, + CredentialRuleEnum credentialRule, const CredentialStruct * credentials, size_t totalCredentials) { UserData & userData = mUserData[userIndex - 1]; auto & user = mUsers[userIndex - 1]; @@ -113,10 +113,10 @@ bool BoltLockManager::SetUser(uint16_t userIndex, FabricIndex creator, FabricInd VerifyOrReturnError(totalCredentials <= CONFIG_LOCK_NUM_CREDENTIALS_PER_USER, false); Platform::CopyString(userData.mName, userName); - memcpy(userData.mCredentials, credentials, totalCredentials * sizeof(DlCredential)); + memcpy(userData.mCredentials, credentials, totalCredentials * sizeof(CredentialStruct)); user.userName = CharSpan(userData.mName, userName.size()); - user.credentials = Span(userData.mCredentials, totalCredentials); + user.credentials = Span(userData.mCredentials, totalCredentials); user.userUniqueId = uniqueId; user.userStatus = userStatus; user.userType = userType; @@ -127,12 +127,12 @@ bool BoltLockManager::SetUser(uint16_t userIndex, FabricIndex creator, FabricInd user.lastModifiedBy = modifier; ChipLogProgress(Zcl, "Setting lock user %u: %s", static_cast(userIndex), - userStatus == DlUserStatus::kAvailable ? "available" : "occupied"); + userStatus == UserStatusEnum::kAvailable ? "available" : "occupied"); return true; } -bool BoltLockManager::GetCredential(uint16_t credentialIndex, DlCredentialType credentialType, +bool BoltLockManager::GetCredential(uint16_t credentialIndex, CredentialTypeEnum credentialType, EmberAfPluginDoorLockCredentialInfo & credential) const { VerifyOrReturnError(credentialIndex > 0 && credentialIndex <= CONFIG_LOCK_NUM_CREDENTIALS, false); @@ -146,7 +146,7 @@ bool BoltLockManager::GetCredential(uint16_t credentialIndex, DlCredentialType c } bool BoltLockManager::SetCredential(uint16_t credentialIndex, FabricIndex creator, FabricIndex modifier, - DlCredentialStatus credentialStatus, DlCredentialType credentialType, const ByteSpan & secret) + DlCredentialStatus credentialStatus, CredentialTypeEnum credentialType, const ByteSpan & secret) { VerifyOrReturnError(credentialIndex > 0 && credentialIndex <= CONFIG_LOCK_NUM_CREDENTIALS, false); VerifyOrReturnError(secret.size() <= kMaxCredentialLength, false); @@ -173,7 +173,7 @@ bool BoltLockManager::SetCredential(uint16_t credentialIndex, FabricIndex creato return true; } -bool BoltLockManager::ValidatePIN(const Optional & pinCode, DlOperationError & err) const +bool BoltLockManager::ValidatePIN(const Optional & pinCode, OperationErrorEnum & err) const { // Optionality of the PIN code is validated by the caller, so assume it is OK not to provide the PIN code. if (!pinCode.HasValue()) @@ -185,7 +185,7 @@ bool BoltLockManager::ValidatePIN(const Optional & pinCode, DlOperatio // Check the PIN code for (const auto & credential : mCredentials) { - if (credential.status == DlCredentialStatus::kAvailable || credential.credentialType != DlCredentialType::kPin) + if (credential.status == DlCredentialStatus::kAvailable || credential.credentialType != CredentialTypeEnum::kPin) { continue; } @@ -198,7 +198,7 @@ bool BoltLockManager::ValidatePIN(const Optional & pinCode, DlOperatio } ChipLogDetail(Zcl, "Invalid lock PIN code provided"); - err = DlOperationError::kInvalidCredential; + err = OperationErrorEnum::kInvalidCredential; return false; } diff --git a/examples/lock-app/qpg/src/ZclCallbacks.cpp b/examples/lock-app/qpg/src/ZclCallbacks.cpp index bc175fbab81ffe..698c04b017d5a3 100644 --- a/examples/lock-app/qpg/src/ZclCallbacks.cpp +++ b/examples/lock-app/qpg/src/ZclCallbacks.cpp @@ -53,27 +53,28 @@ bool emberAfPluginDoorLockGetUser(EndpointId endpointId, uint16_t userIndex, Emb } bool emberAfPluginDoorLockSetUser(EndpointId endpointId, uint16_t userIndex, FabricIndex creator, FabricIndex modifier, - const CharSpan & userName, uint32_t uniqueId, DlUserStatus userStatus, DlUserType userType, - DlCredentialRule credentialRule, const DlCredential * credentials, size_t totalCredentials) + const CharSpan & userName, uint32_t uniqueId, UserStatusEnum userStatus, UserTypeEnum userType, + CredentialRuleEnum credentialRule, const CredentialStruct * credentials, size_t totalCredentials) { return BoltLockMgr().SetUser(userIndex, creator, modifier, userName, uniqueId, userStatus, userType, credentialRule, credentials, totalCredentials); } -bool emberAfPluginDoorLockGetCredential(EndpointId endpointId, uint16_t credentialIndex, DlCredentialType credentialType, +bool emberAfPluginDoorLockGetCredential(EndpointId endpointId, uint16_t credentialIndex, CredentialTypeEnum credentialType, EmberAfPluginDoorLockCredentialInfo & credential) { return BoltLockMgr().GetCredential(credentialIndex, credentialType, credential); } bool emberAfPluginDoorLockSetCredential(EndpointId endpointId, uint16_t credentialIndex, FabricIndex creator, FabricIndex modifier, - DlCredentialStatus credentialStatus, DlCredentialType credentialType, + DlCredentialStatus credentialStatus, CredentialTypeEnum credentialType, const ByteSpan & secret) { return BoltLockMgr().SetCredential(credentialIndex, creator, modifier, credentialStatus, credentialType, secret); } -bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const Optional & pinCode, DlOperationError & err) +bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const Optional & pinCode, + OperationErrorEnum & err) { bool returnValue = false; @@ -86,7 +87,7 @@ bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const O } bool emberAfPluginDoorLockOnDoorUnlockCommand(chip::EndpointId endpointId, const Optional & pinCode, - DlOperationError & err) + OperationErrorEnum & err) { bool returnValue = false; @@ -116,7 +117,7 @@ void emberAfDoorLockClusterInitCallback(EndpointId endpoint) logOnFailure(DoorLock::Attributes::NumberOfCredentialsSupportedPerUser::Set(endpoint, CONFIG_LOCK_NUM_CREDENTIALS_PER_USER), "number of credentials per user"); - // Set FeatureMap to (kUsersManagement|kPINCredentials), default is: - // (kUsersManagement|kAccessSchedules|kRFIDCredentials|kPINCredentials) 0x113 + // Set FeatureMap to (kUser|kPinCredential), default is: + // (kUser|kAccessSchedules|kRfidCredential|kPinCredential) 0x113 logOnFailure(DoorLock::Attributes::FeatureMap::Set(endpoint, 0x101), "feature map"); } diff --git a/examples/lock-app/silabs/SiWx917/BUILD.gn b/examples/lock-app/silabs/SiWx917/BUILD.gn index dd196fa421303b..01710fc7ef48fc 100644 --- a/examples/lock-app/silabs/SiWx917/BUILD.gn +++ b/examples/lock-app/silabs/SiWx917/BUILD.gn @@ -49,15 +49,9 @@ declare_args() { OTA_periodic_query_timeout = 86400 # Wifi related stuff - they are overridden by gn -args="use_wf200=true" - use_wf200 = false - use_rs911x = false - use_rs911x_sockets = false sl_wfx_config_softap = false sl_wfx_config_scan = true - # Disable LCD on supported devices - disable_lcd = true - # Argument to Disable IPv4 for wifi(rs911) chip_enable_wifi_ipv4 = false @@ -71,14 +65,6 @@ declare_args() { chip_default_wifi_psk = "" } -declare_args() { - # Enables LCD Qr Code on supported devices - show_qr_code = !disable_lcd -} - -# qr code cannot be true if lcd is disabled -assert(!(disable_lcd && show_qr_code)) - # Sanity check assert(!(chip_enable_wifi && chip_enable_openthread)) assert(!(use_rs911x && chip_enable_openthread)) diff --git a/examples/lock-app/silabs/SiWx917/README.md b/examples/lock-app/silabs/SiWx917/README.md index 5944a5f8afe767..b31c606145d2a9 100644 --- a/examples/lock-app/silabs/SiWx917/README.md +++ b/examples/lock-app/silabs/SiWx917/README.md @@ -1,10 +1,10 @@ -# Matter EFR32 Lock Example +# Matter SiWx917 Lock Example -An example showing the use of CHIP on the Silicon Labs EFR32 MG12 and MG24. +An example showing the use of CHIP on the Silicon Labs SiWx917 SoC device.
-- [Matter EFR32 Lock Example](#matter-efr32-lock-example) +- [Matter SiWx917 Lock Example](#matter-siwx917-lock-example) - [Introduction](#introduction) - [Building](#building) - [Flashing the Application](#flashing-the-application) @@ -12,7 +12,6 @@ An example showing the use of CHIP on the Silicon Labs EFR32 MG12 and MG24. - [Running the Complete Example](#running-the-complete-example) - [Notes](#notes) - [Memory settings](#memory-settings) - - [OTA Software Update](#ota-software-update) - [Building options](#building-options) - [Disabling logging](#disabling-logging) - [Debug build / release build](#debug-build--release-build) @@ -29,22 +28,23 @@ An example showing the use of CHIP on the Silicon Labs EFR32 MG12 and MG24. ## Introduction -The EFR32 lock example provides a baseline demonstration of a door lock control -device, built using Matter and the Silicon Labs gecko SDK. It can be controlled -by a Chip controller over an Openthread or Wifi network.. +The SiWx917 Lock example provides a baseline demonstration of a door lock +control device, built using Matter, the Silicon Labs Gecko SDK, and the Silicon +Labs WiseMCU SDK. It can be controlled by a Chip controller over a Wi-Fi +network. -The EFR32 device can be commissioned over Bluetooth Low Energy where the device -and the Chip controller will exchange security information with the Rendez-vous -procedure. If using Thread, Thread Network credentials are then provided to the -EFR32 device which will then join the Thread network. +The SiWx917 device can be commissioned over Bluetooth Low Energy where the +device and the Chip controller will exchange security information with the +Rendez-vous procedure. Wi-Fi Network SSID and passcode are then provided to the +SiWx917 device which will then join the Wi-Fi network. If the LCD is enabled, the LCD on the Silabs WSTK shows a QR Code containing the needed commissioning information for the BLE connection and starting the -Rendez-vous procedure. +rendezvous procedure. -The lighting example is intended to serve both as a means to explore the -workings of Matter as well as a template for creating real products based on the -Silicon Labs platform. +The lock example is intended to serve both as a means to explore the workings of +Matter as well as a template for creating real products based on the Silicon +Labs platform. ## Building @@ -73,62 +73,11 @@ Mac OS X > [Hardware Requirements](https://github.com/SiliconLabs/matter/blob/latest/docs/silabs/general/HARDWARE_REQUIREMENTS.md) > in the Silicon Labs Matter Github Repo - MG12 boards: - - - BRD4161A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm - - BRD4162A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4163A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm, - 868MHz@19dBm - - BRD4164A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm - - BRD4166A / SLTB004A / Thunderboard Sense 2 / 2.4GHz@10dBm - - BRD4170A / SLWSTK6000B / Multiband Wireless Starter Kit / 2.4GHz@19dBm, - 915MHz@19dBm - - BRD4304A / SLWSTK6000B / MGM12P Module / 2.4GHz@19dBm - - MG21 boards: Currently not supported due to RAM limitation. - - - BRD4180A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - - MG24 boards : - - - BRD2601B / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD2703A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4186A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4186C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4187A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - - BRD4187C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - - MG12 boards: - - - BRD4161A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm - - BRD4162A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4163A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm, - 868MHz@19dBm - - BRD4164A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm - - BRD4166A / SLTB004A / Thunderboard Sense 2 / 2.4GHz@10dBm - - BRD4170A / SLWSTK6000B / Multiband Wireless Starter Kit / 2.4GHz@19dBm, - 915MHz@19dBm - - BRD4304A / SLWSTK6000B / MGM12P Module / 2.4GHz@19dBm - - MG21 boards: Currently not supported due to RAM limitation. - - - BRD4180A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - - MG24 boards : - - - BRD4162A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4163A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm, - 868MHz@19dBm - - BRD4186A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4186C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4187A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - - BRD4187C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - * Build the example application: ``` cd ~/connectedhomeip - ./scripts/examples/gn_efr32_example.sh ./examples/lock-app/efr32/ ./out/lock_app BRD4161A + ./scripts/examples/gn_efr32_example.sh ./examples/lock-app/silabs/SiWx917/ ./out/lock_app BRD4325A --wifi rs911x ``` - To delete generated executable, libraries and object files use: @@ -138,198 +87,35 @@ Mac OS X $ rm -rf ./out/ ``` - OR use GN/Ninja directly - - ``` - $ cd ~/connectedhomeip/examples/lock-app/efr32 - $ git submodule update --init - $ source third_party/connectedhomeip/scripts/activate.sh - $ export EFR32_BOARD=BRD4161A - $ gn gen out/debug --args="efr32_sdk_root=\"${EFR32_SDK_ROOT}\" silabs_board=\"${EFR32_BOARD}\"" - $ ninja -C out/debug - ``` - -- To delete generated executable, libraries and object files use: - - ``` - $ cd ~/connectedhomeip/examples/lock-app/efr32 - $ rm -rf out/ - ``` - -* Build the example as Sleepy End Device (SED) - - ``` - $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/efr32/ ./out/lighting-app_SED BRD4161A --sed - ``` - - or use gn as previously mentioned but adding the following arguments: - - ``` - $ gn gen out/debug '--args=silabs_board="BRD4161A" enable_sleepy_device=true chip_openthread_ftd=false' - ``` - -* Build the example with pigweed RCP - - ``` - $ ./scripts/examples/gn_efr32_example.sh examples/lock-app/efr32/ out/lock_app_rpc BRD4161A 'import("//with_pw_rpc.gni")' - ``` - - or use GN/Ninja Directly - - ``` - $ cd ~/connectedhomeip/examples/lock-app/efr32 - $ git submodule update --init - $ source third_party/connectedhomeip/scripts/activate.sh - $ export EFR32_BOARD=BRD4161A - $ gn gen out/debug --args='import("//with_pw_rpc.gni")' - $ ninja -C out/debug - ``` - -For more build options, help is provided when running the build script without -arguments - - ``` - ./scripts/examples/gn_efr32_example.sh - ``` + ## Flashing the Application -- On the command line: - - ``` - $ cd ~/connectedhomeip/examples/lock-app/efr32 - $ python3 out/debug/chip-efr32-lock-example.flash.py - ``` - -- Or with the Ozone debugger, just load the .out file. +- Flashing requires the SiWx917 SoC device to be configured in the Ozone + Debugger. +- Once it's configured, it can be run with the Ozone Debugger by loading the + .out file. + - > For detailed instructions, please refer to + > [Running the Matter Demo on SiWx917 SoC](https://github.com/SiliconLabs/matter/blob/latest/docs/silabs/wifi/RUN_DEMO_SiWx917_SoC.md) + > in the Silicon Labs Matter Github Repo ## Viewing Logging Output -The example application is built to use the SEGGER Real Time Transfer (RTT) -facility for log output. RTT is a feature built-in to the J-Link Interface MCU -on the WSTK development board. It allows bi-directional communication with an -embedded application without the need for a dedicated UART. - -Using the RTT facility requires downloading and installing the _SEGGER J-Link -Software and Documentation Pack_ -([web site](https://www.segger.com/downloads/jlink#J-LinkSoftwareAndDocumentationPack)). - -Alternatively, SEGGER Ozone J-Link debugger can be used to view RTT logs too -after flashing the .out file. - -- Download the J-Link installer by navigating to the appropriate URL and - agreeing to the license agreement. - -- [JLink_Linux_x86_64.deb](https://www.segger.com/downloads/jlink/JLink_Linux_x86_64.deb) -- [JLink_MacOSX.pkg](https://www.segger.com/downloads/jlink/JLink_MacOSX.pkg) - -* Install the J-Link software - - ``` - $ cd ~/Downloads - $ sudo dpkg -i JLink_Linux_V*_x86_64.deb - ``` - -* In Linux, grant the logged in user the ability to talk to the development - hardware via the linux tty device (/dev/ttyACMx) by adding them to the - dialout group. - - ``` - $ sudo usermod -a -G dialout ${USER} - ``` - -Once the above is complete, log output can be viewed using the JLinkExe tool in -combination with JLinkRTTClient as follows: - -- Run the JLinkExe tool with arguments to autoconnect to the WSTK board: - - For MG12 use: - - ``` - $ JLinkExe -device EFR32MG12PXXXF1024 -if JTAG -speed 4000 -autoconnect 1 - ``` - - For MG21 use: - - ``` - $ JLinkExe -device EFR32MG21AXXXF1024 -if SWD -speed 4000 -autoconnect 1 - ``` - -- In a second terminal, run the JLinkRTTClient to view logs: - - ``` - $ JLinkRTTClient - ``` +The example application's logging output can be viewed in the Ozone Debugger. ## Running the Complete Example -- It is assumed here that you already have an OpenThread border router - configured and running. If not see the following guide - [Openthread_border_router](https://github.com/project-chip/connectedhomeip/blob/master/docs/guides/openthread_border_router_pi.md) - for more information on how to setup a border router on a raspberryPi. - - Take note that the RCP code is available directly through - [Simplicity Studio 5](https://www.silabs.com/products/development-tools/software/simplicity-studio/simplicity-studio-5) - under File->New->Project Wizard->Examples->Thread : ot-rcp - -- User interface : **LCD** The LCD on Silabs WSTK shows a QR Code. This QR - Code is be scanned by the CHIP Tool app For the Rendez-vous procedure over - BLE - - * On devices that do not have or support the LCD Display like the BRD4166A Thunderboard Sense 2, - a URL can be found in the RTT logs. - - [SVR] Copy/paste the below URL in a browser to see the QR Code: - [SVR] https://project-chip.github.io/connectedhomeip/qrcode.html?data=CH%3AI34NM%20-00%200C9SS0 - - **LED 0** shows the overall state of the device and its connectivity. The - following states are possible: - - - _Short Flash On (50 ms on/950 ms off)_ ; The device is in the - unprovisioned (unpaired) state and is waiting for a commissioning - application to connect. - - - _Rapid Even Flashing_ ; (100 ms on/100 ms off)_ — The device is in the - unprovisioned state and a commissioning application is connected through - Bluetooth LE. - - - _Short Flash Off_ ; (950ms on/50ms off)_ — The device is fully - provisioned, but does not yet have full Thread network or service - connectivity. +- You can provision and control the Chip device using the chip-tool standalone - - _Solid On_ ; The device is fully provisioned and has full Thread - network and service connectivity. + [chip-tool](https://github.com/project-chip/connectedhomeip/blob/master/examples/chip-tool/README.md) - **LED 1** Simulates the Lock The following states are possible: - - - _Solid On_ ; Bolt is unlocked - - _Blinking_ ; Bolt is moving to the desired state - - _Off_ ; Bolt is locked - - **Push Button 0** - - - _Press and Release_ : Start, or restart, BLE advertisement in fast mode. It will advertise in this mode - for 30 seconds. The device will then switch to a slower interval advertisement. - After 15 minutes, the advertisement stops. - - - _Pressed and hold for 6 s_ : Initiates the factory reset of the device. - Releasing the button within the 6-second window cancels the factory reset - procedure. **LEDs** blink in unison when the factory reset procedure is - initiated. - - **Push Button 1** Toggles the bolt state On/Off - -- You can provision and control the Chip device using the python controller, - Chip tool standalone, Android or iOS app - - [CHIPTool](https://github.com/project-chip/connectedhomeip/blob/master/examples/chip-tool/README.md) - -Here is some CHIPTool examples: +Here are some chip-tool examples: Pairing with chip-tool: ``` - chip-tool pairing ble-thread 1 hex: 20202021 3840 + chip-tool pairing ble-wifi 1122 $SSID $PSK 20202021 3840 ``` + - > $SSID and $PSK are the SSID and passcode of your Wi-Fi Access Point. Set a user: ``` @@ -358,50 +144,42 @@ Here is some CHIPTool examples: Unlock door: ``` ./out/chip-tool doorlock unlock-door node-id/group-id - ./out/chip-tool doorlock unlock-door 1 1 --timedInteractionTimeoutMs 1000 + ./out/chip-tool doorlock unlock-door 1 1 ``` Lock door: ``` ./out/chip-tool doorlock lock-door node-id/group-id - ./out/chip-tool doorlock lock-door 1 1 --timedInteractionTimeoutMs 1000 + ./out/chip-tool doorlock lock-door 1 1 ``` ### Notes -- Depending on your network settings your router might not provide native ipv6 - addresses to your devices (Border router / PC). If this is the case, you - need to add a static ipv6 addresses on both device and then an ipv6 route to - the border router on your PC - -#On Border Router: \$ sudo ip addr add dev 2002::2/64 +- Depending on your network settings your router might not provide native IPv6 + addresses to your devices (Router / PC). If this is the case, you need to + add a static IPv6 addresses on both devices and then an IPv6 route to the + router on your PC #On PC(Linux): \$ sudo ip addr add dev 2002::1/64 -#Add Ipv6 route on PC(Linux) \$ sudo ip route add /64 +#Add IPv6 route on PC(Linux) \$ sudo ip route add /64 via 2002::2 ## Memory settings While most of the RAM usage in CHIP is static, allowing easier debugging and optimization with symbols analysis, we still need some HEAP for the crypto and -OpenThread. Size of the HEAP can be modified by changing the value of the +Wi-Fi stack. Size of the HEAP can be modified by changing the value of the `configTOTAL_HEAP_SIZE` define inside of the FreeRTOSConfig.h file of this -example. Please take note that a HEAP size smaller than 13k can and will cause a -Mbedtls failure during the BLE rendez-vous or CASE session +example. Please take note that a HEAP size smaller than 13k can and will cause +an Mbedtls failure during the BLE rendezvous or CASE session To track memory usage you can set `enable_heap_monitoring = true` either in the BUILD.gn file or pass it as a build argument to gn. This will print on the RTT console the RAM usage of each individual task and the number of Memory allocation and Free. While this is not extensive monitoring you're welcome to -modify `examples/platform/efr32/MemMonitoring.cpp` to add your own memory -tracking code inside the `trackAlloc` and `trackFree` function - -## OTA Software Update - -For the description of Software Update process with EFR32 example applications -see -[EFR32 OTA Software Update](../../../../docs/guides/silabs_efr32_software_update.md) +modify `examples/platform/silabs/SiWx917/MemMonitoring.cpp` to add your own +memory tracking code inside the `trackAlloc` and `trackFree` function ## Building options @@ -414,7 +192,7 @@ features can easily be toggled on or off. Here is a short list of options : `chip_progress_logging, chip_detail_logging, chip_automation_logging` ``` - $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/efr32 ./out/lighting-app BRD4164A "chip_detail_logging=false chip_automation_logging=false chip_progress_logging=false" + $ ./scripts/examples/gn_efr32_example.sh ./examples/lock-app/silabs/SiWx917 ./out/lock-app BRD4325A "chip_detail_logging=false chip_automation_logging=false chip_progress_logging=false" --wifi rs911x ``` ### Debug build / release build @@ -422,7 +200,7 @@ features can easily be toggled on or off. Here is a short list of options : `is_debug` ``` - $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/efr32 ./out/lighting-app BRD4164A "is_debug=false" + $ ./scripts/examples/gn_efr32_example.sh ./examples/lock-app/silabs/SiWx917 ./out/lock-app BRD4325A "is_debug=false" --wifi rs911x ``` ### Disabling LCD @@ -430,7 +208,7 @@ features can easily be toggled on or off. Here is a short list of options : `show_qr_code` ``` - $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/efr32 ./out/lighting-app BRD4164A "show_qr_code=false" + $ ./scripts/examples/gn_efr32_example.sh ./examples/lock-app/silabs/SiWx917 ./out/lock-app BRD4325A "show_qr_code=false" --wifi rs911x ``` ### KVS maximum entry count @@ -441,5 +219,5 @@ features can easily be toggled on or off. Here is a short list of options : Set the maximum Kvs entries that can be stored in NVM (Default 75) Thresholds: 30 <= kvs_max_entries <= 255 - $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/efr32 ./out/lighting-app BRD4164A kvs_max_entries=50 + $ ./scripts/examples/gn_efr32_example.sh ./examples/lock-app/silabs/SiWx917 ./out/lock-app BRD4325A kvs_max_entries=50 --wifi rs911x ``` diff --git a/examples/lock-app/silabs/SiWx917/src/AppTask.cpp b/examples/lock-app/silabs/SiWx917/src/AppTask.cpp index c4878ee9ba8a7f..4685000385ae8b 100644 --- a/examples/lock-app/silabs/SiWx917/src/AppTask.cpp +++ b/examples/lock-app/silabs/SiWx917/src/AppTask.cpp @@ -37,8 +37,6 @@ #endif // DISPLAY_ENABLED #include -#include -#include #include #include diff --git a/examples/lock-app/silabs/efr32/BUILD.gn b/examples/lock-app/silabs/efr32/BUILD.gn index f07593e26bdc1f..fda976b33fda14 100644 --- a/examples/lock-app/silabs/efr32/BUILD.gn +++ b/examples/lock-app/silabs/efr32/BUILD.gn @@ -35,114 +35,11 @@ efr32_project_dir = "${chip_root}/examples/lock-app/silabs/efr32" examples_plat_dir = "${chip_root}/examples/platform/silabs/efr32" examples_common_plat_dir = "${chip_root}/examples/platform/silabs" +import("${examples_plat_dir}/args.gni") + declare_args() { # Dump memory usage at link time. chip_print_memory_usage = false - - # Monitor & log memory usage at runtime. - enable_heap_monitoring = false - - # Enable Sleepy end device - enable_sleepy_device = false - - # OTA timeout in seconds - OTA_periodic_query_timeout = 86400 - - # Wifi related stuff - they are overridden by gn -args="use_wf200=true" - use_wf200 = false - use_rs911x = false - use_rs911x_sockets = false - sl_wfx_config_softap = false - sl_wfx_config_scan = true - - # Disable LCD on supported devices - disable_lcd = false - - # Argument to Disable IPv4 for wifi(rs911) - chip_enable_wifi_ipv4 = false - - # Argument to force enable WPA3 security - rs91x_wpa3_only = false - - #default WiFi SSID - chip_default_wifi_ssid = "" - - #default Wifi Password - chip_default_wifi_psk = "" -} - -declare_args() { - # Enables LCD Qr Code on supported devices - show_qr_code = !disable_lcd -} - -# qr code cannot be true if lcd is disabled -assert(!(disable_lcd && show_qr_code)) - -# Sanity check -assert(!(chip_enable_wifi && chip_enable_openthread)) -assert(!(use_rs911x && chip_enable_openthread)) -assert(!(use_wf200 && chip_enable_openthread)) -if (chip_enable_wifi) { - assert(use_rs911x || use_wf200) - enable_openthread_cli = false - import("${chip_root}/src/platform/silabs/EFR32/wifi_args.gni") -} - -# ThunderBoards, Explorer Kit and MGM240L do not support LCD (No LCD) -if (silabs_board == "BRD4166A" || silabs_board == "BRD2601B" || - silabs_board == "BRD2703A" || silabs_board == "BRD4319A") { - show_qr_code = false - disable_lcd = true -} - -defines = [] - -# WiFi settings -if (chip_enable_wifi) { - if (chip_default_wifi_ssid != "") { - defines += [ - "CHIP_ONNETWORK_PAIRING=1", - "CHIP_WIFI_SSID=\"${chip_default_wifi_ssid}\"", - ] - } - if (chip_default_wifi_psk != "") { - assert(chip_default_wifi_ssid != "", - "ssid can't be null if psk is provided") - defines += [ "CHIP_WIFI_PSK=\"${chip_default_wifi_psk}\"" ] - } - wifi_sdk_dir = "${chip_root}/src/platform/silabs/EFR32/wifi" - efr32_lwip_defs = [ "LWIP_NETIF_API=1" ] - if (lwip_ipv4) { - efr32_lwip_defs += [ - "LWIP_IPV4=1", - - # adds following options to provide - # them to .cpp source files - # flags ported from lwipopts file - # TODO: move lwipopts to one location - "LWIP_ARP=1", - "LWIP_ICMP=1", - "LWIP_IGMP=1", - "LWIP_DHCP=1", - "LWIP_DNS=0", - ] - } else { - efr32_lwip_defs += [ "LWIP_IPV4=0" ] - } - if (lwip_ipv6) { - efr32_lwip_defs += [ "LWIP_IPV6=1" ] - } else { - efr32_lwip_defs += [ "LWIP_IPV6=0" ] - } - - if (use_rs911x) { - wiseconnect_sdk_root = - "${chip_root}/third_party/silabs/wiseconnect-wifi-bt-sdk" - import("${examples_plat_dir}/rs911x/rs911x.gni") - } else { - import("${examples_plat_dir}/wf200/wf200.gni") - } } efr32_sdk("sdk") { @@ -159,42 +56,18 @@ efr32_sdk("sdk") { "${examples_common_plat_dir}", ] - defines += [ - "BOARD_ID=${silabs_board}", - "OTA_PERIODIC_TIMEOUT=${OTA_periodic_query_timeout}", - ] + if (use_wf200) { + # TODO efr32_sdk should not need a header from this location + include_dirs += [ "${examples_plat_dir}/wf200" ] + } + defines = [] if (chip_enable_pw_rpc) { defines += [ "HAL_VCOM_ENABLE=1", "PW_RPC_ENABLED", ] } - - # WiFi Settings - if (chip_enable_wifi) { - if (use_rs911x) { - defines += rs911x_defs - include_dirs += rs911x_plat_incs - } else if (use_wf200) { - defines += wf200_defs - include_dirs += wf200_plat_incs - } - - if (use_rs911x_sockets) { - include_dirs += [ "${examples_plat_dir}/wifi/rsi-sockets" ] - defines += rs911x_sock_defs - } else { - # Using LWIP instead of the native TCP/IP stack - defines += efr32_lwip_defs - } - if (sl_wfx_config_softap) { - defines += [ "SL_WFX_CONFIG_SOFTAP" ] - } - if (sl_wfx_config_scan) { - defines += [ "SL_WFX_CONFIG_SCAN" ] - } - } } efr32_executable("lock_app") { @@ -204,109 +77,18 @@ efr32_executable("lock_app") { defines = [] sources = [ - "${examples_common_plat_dir}/heap_4_silabs.c", - "${examples_plat_dir}/BaseApplication.cpp", - "${examples_plat_dir}/efr32_utils.cpp", - "${examples_plat_dir}/init_efrPlatform.cpp", - "${examples_plat_dir}/matter_config.cpp", "src/AppTask.cpp", "src/LockManager.cpp", "src/ZclCallbacks.cpp", "src/main.cpp", ] - if (use_wstk_leds) { - sources += [ "${examples_plat_dir}/LEDWidget.cpp" ] - } - - if (chip_enable_pw_rpc || chip_build_libshell || enable_openthread_cli || - use_wf200 || use_rs911x) { - sources += [ "${examples_plat_dir}/uart.cpp" ] - } - - if (chip_build_libshell) { - sources += [ "src/EventHandlerLibShell.cpp" ] - } - deps = [ ":sdk", - "${chip_root}/examples/lock-app/lock-common", - "${chip_root}/examples/providers:device_info_provider", - "${chip_root}/src/lib", - "${chip_root}/src/setup_payload", - "${chip_root}/third_party/openthread/platforms:libopenthread-platform", - "${chip_root}/third_party/openthread/platforms:libopenthread-platform-utils", - "${examples_plat_dir}:efr-matter-shell", + "${examples_plat_dir}:efr32-common", + app_data_model, ] - # OpenThread Settings - if (chip_enable_openthread) { - deps += [ - "${chip_root}/third_party/openthread:openthread", - "${chip_root}/third_party/openthread:openthread-platform", - "${examples_plat_dir}:efr-matter-shell", - ] - } - - if (chip_enable_ota_requestor) { - defines += [ "EFR32_OTA_ENABLED" ] - sources += [ "${examples_plat_dir}/OTAConfig.cpp" ] - } - - # WiFi Settings - if (chip_enable_wifi) { - if (use_rs911x) { - sources += rs911x_src_plat - - # All the stuff from wiseconnect - sources += rs911x_src_sapi - - # Apparently - the rsi library needs this (though we may not use use it) - sources += rs911x_src_sock - include_dirs += rs911x_inc_plat - - if (use_rs911x_sockets) { - # - # Using native sockets inside RS911x - # - include_dirs += rs911x_sock_inc - } else { - # - # We use LWIP - not built-in sockets - # - sources += rs911x_src_lwip - } - } else if (use_wf200) { - sources += wf200_plat_src - include_dirs += wf200_plat_incs - } - - if (chip_enable_wifi_ipv4) { - defines += [ "CHIP_DEVICE_CONFIG_ENABLE_IPV4" ] - } - - if (rs91x_wpa3_only) { - # TODO: Change this macro once WF200 support is provided - defines += [ "WIFI_ENABLE_SECURITY_WPA3=1" ] - } - } - - if (!disable_lcd) { - sources += [ - "${examples_plat_dir}/display/demo-ui.c", - "${examples_plat_dir}/display/lcd.cpp", - ] - include_dirs += [ "${examples_plat_dir}/display" ] - defines += [ - "DISPLAY_ENABLED", - "IS_DEMO_LOCK=1", - ] - if (show_qr_code) { - defines += [ "QR_CODE_ENABLED" ] - deps += [ "${chip_root}/examples/common/QRCode" ] - } - } - if (chip_enable_pw_rpc) { defines += [ "PW_RPC_ENABLED", @@ -348,11 +130,6 @@ efr32_executable("lock_app") { ] } - if (enable_heap_monitoring) { - sources += [ "${examples_common_plat_dir}/MemMonitoring.cpp" ] - defines += [ "HEAP_MONITORING" ] - } - ldscript = "${examples_plat_dir}/ldscripts/${silabs_family}.ld" inputs = [ ldscript ] @@ -374,18 +151,9 @@ efr32_executable("lock_app") { ] } - # Attestation Credentials - if (chip_build_platform_attestation_credentials_provider) { - deps += [ "${examples_plat_dir}:efr32-attestation-credentials" ] - } - - # Factory Data Provider - if (use_efr32_factory_data_provider) { - deps += [ "${examples_plat_dir}:efr32-factory-data-provider" ] - } - output_dir = root_out_dir } + group("efr32") { deps = [ ":lock_app" ] } diff --git a/examples/lock-app/silabs/efr32/README.md b/examples/lock-app/silabs/efr32/README.md index 5944a5f8afe767..e3c7b86367573c 100644 --- a/examples/lock-app/silabs/efr32/README.md +++ b/examples/lock-app/silabs/efr32/README.md @@ -42,9 +42,9 @@ If the LCD is enabled, the LCD on the Silabs WSTK shows a QR Code containing the needed commissioning information for the BLE connection and starting the Rendez-vous procedure. -The lighting example is intended to serve both as a means to explore the -workings of Matter as well as a template for creating real products based on the -Silicon Labs platform. +The lock example is intended to serve both as a means to explore the workings of +Matter as well as a template for creating real products based on the Silicon +Labs platform. ## Building @@ -98,37 +98,11 @@ Mac OS X - BRD4187A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - BRD4187C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - MG12 boards: - - - BRD4161A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm - - BRD4162A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4163A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm, - 868MHz@19dBm - - BRD4164A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm - - BRD4166A / SLTB004A / Thunderboard Sense 2 / 2.4GHz@10dBm - - BRD4170A / SLWSTK6000B / Multiband Wireless Starter Kit / 2.4GHz@19dBm, - 915MHz@19dBm - - BRD4304A / SLWSTK6000B / MGM12P Module / 2.4GHz@19dBm - - MG21 boards: Currently not supported due to RAM limitation. - - - BRD4180A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - - MG24 boards : - - - BRD4162A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4163A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@10dBm, - 868MHz@19dBm - - BRD4186A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4186C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@10dBm - - BRD4187A / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - - BRD4187C / SLWSTK6006A / Wireless Starter Kit / 2.4GHz@20dBm - * Build the example application: ``` cd ~/connectedhomeip - ./scripts/examples/gn_efr32_example.sh ./examples/lock-app/efr32/ ./out/lock_app BRD4161A + ./scripts/examples/gn_efr32_example.sh ./examples/lock-app/silabs/efr32/ ./out/lock_app BRD4161A ``` - To delete generated executable, libraries and object files use: @@ -141,7 +115,7 @@ Mac OS X OR use GN/Ninja directly ``` - $ cd ~/connectedhomeip/examples/lock-app/efr32 + $ cd ~/connectedhomeip/examples/silabs/lock-app/efr32 $ git submodule update --init $ source third_party/connectedhomeip/scripts/activate.sh $ export EFR32_BOARD=BRD4161A @@ -152,14 +126,14 @@ Mac OS X - To delete generated executable, libraries and object files use: ``` - $ cd ~/connectedhomeip/examples/lock-app/efr32 + $ cd ~/connectedhomeip/examples/lock-app/silabs/efr32 $ rm -rf out/ ``` * Build the example as Sleepy End Device (SED) ``` - $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/efr32/ ./out/lighting-app_SED BRD4161A --sed + $ ./scripts/examples/gn_efr32_example.sh ./examples/lock-app/silabs/efr32/ ./out/lock-app_SED BRD4161A --sed ``` or use gn as previously mentioned but adding the following arguments: @@ -171,13 +145,13 @@ Mac OS X * Build the example with pigweed RCP ``` - $ ./scripts/examples/gn_efr32_example.sh examples/lock-app/efr32/ out/lock_app_rpc BRD4161A 'import("//with_pw_rpc.gni")' + $ ./scripts/examples/gn_efr32_example.sh examples/lock-app/silabs/efr32/ out/lock_app_rpc BRD4161A 'import("//with_pw_rpc.gni")' ``` or use GN/Ninja Directly ``` - $ cd ~/connectedhomeip/examples/lock-app/efr32 + $ cd ~/connectedhomeip/examples/lock-app/silabs/efr32 $ git submodule update --init $ source third_party/connectedhomeip/scripts/activate.sh $ export EFR32_BOARD=BRD4161A @@ -197,7 +171,7 @@ arguments - On the command line: ``` - $ cd ~/connectedhomeip/examples/lock-app/efr32 + $ cd ~/connectedhomeip/examples/lock-app/silabs/efr32 $ python3 out/debug/chip-efr32-lock-example.flash.py ``` @@ -394,7 +368,7 @@ To track memory usage you can set `enable_heap_monitoring = true` either in the BUILD.gn file or pass it as a build argument to gn. This will print on the RTT console the RAM usage of each individual task and the number of Memory allocation and Free. While this is not extensive monitoring you're welcome to -modify `examples/platform/efr32/MemMonitoring.cpp` to add your own memory +modify `examples/platform/silabs/efr32/MemMonitoring.cpp` to add your own memory tracking code inside the `trackAlloc` and `trackFree` function ## OTA Software Update @@ -414,7 +388,7 @@ features can easily be toggled on or off. Here is a short list of options : `chip_progress_logging, chip_detail_logging, chip_automation_logging` ``` - $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/efr32 ./out/lighting-app BRD4164A "chip_detail_logging=false chip_automation_logging=false chip_progress_logging=false" + $ ./scripts/examples/gn_efr32_example.sh ./examples/lock-app/silabs/efr32 ./out/lock-app BRD4164A "chip_detail_logging=false chip_automation_logging=false chip_progress_logging=false" ``` ### Debug build / release build @@ -422,7 +396,7 @@ features can easily be toggled on or off. Here is a short list of options : `is_debug` ``` - $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/efr32 ./out/lighting-app BRD4164A "is_debug=false" + $ ./scripts/examples/gn_efr32_example.sh ./examples/lock-app/silabs/efr32 ./out/lock-app BRD4164A "is_debug=false" ``` ### Disabling LCD @@ -430,7 +404,7 @@ features can easily be toggled on or off. Here is a short list of options : `show_qr_code` ``` - $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/efr32 ./out/lighting-app BRD4164A "show_qr_code=false" + $ ./scripts/examples/gn_efr32_example.sh ./examples/lock-app/silabs/efr32 ./out/lock-app BRD4164A "show_qr_code=false" ``` ### KVS maximum entry count @@ -441,5 +415,5 @@ features can easily be toggled on or off. Here is a short list of options : Set the maximum Kvs entries that can be stored in NVM (Default 75) Thresholds: 30 <= kvs_max_entries <= 255 - $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/efr32 ./out/lighting-app BRD4164A kvs_max_entries=50 + $ ./scripts/examples/gn_efr32_example.sh ./examples/lock-app/silabs/efr32 ./out/lock-app BRD4164A kvs_max_entries=50 ``` diff --git a/examples/lock-app/silabs/efr32/args.gni b/examples/lock-app/silabs/efr32/args.gni index c7b087a4ee4f49..2795c9453cd48b 100644 --- a/examples/lock-app/silabs/efr32/args.gni +++ b/examples/lock-app/silabs/efr32/args.gni @@ -18,6 +18,7 @@ import("${chip_root}/src/platform/silabs/EFR32/args.gni") efr32_sdk_target = get_label_info(":sdk", "label_no_toolchain") +app_data_model = "${chip_root}/examples/lock-app/lock-common" chip_enable_ota_requestor = true chip_enable_openthread = true openthread_external_platform = diff --git a/examples/lock-app/silabs/efr32/build_for_wifi_args.gni b/examples/lock-app/silabs/efr32/build_for_wifi_args.gni index 86d8a19bbc36ce..556c097dcf568c 100644 --- a/examples/lock-app/silabs/efr32/build_for_wifi_args.gni +++ b/examples/lock-app/silabs/efr32/build_for_wifi_args.gni @@ -19,3 +19,4 @@ chip_enable_openthread = false import("${chip_root}/src/platform/silabs/EFR32/wifi_args.gni") chip_enable_ota_requestor = true +app_data_model = "${chip_root}/examples/lock-app/lock-common" diff --git a/examples/lock-app/silabs/efr32/include/AppConfig.h b/examples/lock-app/silabs/efr32/include/AppConfig.h index 3014c5be66479c..36856b8cb38ed8 100644 --- a/examples/lock-app/silabs/efr32/include/AppConfig.h +++ b/examples/lock-app/silabs/efr32/include/AppConfig.h @@ -27,6 +27,62 @@ // state to another. #define ACTUATOR_MOVEMENT_PERIOS_MS 10 +#define ON_DEMO_BITMAP \ + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0xC0, 0xFF, 0xFF, 0xFF, 0xFF, \ + 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x00, 0x00, \ + 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0xE0, 0x07, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0xF8, 0x1F, 0xF8, 0xFF, 0xFF, 0xFF, \ + 0xFF, 0x0F, 0xFC, 0x3F, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0xFE, 0x7F, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0xFE, 0x7F, \ + 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0xFF, 0xFF, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0xFF, 0xFF, 0xE0, 0xFF, 0xFF, 0xFF, \ + 0xFF, 0x07, 0xFF, 0xFF, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0xFF, 0xFF, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0xFF, 0xFF, \ + 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0xFF, 0xFF, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0xFF, 0xFF, 0xE0, 0xFF, 0xFF, 0xFF, \ + 0xFF, 0x07, 0xFF, 0xFF, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0xFF, 0xFF, 0xE0, 0xFF, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, \ + 0x00, 0xF8, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, \ + 0x07, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, \ + 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, \ + 0x07, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, \ + 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0x80, 0x01, 0x00, 0xE0, 0xFF, 0xFF, \ + 0x07, 0x00, 0xE0, 0x07, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0xF0, 0x0F, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0xF8, 0x1F, \ + 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0xF8, 0x1F, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0xFC, 0x3F, 0x00, 0xE0, 0xFF, 0xFF, \ + 0x07, 0x00, 0xFC, 0x3F, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0xF8, 0x1F, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0xF8, 0x1F, \ + 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0xF0, 0x0F, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0xE0, 0x07, 0x00, 0xE0, 0xFF, 0xFF, \ + 0x07, 0x00, 0x80, 0x01, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, \ + 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, \ + 0x07, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, \ + 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, \ + 0x07, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, \ + 0x00, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF + +#define OFF_DEMO_BITMAP \ + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0xC0, 0xFF, 0xFF, 0xFF, 0xFF, \ + 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F, 0x00, 0x00, \ + 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0xE0, 0x07, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0xF8, 0x1F, 0xF8, 0xFF, 0xFF, 0xFF, \ + 0xFF, 0x0F, 0xFC, 0x3F, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0xFE, 0x7F, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0xFE, 0x7F, \ + 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0xFF, 0xFF, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0xFF, 0xFF, 0xE0, 0xFF, 0xFF, 0xFF, \ + 0xFF, 0x07, 0xFF, 0xFF, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ + 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0xFF, 0xFF, 0xFF, \ + 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0xFF, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, \ + 0x00, 0xF8, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, \ + 0x07, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, \ + 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, \ + 0x07, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, \ + 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0x80, 0x01, 0x00, 0xE0, 0xFF, 0xFF, \ + 0x07, 0x00, 0xE0, 0x07, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0xF0, 0x0F, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0xF8, 0x1F, \ + 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0xF8, 0x1F, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0xFC, 0x3F, 0x00, 0xE0, 0xFF, 0xFF, \ + 0x07, 0x00, 0xFC, 0x3F, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0xF8, 0x1F, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0xF8, 0x1F, \ + 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0xF0, 0x0F, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0xE0, 0x07, 0x00, 0xE0, 0xFF, 0xFF, \ + 0x07, 0x00, 0x80, 0x01, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, \ + 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, \ + 0x07, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, \ + 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0x07, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, \ + 0x07, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, \ + 0x00, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, \ + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF + // EFR Logging #ifdef __cplusplus extern "C" { diff --git a/examples/lock-app/silabs/efr32/include/EventHandlerLibShell.h b/examples/lock-app/silabs/efr32/include/EventHandlerLibShell.h index 3ad9f11cbf2fdc..e915e472750da4 100644 --- a/examples/lock-app/silabs/efr32/include/EventHandlerLibShell.h +++ b/examples/lock-app/silabs/efr32/include/EventHandlerLibShell.h @@ -27,13 +27,13 @@ class EventData class AlarmEventData : public EventData { public: - DlAlarmCode alarmCode; + AlarmCodeEnum alarmCode; }; class DoorStateEventData : public EventData { public: - DlDoorState doorState; + DoorStateEnum doorState; }; CHIP_ERROR RegisterLockEvents(); diff --git a/examples/lock-app/silabs/efr32/include/LockManager.h b/examples/lock-app/silabs/efr32/include/LockManager.h index e2a6b7f586978d..018a9ff72c767f 100644 --- a/examples/lock-app/silabs/efr32/include/LockManager.h +++ b/examples/lock-app/silabs/efr32/include/LockManager.h @@ -141,25 +141,26 @@ class LockManager typedef void (*Callback_fn_completed)(Action_t); void SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Callback_fn_completed aActionCompleted_CB); - bool Lock(chip::EndpointId endpointId, const Optional & pin, DlOperationError & err); - bool Unlock(chip::EndpointId endpointId, const Optional & pin, DlOperationError & err); + bool Lock(chip::EndpointId endpointId, const Optional & pin, OperationErrorEnum & err); + bool Unlock(chip::EndpointId endpointId, const Optional & pin, OperationErrorEnum & err); bool GetUser(chip::EndpointId endpointId, uint16_t userIndex, EmberAfPluginDoorLockUserInfo & user); bool SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - const chip::CharSpan & userName, uint32_t uniqueId, DlUserStatus userStatus, DlUserType usertype, - DlCredentialRule credentialRule, const DlCredential * credentials, size_t totalCredentials); + const chip::CharSpan & userName, uint32_t uniqueId, UserStatusEnum userStatus, UserTypeEnum usertype, + CredentialRuleEnum credentialRule, const CredentialStruct * credentials, size_t totalCredentials); - bool GetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, DlCredentialType credentialType, + bool GetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, CredentialTypeEnum credentialType, EmberAfPluginDoorLockCredentialInfo & credential); bool SetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - DlCredentialStatus credentialStatus, DlCredentialType credentialType, const chip::ByteSpan & credentialData); + DlCredentialStatus credentialStatus, CredentialTypeEnum credentialType, + const chip::ByteSpan & credentialData); DlStatus GetWeekdaySchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex, EmberAfPluginDoorLockWeekDaySchedule & schedule); DlStatus SetWeekdaySchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex, DlScheduleStatus status, - DlDaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute); + DaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute); DlStatus GetYeardaySchedule(chip::EndpointId endpointId, uint8_t yearDayIndex, uint16_t userIndex, EmberAfPluginDoorLockYearDaySchedule & schedule); @@ -170,16 +171,16 @@ class LockManager DlStatus GetHolidaySchedule(chip::EndpointId endpointId, uint8_t holidayIndex, EmberAfPluginDoorLockHolidaySchedule & schedule); DlStatus SetHolidaySchedule(chip::EndpointId endpointId, uint8_t holidayIndex, DlScheduleStatus status, uint32_t localStartTime, - uint32_t localEndTime, DlOperatingMode operatingMode); + uint32_t localEndTime, OperatingModeEnum operatingMode); bool IsValidUserIndex(uint16_t userIndex); - bool IsValidCredentialIndex(uint16_t credentialIndex, DlCredentialType type); + bool IsValidCredentialIndex(uint16_t credentialIndex, CredentialTypeEnum type); bool IsValidWeekdayScheduleIndex(uint8_t scheduleIndex); bool IsValidYeardayScheduleIndex(uint8_t scheduleIndex); bool IsValidHolidayScheduleIndex(uint8_t scheduleIndex); bool setLockState(chip::EndpointId endpointId, DlLockState lockState, const Optional & pin, - DlOperationError & err); + OperationErrorEnum & err); const char * lockStateToString(DlLockState lockState) const; bool ReadConfigValues(); @@ -206,7 +207,7 @@ class LockManager char mUserNames[ArraySize(mLockUsers)][DOOR_LOCK_MAX_USER_NAME_SIZE]; uint8_t mCredentialData[kMaxCredentials][kMaxCredentialSize]; - DlCredential mCredentials[kMaxUsers][kMaxCredentialsPerUser]; + CredentialStruct mCredentials[kMaxUsers][kMaxCredentialsPerUser]; static LockManager sLock; EFR32DoorLock::LockInitParams::LockParam LockParams; diff --git a/examples/lock-app/silabs/efr32/src/AppTask.cpp b/examples/lock-app/silabs/efr32/src/AppTask.cpp index 8cd16f2a5a52cd..a39cf6a15df18f 100644 --- a/examples/lock-app/silabs/efr32/src/AppTask.cpp +++ b/examples/lock-app/silabs/efr32/src/AppTask.cpp @@ -37,8 +37,6 @@ #endif // DISPLAY_ENABLED #include -#include -#include #include #include @@ -66,8 +64,8 @@ #define APP_LOCK_SWITCH &sl_button_btn1 using chip::app::Clusters::DoorLock::DlLockState; -using chip::app::Clusters::DoorLock::DlOperationError; -using chip::app::Clusters::DoorLock::DlOperationSource; +using chip::app::Clusters::DoorLock::OperationErrorEnum; +using chip::app::Clusters::DoorLock::OperationSourceEnum; using namespace chip; using namespace ::chip::DeviceLayer; @@ -252,6 +250,21 @@ CHIP_ERROR AppTask::Init() sLockLED.Set(state.Value() == DlLockState::kUnlocked); #endif // ENABLE_WSTK_LEDS + // Update the LCD with the Stored value. Show QR Code if not provisioned +#ifdef DISPLAY_ENABLED + GetLCD().WriteDemoUI(state.Value() != DlLockState::kUnlocked); +#ifdef QR_CODE_ENABLED +#ifdef SL_WIFI + if (!ConnectivityMgr().IsWiFiStationProvisioned()) +#else + if (!ConnectivityMgr().IsThreadProvisioned()) +#endif /* !SL_WIFI */ + { + GetLCD().ShowQRCode(true, true); + } +#endif // QR_CODE_ENABLED +#endif + chip::DeviceLayer::PlatformMgr().ScheduleWork(UpdateClusterState, reinterpret_cast(nullptr)); ConfigurationMgr().LogDeviceConfig(); @@ -434,7 +447,7 @@ void AppTask::UpdateClusterState(intptr_t context) bool unlocked = LockMgr().NextState(); DlLockState newState = unlocked ? DlLockState::kUnlocked : DlLockState::kLocked; - DlOperationSource source = DlOperationSource::kUnspecified; + OperationSourceEnum source = OperationSourceEnum::kUnspecified; // write the new lock value EmberAfStatus status = diff --git a/examples/lock-app/silabs/efr32/src/EventHandlerLibShell.cpp b/examples/lock-app/silabs/efr32/src/EventHandlerLibShell.cpp index 02979f56238a23..ef79290bd1961f 100644 --- a/examples/lock-app/silabs/efr32/src/EventHandlerLibShell.cpp +++ b/examples/lock-app/silabs/efr32/src/EventHandlerLibShell.cpp @@ -104,7 +104,7 @@ CHIP_ERROR AlarmEventHandler(int argc, char ** argv) AlarmEventData * data = Platform::New(); data->eventId = Events::DoorLockAlarm::Id; - data->alarmCode = static_cast(atoi(argv[0])); + data->alarmCode = static_cast(atoi(argv[0])); DeviceLayer::PlatformMgr().ScheduleWork(EventWorkerFunction, reinterpret_cast(data)); @@ -136,7 +136,7 @@ CHIP_ERROR DoorStateEventHandler(int argc, char ** argv) DoorStateEventData * data = Platform::New(); data->eventId = Events::DoorStateChange::Id; - data->doorState = static_cast(atoi(argv[0])); + data->doorState = static_cast(atoi(argv[0])); DeviceLayer::PlatformMgr().ScheduleWork(EventWorkerFunction, reinterpret_cast(data)); diff --git a/examples/lock-app/silabs/efr32/src/LockManager.cpp b/examples/lock-app/silabs/efr32/src/LockManager.cpp index abc7b4513e2f71..54bd876147d1c3 100644 --- a/examples/lock-app/silabs/efr32/src/LockManager.cpp +++ b/examples/lock-app/silabs/efr32/src/LockManager.cpp @@ -104,9 +104,9 @@ bool LockManager::IsValidUserIndex(uint16_t userIndex) return (userIndex < kMaxUsers); } -bool LockManager::IsValidCredentialIndex(uint16_t credentialIndex, DlCredentialType type) +bool LockManager::IsValidCredentialIndex(uint16_t credentialIndex, CredentialTypeEnum type) { - if (DlCredentialType::kProgrammingPIN == type) + if (CredentialTypeEnum::kProgrammingPIN == type) { return (0 == credentialIndex); // 0 is required index for Programming PIN } @@ -144,7 +144,7 @@ bool LockManager::ReadConfigValues() sizeof(mCredentialData), outLen); SILABSConfig::ReadConfigValueBin(SILABSConfig::kConfigKey_UserCredentials, reinterpret_cast(mCredentials), - sizeof(DlCredential) * LockParams.numberOfUsers * LockParams.numberOfCredentialsPerUser, + sizeof(CredentialStruct) * LockParams.numberOfUsers * LockParams.numberOfCredentialsPerUser, outLen); SILABSConfig::ReadConfigValueBin(SILABSConfig::kConfigKey_WeekDaySchedules, reinterpret_cast(mWeekdaySchedule), @@ -283,12 +283,12 @@ void LockManager::ActuatorMovementTimerEventHandler(AppEvent * aEvent) } } -bool LockManager::Lock(chip::EndpointId endpointId, const Optional & pin, DlOperationError & err) +bool LockManager::Lock(chip::EndpointId endpointId, const Optional & pin, OperationErrorEnum & err) { return setLockState(endpointId, DlLockState::kLocked, pin, err); } -bool LockManager::Unlock(chip::EndpointId endpointId, const Optional & pin, DlOperationError & err) +bool LockManager::Unlock(chip::EndpointId endpointId, const Optional & pin, OperationErrorEnum & err) { return setLockState(endpointId, DlLockState::kUnlocked, pin, err); } @@ -306,14 +306,14 @@ bool LockManager::GetUser(chip::EndpointId endpointId, uint16_t userIndex, Ember const auto & userInDb = mLockUsers[userIndex]; user.userStatus = userInDb.userStatus; - if (DlUserStatus::kAvailable == user.userStatus) + if (UserStatusEnum::kAvailable == user.userStatus) { ChipLogDetail(Zcl, "Found unoccupied user [endpoint=%d]", endpointId); return true; } user.userName = chip::CharSpan(userInDb.userName.data(), userInDb.userName.size()); - user.credentials = chip::Span(mCredentials[userIndex], userInDb.credentials.size()); + user.credentials = chip::Span(mCredentials[userIndex], userInDb.credentials.size()); user.userUniqueId = userInDb.userUniqueId; user.userType = userInDb.userType; user.credentialRule = userInDb.credentialRule; @@ -336,8 +336,8 @@ bool LockManager::GetUser(chip::EndpointId endpointId, uint16_t userIndex, Ember } bool LockManager::SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - const chip::CharSpan & userName, uint32_t uniqueId, DlUserStatus userStatus, DlUserType usertype, - DlCredentialRule credentialRule, const DlCredential * credentials, size_t totalCredentials) + const chip::CharSpan & userName, uint32_t uniqueId, UserStatusEnum userStatus, UserTypeEnum usertype, + CredentialRuleEnum credentialRule, const CredentialStruct * credentials, size_t totalCredentials) { ChipLogProgress(Zcl, "Door Lock App: LockManager::SetUser " @@ -383,14 +383,14 @@ bool LockManager::SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip: mCredentials[userIndex][i].CredentialIndex = i + 1; } - userInStorage.credentials = chip::Span(mCredentials[userIndex], totalCredentials); + userInStorage.credentials = chip::Span(mCredentials[userIndex], totalCredentials); // Save user information in NVM flash SILABSConfig::WriteConfigValueBin(SILABSConfig::kConfigKey_LockUser, reinterpret_cast(&mLockUsers), sizeof(EmberAfPluginDoorLockUserInfo) * LockParams.numberOfUsers); SILABSConfig::WriteConfigValueBin(SILABSConfig::kConfigKey_UserCredentials, reinterpret_cast(mCredentials), - sizeof(DlCredential) * LockParams.numberOfUsers * LockParams.numberOfCredentialsPerUser); + sizeof(CredentialStruct) * LockParams.numberOfUsers * LockParams.numberOfCredentialsPerUser); SILABSConfig::WriteConfigValueBin(SILABSConfig::kConfigKey_LockUserName, reinterpret_cast(mUserNames), sizeof(mUserNames)); @@ -400,11 +400,11 @@ bool LockManager::SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip: return true; } -bool LockManager::GetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, DlCredentialType credentialType, +bool LockManager::GetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, CredentialTypeEnum credentialType, EmberAfPluginDoorLockCredentialInfo & credential) { - if (DlCredentialType::kProgrammingPIN == credentialType) + if (CredentialTypeEnum::kProgrammingPIN == credentialType) { VerifyOrReturnValue(IsValidCredentialIndex(credentialIndex, credentialType), false); // programming pin index is only index allowed to contain 0 @@ -443,11 +443,11 @@ bool LockManager::GetCredential(chip::EndpointId endpointId, uint16_t credential } bool LockManager::SetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, chip::FabricIndex creator, - chip::FabricIndex modifier, DlCredentialStatus credentialStatus, DlCredentialType credentialType, + chip::FabricIndex modifier, DlCredentialStatus credentialStatus, CredentialTypeEnum credentialType, const chip::ByteSpan & credentialData) { - if (DlCredentialType::kProgrammingPIN == credentialType) + if (CredentialTypeEnum::kProgrammingPIN == credentialType) { VerifyOrReturnValue(IsValidCredentialIndex(credentialIndex, credentialType), false); // programming pin index is only index allowed to contain 0 @@ -509,7 +509,7 @@ DlStatus LockManager::GetWeekdaySchedule(chip::EndpointId endpointId, uint8_t we } DlStatus LockManager::SetWeekdaySchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex, - DlScheduleStatus status, DlDaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, + DlScheduleStatus status, DaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute) { @@ -609,7 +609,7 @@ DlStatus LockManager::GetHolidaySchedule(chip::EndpointId endpointId, uint8_t ho } DlStatus LockManager::SetHolidaySchedule(chip::EndpointId endpointId, uint8_t holidayIndex, DlScheduleStatus status, - uint32_t localStartTime, uint32_t localEndTime, DlOperatingMode operatingMode) + uint32_t localStartTime, uint32_t localEndTime, OperatingModeEnum operatingMode) { VerifyOrReturnValue(holidayIndex > 0, DlStatus::kFailure); // indices are one-indexed @@ -650,7 +650,7 @@ const char * LockManager::lockStateToString(DlLockState lockState) const } bool LockManager::setLockState(chip::EndpointId endpointId, DlLockState lockState, const Optional & pin, - DlOperationError & err) + OperationErrorEnum & err) { // Assume pin is required until told otherwise @@ -681,7 +681,7 @@ bool LockManager::setLockState(chip::EndpointId endpointId, DlLockState lockStat // Check the PIN code for (uint8_t i = 0; i < kMaxCredentials; i++) { - if (mLockCredentials[i].credentialType != DlCredentialType::kPin || + if (mLockCredentials[i].credentialType != CredentialTypeEnum::kPin || mLockCredentials[i].status == DlCredentialStatus::kAvailable) { continue; @@ -704,6 +704,6 @@ bool LockManager::setLockState(chip::EndpointId endpointId, DlLockState lockStat "[endpointId=%d]", lockStateToString(lockState), endpointId); - err = DlOperationError::kInvalidCredential; + err = OperationErrorEnum::kInvalidCredential; return false; } diff --git a/examples/lock-app/silabs/efr32/src/ZclCallbacks.cpp b/examples/lock-app/silabs/efr32/src/ZclCallbacks.cpp index 9c1812a90c0a04..778637e250a5a5 100644 --- a/examples/lock-app/silabs/efr32/src/ZclCallbacks.cpp +++ b/examples/lock-app/silabs/efr32/src/ZclCallbacks.cpp @@ -58,7 +58,8 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & */ void emberAfDoorLockClusterInitCallback(EndpointId endpoint) {} -bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const Optional & pinCode, DlOperationError & err) +bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const Optional & pinCode, + OperationErrorEnum & err) { ChipLogProgress(Zcl, "Door Lock App: Lock Command endpoint=%d", endpointId); bool status = LockMgr().Lock(endpointId, pinCode, err); @@ -70,7 +71,7 @@ bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const O } bool emberAfPluginDoorLockOnDoorUnlockCommand(chip::EndpointId endpointId, const Optional & pinCode, - DlOperationError & err) + OperationErrorEnum & err) { ChipLogProgress(Zcl, "Door Lock App: Unlock Command endpoint=%d", endpointId); bool status = LockMgr().Unlock(endpointId, pinCode, err); @@ -82,7 +83,7 @@ bool emberAfPluginDoorLockOnDoorUnlockCommand(chip::EndpointId endpointId, const return status; } -bool emberAfPluginDoorLockGetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, DlCredentialType credentialType, +bool emberAfPluginDoorLockGetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, CredentialTypeEnum credentialType, EmberAfPluginDoorLockCredentialInfo & credential) { return LockMgr().GetCredential(endpointId, credentialIndex, credentialType, credential); @@ -90,7 +91,7 @@ bool emberAfPluginDoorLockGetCredential(chip::EndpointId endpointId, uint16_t cr bool emberAfPluginDoorLockSetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, chip::FabricIndex creator, chip::FabricIndex modifier, DlCredentialStatus credentialStatus, - DlCredentialType credentialType, const chip::ByteSpan & credentialData) + CredentialTypeEnum credentialType, const chip::ByteSpan & credentialData) { return LockMgr().SetCredential(endpointId, credentialIndex, creator, modifier, credentialStatus, credentialType, credentialData); @@ -103,8 +104,8 @@ bool emberAfPluginDoorLockGetUser(chip::EndpointId endpointId, uint16_t userInde bool emberAfPluginDoorLockSetUser(chip::EndpointId endpointId, uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, const chip::CharSpan & userName, uint32_t uniqueId, - DlUserStatus userStatus, DlUserType usertype, DlCredentialRule credentialRule, - const DlCredential * credentials, size_t totalCredentials) + UserStatusEnum userStatus, UserTypeEnum usertype, CredentialRuleEnum credentialRule, + const CredentialStruct * credentials, size_t totalCredentials) { return LockMgr().SetUser(endpointId, userIndex, creator, modifier, userName, uniqueId, userStatus, usertype, credentialRule, @@ -130,7 +131,7 @@ DlStatus emberAfPluginDoorLockGetSchedule(chip::EndpointId endpointId, uint8_t h } DlStatus emberAfPluginDoorLockSetSchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex, - DlScheduleStatus status, DlDaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, + DlScheduleStatus status, DaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute) { return LockMgr().SetWeekdaySchedule(endpointId, weekdayIndex, userIndex, status, daysMask, startHour, startMinute, endHour, @@ -144,7 +145,7 @@ DlStatus emberAfPluginDoorLockSetSchedule(chip::EndpointId endpointId, uint8_t y } DlStatus emberAfPluginDoorLockSetSchedule(chip::EndpointId endpointId, uint8_t holidayIndex, DlScheduleStatus status, - uint32_t localStartTime, uint32_t localEndTime, DlOperatingMode operatingMode) + uint32_t localStartTime, uint32_t localEndTime, OperatingModeEnum operatingMode) { return LockMgr().SetHolidaySchedule(endpointId, holidayIndex, status, localStartTime, localEndTime, operatingMode); } diff --git a/examples/lock-app/silabs/efr32/with_pw_rpc.gni b/examples/lock-app/silabs/efr32/with_pw_rpc.gni index faa281a6a4597c..b691609e6bf2d0 100644 --- a/examples/lock-app/silabs/efr32/with_pw_rpc.gni +++ b/examples/lock-app/silabs/efr32/with_pw_rpc.gni @@ -21,6 +21,7 @@ import("${chip_root}/examples/platform/silabs/efr32/args.gni") efr32_sdk_target = get_label_info(":sdk", "label_no_toolchain") +app_data_model = "${chip_root}/examples/lock-app/lock-common" chip_enable_pw_rpc = true chip_enable_openthread = true chip_openthread_ftd = true diff --git a/examples/log-source-app/log-source-common/log-source-app.matter b/examples/log-source-app/log-source-common/log-source-app.matter index 543964d22f8683..6a23601e67d1fa 100644 --- a/examples/log-source-app/log-source-common/log-source-app.matter +++ b/examples/log-source-app/log-source-common/log-source-app.matter @@ -309,8 +309,13 @@ server cluster DiagnosticLogs = 50 { } server cluster OperationalCredentials = 62 { - enum OperationalCertStatus : ENUM8 { - kSuccess = 0; + enum CertificateChainTypeEnum : ENUM8 { + kDACCertificate = 1; + kPAICertificate = 2; + } + + enum NodeOperationalCertStatusEnum : ENUM8 { + kOk = 0; kInvalidPublicKey = 1; kInvalidNodeOpId = 2; kInvalidNOC = 3; @@ -322,16 +327,16 @@ server cluster OperationalCredentials = 62 { kInvalidFabricIndex = 11; } - fabric_scoped struct FabricDescriptor { + fabric_scoped struct FabricDescriptorStruct { octet_string<65> rootPublicKey = 1; - vendor_id vendorId = 2; - fabric_id fabricId = 3; - node_id nodeId = 4; + vendor_id vendorID = 2; + fabric_id fabricID = 3; + node_id nodeID = 4; char_string<32> label = 5; fabric_idx fabricIndex = 254; } - readonly attribute FabricDescriptor fabrics[] = 1; + readonly attribute FabricDescriptorStruct fabrics[] = 1; readonly attribute int8u supportedFabrics = 2; readonly attribute int8u commissionedFabrics = 3; readonly attribute OCTET_STRING trustedRootCertificates[] = 4; @@ -343,7 +348,7 @@ server cluster OperationalCredentials = 62 { } request struct CertificateChainRequestRequest { - INT8U certificateType = 0; + CertificateChainTypeEnum certificateType = 0; } request struct CSRRequestRequest { @@ -368,12 +373,12 @@ server cluster OperationalCredentials = 62 { } request struct AddTrustedRootCertificateRequest { - OCTET_STRING rootCertificate = 0; + OCTET_STRING rootCACertificate = 0; } response struct AttestationResponse = 1 { OCTET_STRING attestationElements = 0; - OCTET_STRING signature = 1; + OCTET_STRING attestationSignature = 1; } response struct CertificateChainResponse = 3 { @@ -386,7 +391,7 @@ server cluster OperationalCredentials = 62 { } response struct NOCResponse = 8 { - OperationalCertStatus statusCode = 0; + NodeOperationalCertStatusEnum statusCode = 0; optional fabric_idx fabricIndex = 1; optional CHAR_STRING debugText = 2; } @@ -408,7 +413,7 @@ endpoint 0 { callback attribute extension; callback attribute subjectsPerAccessControlEntry default = 4; callback attribute targetsPerAccessControlEntry default = 3; - callback attribute accessControlEntriesPerFabric default = 3; + callback attribute accessControlEntriesPerFabric default = 4; callback attribute attributeList; ram attribute featureMap; ram attribute clusterRevision default = 1; diff --git a/examples/log-source-app/log-source-common/log-source-app.zap b/examples/log-source-app/log-source-common/log-source-app.zap index 36521f83142409..9774fe1fe26cd0 100644 --- a/examples/log-source-app/log-source-common/log-source-app.zap +++ b/examples/log-source-app/log-source-common/log-source-app.zap @@ -826,7 +826,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "4", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2045,7 +2045,7 @@ "code": 3, "mfgCode": null, "side": "server", - "type": "DlDoorState", + "type": "DoorStateEnum", "included": 0, "storageOption": "RAM", "singleton": 0, @@ -2125,7 +2125,7 @@ "code": 37, "mfgCode": null, "side": "server", - "type": "DlOperatingMode", + "type": "OperatingModeEnum", "included": 0, "storageOption": "RAM", "singleton": 0, diff --git a/examples/ota-provider-app/esp32/main/CMakeLists.txt b/examples/ota-provider-app/esp32/main/CMakeLists.txt index 8c58d0b4b4fc18..7bbf39d18ab0e3 100644 --- a/examples/ota-provider-app/esp32/main/CMakeLists.txt +++ b/examples/ota-provider-app/esp32/main/CMakeLists.txt @@ -23,7 +23,6 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/providers" SRC_DIRS "${CMAKE_CURRENT_LIST_DIR}" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/ota-provider-app/zap-generated" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated/attributes" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server" diff --git a/examples/ota-provider-app/ota-provider-common/ota-provider-app.matter b/examples/ota-provider-app/ota-provider-common/ota-provider-app.matter index 9fe993dff84b3b..9f063951dc612f 100644 --- a/examples/ota-provider-app/ota-provider-common/ota-provider-app.matter +++ b/examples/ota-provider-app/ota-provider-common/ota-provider-app.matter @@ -505,7 +505,7 @@ server cluster GeneralDiagnostics = 51 { kSoftwareReset = 6; } - enum HardwareFault : ENUM8 { + enum HardwareFaultEnum : ENUM8 { kUnspecified = 0; kRadio = 1; kSensor = 2; @@ -519,7 +519,7 @@ server cluster GeneralDiagnostics = 51 { kTamperDetected = 10; } - enum InterfaceType : ENUM8 { + enum InterfaceTypeEnum : ENUM8 { kUnspecified = 0; kWiFi = 1; kEthernet = 2; @@ -527,14 +527,14 @@ server cluster GeneralDiagnostics = 51 { kThread = 4; } - enum NetworkFaultType : ENUM8 { + enum NetworkFaultEnum : ENUM8 { kUnspecified = 0; kHardwareFailure = 1; kNetworkJammed = 2; kConnectionFailed = 3; } - enum RadioFault : ENUM8 { + enum RadioFaultEnum : ENUM8 { kUnspecified = 0; kWiFiFault = 1; kCellularFault = 2; @@ -552,22 +552,22 @@ server cluster GeneralDiagnostics = 51 { octet_string<8> hardwareAddress = 4; octet_string IPv4Addresses[] = 5; octet_string IPv6Addresses[] = 6; - InterfaceType type = 7; + InterfaceTypeEnum type = 7; } critical event HardwareFaultChange = 0 { - HardwareFault current[] = 0; - HardwareFault previous[] = 1; + HardwareFaultEnum current[] = 0; + HardwareFaultEnum previous[] = 1; } critical event RadioFaultChange = 1 { - RadioFault current[] = 0; - RadioFault previous[] = 1; + RadioFaultEnum current[] = 0; + RadioFaultEnum previous[] = 1; } critical event NetworkFaultChange = 2 { - NetworkFaultType current[] = 0; - NetworkFaultType previous[] = 1; + NetworkFaultEnum current[] = 0; + NetworkFaultEnum previous[] = 1; } critical event BootReason = 3 { @@ -579,9 +579,9 @@ server cluster GeneralDiagnostics = 51 { readonly attribute int64u upTime = 2; readonly attribute int32u totalOperationalHours = 3; readonly attribute BootReasonEnum bootReason = 4; - readonly attribute HardwareFault activeHardwareFaults[] = 5; - readonly attribute RadioFault activeRadioFaults[] = 6; - readonly attribute NetworkFaultType activeNetworkFaults[] = 7; + readonly attribute HardwareFaultEnum activeHardwareFaults[] = 5; + readonly attribute RadioFaultEnum activeRadioFaults[] = 6; + readonly attribute NetworkFaultEnum activeNetworkFaults[] = 7; readonly attribute boolean testEventTriggersEnabled = 8; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -595,7 +595,7 @@ server cluster GeneralDiagnostics = 51 { } server cluster AdministratorCommissioning = 60 { - enum CommissioningWindowStatus : ENUM8 { + enum CommissioningWindowStatusEnum : ENUM8 { kWindowNotOpen = 0; kEnhancedWindowOpen = 1; kBasicWindowOpen = 2; @@ -607,7 +607,7 @@ server cluster AdministratorCommissioning = 60 { kWindowNotOpen = 4; } - readonly attribute CommissioningWindowStatus windowStatus = 0; + readonly attribute CommissioningWindowStatusEnum windowStatus = 0; readonly attribute nullable fabric_idx adminFabricIndex = 1; readonly attribute nullable int16u adminVendorId = 2; readonly attribute bitmap32 featureMap = 65532; @@ -631,8 +631,13 @@ server cluster AdministratorCommissioning = 60 { } server cluster OperationalCredentials = 62 { - enum OperationalCertStatus : ENUM8 { - kSuccess = 0; + enum CertificateChainTypeEnum : ENUM8 { + kDACCertificate = 1; + kPAICertificate = 2; + } + + enum NodeOperationalCertStatusEnum : ENUM8 { + kOk = 0; kInvalidPublicKey = 1; kInvalidNodeOpId = 2; kInvalidNOC = 3; @@ -650,17 +655,17 @@ server cluster OperationalCredentials = 62 { fabric_idx fabricIndex = 254; } - fabric_scoped struct FabricDescriptor { + fabric_scoped struct FabricDescriptorStruct { octet_string<65> rootPublicKey = 1; - vendor_id vendorId = 2; - fabric_id fabricId = 3; - node_id nodeId = 4; + vendor_id vendorID = 2; + fabric_id fabricID = 3; + node_id nodeID = 4; char_string<32> label = 5; fabric_idx fabricIndex = 254; } readonly attribute access(read: administer) NOCStruct NOCs[] = 0; - readonly attribute FabricDescriptor fabrics[] = 1; + readonly attribute FabricDescriptorStruct fabrics[] = 1; readonly attribute int8u supportedFabrics = 2; readonly attribute int8u commissionedFabrics = 3; readonly attribute OCTET_STRING trustedRootCertificates[] = 4; @@ -673,7 +678,7 @@ server cluster OperationalCredentials = 62 { } request struct CertificateChainRequestRequest { - INT8U certificateType = 0; + CertificateChainTypeEnum certificateType = 0; } request struct CSRRequestRequest { @@ -703,12 +708,12 @@ server cluster OperationalCredentials = 62 { } request struct AddTrustedRootCertificateRequest { - OCTET_STRING rootCertificate = 0; + OCTET_STRING rootCACertificate = 0; } response struct AttestationResponse = 1 { OCTET_STRING attestationElements = 0; - OCTET_STRING signature = 1; + OCTET_STRING attestationSignature = 1; } response struct CertificateChainResponse = 3 { @@ -721,7 +726,7 @@ server cluster OperationalCredentials = 62 { } response struct NOCResponse = 8 { - OperationalCertStatus statusCode = 0; + NodeOperationalCertStatusEnum statusCode = 0; optional fabric_idx fabricIndex = 1; optional CHAR_STRING debugText = 2; } @@ -836,7 +841,7 @@ endpoint 0 { callback attribute extension; callback attribute subjectsPerAccessControlEntry default = 4; callback attribute targetsPerAccessControlEntry default = 3; - callback attribute accessControlEntriesPerFabric default = 3; + callback attribute accessControlEntriesPerFabric default = 4; callback attribute attributeList; ram attribute featureMap; ram attribute clusterRevision default = 1; diff --git a/examples/ota-provider-app/ota-provider-common/ota-provider-app.zap b/examples/ota-provider-app/ota-provider-common/ota-provider-app.zap index 56d5935f595c42..1d460b40c25855 100644 --- a/examples/ota-provider-app/ota-provider-common/ota-provider-app.zap +++ b/examples/ota-provider-app/ota-provider-common/ota-provider-app.zap @@ -1040,7 +1040,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "4", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2589,7 +2589,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -2623,7 +2623,7 @@ ] }, { - "name": "AdministratorCommissioning", + "name": "Administrator Commissioning", "code": 60, "mfgCode": null, "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", @@ -2635,7 +2635,7 @@ "code": 0, "mfgCode": null, "side": "server", - "type": "CommissioningWindowStatus", + "type": "CommissioningWindowStatusEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -3477,7 +3477,7 @@ "code": 3, "mfgCode": null, "side": "server", - "type": "DlDoorState", + "type": "DoorStateEnum", "included": 0, "storageOption": "RAM", "singleton": 0, @@ -3557,7 +3557,7 @@ "code": 37, "mfgCode": null, "side": "server", - "type": "DlOperatingMode", + "type": "OperatingModeEnum", "included": 0, "storageOption": "RAM", "singleton": 0, diff --git a/examples/ota-requestor-app/ameba/main/DeviceCallbacks.cpp b/examples/ota-requestor-app/ameba/main/DeviceCallbacks.cpp index 8e6b1192b96dd8..0ef956fe939e11 100644 --- a/examples/ota-requestor-app/ameba/main/DeviceCallbacks.cpp +++ b/examples/ota-requestor-app/ameba/main/DeviceCallbacks.cpp @@ -25,7 +25,7 @@ #include "DeviceCallbacks.h" #include "CHIPDeviceManager.h" -#include +#include #include #include #include @@ -139,7 +139,7 @@ void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event void DeviceCallbacks::OnOnOffPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { - VerifyOrExit(attributeId == ZCL_ON_OFF_ATTRIBUTE_ID, + VerifyOrExit(attributeId == app::Clusters::OnOff::Attributes::OnOff::Id, ChipLogError(DeviceLayer, TAG, "Unhandled Attribute ID: '0x%04x", attributeId)); VerifyOrExit(endpointId == 1 || endpointId == 2, ChipLogError(DeviceLayer, TAG, "Unexpected EndPoint ID: `0x%02x'", endpointId)); @@ -161,7 +161,7 @@ void IdentifyTimerHandler(Layer * systemLayer, void * appState, CHIP_ERROR error void DeviceCallbacks::OnIdentifyPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { - VerifyOrExit(attributeId == ZCL_IDENTIFY_TIME_ATTRIBUTE_ID, + VerifyOrExit(attributeId == app::Clusters::Identify::Attributes::IdentifyTime::Id, ChipLogError(DeviceLayer, "[%s] Unhandled Attribute ID: '0x%04x", TAG, attributeId)); VerifyOrExit(endpointId == 1, ChipLogError(DeviceLayer, "[%s] Unexpected EndPoint ID: `0x%02x'", TAG, endpointId)); diff --git a/examples/ota-requestor-app/esp32/main/CMakeLists.txt b/examples/ota-requestor-app/esp32/main/CMakeLists.txt index cdd50a0b220c1b..f2320f4c3785f4 100644 --- a/examples/ota-requestor-app/esp32/main/CMakeLists.txt +++ b/examples/ota-requestor-app/esp32/main/CMakeLists.txt @@ -28,7 +28,6 @@ set(PRIV_INCLUDE_DIRS_LIST set(SRC_DIRS_LIST "${CMAKE_CURRENT_LIST_DIR}" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/ota-requestor-app/zap-generated" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated/attributes" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server" diff --git a/examples/ota-requestor-app/linux/README.md b/examples/ota-requestor-app/linux/README.md index f14d5fa7cdf094..9cb47171aae555 100644 --- a/examples/ota-requestor-app/linux/README.md +++ b/examples/ota-requestor-app/linux/README.md @@ -16,11 +16,13 @@ scripts/examples/gn_build_example.sh examples/ota-requestor-app/linux out/debug In addition to the general options available to all Linux applications, the following command line options are available for the OTA Requestor application. +Note that these options are for testing purposes. | Command Line Option | Description | | -------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | -a, --autoApplyImage | If supplied, apply the image immediately after download. Otherwise, the OTA update is complete after image download. | | -c, --requestorCanConsent \ | Value for the RequestorCanConsent field in the QueryImage command. If not supplied, the value is determined by the driver. | +| -d, --disableNotifyUpdateApplied | If supplied, disable sending of the NotifyUpdateApplied command. Otherwise, after successfully loading into the updated image, send the NotifyUpdateApplied command. | | -f, --otaDownloadPath \ | If supplied, the OTA image is downloaded to the given fully-qualified file-path. Otherwise, the default location for the downloaded image is at /tmp/test.bin | | -p, --periodicQueryTimeout \