diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index dc47f2772e8b55..7e63af38cb99c8 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -17,7 +17,7 @@ "build": { "dockerfile": "Dockerfile", "args": { - "BUILD_VERSION": "0.6.47" + "BUILD_VERSION": "0.7.0" } }, "remoteUser": "vscode", diff --git a/.github/.wordlist.txt b/.github/.wordlist.txt index 5b812d9e1dc6b1..4b91d6cb46ff81 100644 --- a/.github/.wordlist.txt +++ b/.github/.wordlist.txt @@ -985,6 +985,7 @@ otatesting otaURL OTBR otcli +outform outgoingCommands OxygenConcentrationMeasurement OzoneConcentrationMeasurement @@ -1024,6 +1025,7 @@ Pigweed PinCode pinrequest pkgconfig +PKI plaintext PlatformManager PlatformManagerImpl @@ -1180,6 +1182,7 @@ sdkconfig SDKs SDKTARGETSYSROOT sdl +SecureCertDACProvider SED SEGGER semver diff --git a/.github/workflows/bloat_check.yaml b/.github/workflows/bloat_check.yaml index b5de443569d2e6..17b890acb8d618 100644 --- a/.github/workflows/bloat_check.yaml +++ b/.github/workflows/bloat_check.yaml @@ -33,7 +33,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.6.47 + image: connectedhomeip/chip-build:0.7.0 steps: - uses: Wandalen/wretry.action@v1.0.36 diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index c580dda8e5603f..3db04035806804 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.47 + image: connectedhomeip/chip-build:0.7.0 volumes: - "/tmp/log_output:/tmp/test_logs" options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 @@ -148,7 +148,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.47 + image: connectedhomeip/chip-build:0.7.0 volumes: - "/tmp/log_output:/tmp/test_logs" options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 @@ -261,6 +261,8 @@ jobs: run: | ./scripts/run_in_build_env.sh "./scripts/codepregen.py ./zzz_pregenerated" mv scripts/codegen.py scripts/codegen.py.renamed + - name: Clean output + run: rm -rf ./out - name: Build using build_examples.py (pregen) timeout-minutes: 60 run: | @@ -273,10 +275,10 @@ jobs: " - name: Check no code generation in output run: | - CNT=$(find -name "CHIPClusters.h" out | wc -l) + CNT=$(find out -name "CHIPClusters.h" | wc -l) if [ "${CNT}" != "0" ]; then echo "ERROR: found unexpected generated files:" - find -name "CHIPClusters.h" out + find out -name "CHIPClusters.h" exit 1 fi - name: Undo code pre-generation changes (make compile time codegen work again) @@ -318,7 +320,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.47 + image: connectedhomeip/chip-build:0.7.0 volumes: - "/tmp/log_output:/tmp/test_logs" options: --sysctl "net.ipv6.conf.all.disable_ipv6=0 @@ -485,7 +487,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.47 + image: connectedhomeip/chip-build:0.7.0 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 29ae5c8fd548a5..1581ab30078ba0 100644 --- a/.github/workflows/chef.yaml +++ b/.github/workflows/chef.yaml @@ -30,7 +30,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.47 + image: connectedhomeip/chip-build:0.7.0 options: --user root steps: @@ -66,7 +66,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32:0.6.47 + image: connectedhomeip/chip-build-esp32:0.7.0 options: --user root steps: @@ -102,7 +102,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-nrf-platform:0.6.47 + image: connectedhomeip/chip-build-nrf-platform:0.7.0 options: --user root steps: diff --git a/.github/workflows/cirque.yaml b/.github/workflows/cirque.yaml index f1ce18e3693319..3ba684577149de 100644 --- a/.github/workflows/cirque.yaml +++ b/.github/workflows/cirque.yaml @@ -30,7 +30,7 @@ jobs: timeout-minutes: 90 env: - DOCKER_RUN_VERSION: 0.6.47 + DOCKER_RUN_VERSION: 0.7.0 GITHUB_CACHE_PATH: /tmp/cirque-cache runs-on: ubuntu-latest @@ -39,7 +39,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.47 + # image: connectedhomeip/chip-build-cirque:0.7.0 # volumes: # - "/tmp:/tmp" # - "/dev/pts:/dev/pts" diff --git a/.github/workflows/darwin.yaml b/.github/workflows/darwin.yaml index 40ec4df82cc88d..2a7c3642919323 100644 --- a/.github/workflows/darwin.yaml +++ b/.github/workflows/darwin.yaml @@ -68,7 +68,7 @@ jobs: - 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' + run: scripts/run_in_build_env.sh 'D=$(dirname $(which zap-cli)) && mv $D/zap-cli $D/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' @@ -112,7 +112,7 @@ jobs: 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' + run: scripts/run_in_build_env.sh 'D=$(dirname $(which zap-cli.moved)) && mv $D/zap-cli.moved $D/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 diff --git a/.github/workflows/doxygen.yaml b/.github/workflows/doxygen.yaml index 692ab763340db7..7c24e5fb5c776f 100644 --- a/.github/workflows/doxygen.yaml +++ b/.github/workflows/doxygen.yaml @@ -82,7 +82,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build-doxygen:0.6.47 + image: connectedhomeip/chip-build-doxygen:0.7.0 if: github.actor != 'restyled-io[bot]' diff --git a/.github/workflows/examples-ameba.yaml b/.github/workflows/examples-ameba.yaml index a747a9565fdd60..b902a3815838c1 100644 --- a/.github/workflows/examples-ameba.yaml +++ b/.github/workflows/examples-ameba.yaml @@ -36,7 +36,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-ameba:0.6.47 + image: connectedhomeip/chip-build-ameba:0.7.0 options: --user root steps: diff --git a/.github/workflows/examples-bouffalolab.yaml b/.github/workflows/examples-bouffalolab.yaml index b87b5da515c373..e7fbe4a8a13856 100644 --- a/.github/workflows/examples-bouffalolab.yaml +++ b/.github/workflows/examples-bouffalolab.yaml @@ -36,7 +36,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-bouffalolab:0.6.47 + image: connectedhomeip/chip-build-bouffalolab:0.7.0 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 a4e2a302bcb8b3..2e0bee2f65cd3a 100644 --- a/.github/workflows/examples-cc13x2x7_26x2x7.yaml +++ b/.github/workflows/examples-cc13x2x7_26x2x7.yaml @@ -38,7 +38,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-ti:0.6.47 + image: connectedhomeip/chip-build-ti:0.7.0 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-cc32xx.yaml b/.github/workflows/examples-cc32xx.yaml index 3bfed24d5497d4..4ebc1114cfc35d 100644 --- a/.github/workflows/examples-cc32xx.yaml +++ b/.github/workflows/examples-cc32xx.yaml @@ -35,7 +35,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-ti:0.6.47 + image: connectedhomeip/chip-build-ti:0.7.0 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-efr32.yaml b/.github/workflows/examples-efr32.yaml index 5b448eb525a121..ce2163d1581b18 100644 --- a/.github/workflows/examples-efr32.yaml +++ b/.github/workflows/examples-efr32.yaml @@ -39,7 +39,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-efr32:0.6.50 + image: connectedhomeip/chip-build-efr32:0.7.0 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-esp32.yaml b/.github/workflows/examples-esp32.yaml index 4065aecf78d074..42cf0bdf72839c 100644 --- a/.github/workflows/examples-esp32.yaml +++ b/.github/workflows/examples-esp32.yaml @@ -35,7 +35,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32:0.6.47 + image: connectedhomeip/chip-build-esp32:0.7.0 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" @@ -87,10 +87,18 @@ jobs: build \ --copy-artifacts-to out/artifacts \ " + - name: Prepare bloat report + run: | + .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ + esp32 m5stack all-clusters-app \ + out/esp32-m5stack-all-clusters/chip-all-clusters-app.elf \ + /tmp/bloat_reports/ - name: Prepare code pregen and ensure compile time pregen not possible run: | ./scripts/run_in_build_env.sh "./scripts/codepregen.py ./zzz_pregenerated" mv scripts/codegen.py scripts/codegen.py.renamed + - name: Clean output + run: rm -rf ./out - name: Build some M5Stack variations with pregen timeout-minutes: 60 run: | @@ -105,22 +113,16 @@ jobs: " - name: Check no code generation in output run: | - CNT=$(find -name "CHIPClusters.h" out | wc -l) + CNT=$(find out -name "CHIPClusters.h" | wc -l) if [ "${CNT}" != "0" ]; then echo "ERROR: found unexpected generated files:" - find -name "CHIPClusters.h" out + find out -name "CHIPClusters.h" exit 1 fi - name: Undo code pregeneration changes run: | rm -rf ./zzz_pregenerated mv scripts/codegen.py.renamed scripts/codegen.py - - name: Prepare bloat report - run: | - .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ - esp32 m5stack all-clusters-app \ - out/esp32-m5stack-all-clusters/chip-all-clusters-app.elf \ - /tmp/bloat_reports/ - name: Build example All Clusters App C3 timeout-minutes: 15 run: scripts/examples/esp_example.sh all-clusters-app sdkconfig_c3devkit.defaults @@ -158,7 +160,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32:0.6.47 + image: connectedhomeip/chip-build-esp32:0.7.0 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-infineon.yaml b/.github/workflows/examples-infineon.yaml index b8e8f73c46912a..b3f3e946e53b49 100644 --- a/.github/workflows/examples-infineon.yaml +++ b/.github/workflows/examples-infineon.yaml @@ -36,7 +36,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-infineon:0.6.47 + image: connectedhomeip/chip-build-infineon:0.7.0 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-k32w.yaml b/.github/workflows/examples-k32w.yaml index 4ecbee87147a7b..a9c405d010fd4a 100644 --- a/.github/workflows/examples-k32w.yaml +++ b/.github/workflows/examples-k32w.yaml @@ -38,7 +38,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-k32w:0.6.47 + image: connectedhomeip/chip-build-k32w:0.7.0 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 8d26d9d6f12d86..0d949bdc748b97 100644 --- a/.github/workflows/examples-linux-arm.yaml +++ b/.github/workflows/examples-linux-arm.yaml @@ -35,7 +35,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-crosscompile:0.6.47 + image: connectedhomeip/chip-build-crosscompile:0.7.0 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-linux-imx.yaml b/.github/workflows/examples-linux-imx.yaml index caa56ec4864df7..1c6220bdca5fb7 100644 --- a/.github/workflows/examples-linux-imx.yaml +++ b/.github/workflows/examples-linux-imx.yaml @@ -35,7 +35,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-imx:0.6.47 + image: connectedhomeip/chip-build-imx:0.7.0 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 9097133fe6e6b0..fc40301b2b9249 100644 --- a/.github/workflows/examples-linux-standalone.yaml +++ b/.github/workflows/examples-linux-standalone.yaml @@ -35,7 +35,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.47 + image: connectedhomeip/chip-build:0.7.0 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-mbed.yaml b/.github/workflows/examples-mbed.yaml index e886d5617f890d..dadbb5eff3d476 100644 --- a/.github/workflows/examples-mbed.yaml +++ b/.github/workflows/examples-mbed.yaml @@ -41,7 +41,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-mbed-os:0.6.47 + image: connectedhomeip/chip-build-mbed-os:0.7.0 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-mw320.yaml b/.github/workflows/examples-mw320.yaml index 98c01fc4eab8b6..36f7c9cdb26c2e 100755 --- a/.github/workflows/examples-mw320.yaml +++ b/.github/workflows/examples-mw320.yaml @@ -38,7 +38,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.47 + image: connectedhomeip/chip-build:0.7.0 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-nrfconnect.yaml b/.github/workflows/examples-nrfconnect.yaml index ab8b44c89a7ba3..2c4a318ee6ed9a 100644 --- a/.github/workflows/examples-nrfconnect.yaml +++ b/.github/workflows/examples-nrfconnect.yaml @@ -38,7 +38,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-nrf-platform:0.6.47 + image: connectedhomeip/chip-build-nrf-platform:0.7.0 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-openiotsdk.yaml b/.github/workflows/examples-openiotsdk.yaml index 6a01bc03cca670..2e3af4d79473ef 100644 --- a/.github/workflows/examples-openiotsdk.yaml +++ b/.github/workflows/examples-openiotsdk.yaml @@ -36,7 +36,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-openiotsdk:0.6.47 + image: connectedhomeip/chip-build-openiotsdk:0.7.0 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" options: --privileged diff --git a/.github/workflows/examples-qpg.yaml b/.github/workflows/examples-qpg.yaml index a7888a092a3e23..3320d618d07798 100644 --- a/.github/workflows/examples-qpg.yaml +++ b/.github/workflows/examples-qpg.yaml @@ -38,7 +38,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.47 + image: connectedhomeip/chip-build:0.7.0 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 547e6bf7bd8ad0..2ebd9923551732 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -94,6 +94,18 @@ jobs: - name: clean out build output run: rm -rf ./out + - name: Build example Telink Bridge App + run: | + ./scripts/run_in_build_env.sh \ + "./scripts/build/build_examples.py --target 'telink-tlsr9518adk80d-bridge' build" + .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ + telink tlsr9518adk80d bridge-app \ + out/telink-tlsr9518adk80d-bridge/zephyr/zephyr.elf \ + /tmp/bloat_reports/ + + - name: clean out build output + run: rm -rf ./out + - name: Build example Telink Contact Sensor App run: | ./scripts/run_in_build_env.sh \ diff --git a/.github/workflows/examples-tizen.yaml b/.github/workflows/examples-tizen.yaml index 7c9d71c8b2c8d8..2946170d872793 100644 --- a/.github/workflows/examples-tizen.yaml +++ b/.github/workflows/examples-tizen.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-tizen:0.6.47 + image: connectedhomeip/chip-build-tizen:0.7.0 options: --user root volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/fuzzing-build.yaml b/.github/workflows/fuzzing-build.yaml index ae4658086ced6b..82aa03af5cef67 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.47 + image: connectedhomeip/chip-build:0.7.0 volumes: - "/tmp/log_output:/tmp/test_logs" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 17c31b004581d8..9b5de4ac637f40 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -221,3 +221,12 @@ jobs: if: always() run: | flake8 --extend-ignore=E501,W391 + + # git grep exits with 0 if it finds a match, but we want + # 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 "SuccessOrExit(CHIP_ERROR_*)", which should probably be "SuccessOrExit(err = CHIP_ERROR_*)" + if: always() + run: | + git grep -n 'SuccessOrExit(CHIP_ERROR' -- './*' ':(exclude).github/workflows/lint.yml' && exit 1 || exit 0 + diff --git a/.github/workflows/qemu.yaml b/.github/workflows/qemu.yaml index 1d0cf735d0cd9b..9cff443cfeb0c3 100644 --- a/.github/workflows/qemu.yaml +++ b/.github/workflows/qemu.yaml @@ -39,7 +39,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32-qemu:0.6.47 + image: connectedhomeip/chip-build-esp32-qemu:0.7.0 volumes: - "/tmp/log_output:/tmp/test_logs" @@ -103,7 +103,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-tizen-qemu:0.6.47 + image: connectedhomeip/chip-build-tizen-qemu:0.7.0 volumes: - "/tmp/log_output:/tmp/test_logs" diff --git a/.github/workflows/release_artifacts.yaml b/.github/workflows/release_artifacts.yaml index b43247453230fb..f725931e760da5 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.47 + image: connectedhomeip/chip-build-esp32:0.7.0 steps: - uses: Wandalen/wretry.action@v1.0.36 @@ -85,7 +85,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build-efr32:0.6.47 + image: connectedhomeip/chip-build-efr32:0.7.0 steps: - uses: Wandalen/wretry.action@v1.0.36 name: Checkout diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index da3e93be3c62e0..f52c3ccf8f1d7d 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -48,7 +48,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.6.47 + image: connectedhomeip/chip-build:0.7.0 options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1" @@ -442,7 +442,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.6.47 + image: connectedhomeip/chip-build:0.7.0 options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=0 net.ipv6.conf.all.forwarding=0" @@ -499,6 +499,7 @@ 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 --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"' + 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_CGEN_2_4.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 }} @@ -528,7 +529,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build-java:0.6.47 + image: connectedhomeip/chip-build-java:0.7.0 options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=0 net.ipv6.conf.all.forwarding=0" diff --git a/.github/workflows/unit_integration_test.yaml b/.github/workflows/unit_integration_test.yaml index 19d001989e4589..7623e8082c97cd 100644 --- a/.github/workflows/unit_integration_test.yaml +++ b/.github/workflows/unit_integration_test.yaml @@ -38,7 +38,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.6.47 + image: connectedhomeip/chip-build:0.7.0 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 c0693a79d3b865..406e546a6b4a96 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.47 + image: connectedhomeip/chip-build:0.7.0 defaults: run: shell: sh diff --git a/.github/workflows/zap_templates.yaml b/.github/workflows/zap_templates.yaml index f4bd3744aa84e8..9e0febe3f817c0 100644 --- a/.github/workflows/zap_templates.yaml +++ b/.github/workflows/zap_templates.yaml @@ -30,7 +30,7 @@ jobs: runs-on: ubuntu-20.04 container: - image: connectedhomeip/chip-build:0.6.47 + image: connectedhomeip/chip-build:0.7.0 defaults: run: shell: sh diff --git a/.vscode/tasks.json b/.vscode/tasks.json index f73966cddf7c22..2e495a9536fd2c 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -638,6 +638,7 @@ "qpg-qpg6100-lock", "telink-tlsr9518adk80d-all-clusters", "telink-tlsr9518adk80d-all-clusters-minimal", + "telink-tlsr9518adk80d-bridge", "telink-tlsr9518adk80d-contact-sensor", "telink-tlsr9518adk80d-light", "telink-tlsr9518adk80d-light-switch", diff --git a/build/chip/fuzz_test.gni b/build/chip/fuzz_test.gni index 3d101c21e03762..7d40a70851a222 100644 --- a/build/chip/fuzz_test.gni +++ b/build/chip/fuzz_test.gni @@ -45,17 +45,21 @@ template("chip_fuzz_target") { executable(target_name) { forward_variables_from(invoker, "*") - if (defined(public_configs)) { - public_configs += [ - "//build/config/compiler:libfuzzer_fuzzing", - "//build/config/compiler:sanitize_address", - ] + fuzz_configs = [] + if (oss_fuzz) { + fuzz_configs += [ "//build/config/compiler:oss_fuzz" ] } else { - public_configs = [ + fuzz_configs += [ "//build/config/compiler:libfuzzer_fuzzing", "//build/config/compiler:sanitize_address", ] } + + if (defined(public_configs)) { + public_configs += fuzz_configs + } else { + public_configs = fuzz_configs + } if (!defined(oubput_dir)) { output_dir = "${root_out_dir}/tests" } diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn index 5c2accfcdc078e..577dac76c66642 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -453,11 +453,20 @@ config("libfuzzer_fuzzing") { ldflags = cflags } +config("oss_fuzz") { + cflags = string_split(getenv("CFLAGS")) + ldflags = string_split(getenv("CXXFLAGS")) + ldflags += [ getenv("LIB_FUZZING_ENGINE") ] +} + config("fuzzing_default") { configs = [] if (is_libfuzzer) { configs += [ ":libfuzzer_fuzzing" ] } + if (oss_fuzz) { + configs += [ ":oss_fuzz" ] + } } config("coverage") { diff --git a/build/config/compiler/compiler.gni b/build/config/compiler/compiler.gni index b25aa5c51ca957..5717df7fa33474 100644 --- a/build/config/compiler/compiler.gni +++ b/build/config/compiler/compiler.gni @@ -56,4 +56,7 @@ declare_args() { # Debug prefix mapping (values for -fdebug-prefix-map=). prefix_mappings = [] + + # Enable fuzzer build for OSS-Fuzz + oss_fuzz = false } diff --git a/build/config/linux/pkg_config.gni b/build/config/linux/pkg_config.gni index fb8f5aab32d703..016defafbc3617 100644 --- a/build/config/linux/pkg_config.gni +++ b/build/config/linux/pkg_config.gni @@ -125,6 +125,17 @@ template("pkg_config") { lib_dirs = pkgresult[3] } + # Link libraries statically for OSS-Fuzz fuzzer build + if (oss_fuzz) { + libs = [] + ldflags = [ "-Wl,-Bstatic" ] + foreach(lib, pkgresult[2]) { + ldflags += [ "-l$lib" ] + } + ldflags += [ "-Wl,-Bdynamic" ] + lib_dirs = pkgresult[3] + } + forward_variables_from(invoker, [ "defines", diff --git a/config/ameba/chip.cmake b/config/ameba/chip.cmake index 8de905ae3a9a95..d221ab57352f94 100644 --- a/config/ameba/chip.cmake +++ b/config/ameba/chip.cmake @@ -107,7 +107,7 @@ string(APPEND CHIP_GN_ARGS "ameba_cc = \"arm-none-eabi-gcc\"\n") string(APPEND CHIP_GN_ARGS "ameba_cxx = \"arm-none-eabi-c++\"\n") string(APPEND CHIP_GN_ARGS "ameba_cpu = \"ameba\"\n") string(APPEND CHIP_GN_ARGS "chip_inet_config_enable_ipv4 = false\n") -string(APPEND CHIP_GN_ARGS "chip_use_transitional_commissionable_data_provider = false\n") +string(APPEND CHIP_GN_ARGS "chip_use_transitional_commissionable_data_provider = true\n") # Enable persistent storage audit if (matter_enable_persistentstorage_audit) diff --git a/config/esp32/components/chip/CMakeLists.txt b/config/esp32/components/chip/CMakeLists.txt index 94816931f29dfd..a88839a5565fee 100644 --- a/config/esp32/components/chip/CMakeLists.txt +++ b/config/esp32/components/chip/CMakeLists.txt @@ -155,12 +155,16 @@ if ((CONFIG_BT_ENABLED) AND (CONFIG_ENABLE_CHIPOBLE)) endif() endif() -if (CONFIG_OPENTHREAD_ENABLED) +if (CONFIG_ENABLE_MATTER_OVER_THREAD) chip_gn_arg_append("chip_enable_openthread" "true") +else() + chip_gn_arg_append("chip_enable_openthread" "false") endif() if (CONFIG_OPENTHREAD_FTD) chip_gn_arg_append("chip_openthread_ftd" "true") +else() + chip_gn_arg_append("chip_openthread_ftd" "false") endif() if (CONFIG_ENABLE_OTA_REQUESTOR) @@ -207,6 +211,11 @@ if (CONFIG_ENABLE_ESP32_DEVICE_INFO_PROVIDER) chip_gn_arg_append("chip_use_device_info_provider" "true") endif() +if (CONFIG_SEC_CERT_DAC_PROVIDER) + chip_gn_arg_append("chip_use_secure_cert_dac_provider" "true") +endif() + + set(args_gn_input "${CMAKE_CURRENT_BINARY_DIR}/args.gn.in") file(GENERATE OUTPUT "${args_gn_input}" CONTENT "${chip_gn_args}") @@ -346,6 +355,11 @@ endif() idf_component_get_property(main_lib main COMPONENT_LIB) list(APPEND chip_libraries $) +if (CONFIG_SEC_CERT_DAC_PROVIDER) + idf_component_get_property(esp32_secure_cert_mgr_lib espressif__esp_secure_cert_mgr COMPONENT_LIB) + list(APPEND chip_libraries $) +endif() + target_link_libraries(${COMPONENT_LIB} INTERFACE -Wl,--start-group ${chip_libraries} $ $ diff --git a/config/esp32/components/chip/Kconfig b/config/esp32/components/chip/Kconfig index 2b2175f3e834c3..3b6d84a5c776fc 100644 --- a/config/esp32/components/chip/Kconfig +++ b/config/esp32/components/chip/Kconfig @@ -498,6 +498,13 @@ menu "CHIP Device Layer" menu "CHIP Thread Options" visible if OPENTHREAD_ENABLED + config ENABLE_MATTER_OVER_THREAD + bool "Enable Matter-over-Thread Support" + default y + depends on OPENTHREAD_ENABLED + help + Enables support for sending and receiving CHIP messages over a Thread Connection. + config THREAD_TASK_STACK_SIZE int "Thread task stack size" default 5120 @@ -678,6 +685,13 @@ menu "CHIP Device Layer" help Enable ESP32 Device LocationCapability + config SEC_CERT_DAC_PROVIDER + bool "Use Secure Cert DAC Provider" + default n + help + Use ESP32 Secure Cert DAC Provider which is ESP32 DeviceAttestationCredentialsProvider implementation which reads attestation + information from the esp_secure_cert partition + endmenu diff --git a/config/esp32/components/chip/idf_component.yml b/config/esp32/components/chip/idf_component.yml index 7ffcad18792541..30d77e8b2eb7c9 100644 --- a/config/esp32/components/chip/idf_component.yml +++ b/config/esp32/components/chip/idf_component.yml @@ -5,3 +5,8 @@ dependencies: rules: - if: "idf_version >=5.0" - if: "target != esp32h2" + + espressif/esp_secure_cert_mgr: + version: "^2.2.1" + rules: + - if: "idf_version >=4.3" diff --git a/config/mbed/CMakeLists.txt b/config/mbed/CMakeLists.txt index 2a0eb84dda52b3..a7006062f12ace 100644 --- a/config/mbed/CMakeLists.txt +++ b/config/mbed/CMakeLists.txt @@ -209,6 +209,10 @@ list(APPEND CHIP_DEFINES PW_RPC_USE_GLOBAL_MUTEX=0 ) +# TODO: Update this to use target_link_libraries instead of +# target_include_directories. target_include_directories never should be used to +# access other libraries since it does not add source files to the build graph +# and does not support transitive dependencies. target_include_directories(${APP_TARGET} PRIVATE ${PIGWEED_ROOT}/pw_sys_io/public ${PIGWEED_ROOT}/pw_assert/public @@ -241,6 +245,7 @@ target_include_directories(${APP_TARGET} PRIVATE ${PIGWEED_ROOT}/pw_function/public ${PIGWEED_ROOT}/pw_preprocessor/public ${PIGWEED_ROOT}/pw_rpc/system_server/public + ${PIGWEED_ROOT}/pw_toolchain/public ${PIGWEED_ROOT}/third_party/fuchsia/repo/sdk/lib/fit/include ${PIGWEED_ROOT}/third_party/fuchsia/repo/sdk/lib/stdcompat/include ${CHIP_ROOT}/third_party/nanopb/repo diff --git a/docs/ERROR_CODES.md b/docs/ERROR_CODES.md index bf3e252369efb3..03bf49fe4b3ccb 100644 --- a/docs/ERROR_CODES.md +++ b/docs/ERROR_CODES.md @@ -110,6 +110,7 @@ This file was **AUTOMATICALLY** generated by | 159 | 0x9F | `CHIP_ERROR_PERSISTED_STORAGE_FAILED` | | 160 | 0xA0 | `CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND` | | 161 | 0xA1 | `CHIP_ERROR_IM_FABRIC_DELETED` | +| 164 | 0xA4 | `CHIP_ERROR_IN_PROGRESS` | | 165 | 0xA5 | `CHIP_ERROR_ACCESS_DENIED` | | 166 | 0xA6 | `CHIP_ERROR_UNKNOWN_RESOURCE_ID` | | 167 | 0xA7 | `CHIP_ERROR_VERSION_MISMATCH` | diff --git a/docs/code_generation.md b/docs/code_generation.md index f9b0d587f3fd9b..318cfedd359954 100644 --- a/docs/code_generation.md +++ b/docs/code_generation.md @@ -234,9 +234,48 @@ scripts/codepregen.py ${OUTPUT_DIRECTORY:-./zzz_pregenerated/} # To generate a single output you can use `--input-glob`: -scripts/codepregen.py --input-glob "*all-clusters*" ${OUTPUT_DIRECTORY:-./zzz_pregenerated/} +scripts/codepregen.py --input-glob "*all-clusters*" --input-glob "*controller*" ${OUTPUT_DIRECTORY:-./zzz_pregenerated/} ``` +### External applications/zap files + +#### Ensure you have a `.matter` file + +Code generation generally will use both `.zap` or `.matter` files. If you only +have a `.zap` file, you can create the corresponding `.matter` file via: + +```bash +scripts/tools/zap/generate.py ${ZAP_FILE_PATH} +``` + +The above will use the template `src/app/zap-templates/matter-idl.json` to +generate a `.matter` file corresponding to the input `.zap` file. + +`.matter` files are designed to be human readable. It is recommended to take a +look at the generated file and see if it contains what is expected and also lint +it. If anything seems wrong, the `.zap` file should be fixed (`.matter` +represents the content of `.zap`). To lint use: + +```bash +scripts/idl_lint.py ${MATTER_FILE_PATH} +``` + +#### Running pre-generation + +If you have zap files outside the CHIP repository (i.e. not in `src` or +`examples`) you should provide the root of your application source. + +```bash +scripts/codepregen.py --external-root ${PATH_TO_SOURCE_ROOT} ${OUTPUT_DIRECTORY:-./zzz_pregenerated/} +``` + +NOTE: `$PATH_TO_SOURCE_ROOT` should be a top-level directory containing +zap/matter files as the code pre-generation will generate files based on the +path inside the root: + +- if files are `$PATH_TO_SOURCE_ROOT/some/path/foo.zap` this will generate + files into `$OUTPUT_DIRECTORY/some/path/foo/...` + ### Using pre-generated code Instead of generating code at compile time, the chip build system accepts usage diff --git a/docs/guides/esp32/README.md b/docs/guides/esp32/README.md index ebdfaac513209d..a77fa0ca970384 100644 --- a/docs/guides/esp32/README.md +++ b/docs/guides/esp32/README.md @@ -16,3 +16,4 @@ example on ESP32 series of SoCs - [Flash and NVS encryption for securing factory data](flash_nvs_encryption.md) - [RPC Console and Device Tracing](rpc_console.md) - [Matter OTA](ota.md) +- [Generating and Using ESP Secure Cert Parttiton](secure_cert_partition.md) diff --git a/docs/guides/esp32/secure_cert_partition.md b/docs/guides/esp32/secure_cert_partition.md new file mode 100644 index 00000000000000..a001fb0f030cf2 --- /dev/null +++ b/docs/guides/esp32/secure_cert_partition.md @@ -0,0 +1,183 @@ +# Using esp_secure_cert partition + +## 1.1 ESP Secure Cert Partition + +- When a device is pre-provisioned, the PKI credentials are generated for the + device and stored in a partition named esp_secure_cert. +- In the Matter Pre-Provisioning service, the Matter DAC certificate is + pre-flashed in esp_secure_cert partition. +- The ESP32SecureCertDACProvider reads the PKI credentials from + esp_secure_cert_partition. +- The DAC,PAI and private key are read from the esp_secure_cert_partition, but + the certificate declaration is read from the factory data partition. + Therefore, we need to also generate a factory partition besides + esp_secure_cert_partition. +- The esp_secure_cert partition can be generated on host with help of + configure_esp_secure_cert.py utility. +- The use of esp_secure_cert_partition is demonstrated in lighting-app. + +## 1.2 Prerequisites: + +To generate the esp_secure_cert_partition and the factory_data_partition, we +need the DAC and PAI certificate as well as the private key(DAC key) in .der +format. The factory_data_provider in addition requires the certificate +declaration in .der format. The generation of the required certificates and keys +is mentioned in the steps given below. + +### 1.2.1 Build certification generation tool: + +Run the commands below: + +``` +cd path/to/connectedhomeip +source scripts/activate.sh +gn gen out/host +ninja -C out/host chip-cert +cd out/host +``` + +At /path/to/connectedhomeip/out/host run the below commands. + +### 1.2.2 Generating Certification Declaration + +``` +./chip-cert gen-cd -K ../../credentials/test/certification-declaration/Chip-Test-CD-Signing-Key.pem -C ../../credentials/test/certification-declaration/Chip-Test-CD-Signing-Cert.pem -O esp_dac_fff1_8000.der -f 1 -V 0xfff1 -p 0x8000 -d 0x0016 -c "CSA00000SWC00000-01" -l 0 -i 0 -n 1 -t 0 +``` + +### 1.2.3 Generating PAI + +``` +./chip-cert gen-att-cert -t i -c "ESP TEST PAI" -V 0xfff1 -P 0x8000 -C ../../credentials/development/attestation/Chip-Development-PAA-Cert.pem -K ../../credentials/development/attestation/Chip-Development-PAA-Key.pem -o Esp-Development-PAI-Cert.pem -O Esp-Development-PAI-Key.pem -l 4294967295 +``` + +### 1.2.4 Generating DAC + +``` +./chip-cert gen-att-cert -t d -c "ESP TEST DAC 01" -V 0xfff1 -P 0x8000 -C Esp-Development-PAI-Cert.pem -K Esp-Development-PAI-Key.pem -o Esp-Development-DAC-01.pem -O Esp-Development-DAC-Key-01.pem -l 4294967295 +``` + +### 1.2.5 Change format for the certificates and key (.pem to .der format) + +- Convert DAC key from .pem to .der format. + +``` +openssl ec -in Esp-Development-DAC-Key-01.pem -out Esp-Development-DAC-Key-01.der -inform pem -outform der +``` + +- Convert DAC and PAI cert from .pem to .der format + +``` +openssl x509 -in Esp-Development-DAC-01.pem -out Esp-Development-DAC-01.der-inform pem -outform der +openssl x509 -in Esp-Development-PAI-Cert.pem -out Esp-Development-PAI-Cert.der -inform pem -outform der +``` + +The certificates in the steps 1.2 will be generated at +/path/to/connectedhomeip/out/host.For steps 1.3 and 1.4 go to +connectedhomeip/scripts/tools , set IDF_PATH. + +## 1.3 Generating esp_secure_cert_partition + +To generate the esp_secure_cert_partition install esp-secure-cert-tool using + +``` +pip install esp-secure-cert-tool +``` + +Example command to generate a esp_secure_cert_partition + +``` +configure_esp_secure_cert.py --private-key path/to/dac-key \ +--device-cert path/to/dac-cert \ +--ca-cert path/to/pai-cert \ +--target_chip esp32c3 \ +--port /dev/ttyUSB0 -- skip_flash +``` + +Refer +https://github.com/espressif/esp_secure_cert_mgr/tree/main/tools#generate-esp_secure_cert-partition +for more help. + +## 1.4 Generating the factory_data_partition + +Example command to generate a factory_data_partition + +``` +./generate_esp32_chip_factory_bin.py -d 3434 -p 99663300 \ + --product-name ESP-lighting-app --product-id 0x8000 \ + --vendor-name Test-vendor --vendor-id 0xFFF1 \ + --hw-ver 1 --hw-ver-str DevKit \ + --dac-cert path/to/dac-cert \ + --dac-key path/to/dac-key \ + --pai-cert path/to/pai-cert \ + --cd path/to/certificate-declaration +``` + +Refer +https://github.com/project-chip/connectedhomeip/blob/master/docs/guides/esp32/factory_data.md#generate-nvs-binary-image +to generate a factory_data_partition. + +## 1.5 Build the firmware with below configuration options + +``` +# Disable the DS Peripheral support +CONFIG_ESP_SECURE_CERT_DS_PERIPHERAL=n +# Use DAC Provider implementation which reads attestation data from secure cert partition +CONFIG_SEC_CERT_DAC_PROVIDER=y +# Enable some options which reads CD and other basic info from the factory partition +CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER=y +CONFIG_ENABLE_ESP32_DEVICE_INSTANCE_INFO_PROVIDER=y +CONFIG_CHIP_FACTORY_NAMESPACE_PARTITION_LABEL="fctry" +``` + +In order to use the esp_secure_cert_partition, in addition to enabling the above +config options, you should also have the esp_secure_cert_partition and factory +partition in your app. For reference, refer to partitions.csv file of +lighting-app. + +## 1.6 Flashing firmware, secure cert and factory partition + +### Build and flash + +``` +idf.py -p (PORT) build flash +``` + +### Flash `esp_secure_cert` and factory partition binaries + +The `esp_secure_cert` partition binary contains device attestation information +and the factory partition binary contains Matter manufacturing specific data. + +- Flash `esp_secure_cert` partition binary + +``` +esptool.py -p (PORT) write_flash 0xd000 path/to/secure_cert_partition.bin +``` + +- Flash factory partition binary + +``` +esptool.py -p (PORT) write_flash 0x3E0000 path/to/factory_partition.bin +``` + +### Monitor + +``` +idf.py monitor +``` + +Please flash the above mentioned partitions by looking into the addresses in +partitions.csv.The above commands are for example purpose. + +## 1.6 Test commissioning using chip-tool + +Run the following command from host to commission the device. + +``` +./chip-tool pairing ble-wifi 1234 my_SSID my_PASSPHRASE my_PASSCODE my_DISCRIMINATOR --paa-trust-store-path /path/to/PAA-Certificates/ +``` + +For example: + +``` +./chip-tool pairing ble-wifi 0x7283 my_SSID my_PASSPHRASE 99663300 3434 --paa-trust-store-path /path/to/connectedhomeip/credentials/development/attestation/ +``` 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 22ed2439f87039..44a9d73de933bf 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 @@ -266,10 +266,10 @@ client cluster OnOff = 6 { } 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 optional boolean globalSceneControl = 16384; + attribute optional int16u onTime = 16385; + attribute optional int16u offWaitTime = 16386; + attribute access(write: manage) optional nullable OnOffStartUpOnOff startUpOnOff = 16387; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; diff --git a/examples/all-clusters-app/ameba/main/CHIPDeviceManager.cpp b/examples/all-clusters-app/ameba/main/CHIPDeviceManager.cpp index 4c1b55fbddb9fc..d0db78341501a5 100644 --- a/examples/all-clusters-app/ameba/main/CHIPDeviceManager.cpp +++ b/examples/all-clusters-app/ameba/main/CHIPDeviceManager.cpp @@ -28,11 +28,15 @@ #include "CHIPDeviceManager.h" #include #include +#include +#include +#include #include #include #include using namespace ::chip; +using namespace ::chip::Credentials; namespace chip { @@ -40,6 +44,8 @@ namespace DeviceManager { using namespace ::chip::DeviceLayer; +chip::DeviceLayer::FactoryDataProvider mFactoryDataProvider; + void CHIPDeviceManager::CommonDeviceEventHandler(const ChipDeviceEvent * event, intptr_t arg) { CHIPDeviceManagerCallbacks * cb = reinterpret_cast(arg); @@ -61,6 +67,19 @@ CHIP_ERROR CHIPDeviceManager::Init(CHIPDeviceManagerCallbacks * cb) err = PlatformMgr().InitChipStack(); SuccessOrExit(err); + err = mFactoryDataProvider.Init(); + if (err == CHIP_NO_ERROR) + { + SetCommissionableDataProvider(&mFactoryDataProvider); + SetDeviceAttestationCredentialsProvider(&mFactoryDataProvider); + SetDeviceInstanceInfoProvider(&mFactoryDataProvider); + } + else + { + ChipLogProgress(DeviceLayer, "Using example DAC provider"); + SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); + } + if (CONFIG_NETWORK_LAYER_BLE) { ConnectivityMgr().SetBLEAdvertisingEnabled(true); diff --git a/examples/all-clusters-app/ameba/main/DeviceCallbacks.cpp b/examples/all-clusters-app/ameba/main/DeviceCallbacks.cpp index 3f1d88621bdbfb..b31d2629af14aa 100644 --- a/examples/all-clusters-app/ameba/main/DeviceCallbacks.cpp +++ b/examples/all-clusters-app/ameba/main/DeviceCallbacks.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -103,6 +104,7 @@ void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_ case DeviceEventType::kCommissioningComplete: ChipLogProgress(DeviceLayer, "Commissioning Complete"); + chip::DeviceLayer::Internal::AmebaUtils::SetCurrentProvisionedNetwork(); break; } } @@ -142,8 +144,9 @@ void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event chip::app::DnssdServer::Instance().StartServer(); #if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR // Init OTA requestor only when we have gotten IPv6 address - if (OTAInitializer::Instance().CheckInit()) + if (!OTAInitializer::Instance().CheckInit()) { + ChipLogProgress(DeviceLayer, "Initializing OTA"); chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds32(kInitOTARequestorDelaySec), InitOTARequestorHandler, nullptr); } diff --git a/examples/all-clusters-app/ameba/main/chipinterface.cpp b/examples/all-clusters-app/ameba/main/chipinterface.cpp index c0e918e2082a86..c8b2e9a4333e14 100644 --- a/examples/all-clusters-app/ameba/main/chipinterface.cpp +++ b/examples/all-clusters-app/ameba/main/chipinterface.cpp @@ -31,11 +31,8 @@ #include #include #include -#include -#include #include #include -#include #include #include #include @@ -51,7 +48,6 @@ #endif using namespace ::chip; -using namespace ::chip::Credentials; using namespace ::chip::DeviceManager; using namespace ::chip::DeviceLayer; using namespace ::chip::System; @@ -122,7 +118,6 @@ Identify gIdentify1 = { static DeviceCallbacks EchoCallbacks; chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; -chip::DeviceLayer::FactoryDataProvider mFactoryDataProvider; static void InitServer(intptr_t context) { @@ -158,10 +153,6 @@ extern "C" void ChipTest(void) initPref(); - mFactoryDataProvider.Init(); - SetCommissionableDataProvider(&mFactoryDataProvider); - SetDeviceAttestationCredentialsProvider(&mFactoryDataProvider); - CHIPDeviceManager & deviceMgr = CHIPDeviceManager::GetInstance(); err = deviceMgr.Init(&EchoCallbacks); @@ -170,10 +161,6 @@ extern "C" void ChipTest(void) ChipLogError(DeviceLayer, "DeviceManagerInit() - ERROR!\r\n"); } - // Set DeviceInstanceInfoProvider after CHIPDeviceManager init - // CHIPDeviceManager init will set GenericDeviceInsanceInfoProvider first - SetDeviceInstanceInfoProvider(&mFactoryDataProvider); - chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, 0); statusLED1.Init(STATUS_LED_GPIO_NUM); diff --git a/examples/all-clusters-app/esp32/main/CMakeLists.txt b/examples/all-clusters-app/esp32/main/CMakeLists.txt index 144dbd4892af33..4b2f6a464e2933 100644 --- a/examples/all-clusters-app/esp32/main/CMakeLists.txt +++ b/examples/all-clusters-app/esp32/main/CMakeLists.txt @@ -249,6 +249,7 @@ target_link_libraries(${COMPONENT_LIB} PUBLIC target_link_options(${COMPONENT_LIB} PUBLIC "-T${PIGWEED_ROOT}/pw_tokenizer/pw_tokenizer_linker_sections.ld" + "-L${PIGWEED_ROOT}/pw_tokenizer" ) target_compile_options(${COMPONENT_LIB} PRIVATE diff --git a/examples/all-clusters-app/linux/AllClustersCommandDelegate.cpp b/examples/all-clusters-app/linux/AllClustersCommandDelegate.cpp index 0bd2a859f936af..1a794d80f8c16a 100644 --- a/examples/all-clusters-app/linux/AllClustersCommandDelegate.cpp +++ b/examples/all-clusters-app/linux/AllClustersCommandDelegate.cpp @@ -181,7 +181,6 @@ void AllClustersAppCommandHandler::OnGeneralFaultEventHandler(uint32_t eventId) GeneralFaults previous; GeneralFaults current; -#if CHIP_CONFIG_TEST using GeneralDiagnostics::HardwareFaultEnum; // On Linux Simulation, set following hardware faults statically. @@ -192,7 +191,6 @@ void AllClustersAppCommandHandler::OnGeneralFaultEventHandler(uint32_t eventId) ReturnOnFailure(current.add(to_underlying(HardwareFaultEnum::kSensor))); ReturnOnFailure(current.add(to_underlying(HardwareFaultEnum::kPowerSource))); ReturnOnFailure(current.add(to_underlying(HardwareFaultEnum::kUserInterfaceFault))); -#endif Clusters::GeneralDiagnosticsServer::Instance().OnHardwareFaultsDetect(previous, current); } else if (eventId == Clusters::GeneralDiagnostics::Events::RadioFaultChange::Id) @@ -200,7 +198,6 @@ void AllClustersAppCommandHandler::OnGeneralFaultEventHandler(uint32_t eventId) GeneralFaults previous; GeneralFaults current; -#if CHIP_CONFIG_TEST // On Linux Simulation, set following radio faults statically. ReturnOnFailure(previous.add(EMBER_ZCL_RADIO_FAULT_ENUM_WI_FI_FAULT)); ReturnOnFailure(previous.add(EMBER_ZCL_RADIO_FAULT_ENUM_THREAD_FAULT)); @@ -209,7 +206,6 @@ void AllClustersAppCommandHandler::OnGeneralFaultEventHandler(uint32_t eventId) 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); } else if (eventId == Clusters::GeneralDiagnostics::Events::NetworkFaultChange::Id) @@ -217,7 +213,6 @@ void AllClustersAppCommandHandler::OnGeneralFaultEventHandler(uint32_t eventId) GeneralFaults previous; GeneralFaults current; -#if CHIP_CONFIG_TEST // On Linux Simulation, set following radio faults statically. ReturnOnFailure(previous.add(EMBER_ZCL_NETWORK_FAULT_ENUM_HARDWARE_FAILURE)); ReturnOnFailure(previous.add(EMBER_ZCL_NETWORK_FAULT_ENUM_NETWORK_JAMMED)); @@ -225,7 +220,6 @@ void AllClustersAppCommandHandler::OnGeneralFaultEventHandler(uint32_t eventId) 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); } else diff --git a/examples/all-clusters-minimal-app/esp32/main/CMakeLists.txt b/examples/all-clusters-minimal-app/esp32/main/CMakeLists.txt index e2ed8315f4223f..9587e26f048d7d 100644 --- a/examples/all-clusters-minimal-app/esp32/main/CMakeLists.txt +++ b/examples/all-clusters-minimal-app/esp32/main/CMakeLists.txt @@ -244,6 +244,7 @@ target_link_libraries(${COMPONENT_LIB} PUBLIC target_link_options(${COMPONENT_LIB} PUBLIC "-T${PIGWEED_ROOT}/pw_tokenizer/pw_tokenizer_linker_sections.ld" + "-L${PIGWEED_ROOT}/pw_tokenizer" ) target_compile_options(${COMPONENT_LIB} PRIVATE diff --git a/examples/bridge-app/bridge-common/bridge-app.matter b/examples/bridge-app/bridge-common/bridge-app.matter index e3ee71f576c660..c5f6f776539515 100644 --- a/examples/bridge-app/bridge-common/bridge-app.matter +++ b/examples/bridge-app/bridge-common/bridge-app.matter @@ -298,7 +298,7 @@ client cluster AccessControl = 31 { } attribute access(read: administer, write: administer) AccessControlEntryStruct acl[] = 0; - attribute access(read: administer, write: administer) AccessControlExtensionStruct extension[] = 1; + attribute access(read: administer, write: administer) optional AccessControlExtensionStruct extension[] = 1; readonly attribute int16u subjectsPerAccessControlEntry = 2; readonly attribute int16u targetsPerAccessControlEntry = 3; readonly attribute int16u accessControlEntriesPerFabric = 4; diff --git a/examples/bridge-app/esp32/main/main.cpp b/examples/bridge-app/esp32/main/main.cpp index f79f80f8bd5c8a..f0762ef631749b 100644 --- a/examples/bridge-app/esp32/main/main.cpp +++ b/examples/bridge-app/esp32/main/main.cpp @@ -230,7 +230,8 @@ EmberAfStatus HandleReadBridgedDeviceBasicAttribute(Device * dev, chip::Attribut } else if ((attributeId == ClusterRevision::Id) && (maxReadLength == 2)) { - *buffer = (uint16_t) ZCL_BRIDGED_DEVICE_BASIC_INFORMATION_CLUSTER_REVISION; + uint16_t rev = ZCL_BRIDGED_DEVICE_BASIC_INFORMATION_CLUSTER_REVISION; + memcpy(buffer, &rev, sizeof(rev)); } else { @@ -250,7 +251,8 @@ EmberAfStatus HandleReadOnOffAttribute(Device * dev, chip::AttributeId attribute } else if ((attributeId == OnOff::Attributes::ClusterRevision::Id) && (maxReadLength == 2)) { - *buffer = (uint16_t) ZCL_ON_OFF_CLUSTER_REVISION; + uint16_t rev = ZCL_ON_OFF_CLUSTER_REVISION; + memcpy(buffer, &rev, sizeof(rev)); } else { diff --git a/examples/bridge-app/linux/main.cpp b/examples/bridge-app/linux/main.cpp index 3fae757c736ff8..314036a83c5dcd 100644 --- a/examples/bridge-app/linux/main.cpp +++ b/examples/bridge-app/linux/main.cpp @@ -500,11 +500,13 @@ EmberAfStatus HandleReadBridgedDeviceBasicAttribute(Device * dev, chip::Attribut } else if ((attributeId == ClusterRevision::Id) && (maxReadLength == 2)) { - *buffer = (uint16_t) ZCL_BRIDGED_DEVICE_BASIC_INFORMATION_CLUSTER_REVISION; + uint16_t rev = ZCL_BRIDGED_DEVICE_BASIC_INFORMATION_CLUSTER_REVISION; + memcpy(buffer, &rev, sizeof(rev)); } else if ((attributeId == FeatureMap::Id) && (maxReadLength == 4)) { - *buffer = (uint32_t) ZCL_BRIDGED_DEVICE_BASIC_INFORMATION_FEATURE_MAP; + uint32_t featureMap = ZCL_BRIDGED_DEVICE_BASIC_INFORMATION_FEATURE_MAP; + memcpy(buffer, &featureMap, sizeof(featureMap)); } else { @@ -524,7 +526,8 @@ EmberAfStatus HandleReadOnOffAttribute(DeviceOnOff * dev, chip::AttributeId attr } else if ((attributeId == OnOff::Attributes::ClusterRevision::Id) && (maxReadLength == 2)) { - *buffer = (uint16_t) ZCL_ON_OFF_CLUSTER_REVISION; + uint16_t rev = ZCL_ON_OFF_CLUSTER_REVISION; + memcpy(buffer, &rev, sizeof(rev)); } else { diff --git a/examples/bridge-app/telink/.gitignore b/examples/bridge-app/telink/.gitignore new file mode 100644 index 00000000000000..84c048a73cc2e5 --- /dev/null +++ b/examples/bridge-app/telink/.gitignore @@ -0,0 +1 @@ +/build/ diff --git a/examples/bridge-app/telink/CMakeLists.txt b/examples/bridge-app/telink/CMakeLists.txt new file mode 100644 index 00000000000000..52e498d10927fe --- /dev/null +++ b/examples/bridge-app/telink/CMakeLists.txt @@ -0,0 +1,88 @@ +# +# 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. +# 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.13.1) + +set(BOARD tlsr9518adk80d) + +get_filename_component(CHIP_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/third_party/connectedhomeip REALPATH) +get_filename_component(TELINK_COMMON ${CHIP_ROOT}/examples/platform/telink REALPATH) +get_filename_component(GEN_DIR ${CHIP_ROOT}/zzz_generated/ REALPATH) + +if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/boards/${BOARD}.overlay") + set(LOCAL_DTC_OVERLAY_FILE "${CMAKE_CURRENT_SOURCE_DIR}/boards/${BOARD}.overlay") +else() + unset(LOCAL_DTC_OVERLAY_FILE) +endif() + +if(EXISTS "${CHIP_ROOT}/src/platform/telink/${BOARD}.overlay") + set(GLOBAL_DTC_OVERLAY_FILE "${CHIP_ROOT}/src/platform/telink/${BOARD}.overlay") +else() + unset(GLOBAL_DTC_OVERLAY_FILE) +endif() + +if(DTC_OVERLAY_FILE) + set(DTC_OVERLAY_FILE + "${DTC_OVERLAY_FILE} ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}" + CACHE STRING "" FORCE + ) +else() + set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}) +endif() + +set(CONF_FILE ${CHIP_ROOT}/config/telink/app/zephyr.conf prj.conf) + +# Load NCS/Zephyr build system +list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/telink/chip-module) +find_package(Zephyr HINTS $ENV{ZEPHYR_BASE}) + +project(chip-telink-bridge-example) + +include(${CHIP_ROOT}/config/telink/app/enable-gnu-std.cmake) +include(${CHIP_ROOT}/src/app/chip_data_model.cmake) + +target_compile_options(app PRIVATE -fpermissive) + +target_include_directories(app PRIVATE + include + ${GEN_DIR}/app-common + ${GEN_DIR}/bridge-app + ${TELINK_COMMON}/util/include + ${TELINK_COMMON}/app/include) + +add_definitions( + "-DCHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=" + -DCHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT=16 +) + +target_sources(app PRIVATE + src/AppTask.cpp + src/main.cpp + src/ZclCallbacks.cpp + src/Device.cpp + src/DeviceCallbacks.cpp + ${TELINK_COMMON}/util/src/LEDWidget.cpp + ${TELINK_COMMON}/util/src/ButtonManager.cpp + ${TELINK_COMMON}/util/src/ThreadUtil.cpp + ${TELINK_COMMON}/util/src/PWMDevice.cpp) + +chip_configure_data_model(app + INCLUDE_SERVER + ZAP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../bridge-common/bridge-app.zap +) + +if(CONFIG_CHIP_OTA_REQUESTOR) + target_sources(app PRIVATE ${TELINK_COMMON}/util/src/OTAUtil.cpp) +endif() diff --git a/examples/bridge-app/telink/README.md b/examples/bridge-app/telink/README.md new file mode 100644 index 00000000000000..67ded6c90e751f --- /dev/null +++ b/examples/bridge-app/telink/README.md @@ -0,0 +1,321 @@ +# Matter Telink Bridge Example Application + +The Telink Bridge Example demonstrates a simple lighting bridge and the use of +dynamic endpoints. It uses buttons to test changing the lighting and device +states and LEDs to show the state of these changes. You can use this example as +a reference for creating your own application. + +Bridge together with its Bridged Devices is exposed as a single Node with a list +of endpoints. Consequently, a single Node ID and a single Operational +Certificate is assigned during Commissioning and a single pass through the +commissioning flow is required to bring the Bridge (along with its Bridged +Devices) onto a Fabric. This provides for a simple user experience, since the +user only needs to go through the commissioning flow for the Bridge, and not +separately for each of the Bridged Devices. + +![Telink B91 EVK](http://wiki.telink-semi.cn/wiki/assets/Hardware/B91_Generic_Starter_Kit_Hardware_Guide/connection_chart.png) + +## Introduction + +A prototype application that demonstrates dynamic endpoint with device +commissioning and cluster control. It adds the non-chip device as endpoints on a +bridge(Matter device). In this example four light devices supporting on-off +cluster and temperature sensor have been added as endpoints + +1. Light1 at endpoint 3 +2. Light2 at endpoint 7 +3. Light3 at endpoint 5 +4. Light4 at endpoint 6 +5. Temperature Sensor at endpoint 8 + +## Dynamic Endpoints + +The Bridge Example makes use of Dynamic Endpoints. Current SDK support is +limited for dynamic endpoints, since endpoints are typically defined (along with +the clusters and attributes they contain) in a .zap file which then generates +code and static structures to define the endpoints. + +To support endpoints that are not statically defined, the ZCL attribute storage +mechanisms will hold additional endpoint information for `NUM_DYNAMIC_ENDPOINTS` +additional endpoints. These additional endpoint structures must be defined by +the application and can change at runtime. + +To facilitate the creation of these endpoint structures, several macros are +defined: + +`DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(attrListName)` +`DECLARE_DYNAMIC_ATTRIBUTE(attId, attType, attSizeBytes, attrMask)` +`DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(clusterRevision)` + +- These three macros are used to declare a list of attributes for use within a + cluster. The declaration must begin with the + `DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN` macro which will define the name of + the allocated attribute structure. Each attribute is then added by the + `DECLARE_DYNAMIC_ATTRIBUTE` macro. Finally, + `DECLARE_DYNAMIC_ATTRIBUTE_LIST_END` macro should be used to close the + definition. + +- All attributes defined with these macros will be configured as + `ATTRIBUTE_MASK_EXTERNAL_STORAGE` in the ZCL database and therefore will + rely on the application to maintain storage for the attribute. Consequently, + reads or writes to these attributes must be handled within the application + by the `emberAfExternalAttributeWriteCallback` and + `emberAfExternalAttributeReadCallback` functions. See the bridge + application's `main.cpp` for an example of this implementation. + +`DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(clusterListName)` +`DECLARE_DYNAMIC_CLUSTER(clusterId, clusterAttrs, incomingCommands, outgoingCommands)` +`DECLARE_DYNAMIC_CLUSTER_LIST_END` + +- These three macros are used to declare a list of clusters for use within a + endpoint. The declaration must begin with the + `DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN` macro which will define the name of the + allocated cluster structure. Each cluster is then added by the + `DECLARE_DYNAMIC_CLUSTER` macro referencing attribute list previously + defined by the `DECLARE_DYNAMIC_ATTRIBUTE...` macros and the lists of + incoming/outgoing commands terminated by kInvalidCommandId (or nullptr if + there aren't any commands in the list). Finally, + `DECLARE_DYNAMIC_CLUSTER_LIST_END` macro should be used to close the + definition. + +`DECLARE_DYNAMIC_ENDPOINT(endpointName, clusterList)` + +- This macro is used to declare an endpoint and its associated cluster list, + which must be previously defined by the `DECLARE_DYNAMIC_CLUSTER...` macros. + +## Build and flash + +1. Pull docker image from repository: + + ```bash + $ docker pull connectedhomeip/chip-build-telink:latest + ``` + +1. Run docker container: + + ```bash + $ docker run -it --rm -v ${CHIP_BASE}:/root/chip -v /dev/bus/usb:/dev/bus/usb --device-cgroup-rule "c 189:* rmw" connectedhomeip/chip-build-telink:latest + ``` + + here `${CHIP_BASE}` is directory which contains CHIP repo files **!!!Pay + attention that OUTPUT_DIR should contains ABSOLUTE path to output dir** + +1. Activate the build environment: + + ```bash + $ source ./scripts/activate.sh + ``` + +1. In the example dir run: + + ```bash + $ west build + ``` + +1. Flash binary: + + ``` + $ west flash --erase + ``` + +## Usage + +### UART + +To get output from device, connect UART to following pins: + +| Name | Pin | +| :--: | :---------------------------- | +| RX | PB3 (pin 17 of J34 connector) | +| TX | PB2 (pin 16 of J34 connector) | +| GND | GND | + +### Buttons + +The following buttons are available on **tlsr9518adk80d** board: + +| Name | Function | Description | +| :------- | :--------------------- | :----------------------------------------------------------------------------------------------------- | +| Button 1 | Factory reset | Perform factory reset to forget currently commissioned Thread network and back to uncommissioned state | +| Button 2 | Lighting control | Manually triggers the lighting state | +| Button 3 | Thread start | Commission thread with static credentials and enables the Thread on device | +| Button 4 | Open commission window | The button is opening commissioning window to perform commissioning over BLE | + +### LEDs + +#### 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 | +| 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 + +1. Build + [chip-tool cli](https://github.com/project-chip/connectedhomeip/blob/master/examples/chip-tool/README.md) + +2. Pair with device + + ``` + ${CHIP_TOOL_DIR}/chip-tool pairing ble-thread ${NODE_ID} hex:${DATASET} ${PIN_CODE} ${DISCRIMINATOR} + ``` + + Example: + + ``` + ./chip-tool pairing ble-thread 1234 hex:0e080000000000010000000300000f35060004001fffe0020811111111222222220708fd61f77bd3df233e051000112233445566778899aabbccddeeff030e4f70656e54687265616444656d6f010212340410445f2b5ca6f2a93a55ce570a70efeecb0c0402a0fff8 20202021 3840 + ``` + +3. Switch on the light: + + ``` + ${CHIP_TOOL_DIR}/chip-tool onoff on 1 2 + ``` + + here: + + - **onoff** is name of cluster + - **on** command to the cluster + - **1** ID of Node + - **2** ID of endpoint + +4. Switch off the light: + + ``` + ${CHIP_TOOL_DIR}/chip-tool onoff off 1 2 + ``` + + here: + + - **onoff** is name of cluster + - **off** command to the cluster + - **1** ID of Node + - **2** ID of endpoint + +5. Read the light state: + + ``` + ${CHIP_TOOL_DIR}/chip-tool onoff read on-off 1 2 + ``` + + here: + + - **onoff** is name of cluster + - **read** command to the cluster + - **on-off** attribute to read + - **1** ID of Node + - **2** ID of endpoint + +6. Change brightness of light: + + ``` + ${CHIP_TOOL_DIR}/chip-tool levelcontrol move-to-level 32 0 0 0 1 2 + ``` + + here: + + - **levelcontrol** is name of cluster + - **move-to-level** command to the cluster + - **32** brightness value + - **0** transition time + - **0** option mask + - **0** option override + - **1** ID of Node + - **2** ID of endpoint + +7. Read brightness level: + ``` + ./chip-tool levelcontrol read current-level 1 2 + ``` + here: + - **levelcontrol** is name of cluster + - **read** command to the cluster + - **current-level** attribute to read + - **1** ID of Node + - **2** ID of endpoint + +### OTA with Linux OTA Provider + +OTA feature enabled by default only for ota-requestor-app example. To enable OTA +feature for another Telink example: + +- set CONFIG_CHIP_OTA_REQUESTOR=y in corresponding "prj.conf" configuration + file. + +After build application with enabled OTA feature, use next binary files: + +- zephyr.bin - main binary to flash PCB (Use 2MB PCB). +- zephyr-ota.bin - binary for OTA Provider + +All binaries has the same SW version. To test OTA “zephyr-ota.bin” should have +higher SW version than base SW. Set CONFIG_CHIP_DEVICE_SOFTWARE_VERSION=2 in +corresponding “prj.conf” configuration file. + +Usage of OTA: + +- Build the [Linux OTA Provider](../../ota-provider-app/linux) + + ``` + ./scripts/examples/gn_build_example.sh examples/ota-provider-app/linux out/ota-provider-app chip_config_network_layer_ble=false + ``` + +- Run the Linux OTA Provider with OTA image. + + ``` + ./chip-ota-provider-app -f zephyr-ota.bin + ``` + +- Provision the Linux OTA Provider using chip-tool + + ``` + ./chip-tool pairing onnetwork ${OTA_PROVIDER_NODE_ID} 20202021 + ``` + + here: + + - \${OTA_PROVIDER_NODE_ID} is the node id of Linux OTA Provider + +- Configure the ACL of the ota-provider-app to allow access + + ``` + ./chip-tool accesscontrol write acl '[{"fabricIndex": 1, "privilege": 5, "authMode": 2, "subjects": [112233], "targets": null}, {"fabricIndex": 1, "privilege": 3, "authMode": 2, "subjects": null, "targets": null}]' ${OTA_PROVIDER_NODE_ID} 0 + ``` + + here: + + - \${OTA_PROVIDER_NODE_ID} is the node id of Linux OTA Provider + +- Use the chip-tool to announce the ota-provider-app to start the OTA process + + ``` + ./chip-tool otasoftwareupdaterequestor announce-ota-provider ${OTA_PROVIDER_NODE_ID} 0 0 0 ${DEVICE_NODE_ID} 0 + ``` + + here: + + - \${OTA_PROVIDER_NODE_ID} is the node id of Linux OTA Provider + - \${DEVICE_NODE_ID} is the node id of paired device + +Once the transfer is complete, OTA requestor sends ApplyUpdateRequest command to +OTA provider for applying the image. Device will restart on successful +application of OTA image. diff --git a/examples/bridge-app/telink/include/AppConfig.h b/examples/bridge-app/telink/include/AppConfig.h new file mode 100644 index 00000000000000..88918d553e078d --- /dev/null +++ b/examples/bridge-app/telink/include/AppConfig.h @@ -0,0 +1,39 @@ +/* + * + * 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 + +// ---- Bridge App Example Config ---- + +// Buttons config +#define BUTTON_PORT DEVICE_DT_GET(DT_NODELABEL(gpioc)) + +#define BUTTON_PIN_1 2 +#define BUTTON_PIN_3 3 +#define BUTTON_PIN_4 1 +#define BUTTON_PIN_2 0 + +// LEDs config +#define LEDS_PORT DEVICE_DT_GET(DT_NODELABEL(gpiob)) +#define SYSTEM_STATE_LED 7 + +// Lighting LED config +#define USE_RGB_PWM 0 + +#define LIGHTING_PWM_SPEC_RGB_BLUE PWM_DT_SPEC_GET(DT_ALIAS(pwm_led0)) +#define LIGHTING_PWM_SPEC_IDENTIFY_GREEN PWM_DT_SPEC_GET(DT_ALIAS(pwm_led3)) diff --git a/examples/bridge-app/telink/include/AppEvent.h b/examples/bridge-app/telink/include/AppEvent.h new file mode 100644 index 00000000000000..f570dfd1e7cdf7 --- /dev/null +++ b/examples/bridge-app/telink/include/AppEvent.h @@ -0,0 +1,64 @@ +/* + * + * 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 + +struct AppEvent; +typedef void (*EventHandler)(AppEvent *); + +class LEDWidget; + +struct AppEvent +{ + enum AppEventTypes + { + kEventType_Button = 0, + kEventType_Timer, + kEventType_UpdateLedState, + kEventType_IdentifyStart, + kEventType_IdentifyStop, + kEventType_Lighting, + }; + + uint16_t Type; + + union + { + struct + { + uint8_t Action; + } ButtonEvent; + struct + { + void * Context; + } TimerEvent; + struct + { + uint8_t Action; + int32_t Actor; + } LightingEvent; + struct + { + LEDWidget * LedWidget; + } UpdateLedStateEvent; + }; + + EventHandler Handler; +}; diff --git a/examples/bridge-app/telink/include/AppTask.h b/examples/bridge-app/telink/include/AppTask.h new file mode 100644 index 00000000000000..35e9977ebfa0ac --- /dev/null +++ b/examples/bridge-app/telink/include/AppTask.h @@ -0,0 +1,97 @@ +/* + * + * 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 "AppConfig.h" +#include "AppEvent.h" +#if CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED +#include "LEDWidget.h" +#endif +#include "PWMDevice.h" +#include + +#if CONFIG_CHIP_FACTORY_DATA +#include +#endif + +#include + +struct k_timer; +struct Identify; + +class AppTask +{ +public: + CHIP_ERROR StartApp(void); + + void PostEvent(AppEvent * aEvent); + void UpdateClusterState(void); + PWMDevice & GetPWMDevice(void) { return mPwmRgbBlueLed; } + + static void IdentifyEffectHandler(EmberAfIdentifyEffectIdentifier aEffect); + +private: + friend AppTask & GetAppTask(void); + CHIP_ERROR Init(void); + + 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); + +#if CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED + static void UpdateLedStateEventHandler(AppEvent * aEvent); + static void LEDStateUpdateHandler(LEDWidget * ledWidget); + static void UpdateStatusLED(); +#endif + static void LightingActionButtonEventHandler(void); + static void FactoryResetButtonEventHandler(void); + static void StartThreadButtonEventHandler(void); + static void StartBleAdvButtonEventHandler(void); + + static void ChipEventHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg); + + static void FactoryResetTimerTimeoutCallback(k_timer * timer); + + static void FactoryResetTimerEventHandler(AppEvent * aEvent); + static void FactoryResetHandler(AppEvent * aEvent); + static void StartThreadHandler(AppEvent * aEvent); + static void LightingActionEventHandler(AppEvent * aEvent); + static void StartBleAdvHandler(AppEvent * aEvent); + static void UpdateIdentifyStateEventHandler(AppEvent * aEvent); + + static void InitButtons(void); + static void InitServer(intptr_t context); + + static void ThreadProvisioningHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg); + + static AppTask sAppTask; + PWMDevice mPwmRgbBlueLed; + PWMDevice mPwmIdentifyLed; + +#if CONFIG_CHIP_FACTORY_DATA + chip::DeviceLayer::FactoryDataProvider mFactoryDataProvider; +#endif +}; + +inline AppTask & GetAppTask(void) +{ + return AppTask::sAppTask; +} diff --git a/examples/bridge-app/telink/include/CHIPProjectConfig.h b/examples/bridge-app/telink/include/CHIPProjectConfig.h new file mode 100644 index 00000000000000..824acd90d46cbe --- /dev/null +++ b/examples/bridge-app/telink/include/CHIPProjectConfig.h @@ -0,0 +1,44 @@ +/* + * + * 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. + */ + +/** + * @file + * Example project configuration file for CHIP. + * + * This is a place to put application or project-specific overrides + * to the default configuration values for general CHIP features. + * + */ + +#pragma once + +// Use a default pairing code if one hasn't been provisioned in flash. +#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 +#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 + +// Switching from Thread child to router may cause a few second packet stall. +// Until this is improved in OpenThread we need to increase the retransmission +// interval to survive the stall. +#define CHIP_CONFIG_MRP_LOCAL_ACTIVE_RETRY_INTERVAL (1000_ms32) + +/** + * CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE + * + * Reduce packet buffer pool size to 8 (default 15) to reduce ram consumption + */ +#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 8 diff --git a/examples/bridge-app/telink/include/Device.h b/examples/bridge-app/telink/include/Device.h new file mode 100644 index 00000000000000..bd91dcb9f346c0 --- /dev/null +++ b/examples/bridge-app/telink/include/Device.h @@ -0,0 +1,97 @@ +/* + * + * 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. + * 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 Device +{ +public: + static const int kDeviceNameSize = 32; + static const int kDeviceLocationSize = 32; + + enum State_t + { + kState_On = 0, + kState_Off, + } State; + + enum Changed_t + { + kChanged_Reachable = 0x01, + kChanged_State = 0x02, + kChanged_Location = 0x04, + kChanged_Name = 0x08, + kChanged_Last = kChanged_Name, + } Changed; + + Device(const char * szDeviceName, const char * szLocation); + + bool IsOn() const; + bool IsReachable() const; + void SetOnOff(bool aOn); + void SetReachable(bool aReachable); + void SetName(const char * szDeviceName); + void SetLocation(const char * szLocation); + inline void SetEndpointId(chip::EndpointId id) { mEndpointId = id; }; + inline chip::EndpointId GetEndpointId() { return mEndpointId; }; + inline char * GetName() { return mName; }; + inline char * GetLocation() { return mLocation; }; + + using DeviceCallback_fn = std::function; + void SetChangeCallback(DeviceCallback_fn aChanged_CB); + +private: + State_t mState; + bool mReachable; + char mName[kDeviceNameSize]; + char mLocation[kDeviceLocationSize]; + chip::EndpointId mEndpointId; + DeviceCallback_fn mChanged_CB; +}; + +class DeviceTempSensor : public Device +{ +public: + enum Changed_t + { + kChanged_MeasurementValue = kChanged_Last << 1, + } Changed; + + DeviceTempSensor(const char * szDeviceName, std::string szLocation, int16_t min, int16_t max, int16_t measuredValue); + + inline int16_t GetMeasuredValue() { return mMeasurement; }; + void SetMeasuredValue(int16_t measurement); + + using DeviceCallback_fn = std::function; + void SetChangeCallback(DeviceCallback_fn aChanged_CB); + + const int16_t mMin; + const int16_t mMax; + +private: + void HandleDeviceChange(Device * device, Device::Changed_t changeMask); + +private: + int16_t mMeasurement; + DeviceCallback_fn mChanged_CB; +}; diff --git a/examples/bridge-app/telink/prj.conf b/examples/bridge-app/telink/prj.conf new file mode 100644 index 00000000000000..2d69564ad49b85 --- /dev/null +++ b/examples/bridge-app/telink/prj.conf @@ -0,0 +1,79 @@ +# +# 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. +# 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. +# + +# This sample uses sample-defaults.conf to set options common for all +# samples. This file should contain only options specific for this sample +# or overrides of default values. + +# enable GPIO +CONFIG_GPIO=y + +# enable PWM +CONFIG_PWM=y + +# OpenThread configs +CONFIG_OPENTHREAD_MTD=n +CONFIG_OPENTHREAD_FTD=y +CONFIG_CHIP_ENABLE_SLEEPY_END_DEVICE_SUPPORT=n +CONFIG_CHIP_SED_IDLE_INTERVAL=200 +CONFIG_CHIP_THREAD_SSED=n + +# Default OpenThread network settings +CONFIG_OPENTHREAD_PANID=4660 +CONFIG_OPENTHREAD_CHANNEL=15 +CONFIG_OPENTHREAD_NETWORK_NAME="OpenThreadDemo" +CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22" + +# Disable Matter OTA DFU +CONFIG_CHIP_OTA_REQUESTOR=n + +# CHIP configuration +CONFIG_CHIP_PROJECT_CONFIG="include/CHIPProjectConfig.h" +CONFIG_CHIP_OPENTHREAD_CONFIG="../../platform/telink/project_include/OpenThreadConfig.h" + +CONFIG_CHIP_DEVICE_VENDOR_ID=65521 +# 32769 == 0x8001 (example all-clusters-app), otherwise GoogleHome fails commissioning +CONFIG_CHIP_DEVICE_PRODUCT_ID=32769 +CONFIG_CHIP_DEVICE_TYPE=65535 + +CONFIG_CHIP_DEVICE_SOFTWARE_VERSION=1 +CONFIG_CHIP_DEVICE_SOFTWARE_VERSION_STRING="2022" + +# Enable CHIP pairing automatically on application start. +CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART=y + +# CHIP shell +CONFIG_CHIP_LIB_SHELL=n + +# Disable factory data support. +CONFIG_CHIP_FACTORY_DATA=n +CONFIG_CHIP_FACTORY_DATA_BUILD=n +CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE=n +CONFIG_CHIP_CERTIFICATION_DECLARATION_STORAGE=n + +# Enable Button IRQ mode. The poling mode is used by default. +CONFIG_CHIP_BUTTON_MANAGER_IRQ_MODE=n + +# Disable Status LED. +CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED=y + +# Enable Power Management +CONFIG_PM=n +CONFIG_PM_DEVICE=n + +# Custom RF power values +CONFIG_B91_BLE_CTRL_RF_POWER_P9P11DBM=y +CONFIG_CHIP_OPENTHREAD_TX_POWER=9 diff --git a/examples/bridge-app/telink/src/AppTask.cpp b/examples/bridge-app/telink/src/AppTask.cpp new file mode 100644 index 00000000000000..8a9bcd127c7079 --- /dev/null +++ b/examples/bridge-app/telink/src/AppTask.cpp @@ -0,0 +1,1108 @@ +/* + * + * 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 "AppTask.h" + +#include "AppConfig.h" +#include "AppEvent.h" +#include "ButtonManager.h" +#include "Device.h" +#include +#include +#include +#include +#include + +#include "ThreadUtil.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if CONFIG_CHIP_OTA_REQUESTOR +#include "OTAUtil.h" +#endif + +#include +#include + +#include + +#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; +using namespace ::chip::Credentials; +using namespace ::chip::DeviceLayer; + +namespace { +constexpr int kFactoryResetCalcTimeout = 3000; +constexpr int kFactoryResetTriggerCntr = 3; +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; + +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! +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; +uint8_t sFactoryResetCntr = 0; + +#if CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED +LEDWidget sStatusLED; +#endif + +Button sFactoryResetButton; +Button sLightingButton; +Button sThreadStartButton; +Button sBleAdvStartButton; + +bool sIsThreadProvisioned = false; +bool sIsThreadEnabled = false; +bool sIsThreadAttached = false; +bool sHaveBLEConnections = false; + +chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; + +void OnIdentifyTriggerEffect(Identify * identify) +{ + AppTask::IdentifyEffectHandler(identify->mCurrentEffectIdentifier); +} + +Identify sIdentify = { + kLightEndpointId, + [](Identify *) { ChipLogProgress(Zcl, "OnIdentifyStart"); }, + [](Identify *) { ChipLogProgress(Zcl, "OnIdentifyStop"); }, + EMBER_ZCL_IDENTIFY_IDENTIFY_TYPE_VISIBLE_LED, + OnIdentifyTriggerEffect, +}; + +} // namespace + +AppTask AppTask::sAppTask; +#include + +int AddDeviceEndpoint(Device * dev, EmberAfEndpointType * ep, const Span & deviceTypeList, + const Span & dataVersionStorage, chip::EndpointId parentEndpointId); +CHIP_ERROR RemoveDeviceEndpoint(Device * dev); +void HandleDeviceTempSensorStatusChanged(DeviceTempSensor * dev, DeviceTempSensor::Changed_t itemChangedMask); +EmberAfStatus HandleReadTempMeasurementAttribute(DeviceTempSensor * dev, chip::AttributeId attributeId, uint8_t * buffer, + uint16_t maxReadLength); + +static const int kNodeLabelSize = 32; +// Current ZCL implementation of Struct uses a max-size array of 254 bytes +static const int kDescriptorAttributeArraySize = 254; + +static EndpointId gCurrentEndpointId; +static EndpointId gFirstDynamicEndpointId; + +static Device * gDevices[CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT]; // number of dynamic endpoints count + +const int16_t minMeasuredValue = -27315; +const int16_t maxMeasuredValue = 32766; +const int16_t initialMeasuredValue = 100; + +// 5 Bridged devices +static Device gLight1("Light 1", "Office"); +static Device gLight2("Light 2", "Office"); +static Device gLight3("Light 3", "Kitchen"); +static Device gLight4("Light 4", "Kitchen"); +static DeviceTempSensor TempSensor1("TempSensor 1", "Office", minMeasuredValue, maxMeasuredValue, initialMeasuredValue); + +// (taken from src/app/zap-templates/zcl/data-model/chip/matter-devices.xml) +#define DEVICE_TYPE_BRIDGED_NODE 0x0013 +// (taken from lo-devices.xml) +#define DEVICE_TYPE_LO_ON_OFF_LIGHT 0x0100 +#define DEVICE_TYPE_ROOT_NODE 0x0016 +#define DEVICE_TYPE_BRIDGE 0x000e +#define DEVICE_TYPE_TEMP_SENSOR 0x0302 +// Device Version for dynamic endpoints: +#define DEVICE_VERSION_DEFAULT 1 + +/* REVISION definitions: + */ + +#define ZCL_DESCRIPTOR_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) +#define ZCL_TEMPERATURE_SENSOR_CLUSTER_REVISION (4u) +#define ZCL_BRIDGED_DEVICE_BASIC_INFORMATION_FEATURE_MAP (0u) +#define ZCL_TEMPERATURE_SENSOR_FEATURE_MAP (0u) + +/* BRIDGED DEVICE ENDPOINT: contains the following clusters: + - On/Off + - Descriptor + - Bridged Device Basic Information +*/ + +// Declare On/Off cluster attributes +DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(onOffAttrs) +DECLARE_DYNAMIC_ATTRIBUTE(Clusters::OnOff::Attributes::OnOff::Id, BOOLEAN, 1, 0), /* on/off */ + DECLARE_DYNAMIC_ATTRIBUTE(Clusters::OnOff::Attributes::ClusterRevision::Id, INT16U, ZCL_ON_OFF_CLUSTER_REVISION, 0), + DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); + +// Declare Descriptor cluster attributes +DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(descriptorAttrs) +DECLARE_DYNAMIC_ATTRIBUTE(Clusters::Descriptor::Attributes::DeviceTypeList::Id, ARRAY, kDescriptorAttributeArraySize, + 0), /* device list */ + DECLARE_DYNAMIC_ATTRIBUTE(Clusters::Descriptor::Attributes::ServerList::Id, ARRAY, kDescriptorAttributeArraySize, + 0), /* server list */ + DECLARE_DYNAMIC_ATTRIBUTE(Clusters::Descriptor::Attributes::ClientList::Id, ARRAY, kDescriptorAttributeArraySize, + 0), /* client list */ + DECLARE_DYNAMIC_ATTRIBUTE(Clusters::Descriptor::Attributes::PartsList::Id, ARRAY, kDescriptorAttributeArraySize, + 0), /* parts list */ + DECLARE_DYNAMIC_ATTRIBUTE(Clusters::Descriptor::Attributes::ClusterRevision::Id, INT16U, ZCL_DESCRIPTOR_CLUSTER_REVISION, + 0), /* cluster revision */ + DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); + +// Declare Bridged Device Basic Information cluster attributes +DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(bridgedDeviceBasicAttrs) +DECLARE_DYNAMIC_ATTRIBUTE(chip::app::Clusters::BridgedDeviceBasicInformation::Attributes::NodeLabel::Id, CHAR_STRING, + kNodeLabelSize, 0), /* NodeLabel */ + DECLARE_DYNAMIC_ATTRIBUTE(chip::app::Clusters::BridgedDeviceBasicInformation::Attributes::Reachable::Id, BOOLEAN, 1, + 0), /* Reachable */ + DECLARE_DYNAMIC_ATTRIBUTE(chip::app::Clusters::BridgedDeviceBasicInformation::Attributes::ClusterRevision::Id, INT16U, + ZCL_BRIDGED_DEVICE_BASIC_INFORMATION_CLUSTER_REVISION, 0), /* cluster revision */ + DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); + +// Declare Cluster List for Bridged Light endpoint +// TODO: It's not clear whether it would be better to get the command lists from +// the ZAP config on our last fixed endpoint instead. +constexpr CommandId onOffIncomingCommands[] = { + app::Clusters::OnOff::Commands::Off::Id, + app::Clusters::OnOff::Commands::On::Id, + app::Clusters::OnOff::Commands::Toggle::Id, + app::Clusters::OnOff::Commands::OffWithEffect::Id, + app::Clusters::OnOff::Commands::OnWithRecallGlobalScene::Id, + app::Clusters::OnOff::Commands::OnWithTimedOff::Id, + kInvalidCommandId, +}; + +DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(bridgedLightClusters) +DECLARE_DYNAMIC_CLUSTER(Clusters::OnOff::Id, onOffAttrs, onOffIncomingCommands, nullptr), + DECLARE_DYNAMIC_CLUSTER(Clusters::Descriptor::Id, descriptorAttrs, nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER(chip::app::Clusters::BridgedDeviceBasicInformation::Id, bridgedDeviceBasicAttrs, nullptr, + nullptr) DECLARE_DYNAMIC_CLUSTER_LIST_END; + +// ----------------------------Temperature sensor----------------------------------------------- +DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(tempSensorAttrs) +DECLARE_DYNAMIC_ATTRIBUTE(Clusters::TemperatureMeasurement::Attributes::MeasuredValue::Id, INT16S, 2, 0), /* Measured Value */ + DECLARE_DYNAMIC_ATTRIBUTE(Clusters::TemperatureMeasurement::Attributes::MinMeasuredValue::Id, INT16S, 2, + 0), /* Min Measured Value */ + DECLARE_DYNAMIC_ATTRIBUTE(Clusters::TemperatureMeasurement::Attributes::MaxMeasuredValue::Id, INT16S, 2, + 0), /* Max Measured Value */ + DECLARE_DYNAMIC_ATTRIBUTE(Clusters::TemperatureMeasurement::Attributes::FeatureMap::Id, BITMAP32, 4, 0), /* FeatureMap */ + DECLARE_DYNAMIC_ATTRIBUTE(Clusters::TemperatureMeasurement::Attributes::ClusterRevision::Id, INT16U, + ZCL_TEMPERATURE_SENSOR_CLUSTER_REVISION, 0), /* cluster revision */ + DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(); + +// TEMPERATURE SENSOR ENDPOINT: contains the following clusters: +// - Temperature measurement +// - Descriptor +// - Bridged Device Basic Information +DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(bridgedTempSensorClusters) +DECLARE_DYNAMIC_CLUSTER(Clusters::TemperatureMeasurement::Id, tempSensorAttrs, nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER(Clusters::Descriptor::Id, descriptorAttrs, nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER(Clusters::BridgedDeviceBasicInformation::Id, bridgedDeviceBasicAttrs, nullptr, nullptr), + DECLARE_DYNAMIC_CLUSTER_LIST_END; + +// Declare Bridged Light endpoint +DECLARE_DYNAMIC_ENDPOINT(bridgedTempSensorEndpoint, bridgedTempSensorClusters); +DataVersion gTempSensor1DataVersions[ArraySize(bridgedTempSensorClusters)]; + +// Declare Bridged Light endpoint +DECLARE_DYNAMIC_ENDPOINT(bridgedLightEndpoint, bridgedLightClusters); + +DataVersion gLight1DataVersions[ArraySize(bridgedLightClusters)]; +DataVersion gLight2DataVersions[ArraySize(bridgedLightClusters)]; +DataVersion gLight3DataVersions[ArraySize(bridgedLightClusters)]; +DataVersion gLight4DataVersions[ArraySize(bridgedLightClusters)]; +// DataVersion gThermostatDataVersions[ArraySize(thermostatAttrs)]; + +const EmberAfDeviceType gRootDeviceTypes[] = { { DEVICE_TYPE_ROOT_NODE, DEVICE_VERSION_DEFAULT } }; +const EmberAfDeviceType gAggregateNodeDeviceTypes[] = { { DEVICE_TYPE_BRIDGE, DEVICE_VERSION_DEFAULT } }; + +const EmberAfDeviceType gBridgedOnOffDeviceTypes[] = { { DEVICE_TYPE_LO_ON_OFF_LIGHT, DEVICE_VERSION_DEFAULT }, + { DEVICE_TYPE_BRIDGED_NODE, DEVICE_VERSION_DEFAULT } }; + +const EmberAfDeviceType gBridgedTempSensorDeviceTypes[] = { { DEVICE_TYPE_TEMP_SENSOR, DEVICE_VERSION_DEFAULT }, + { DEVICE_TYPE_BRIDGED_NODE, DEVICE_VERSION_DEFAULT } }; + +int AddDeviceEndpoint(Device * dev, EmberAfEndpointType * ep, const Span & deviceTypeList, + const Span & dataVersionStorage, chip::EndpointId parentEndpointId) +{ + uint8_t index = 0; + while (index < CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT) + { + if (NULL == gDevices[index]) + { + gDevices[index] = dev; + EmberAfStatus ret; + while (true) + { + dev->SetEndpointId(gCurrentEndpointId); + ret = + emberAfSetDynamicEndpoint(index, gCurrentEndpointId, ep, dataVersionStorage, deviceTypeList, parentEndpointId); + if (ret == EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogProgress(DeviceLayer, "Added device %s to dynamic endpoint %d (index=%d)", dev->GetName(), + gCurrentEndpointId, index); + return index; + } + else if (ret != EMBER_ZCL_STATUS_DUPLICATE_EXISTS) + { + return -1; + } + // Handle wrap condition + if (++gCurrentEndpointId < gFirstDynamicEndpointId) + { + gCurrentEndpointId = gFirstDynamicEndpointId; + } + } + } + index++; + } + ChipLogProgress(DeviceLayer, "Failed to add dynamic endpoint: No endpoints available!"); + return -1; +} + +CHIP_ERROR RemoveDeviceEndpoint(Device * dev) +{ + for (uint8_t index = 0; index < CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT; index++) + { + if (gDevices[index] == dev) + { + EndpointId ep = emberAfClearDynamicEndpoint(index); + gDevices[index] = NULL; + ChipLogProgress(DeviceLayer, "Removed device %s from dynamic endpoint %d (index=%d)", dev->GetName(), ep, index); + // Silence complaints about unused ep when progress logging + // disabled. + UNUSED_VAR(ep); + return CHIP_NO_ERROR; + } + } + return CHIP_ERROR_INTERNAL; +} + +EmberAfStatus HandleReadBridgedDeviceBasicAttribute(Device * dev, chip::AttributeId attributeId, uint8_t * buffer, + uint16_t maxReadLength) +{ + using namespace chip::app::Clusters::BridgedDeviceBasicInformation::Attributes; + ChipLogProgress(DeviceLayer, "HandleReadBridgedDeviceBasicAttribute: attrId=%" PRIu32 ", maxReadLength=%u", attributeId, + maxReadLength); + + if ((attributeId == Reachable::Id) && (maxReadLength == 1)) + { + *buffer = dev->IsReachable() ? 1 : 0; + } + else if ((attributeId == NodeLabel::Id) && (maxReadLength == 32)) + { + MutableByteSpan zclNameSpan(buffer, maxReadLength); + MakeZclCharString(zclNameSpan, dev->GetName()); + } + else if ((attributeId == FeatureMap::Id) && (maxReadLength == 4)) + { + uint32_t featureMap = ZCL_BRIDGED_DEVICE_BASIC_INFORMATION_FEATURE_MAP; + memcpy(buffer, &featureMap, sizeof(featureMap)); + } + else if ((attributeId == ClusterRevision::Id) && (maxReadLength == 4)) + { + uint16_t clusterRevision = ZCL_BRIDGED_DEVICE_BASIC_INFORMATION_CLUSTER_REVISION; + memcpy(buffer, &clusterRevision, sizeof(clusterRevision)); + } + else + { + return EMBER_ZCL_STATUS_FAILURE; + } + + return EMBER_ZCL_STATUS_SUCCESS; +} + +EmberAfStatus HandleReadOnOffAttribute(Device * dev, chip::AttributeId attributeId, uint8_t * buffer, uint16_t maxReadLength) +{ + ChipLogProgress(DeviceLayer, "HandleReadOnOffAttribute: attrId=%" PRIu32 ", maxReadLength=%u", attributeId, maxReadLength); + + if ((attributeId == Clusters::OnOff::Attributes::OnOff::Id) && (maxReadLength == 1)) + { + *buffer = dev->IsOn() ? 1 : 0; + } + else if ((attributeId == Clusters::OnOff::Attributes::ClusterRevision::Id) && (maxReadLength == 4)) + { + uint16_t clusterRevision = ZCL_ON_OFF_CLUSTER_REVISION; + memcpy(buffer, &clusterRevision, sizeof(clusterRevision)); + } + else + { + return EMBER_ZCL_STATUS_FAILURE; + } + + return EMBER_ZCL_STATUS_SUCCESS; +} + +EmberAfStatus HandleWriteOnOffAttribute(Device * dev, chip::AttributeId attributeId, uint8_t * buffer) +{ + ChipLogProgress(DeviceLayer, "HandleWriteOnOffAttribute: attrId=%" PRIu32, attributeId); + + ReturnErrorCodeIf((attributeId != Clusters::OnOff::Attributes::OnOff::Id) || (!dev->IsReachable()), EMBER_ZCL_STATUS_FAILURE); + dev->SetOnOff(*buffer == 1); + return EMBER_ZCL_STATUS_SUCCESS; +} + +EmberAfStatus emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, + const EmberAfAttributeMetadata * attributeMetadata, uint8_t * buffer, + uint16_t maxReadLength) +{ + using namespace Clusters; + + uint16_t endpointIndex = emberAfGetDynamicIndexFromEndpoint(endpoint); + + if ((endpointIndex < CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT) && (gDevices[endpointIndex] != NULL)) + { + Device * dev = gDevices[endpointIndex]; + + if (clusterId == BridgedDeviceBasicInformation::Id) + { + return HandleReadBridgedDeviceBasicAttribute(dev, attributeMetadata->attributeId, buffer, maxReadLength); + } + else if (clusterId == OnOff::Id) + { + return HandleReadOnOffAttribute(dev, attributeMetadata->attributeId, buffer, maxReadLength); + } + else if (clusterId == TemperatureMeasurement::Id) + { + return HandleReadTempMeasurementAttribute(static_cast(dev), attributeMetadata->attributeId, buffer, + maxReadLength); + } + } + + return EMBER_ZCL_STATUS_FAILURE; +} + +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) + { + Device * dev = gDevices[endpointIndex]; + + if ((dev->IsReachable()) && (clusterId == Clusters::OnOff::Id)) + { + return HandleWriteOnOffAttribute(dev, attributeMetadata->attributeId, buffer); + } + } + + return EMBER_ZCL_STATUS_FAILURE; +} + +namespace { +void CallReportingCallback(intptr_t closure) +{ + auto path = reinterpret_cast(closure); + MatterReportingAttributeChangeCallback(*path); + Platform::Delete(path); +} + +void ScheduleReportingCallback(Device * dev, ClusterId cluster, AttributeId attribute) +{ + auto * path = Platform::New(dev->GetEndpointId(), cluster, attribute); + DeviceLayer::PlatformMgr().ScheduleWork(CallReportingCallback, reinterpret_cast(path)); +} +} // anonymous namespace + +void HandleDeviceStatusChanged(Device * dev, Device::Changed_t itemChangedMask) +{ + using namespace chip::app::Clusters; + if (itemChangedMask & Device::kChanged_Reachable) + { + ScheduleReportingCallback(dev, BridgedDeviceBasicInformation::Id, BridgedDeviceBasicInformation::Attributes::Reachable::Id); + } + + if (itemChangedMask & Device::kChanged_State) + { + ScheduleReportingCallback(dev, OnOff::Id, OnOff::Attributes::OnOff::Id); + } + + if (itemChangedMask & Device::kChanged_Name) + { + ScheduleReportingCallback(dev, BridgedDeviceBasicInformation::Id, BridgedDeviceBasicInformation::Attributes::NodeLabel::Id); + } +} + +bool emberAfActionsClusterInstantActionCallback(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, + const Clusters::Actions::Commands::InstantAction::DecodableType & commandData) +{ + // No actions are implemented, just return status NotFound. + commandObj->AddStatus(commandPath, Protocols::InteractionModel::Status::NotFound); + return true; +} + +class AppFabricTableDelegate : public FabricTable::Delegate +{ + void OnFabricRemoved(const FabricTable & fabricTable, FabricIndex fabricIndex) + { + if (chip::Server::GetInstance().GetFabricTable().FabricCount() == 0) + { + chip::Server::GetInstance().ScheduleFactoryReset(); + } + } +}; + +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 LEDs +#if CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED + LEDWidget::InitGpio(LEDS_PORT); + LEDWidget::SetStateUpdateCallback(LEDStateUpdateHandler); + + sStatusLED.Init(SYSTEM_STATE_LED); + + UpdateStatusLED(); +#endif + + InitButtons(); + + // Initialize function button timer + k_timer_init(&sFactoryResetTimer, &AppTask::FactoryResetTimerTimeoutCallback, nullptr); + k_timer_user_data_set(&sFactoryResetTimer, this); + + // Init lighting manager + uint8_t minLightLevel = kDefaultMinLevel; + Clusters::LevelControl::Attributes::MinLevel::Get(kLightEndpointId, &minLightLevel); + + uint8_t maxLightLevel = kDefaultMaxLevel; + Clusters::LevelControl::Attributes::MaxLevel::Get(kLightEndpointId, &maxLightLevel); + + // Initialize PWM LEDs + 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; + } + + err = sAppTask.mPwmRgbBlueLed.Init(&sPwmRgbSpecBlueLed, minLightLevel, maxLightLevel, maxLightLevel); + if (err != CHIP_NO_ERROR) + { + LOG_ERR("Blue RGB PWM Device Init fail"); + return err; + } + + sAppTask.mPwmRgbBlueLed.SetCallbacks(ActionInitiated, ActionCompleted, nullptr); + sAppTask.mPwmIdentifyLed.SetCallbacks(nullptr, nullptr, ActionIdentifyStateUpdateHandler); + + // Initialize CHIP server +#if CONFIG_CHIP_FACTORY_DATA + ReturnErrorOnFailure(mFactoryDataProvider.Init()); + SetDeviceInstanceInfoProvider(&mFactoryDataProvider); + SetDeviceAttestationCredentialsProvider(&mFactoryDataProvider); + SetCommissionableDataProvider(&mFactoryDataProvider); + // Read EnableKey from the factory data. + MutableByteSpan enableKey(sTestEventTriggerEnableKey); + err = mFactoryDataProvider.GetEnableKey(enableKey); + if (err != CHIP_NO_ERROR) + { + LOG_ERR("GetEnableKey fail"); + memset(sTestEventTriggerEnableKey, 0, sizeof(sTestEventTriggerEnableKey)); + } +#else + SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); +#endif + + static CommonCaseDeviceServerInitParams initParams; + (void) initParams.InitializeStaticResourcesBeforeServerInit(); + ReturnErrorOnFailure(chip::Server::GetInstance().Init(initParams)); + + gExampleDeviceInfoProvider.SetStorageDelegate(&Server::GetInstance().GetPersistentStorage()); + chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); + +#if CONFIG_CHIP_OTA_REQUESTOR + InitBasicOTARequestor(); +#endif + + ConfigurationMgr().LogDeviceConfig(); + PrintOnboardingCodes(chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)); + + // Add CHIP event handler and start CHIP thread. + // Note that all the initialization code should happen prior to this point to avoid data races + // between the main and the CHIP threads. + PlatformMgr().AddEventHandler(ChipEventHandler, 0); + + err = ConnectivityMgr().SetBLEDeviceName("TelinkLight"); + if (err != CHIP_NO_ERROR) + { + LOG_ERR("SetBLEDeviceName fail"); + return err; + } + + err = chip::Server::GetInstance().GetFabricTable().AddFabricDelegate(new AppFabricTableDelegate); + if (err != CHIP_NO_ERROR) + { + LOG_ERR("AppFabricTableDelegate fail"); + return err; + } + + memset(gDevices, 0, sizeof(gDevices)); + + gLight1.SetReachable(true); + gLight2.SetReachable(true); + gLight3.SetReachable(true); + gLight4.SetReachable(true); + TempSensor1.SetReachable(true); + + // Whenever bridged device changes its state + gLight1.SetChangeCallback(&HandleDeviceStatusChanged); + gLight2.SetChangeCallback(&HandleDeviceStatusChanged); + gLight3.SetChangeCallback(&HandleDeviceStatusChanged); + gLight4.SetChangeCallback(&HandleDeviceStatusChanged); + TempSensor1.SetChangeCallback(&HandleDeviceTempSensorStatusChanged); + + PlatformMgr().ScheduleWork(InitServer, reinterpret_cast(nullptr)); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR AppTask::StartApp(void) +{ + CHIP_ERROR err = Init(); + + if (err != CHIP_NO_ERROR) + { + LOG_ERR("AppTask Init fail"); + return err; + } + + AppEvent event = {}; + + while (true) + { + k_msgq_get(&sAppEventQueue, &event, K_FOREVER); + DispatchEvent(&event); + } +} + +static void AppTask::InitServer(intptr_t context) +{ + + // Set starting endpoint id where dynamic endpoints will be assigned, which + // will be the next consecutive endpoint id after the last fixed endpoint. + gFirstDynamicEndpointId = static_cast( + static_cast(emberAfEndpointFromIndex(static_cast(emberAfFixedEndpointCount() - 1))) + 1); + gCurrentEndpointId = gFirstDynamicEndpointId; + + // Disable last fixed endpoint, which is used as a placeholder for all of the + // supported clusters so that ZAP will generate the requisite code. + emberAfEndpointEnableDisable(emberAfEndpointFromIndex(static_cast(emberAfFixedEndpointCount() - 1)), false); + + // A bridge has root node device type on EP0 and aggregate node device type (bridge) at EP1 + emberAfSetDeviceTypeList(0, Span(gRootDeviceTypes)); + emberAfSetDeviceTypeList(1, Span(gAggregateNodeDeviceTypes)); + + // Add lights 1..3 --> will be mapped to ZCL endpoints 3, 4, 5 + AddDeviceEndpoint(&gLight1, &bridgedLightEndpoint, Span(gBridgedOnOffDeviceTypes), + Span(gLight1DataVersions), 1); + AddDeviceEndpoint(&gLight2, &bridgedLightEndpoint, Span(gBridgedOnOffDeviceTypes), + Span(gLight2DataVersions), 1); + AddDeviceEndpoint(&gLight3, &bridgedLightEndpoint, Span(gBridgedOnOffDeviceTypes), + Span(gLight3DataVersions), 1); + + // Remove Light 2 -- Lights 1 & 3 will remain mapped to endpoints 3 & 5 + RemoveDeviceEndpoint(&gLight2); + + // Add Light 4 -- > will be mapped to ZCL endpoint 6 + AddDeviceEndpoint(&gLight4, &bridgedLightEndpoint, Span(gBridgedOnOffDeviceTypes), + Span(gLight4DataVersions), 1); + + // Re-add Light 2 -- > will be mapped to ZCL endpoint 7 + AddDeviceEndpoint(&gLight2, &bridgedLightEndpoint, Span(gBridgedOnOffDeviceTypes), + Span(gLight2DataVersions), 1); + + // Add Temperature Sensor devices --> will be mapped to endpoint 8 + AddDeviceEndpoint(&TempSensor1, &bridgedTempSensorEndpoint, Span(gBridgedTempSensorDeviceTypes), + Span(gTempSensor1DataVersions), 1); +} + +void HandleDeviceTempSensorStatusChanged(DeviceTempSensor * dev, DeviceTempSensor::Changed_t itemChangedMask) +{ + using namespace Clusters; + if (itemChangedMask & + (DeviceTempSensor::kChanged_Reachable | DeviceTempSensor::kChanged_Name | DeviceTempSensor::kChanged_Location)) + { + HandleDeviceStatusChanged(static_cast(dev), (Device::Changed_t) itemChangedMask); + } + if (itemChangedMask & DeviceTempSensor::kChanged_MeasurementValue) + { + ScheduleReportingCallback(dev, TemperatureMeasurement::Id, TemperatureMeasurement::Attributes::MeasuredValue::Id); + } +} + +EmberAfStatus HandleReadTempMeasurementAttribute(DeviceTempSensor * dev, chip::AttributeId attributeId, uint8_t * buffer, + uint16_t maxReadLength) +{ + using namespace Clusters::TemperatureMeasurement::Attributes; + + if ((attributeId == MeasuredValue::Id) && (maxReadLength == 2)) + { + int16_t measuredValue = dev->GetMeasuredValue(); + memcpy(buffer, &measuredValue, sizeof(measuredValue)); + } + else if ((attributeId == MinMeasuredValue::Id) && (maxReadLength == 2)) + { + int16_t minValue = dev->mMin; + memcpy(buffer, &minValue, sizeof(minValue)); + } + else if ((attributeId == MaxMeasuredValue::Id) && (maxReadLength == 2)) + { + int16_t maxValue = dev->mMax; + memcpy(buffer, &maxValue, sizeof(maxValue)); + } + else if ((attributeId == FeatureMap::Id) && (maxReadLength == 4)) + { + uint32_t featureMap = ZCL_TEMPERATURE_SENSOR_FEATURE_MAP; + memcpy(buffer, &featureMap, sizeof(featureMap)); + } + else if ((attributeId == ClusterRevision::Id) && (maxReadLength == 4)) + { + uint16_t clusterRevision = ZCL_TEMPERATURE_SENSOR_CLUSTER_REVISION; + memcpy(buffer, &clusterRevision, sizeof(clusterRevision)); + } + else + { + return EMBER_ZCL_STATUS_FAILURE; + } + + return EMBER_ZCL_STATUS_SUCCESS; +} + +void AppTask::LightingActionButtonEventHandler(void) +{ + AppEvent event; + + event.Type = AppEvent::kEventType_Button; + event.ButtonEvent.Action = kButtonPushEvent; + event.Handler = LightingActionEventHandler; + sAppTask.PostEvent(&event); +} + +void AppTask::LightingActionEventHandler(AppEvent * aEvent) +{ + PWMDevice::Action_t action = PWMDevice::INVALID_ACTION; + int32_t actor = 0; + + if (aEvent->Type == AppEvent::kEventType_Lighting) + { + action = static_cast(aEvent->LightingEvent.Action); + actor = aEvent->LightingEvent.Actor; + } + else if (aEvent->Type == AppEvent::kEventType_Button) + { + action = sAppTask.mPwmRgbBlueLed.IsTurnedOn() ? PWMDevice::OFF_ACTION : PWMDevice::ON_ACTION; + actor = AppEvent::kEventType_Button; + } + + if (action != PWMDevice::INVALID_ACTION && (!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; + + event.Type = AppEvent::kEventType_Button; + event.ButtonEvent.Action = kButtonPushEvent; + event.Handler = FactoryResetHandler; + sAppTask.PostEvent(&event); +} + +void AppTask::FactoryResetHandler(AppEvent * aEvent) +{ + if (sFactoryResetCntr == 0) + { + k_timer_start(&sFactoryResetTimer, K_MSEC(kFactoryResetCalcTimeout), K_NO_WAIT); + } + + sFactoryResetCntr++; + LOG_INF("Factory Reset Trigger Counter: %d/%d", sFactoryResetCntr, kFactoryResetTriggerCntr); + + if (sFactoryResetCntr == kFactoryResetTriggerCntr) + { + k_timer_stop(&sFactoryResetTimer); + sFactoryResetCntr = 0; + + chip::Server::GetInstance().ScheduleFactoryReset(); + } +} + +void AppTask::StartThreadButtonEventHandler(void) +{ + AppEvent event; + + event.Type = AppEvent::kEventType_Button; + event.ButtonEvent.Action = kButtonPushEvent; + event.Handler = StartThreadHandler; + sAppTask.PostEvent(&event); +} + +void AppTask::StartThreadHandler(AppEvent * aEvent) +{ + LOG_INF("StartThreadHandler"); + if (!chip::DeviceLayer::ConnectivityMgr().IsThreadProvisioned()) + { + // Switch context from BLE to Thread + Internal::BLEManagerImpl sInstance; + sInstance.SwitchToIeee802154(); + StartDefaultThreadNetwork(); + } + else + { + LOG_INF("Device already commissioned"); + } +} + +void AppTask::StartBleAdvButtonEventHandler(void) +{ + AppEvent event; + + event.Type = AppEvent::kEventType_Button; + event.ButtonEvent.Action = kButtonPushEvent; + event.Handler = StartBleAdvHandler; + sAppTask.PostEvent(&event); +} + +void AppTask::StartBleAdvHandler(AppEvent * aEvent) +{ + LOG_INF("StartBleAdvHandler"); + + // Don't allow on starting Matter service BLE advertising after Thread provisioning. + if (ConnectivityMgr().IsThreadProvisioned()) + { + LOG_INF("Device already commissioned"); + return; + } + + if (ConnectivityMgr().IsBLEAdvertisingEnabled()) + { + LOG_INF("BLE adv already enabled"); + return; + } + + if (chip::Server::GetInstance().GetCommissioningWindowManager().OpenBasicCommissioningWindow() != CHIP_NO_ERROR) + { + LOG_ERR("OpenBasicCommissioningWindow fail"); + } +} + +#if CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED +void AppTask::UpdateLedStateEventHandler(AppEvent * aEvent) +{ + if (aEvent->Type == AppEvent::kEventType_UpdateLedState) + { + aEvent->UpdateLedStateEvent.LedWidget->UpdateState(); + } +} + +void AppTask::LEDStateUpdateHandler(LEDWidget * ledWidget) +{ + AppEvent event; + event.Type = AppEvent::kEventType_UpdateLedState; + event.Handler = UpdateLedStateEventHandler; + event.UpdateLedStateEvent.LedWidget = ledWidget; + sAppTask.PostEvent(&event); +} + +void AppTask::UpdateStatusLED(void) +{ + if (sIsThreadProvisioned && sIsThreadEnabled) + { + if (sIsThreadAttached) + { + sStatusLED.Blink(950, 50); + } + else + { + sStatusLED.Blink(100, 100); + } + } + else + { + sStatusLED.Blink(50, 950); + } +} +#endif + +void AppTask::ChipEventHandler(const ChipDeviceEvent * event, intptr_t /* arg */) +{ + switch (event->Type) + { + case DeviceEventType::kCHIPoBLEAdvertisingChange: + sHaveBLEConnections = ConnectivityMgr().NumBLEConnections() != 0; +#if CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED + UpdateStatusLED(); +#endif + break; + case DeviceEventType::kThreadStateChange: + sIsThreadProvisioned = ConnectivityMgr().IsThreadProvisioned(); + sIsThreadEnabled = ConnectivityMgr().IsThreadEnabled(); + sIsThreadAttached = ConnectivityMgr().IsThreadAttached(); +#if CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED + UpdateStatusLED(); +#endif + break; + case DeviceEventType::kThreadConnectivityChange: +#if CONFIG_CHIP_OTA_REQUESTOR + if (event->ThreadConnectivityChange.Result == kConnectivity_Established) + { + InitBasicOTARequestor(); + } +#endif + break; + default: + break; + } +} + +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(PWMDevice::Action_t aAction, int32_t aActor) +{ + if (aAction == PWMDevice::ON_ACTION) + { + LOG_DBG("ON_ACTION initiated"); + } + else if (aAction == PWMDevice::OFF_ACTION) + { + LOG_DBG("OFF_ACTION initiated"); + } + else if (aAction == PWMDevice::LEVEL_ACTION) + { + LOG_DBG("LEVEL_ACTION initiated"); + } +} + +void AppTask::ActionCompleted(PWMDevice::Action_t aAction, int32_t aActor) +{ + if (aAction == PWMDevice::ON_ACTION) + { + LOG_DBG("ON_ACTION completed"); + } + else if (aAction == PWMDevice::OFF_ACTION) + { + LOG_DBG("OFF_ACTION completed"); + } + else if (aAction == PWMDevice::LEVEL_ACTION) + { + LOG_DBG("LEVEL_ACTION completed"); + } + + if (aActor == AppEvent::kEventType_Button) + { + sAppTask.UpdateClusterState(); + } +} + +void AppTask::PostEvent(AppEvent * aEvent) +{ + if (k_msgq_put(&sAppEventQueue, aEvent, K_NO_WAIT) != 0) + { + LOG_INF("PostEvent fail"); + } +} + +void AppTask::DispatchEvent(AppEvent * aEvent) +{ + if (aEvent->Handler) + { + aEvent->Handler(aEvent); + } + else + { + LOG_INF("Dropping event without handler"); + } +} + +void AppTask::UpdateClusterState(void) +{ + bool isTurnedOn = sAppTask.mPwmRgbBlueLed.IsTurnedOn(); + + // write the new on/off value + EmberAfStatus status = Clusters::OnOff::Attributes::OnOff::Set(kLightEndpointId, isTurnedOn); + + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + LOG_ERR("Update OnOff fail: %x", status); + } + uint8_t setLevel = sAppTask.mPwmRgbBlueLed.GetLevel(); + status = Clusters::LevelControl::Attributes::CurrentLevel::Set(kLightEndpointId, setLevel); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + LOG_ERR("Update CurrentLevel fail: %x", status); + } +} + +void AppTask::FactoryResetTimerTimeoutCallback(k_timer * timer) +{ + if (!timer) + { + return; + } + + AppEvent event; + event.Type = AppEvent::kEventType_Timer; + event.Handler = FactoryResetTimerEventHandler; + sAppTask.PostEvent(&event); +} + +void AppTask::FactoryResetTimerEventHandler(AppEvent * aEvent) +{ + if (aEvent->Type != AppEvent::kEventType_Timer) + { + return; + } + + sFactoryResetCntr = 0; + LOG_INF("Factory Reset Trigger Counter is cleared"); +} + +void AppTask::InitButtons(void) +{ +#if CONFIG_CHIP_BUTTON_MANAGER_IRQ_MODE + sFactoryResetButton.Configure(BUTTON_PORT, BUTTON_PIN_1, FactoryResetButtonEventHandler); + sLightingButton.Configure(BUTTON_PORT, BUTTON_PIN_2, LightingActionButtonEventHandler); + sThreadStartButton.Configure(BUTTON_PORT, BUTTON_PIN_3, StartThreadButtonEventHandler); + sBleAdvStartButton.Configure(BUTTON_PORT, BUTTON_PIN_4, StartBleAdvButtonEventHandler); +#else + sFactoryResetButton.Configure(BUTTON_PORT, BUTTON_PIN_3, BUTTON_PIN_1, FactoryResetButtonEventHandler); + sLightingButton.Configure(BUTTON_PORT, BUTTON_PIN_4, BUTTON_PIN_1, LightingActionButtonEventHandler); + sThreadStartButton.Configure(BUTTON_PORT, BUTTON_PIN_3, BUTTON_PIN_2, StartThreadButtonEventHandler); + sBleAdvStartButton.Configure(BUTTON_PORT, BUTTON_PIN_4, BUTTON_PIN_2, StartBleAdvButtonEventHandler); +#endif + + ButtonManagerInst().AddButton(sFactoryResetButton); + ButtonManagerInst().AddButton(sLightingButton); + ButtonManagerInst().AddButton(sThreadStartButton); + ButtonManagerInst().AddButton(sBleAdvStartButton); +} diff --git a/examples/bridge-app/telink/src/Device.cpp b/examples/bridge-app/telink/src/Device.cpp new file mode 100644 index 00000000000000..053bf2ce187679 --- /dev/null +++ b/examples/bridge-app/telink/src/Device.cpp @@ -0,0 +1,164 @@ +/* + * + * 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. + * 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 "Device.h" + +#include +#include +#include + +using namespace ::chip::Platform; + +Device::Device(const char * szDeviceName, const char * szLocation) +{ + CopyString(mName, sizeof(mName), szDeviceName); + CopyString(mLocation, sizeof(mLocation), szLocation); + mState = kState_Off; + mReachable = false; + mEndpointId = 0; + mChanged_CB = nullptr; +} + +bool Device::IsOn() const +{ + return mState == kState_On; +} + +bool Device::IsReachable() const +{ + return mReachable; +} + +void Device::SetOnOff(bool aOn) +{ + bool changed; + + if (aOn) + { + changed = (mState != kState_On); + mState = kState_On; + ChipLogProgress(DeviceLayer, "Device[%s]: ON", mName); + } + else + { + changed = (mState != kState_Off); + mState = kState_Off; + ChipLogProgress(DeviceLayer, "Device[%s]: OFF", mName); + } + + if (changed && mChanged_CB) + { + mChanged_CB(this, kChanged_State); + } +} + +void Device::SetReachable(bool aReachable) +{ + bool changed = (mReachable != aReachable); + + mReachable = aReachable; + + if (aReachable) + { + ChipLogProgress(DeviceLayer, "Device[%s]: ONLINE", mName); + } + else + { + ChipLogProgress(DeviceLayer, "Device[%s]: OFFLINE", mName); + } + + if (changed && mChanged_CB) + { + mChanged_CB(this, kChanged_Reachable); + } +} + +void Device::SetName(const char * szName) +{ + bool changed = (strncmp(mName, szName, sizeof(mName)) != 0); + + ChipLogProgress(DeviceLayer, "Device[%s]: New Name=\"%s\"", mName, szName); + + CopyString(mName, sizeof(mName), szName); + + if (changed && mChanged_CB) + { + mChanged_CB(this, kChanged_Name); + } +} + +void Device::SetLocation(const char * szLocation) +{ + bool changed = (strncmp(mLocation, szLocation, sizeof(mLocation)) != 0); + + CopyString(mLocation, sizeof(mLocation), szLocation); + + ChipLogProgress(DeviceLayer, "Device[%s]: Location=\"%s\"", mName, mLocation); + + if (changed && mChanged_CB) + { + mChanged_CB(this, kChanged_Location); + } +} + +void Device::SetChangeCallback(DeviceCallback_fn aChanged_CB) +{ + mChanged_CB = aChanged_CB; +} + +DeviceTempSensor::DeviceTempSensor(const char * szDeviceName, std::string szLocation, int16_t min, int16_t max, + int16_t measuredValue) : + Device(szDeviceName, szLocation.c_str()), + mMin(min), mMax(max), mMeasurement(measuredValue) +{} + +void DeviceTempSensor::SetMeasuredValue(int16_t measurement) +{ + // Limit measurement based on the min and max. + if (measurement < mMin) + { + measurement = mMin; + } + else if (measurement > mMax) + { + measurement = mMax; + } + + bool changed = mMeasurement != measurement; + + ChipLogProgress(DeviceLayer, "TempSensorDevice new measurement=\"%d\"", measurement); + + mMeasurement = measurement; + + if (changed && mChanged_CB) + { + mChanged_CB(this, kChanged_MeasurementValue); + } +} + +void DeviceTempSensor::SetChangeCallback(DeviceCallback_fn aChanged_CB) +{ + mChanged_CB = aChanged_CB; +} + +void DeviceTempSensor::HandleDeviceChange(Device * device, Device::Changed_t changeMask) +{ + if (mChanged_CB) + { + mChanged_CB(this, (DeviceTempSensor::Changed_t) changeMask); + } +} diff --git a/examples/bridge-app/telink/src/DeviceCallbacks.cpp b/examples/bridge-app/telink/src/DeviceCallbacks.cpp new file mode 100644 index 00000000000000..850f88d742b8e7 --- /dev/null +++ b/examples/bridge-app/telink/src/DeviceCallbacks.cpp @@ -0,0 +1,104 @@ +/* + * + * 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 +#include +#include +#include +#include +#include +#include + +using namespace ::chip; +using namespace ::chip::app; +using namespace ::chip::app::Clusters; +using namespace ::chip::app::Clusters::Actions::Attributes; +using namespace ::chip::Inet; +using namespace ::chip::System; + +namespace { + +class ActionsAttrAccess : public AttributeAccessInterface +{ +public: + // Register for the Actions cluster on all endpoints. + ActionsAttrAccess() : AttributeAccessInterface(Optional::Missing(), Actions::Id) {} + + CHIP_ERROR Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) override; + +private: + static constexpr uint16_t ClusterRevision = 1; + + CHIP_ERROR ReadActionListAttribute(EndpointId endpoint, AttributeValueEncoder & aEncoder); + CHIP_ERROR ReadEndpointListAttribute(EndpointId endpoint, AttributeValueEncoder & aEncoder); + CHIP_ERROR ReadSetupUrlAttribute(EndpointId endpoint, AttributeValueEncoder & aEncoder); + CHIP_ERROR ReadClusterRevision(EndpointId endpoint, AttributeValueEncoder & aEncoder); +}; + +constexpr uint16_t ActionsAttrAccess::ClusterRevision; + +CHIP_ERROR ActionsAttrAccess::ReadActionListAttribute(EndpointId endpoint, AttributeValueEncoder & aEncoder) +{ + // Just return an empty list + return aEncoder.EncodeEmptyList(); +} + +CHIP_ERROR ActionsAttrAccess::ReadEndpointListAttribute(EndpointId endpoint, AttributeValueEncoder & aEncoder) +{ + // Just return an empty list + return aEncoder.EncodeEmptyList(); +} + +CHIP_ERROR ActionsAttrAccess::ReadSetupUrlAttribute(EndpointId endpoint, AttributeValueEncoder & aEncoder) +{ + const char SetupUrl[] = "https://example.com"; + return aEncoder.Encode(chip::CharSpan::fromCharString(SetupUrl)); +} + +CHIP_ERROR ActionsAttrAccess::ReadClusterRevision(EndpointId endpoint, AttributeValueEncoder & aEncoder) +{ + return aEncoder.Encode(ClusterRevision); +} + +ActionsAttrAccess gAttrAccess; + +CHIP_ERROR ActionsAttrAccess::Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) +{ + VerifyOrDie(aPath.mClusterId == Actions::Id); + + switch (aPath.mAttributeId) + { + case ActionList::Id: + return ReadActionListAttribute(aPath.mEndpointId, aEncoder); + case EndpointLists::Id: + return ReadEndpointListAttribute(aPath.mEndpointId, aEncoder); + case SetupURL::Id: + return ReadSetupUrlAttribute(aPath.mEndpointId, aEncoder); + case ClusterRevision::Id: + return ReadClusterRevision(aPath.mEndpointId, aEncoder); + default: + break; + } + return CHIP_NO_ERROR; +} +} // anonymous namespace + +void MatterActionsPluginServerInitCallback(void) +{ + registerAttributeAccessOverride(&gAttrAccess); +} diff --git a/examples/bridge-app/telink/src/ZclCallbacks.cpp b/examples/bridge-app/telink/src/ZclCallbacks.cpp new file mode 100644 index 00000000000000..b6f5ed558c584e --- /dev/null +++ b/examples/bridge-app/telink/src/ZclCallbacks.cpp @@ -0,0 +1,58 @@ +/* + * + * 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 "AppTask.h" +#include "ColorFormat.h" +#include "PWMDevice.h" + +#include +#include +#include +#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; + +/** @brief OnOff Cluster Init + * + * This function is called when a specific cluster is initialized. It gives the + * application an opportunity to take care of cluster initialization procedures. + * It is called exactly once for each endpoint where cluster is present. + * + * @param endpoint Ver.: always + * + */ +void emberAfOnOffClusterInitCallback(EndpointId endpoint) +{ + EmberAfStatus status; + bool storedValue; + + // Read storedValue on/off value + status = Attributes::OnOff::Get(1, &storedValue); + if (status == EMBER_ZCL_STATUS_SUCCESS) + { + // Set actual state to stored before reboot + GetAppTask().GetPWMDevice().Set(storedValue); + } + + GetAppTask().UpdateClusterState(); +} diff --git a/examples/bridge-app/telink/src/main.cpp b/examples/bridge-app/telink/src/main.cpp new file mode 100644 index 00000000000000..71aa52f9d91901 --- /dev/null +++ b/examples/bridge-app/telink/src/main.cpp @@ -0,0 +1,82 @@ +/* + * + * 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 "AppTask.h" + +#include +#include + +#include + +LOG_MODULE_REGISTER(app, CONFIG_CHIP_APP_LOG_LEVEL); + +using namespace ::chip; +using namespace ::chip::Inet; +using namespace ::chip::DeviceLayer; + +int main(void) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + + err = chip::Platform::MemoryInit(); + if (err != CHIP_NO_ERROR) + { + LOG_ERR("MemoryInit fail"); + goto exit; + } + + err = PlatformMgr().InitChipStack(); + if (err != CHIP_NO_ERROR) + { + LOG_ERR("InitChipStack fail"); + goto exit; + } + + err = PlatformMgr().StartEventLoopTask(); + if (err != CHIP_NO_ERROR) + { + LOG_ERR("StartEventLoopTask fail"); + goto exit; + } + + err = ThreadStackMgr().InitThreadStack(); + if (err != CHIP_NO_ERROR) + { + LOG_ERR("InitThreadStack fail"); + goto exit; + } + +#ifdef CONFIG_OPENTHREAD_MTD_SED + err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SleepyEndDevice); +#elif CONFIG_OPENTHREAD_MTD + err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice); +#else + err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router); +#endif + if (err != CHIP_NO_ERROR) + { + LOG_ERR("SetThreadDeviceType fail"); + goto exit; + } + + err = GetAppTask().StartApp(); + +exit: + LOG_ERR("Exit err %" CHIP_ERROR_FORMAT, err.Format()); + return (err == CHIP_NO_ERROR) ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/examples/bridge-app/telink/third_party/connectedhomeip b/examples/bridge-app/telink/third_party/connectedhomeip new file mode 120000 index 00000000000000..c866b86874994d --- /dev/null +++ b/examples/bridge-app/telink/third_party/connectedhomeip @@ -0,0 +1 @@ +../../../.. \ No newline at end of file diff --git a/examples/chef/devices/noip_rootnode_dimmablelight_bCwGYSDpoe.matter b/examples/chef/devices/noip_rootnode_dimmablelight_bCwGYSDpoe.matter index e742712b3cc339..53052304d1a966 100644 --- a/examples/chef/devices/noip_rootnode_dimmablelight_bCwGYSDpoe.matter +++ b/examples/chef/devices/noip_rootnode_dimmablelight_bCwGYSDpoe.matter @@ -1440,15 +1440,15 @@ client cluster OccupancySensing = 1030 { readonly attribute OccupancyBitmap occupancy = 0; readonly attribute OccupancySensorTypeEnum occupancySensorType = 1; readonly attribute OccupancySensorTypeBitmap occupancySensorTypeBitmap = 2; - attribute access(write: manage) int16u PIROccupiedToUnoccupiedDelay = 16; - attribute access(write: manage) int16u PIRUnoccupiedToOccupiedDelay = 17; - attribute access(write: manage) int8u PIRUnoccupiedToOccupiedThreshold = 18; - attribute access(write: manage) int16u ultrasonicOccupiedToUnoccupiedDelay = 32; - attribute access(write: manage) int16u ultrasonicUnoccupiedToOccupiedDelay = 33; - attribute access(write: manage) int8u ultrasonicUnoccupiedToOccupiedThreshold = 34; - attribute access(write: manage) int16u physicalContactOccupiedToUnoccupiedDelay = 48; - attribute access(write: manage) int16u physicalContactUnoccupiedToOccupiedDelay = 49; - attribute access(write: manage) int8u physicalContactUnoccupiedToOccupiedThreshold = 50; + attribute access(write: manage) optional int16u PIROccupiedToUnoccupiedDelay = 16; + attribute access(write: manage) optional int16u PIRUnoccupiedToOccupiedDelay = 17; + attribute access(write: manage) optional int8u PIRUnoccupiedToOccupiedThreshold = 18; + attribute access(write: manage) optional int16u ultrasonicOccupiedToUnoccupiedDelay = 32; + attribute access(write: manage) optional int16u ultrasonicUnoccupiedToOccupiedDelay = 33; + attribute access(write: manage) optional int8u ultrasonicUnoccupiedToOccupiedThreshold = 34; + attribute access(write: manage) optional int16u physicalContactOccupiedToUnoccupiedDelay = 48; + attribute access(write: manage) optional int16u physicalContactUnoccupiedToOccupiedDelay = 49; + attribute access(write: manage) optional int8u physicalContactUnoccupiedToOccupiedThreshold = 50; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; diff --git a/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.matter b/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.matter index cf95bc39d39043..73d480c465be44 100644 --- a/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.matter +++ b/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.matter @@ -1304,15 +1304,15 @@ client cluster OccupancySensing = 1030 { readonly attribute OccupancyBitmap occupancy = 0; readonly attribute OccupancySensorTypeEnum occupancySensorType = 1; readonly attribute OccupancySensorTypeBitmap occupancySensorTypeBitmap = 2; - attribute access(write: manage) int16u PIROccupiedToUnoccupiedDelay = 16; - attribute access(write: manage) int16u PIRUnoccupiedToOccupiedDelay = 17; - attribute access(write: manage) int8u PIRUnoccupiedToOccupiedThreshold = 18; - attribute access(write: manage) int16u ultrasonicOccupiedToUnoccupiedDelay = 32; - attribute access(write: manage) int16u ultrasonicUnoccupiedToOccupiedDelay = 33; - attribute access(write: manage) int8u ultrasonicUnoccupiedToOccupiedThreshold = 34; - attribute access(write: manage) int16u physicalContactOccupiedToUnoccupiedDelay = 48; - attribute access(write: manage) int16u physicalContactUnoccupiedToOccupiedDelay = 49; - attribute access(write: manage) int8u physicalContactUnoccupiedToOccupiedThreshold = 50; + attribute access(write: manage) optional int16u PIROccupiedToUnoccupiedDelay = 16; + attribute access(write: manage) optional int16u PIRUnoccupiedToOccupiedDelay = 17; + attribute access(write: manage) optional int8u PIRUnoccupiedToOccupiedThreshold = 18; + attribute access(write: manage) optional int16u ultrasonicOccupiedToUnoccupiedDelay = 32; + attribute access(write: manage) optional int16u ultrasonicUnoccupiedToOccupiedDelay = 33; + attribute access(write: manage) optional int8u ultrasonicUnoccupiedToOccupiedThreshold = 34; + attribute access(write: manage) optional int16u physicalContactOccupiedToUnoccupiedDelay = 48; + attribute access(write: manage) optional int16u physicalContactUnoccupiedToOccupiedDelay = 49; + attribute access(write: manage) optional int8u physicalContactUnoccupiedToOccupiedThreshold = 50; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; diff --git a/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter b/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter index 8ffe51f5faa9dc..4a768a2adeeb62 100644 --- a/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter +++ b/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter @@ -1342,54 +1342,54 @@ client cluster Thermostat = 513 { } readonly attribute nullable int16s localTemperature = 0; - readonly attribute nullable int16s outdoorTemperature = 1; - readonly attribute bitmap8 occupancy = 2; - readonly attribute int16s absMinHeatSetpointLimit = 3; - readonly attribute int16s absMaxHeatSetpointLimit = 4; - readonly attribute int16s absMinCoolSetpointLimit = 5; - readonly attribute int16s absMaxCoolSetpointLimit = 6; - readonly attribute int8u PICoolingDemand = 7; - readonly attribute int8u PIHeatingDemand = 8; - attribute access(write: manage) bitmap8 HVACSystemTypeConfiguration = 9; - attribute access(write: manage) int8s localTemperatureCalibration = 16; - attribute int16s occupiedCoolingSetpoint = 17; - attribute int16s occupiedHeatingSetpoint = 18; - attribute int16s unoccupiedCoolingSetpoint = 19; - attribute int16s unoccupiedHeatingSetpoint = 20; - attribute access(write: manage) int16s minHeatSetpointLimit = 21; - attribute access(write: manage) int16s maxHeatSetpointLimit = 22; - attribute access(write: manage) int16s minCoolSetpointLimit = 23; - attribute access(write: manage) int16s maxCoolSetpointLimit = 24; - attribute access(write: manage) int8s minSetpointDeadBand = 25; - attribute access(write: manage) bitmap8 remoteSensing = 26; + readonly attribute optional nullable int16s outdoorTemperature = 1; + readonly attribute optional bitmap8 occupancy = 2; + readonly attribute optional int16s absMinHeatSetpointLimit = 3; + readonly attribute optional int16s absMaxHeatSetpointLimit = 4; + readonly attribute optional int16s absMinCoolSetpointLimit = 5; + readonly attribute optional int16s absMaxCoolSetpointLimit = 6; + readonly attribute optional int8u PICoolingDemand = 7; + readonly attribute optional int8u PIHeatingDemand = 8; + attribute access(write: manage) optional bitmap8 HVACSystemTypeConfiguration = 9; + attribute access(write: manage) optional int8s localTemperatureCalibration = 16; + attribute optional int16s occupiedCoolingSetpoint = 17; + attribute optional int16s occupiedHeatingSetpoint = 18; + attribute optional int16s unoccupiedCoolingSetpoint = 19; + attribute optional int16s unoccupiedHeatingSetpoint = 20; + attribute access(write: manage) optional int16s minHeatSetpointLimit = 21; + attribute access(write: manage) optional int16s maxHeatSetpointLimit = 22; + attribute access(write: manage) optional int16s minCoolSetpointLimit = 23; + attribute access(write: manage) optional int16s maxCoolSetpointLimit = 24; + attribute access(write: manage) optional int8s minSetpointDeadBand = 25; + attribute access(write: manage) optional bitmap8 remoteSensing = 26; attribute access(write: manage) ThermostatControlSequence controlSequenceOfOperation = 27; attribute access(write: manage) enum8 systemMode = 28; - readonly attribute enum8 thermostatRunningMode = 30; - readonly attribute enum8 startOfWeek = 32; - readonly attribute int8u numberOfWeeklyTransitions = 33; - readonly attribute int8u numberOfDailyTransitions = 34; - attribute access(write: manage) enum8 temperatureSetpointHold = 35; - attribute access(write: manage) nullable int16u temperatureSetpointHoldDuration = 36; - attribute access(write: manage) bitmap8 thermostatProgrammingOperationMode = 37; - readonly attribute bitmap16 thermostatRunningState = 41; - readonly attribute enum8 setpointChangeSource = 48; - readonly attribute nullable int16s setpointChangeAmount = 49; - readonly attribute epoch_s setpointChangeSourceTimestamp = 50; - attribute access(write: manage) nullable int8u occupiedSetback = 52; - readonly attribute nullable int8u occupiedSetbackMin = 53; - readonly attribute nullable int8u occupiedSetbackMax = 54; - attribute access(write: manage) nullable int8u unoccupiedSetback = 55; - readonly attribute nullable int8u unoccupiedSetbackMin = 56; - readonly attribute nullable int8u unoccupiedSetbackMax = 57; - attribute access(write: manage) int8u emergencyHeatDelta = 58; - attribute access(write: manage) enum8 ACType = 64; - attribute access(write: manage) int16u ACCapacity = 65; - attribute access(write: manage) enum8 ACRefrigerantType = 66; - attribute access(write: manage) enum8 ACCompressorType = 67; - attribute access(write: manage) bitmap32 ACErrorCode = 68; - attribute access(write: manage) enum8 ACLouverPosition = 69; - readonly attribute nullable int16s ACCoilTemperature = 70; - attribute access(write: manage) enum8 ACCapacityformat = 71; + readonly attribute optional enum8 thermostatRunningMode = 30; + readonly attribute optional enum8 startOfWeek = 32; + readonly attribute optional int8u numberOfWeeklyTransitions = 33; + readonly attribute optional int8u numberOfDailyTransitions = 34; + attribute access(write: manage) optional enum8 temperatureSetpointHold = 35; + attribute access(write: manage) optional nullable int16u temperatureSetpointHoldDuration = 36; + attribute access(write: manage) optional bitmap8 thermostatProgrammingOperationMode = 37; + readonly attribute optional bitmap16 thermostatRunningState = 41; + readonly attribute optional enum8 setpointChangeSource = 48; + readonly attribute optional nullable int16s setpointChangeAmount = 49; + readonly attribute optional epoch_s setpointChangeSourceTimestamp = 50; + attribute access(write: manage) optional nullable int8u occupiedSetback = 52; + readonly attribute optional nullable int8u occupiedSetbackMin = 53; + readonly attribute optional nullable int8u occupiedSetbackMax = 54; + attribute access(write: manage) optional nullable int8u unoccupiedSetback = 55; + readonly attribute optional nullable int8u unoccupiedSetbackMin = 56; + readonly attribute optional nullable int8u unoccupiedSetbackMax = 57; + attribute access(write: manage) optional int8u emergencyHeatDelta = 58; + attribute access(write: manage) optional enum8 ACType = 64; + attribute access(write: manage) optional int16u ACCapacity = 65; + attribute access(write: manage) optional enum8 ACRefrigerantType = 66; + attribute access(write: manage) optional enum8 ACCompressorType = 67; + attribute access(write: manage) optional bitmap32 ACErrorCode = 68; + attribute access(write: manage) optional enum8 ACLouverPosition = 69; + readonly attribute optional nullable int16s ACCoilTemperature = 70; + attribute access(write: manage) optional enum8 ACCapacityformat = 71; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; diff --git a/examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.matter b/examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.matter index 241092e2f71717..f863037c5acdbc 100644 --- a/examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.matter +++ b/examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.matter @@ -138,10 +138,10 @@ client cluster OnOff = 6 { } 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 optional boolean globalSceneControl = 16384; + attribute optional int16u onTime = 16385; + attribute optional int16u offWaitTime = 16386; + attribute access(write: manage) optional nullable OnOffStartUpOnOff startUpOnOff = 16387; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; diff --git a/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter b/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter index 9866cd0f31401a..ed59c723066774 100644 --- a/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter +++ b/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter @@ -1283,13 +1283,13 @@ client cluster FanControl = 514 { attribute FanModeSequenceType fanModeSequence = 1; attribute nullable int8u percentSetting = 2; readonly attribute int8u percentCurrent = 3; - readonly attribute int8u speedMax = 4; - attribute nullable int8u speedSetting = 5; - readonly attribute int8u speedCurrent = 6; - readonly attribute bitmap8 rockSupport = 7; - attribute bitmap8 rockSetting = 8; - readonly attribute bitmap8 windSupport = 9; - attribute bitmap8 windSetting = 10; + readonly attribute optional int8u speedMax = 4; + attribute optional nullable int8u speedSetting = 5; + readonly attribute optional int8u speedCurrent = 6; + readonly attribute optional bitmap8 rockSupport = 7; + attribute optional bitmap8 rockSetting = 8; + readonly attribute optional bitmap8 windSupport = 9; + attribute optional bitmap8 windSetting = 10; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -1315,7 +1315,7 @@ client cluster TemperatureMeasurement = 1026 { readonly attribute nullable int16s measuredValue = 0; readonly attribute nullable int16s minMeasuredValue = 1; readonly attribute nullable int16s maxMeasuredValue = 2; - readonly attribute int16u tolerance = 3; + readonly attribute optional int16u tolerance = 3; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -1329,7 +1329,7 @@ client cluster RelativeHumidityMeasurement = 1029 { readonly attribute nullable int16u measuredValue = 0; readonly attribute nullable int16u minMeasuredValue = 1; readonly attribute nullable int16u maxMeasuredValue = 2; - readonly attribute int16u tolerance = 3; + readonly attribute optional int16u tolerance = 3; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -1360,15 +1360,15 @@ client cluster OccupancySensing = 1030 { readonly attribute OccupancyBitmap occupancy = 0; readonly attribute OccupancySensorTypeEnum occupancySensorType = 1; readonly attribute OccupancySensorTypeBitmap occupancySensorTypeBitmap = 2; - attribute access(write: manage) int16u PIROccupiedToUnoccupiedDelay = 16; - attribute access(write: manage) int16u PIRUnoccupiedToOccupiedDelay = 17; - attribute access(write: manage) int8u PIRUnoccupiedToOccupiedThreshold = 18; - attribute access(write: manage) int16u ultrasonicOccupiedToUnoccupiedDelay = 32; - attribute access(write: manage) int16u ultrasonicUnoccupiedToOccupiedDelay = 33; - attribute access(write: manage) int8u ultrasonicUnoccupiedToOccupiedThreshold = 34; - attribute access(write: manage) int16u physicalContactOccupiedToUnoccupiedDelay = 48; - attribute access(write: manage) int16u physicalContactUnoccupiedToOccupiedDelay = 49; - attribute access(write: manage) int8u physicalContactUnoccupiedToOccupiedThreshold = 50; + attribute access(write: manage) optional int16u PIROccupiedToUnoccupiedDelay = 16; + attribute access(write: manage) optional int16u PIRUnoccupiedToOccupiedDelay = 17; + attribute access(write: manage) optional int8u PIRUnoccupiedToOccupiedThreshold = 18; + attribute access(write: manage) optional int16u ultrasonicOccupiedToUnoccupiedDelay = 32; + attribute access(write: manage) optional int16u ultrasonicUnoccupiedToOccupiedDelay = 33; + attribute access(write: manage) optional int8u ultrasonicUnoccupiedToOccupiedThreshold = 34; + attribute access(write: manage) optional int16u physicalContactOccupiedToUnoccupiedDelay = 48; + attribute access(write: manage) optional int16u physicalContactUnoccupiedToOccupiedDelay = 49; + attribute access(write: manage) optional int8u physicalContactUnoccupiedToOccupiedThreshold = 50; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; diff --git a/examples/chef/esp32/main/CMakeLists.txt b/examples/chef/esp32/main/CMakeLists.txt index 0099a8547c78c2..e1940af232fd8d 100644 --- a/examples/chef/esp32/main/CMakeLists.txt +++ b/examples/chef/esp32/main/CMakeLists.txt @@ -209,6 +209,7 @@ target_link_libraries(${COMPONENT_LIB} PUBLIC target_link_options(${COMPONENT_LIB} PUBLIC "-T${PIGWEED_ROOT}/pw_tokenizer/pw_tokenizer_linker_sections.ld" + "-L${PIGWEED_ROOT}/pw_tokenizer" ) target_compile_options(${COMPONENT_LIB} PRIVATE diff --git a/examples/chip-tool/BUILD.gn b/examples/chip-tool/BUILD.gn index 8c70dcb8eedb31..85f1c56e2d8266 100644 --- a/examples/chip-tool/BUILD.gn +++ b/examples/chip-tool/BUILD.gn @@ -48,6 +48,8 @@ static_library("chip-tool-utils") { sources = [ "${chip_root}/src/app/tests/suites/include/ConstraintsChecker.h", "${chip_root}/src/app/tests/suites/include/ValueChecker.h", + "${chip_root}/src/controller/ExamplePersistentStorage.cpp", + "${chip_root}/src/controller/ExamplePersistentStorage.h", "${chip_root}/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp", "${chip_root}/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp", "commands/clusters/ModelCommand.cpp", @@ -68,17 +70,11 @@ static_library("chip-tool-utils") { "commands/discover/DiscoverCommand.cpp", "commands/discover/DiscoverCommissionablesCommand.cpp", "commands/discover/DiscoverCommissionersCommand.cpp", - "commands/pairing/PairingCommand.cpp", - - # TODO - enable CommissionedListCommand once DNS Cache is implemented - # "commands/pairing/CommissionedListCommand.cpp", - # "commands/pairing/CommissionedListCommand.h", - "${chip_root}/src/controller/ExamplePersistentStorage.cpp", - "${chip_root}/src/controller/ExamplePersistentStorage.h", "commands/pairing/CloseSessionCommand.cpp", "commands/pairing/CloseSessionCommand.h", "commands/pairing/OpenCommissioningWindowCommand.cpp", "commands/pairing/OpenCommissioningWindowCommand.h", + "commands/pairing/PairingCommand.cpp", "commands/pairing/ToTLVCert.cpp", "commands/payload/AdditionalDataParseCommand.cpp", "commands/payload/SetupPayloadGenerateCommand.cpp", diff --git a/examples/chip-tool/commands/pairing/Commands.h b/examples/chip-tool/commands/pairing/Commands.h index 9fafed65524a3a..4f4f445d929a8c 100644 --- a/examples/chip-tool/commands/pairing/Commands.h +++ b/examples/chip-tool/commands/pairing/Commands.h @@ -20,7 +20,6 @@ #include "commands/common/Commands.h" #include "commands/pairing/CloseSessionCommand.h" -#include "commands/pairing/CommissionedListCommand.h" #include "commands/pairing/GetCommissionerNodeIdCommand.h" #include "commands/pairing/GetCommissionerRootCertificateCommand.h" #include "commands/pairing/IssueNOCChainCommand.h" diff --git a/examples/chip-tool/commands/pairing/CommissionedListCommand.cpp b/examples/chip-tool/commands/pairing/CommissionedListCommand.cpp deleted file mode 100644 index ef30ef4978819f..00000000000000 --- a/examples/chip-tool/commands/pairing/CommissionedListCommand.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2021 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 "CommissionedListCommand.h" - -#include -#include -#include -#include - -CHIP_ERROR CommissionedListCommand::Run() -{ - ReturnLogErrorOnFailure(mStorage.Init()); - return PrintInformation(); -} - -CHIP_ERROR CommissionedListCommand::PrintInformation() -{ - uint64_t pairedNodesIds[chip::Controller::kNumMaxPairedDevices]; - uint16_t pairedNodesIdsSize = sizeof(pairedNodesIds); - memset(pairedNodesIds, 0, pairedNodesIdsSize); - - // TODO: Get the list of paired node IDs. chip-tool needs to store that as - // devices get paired. - uint16_t pairedDevicesCount = 0; - while (pairedNodesIds[pairedDevicesCount] != 0x0 && pairedDevicesCount < chip::Controller::kNumMaxPairedDevices) - { - pairedDevicesCount++; - } - - if (pairedDevicesCount == 0) - { - ChipLogProgress(chipTool, "No paired devices."); - } - else - { - fprintf(stdout, "NOTES: Only the devices locally commissioned with chip-tool are displayed.\n"); - fprintf(stdout, "+---------------------------------------------------------------------------------------------+\n"); - fprintf(stdout, "| NodeId | Address | Port | Interface |\n"); - fprintf(stdout, "+---------------------------------------------------------------------------------------------+\n"); - for (uint16_t i = 0; i < pairedDevicesCount; i++) - { - ReturnLogErrorOnFailure(PrintDeviceInformation(pairedNodesIds[i])); - } - fprintf(stdout, "+---------------------------------------------------------------------------------------------+\n"); - } - - return CHIP_NO_ERROR; -} - -CHIP_ERROR CommissionedListCommand::PrintDeviceInformation(chip::NodeId deviceId) -{ - // TODO: Controller::SerializedDevice and Controller::SerializableDevice are - // gone. Need to figure out what chip-tool should actually store/retrieve - // here. - chip::Controller::SerializedDevice deviceInfo; - uint16_t size = sizeof(deviceInfo.inner); - - chip::Controller::SerializableDevice serializable; - constexpr size_t maxlen = BASE64_ENCODED_LEN(sizeof(serializable)); - const size_t len = strnlen(chip::Uint8::to_const_char(&deviceInfo.inner[0]), maxlen); - - VerifyOrReturnError(len < sizeof(chip::Controller::SerializedDevice), CHIP_ERROR_INVALID_ARGUMENT); - VerifyOrReturnError(chip::CanCastTo(len), CHIP_ERROR_INVALID_ARGUMENT); - - CHIP_ZERO_AT(serializable); - const uint16_t deserializedLen = chip::Base64Decode(chip::Uint8::to_const_char(deviceInfo.inner), static_cast(len), - chip::Uint8::to_uchar(reinterpret_cast(&serializable))); - - VerifyOrReturnError(deserializedLen > 0, CHIP_ERROR_INVALID_ARGUMENT); - VerifyOrReturnError(deserializedLen <= sizeof(serializable), CHIP_ERROR_INVALID_ARGUMENT); - - const uint16_t port = chip::Encoding::LittleEndian::HostSwap16(serializable.mDevicePort); - fprintf(stderr, "| 0x%-16" PRIx64 " | %-45s | %-5u| %-15s |\n", deviceId, serializable.mDeviceAddr, port, - serializable.mInterfaceName); - - return CHIP_NO_ERROR; -} diff --git a/examples/chip-tool/commands/pairing/CommissionedListCommand.h b/examples/chip-tool/commands/pairing/CommissionedListCommand.h deleted file mode 100644 index ca63c553c409bd..00000000000000 --- a/examples/chip-tool/commands/pairing/CommissionedListCommand.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2021 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/Command.h" -#include - -class CommissionedListCommand : public Command -{ -public: - CommissionedListCommand() : Command("list") {} - CHIP_ERROR Run() override; - -private: - CHIP_ERROR PrintInformation(); - CHIP_ERROR PrintDeviceInformation(chip::NodeId deviceId); - - PersistentStorage mStorage; -}; diff --git a/examples/chip-tool/templates/logging/DataModelLogger-src.zapt b/examples/chip-tool/templates/logging/DataModelLogger-src.zapt index 64f701e140b43d..d710ff53735f6c 100644 --- a/examples/chip-tool/templates/logging/DataModelLogger-src.zapt +++ b/examples/chip-tool/templates/logging/DataModelLogger-src.zapt @@ -159,7 +159,7 @@ CHIP_ERROR DataModelLogger::LogEvent(const chip::app::EventHeader & header, chip switch (header.mPath.mClusterId) { {{#all_user_clusters side='client'}} -{{#chip_server_cluster_events}} +{{#zcl_events}} {{#first}} case {{asUpperCamelCase parent.name}}::Id: { @@ -177,7 +177,7 @@ CHIP_ERROR DataModelLogger::LogEvent(const chip::app::EventHeader & header, chip break; } {{/last}} -{{/chip_server_cluster_events}} +{{/zcl_events}} {{/all_user_clusters}} default: break; diff --git a/examples/darwin-framework-tool/commands/pairing/GetCommissionerNodeIdCommand.mm b/examples/darwin-framework-tool/commands/pairing/GetCommissionerNodeIdCommand.mm index 115f7b0821c048..1dd852bd4d0817 100644 --- a/examples/darwin-framework-tool/commands/pairing/GetCommissionerNodeIdCommand.mm +++ b/examples/darwin-framework-tool/commands/pairing/GetCommissionerNodeIdCommand.mm @@ -25,8 +25,8 @@ auto * controller = CurrentCommissioner(); VerifyOrReturnError(nil != controller, CHIP_ERROR_INCORRECT_STATE); - auto id = [controller.controllerNodeId unsignedLongLongValue]; - ChipLogProgress(chipTool, "Commissioner Node Id 0x" ChipLogFormatX64, ChipLogValueX64(id)); + ChipLogProgress( + chipTool, "Commissioner Node Id 0x" ChipLogFormatX64, ChipLogValueX64(controller.controllerNodeId.unsignedLongLongValue)); SetCommandExitStatus(CHIP_NO_ERROR); return CHIP_NO_ERROR; diff --git a/examples/darwin-framework-tool/commands/payload/SetupPayloadParseCommand.mm b/examples/darwin-framework-tool/commands/payload/SetupPayloadParseCommand.mm index d7ea6f981e7302..d077115eaa7453 100644 --- a/examples/darwin-framework-tool/commands/payload/SetupPayloadParseCommand.mm +++ b/examples/darwin-framework-tool/commands/payload/SetupPayloadParseCommand.mm @@ -24,8 +24,6 @@ namespace { -#if CHIP_PROGRESS_LOGGING - NSString * CustomFlowString(MTRCommissioningFlow flow) { switch (flow) { @@ -42,8 +40,6 @@ return @"???"; } -#endif // CHIP_PROGRESS_LOGGING - } // namespace void SetupPayloadParseCommand::LogNSError(const char * logString, NSError * error) diff --git a/examples/dynamic-bridge-app/bridge-common/bridge-app.matter b/examples/dynamic-bridge-app/bridge-common/bridge-app.matter index 01a6e33e868002..6413f0f34d914b 100644 --- a/examples/dynamic-bridge-app/bridge-common/bridge-app.matter +++ b/examples/dynamic-bridge-app/bridge-common/bridge-app.matter @@ -298,7 +298,7 @@ client cluster AccessControl = 31 { } attribute access(read: administer, write: administer) AccessControlEntryStruct acl[] = 0; - attribute access(read: administer, write: administer) AccessControlExtensionStruct extension[] = 1; + attribute access(read: administer, write: administer) optional AccessControlExtensionStruct extension[] = 1; readonly attribute int16u subjectsPerAccessControlEntry = 2; readonly attribute int16u targetsPerAccessControlEntry = 3; readonly attribute int16u accessControlEntriesPerFabric = 4; diff --git a/examples/light-switch-app/ameba/main/CHIPDeviceManager.cpp b/examples/light-switch-app/ameba/main/CHIPDeviceManager.cpp index 4c1b55fbddb9fc..d0db78341501a5 100644 --- a/examples/light-switch-app/ameba/main/CHIPDeviceManager.cpp +++ b/examples/light-switch-app/ameba/main/CHIPDeviceManager.cpp @@ -28,11 +28,15 @@ #include "CHIPDeviceManager.h" #include #include +#include +#include +#include #include #include #include using namespace ::chip; +using namespace ::chip::Credentials; namespace chip { @@ -40,6 +44,8 @@ namespace DeviceManager { using namespace ::chip::DeviceLayer; +chip::DeviceLayer::FactoryDataProvider mFactoryDataProvider; + void CHIPDeviceManager::CommonDeviceEventHandler(const ChipDeviceEvent * event, intptr_t arg) { CHIPDeviceManagerCallbacks * cb = reinterpret_cast(arg); @@ -61,6 +67,19 @@ CHIP_ERROR CHIPDeviceManager::Init(CHIPDeviceManagerCallbacks * cb) err = PlatformMgr().InitChipStack(); SuccessOrExit(err); + err = mFactoryDataProvider.Init(); + if (err == CHIP_NO_ERROR) + { + SetCommissionableDataProvider(&mFactoryDataProvider); + SetDeviceAttestationCredentialsProvider(&mFactoryDataProvider); + SetDeviceInstanceInfoProvider(&mFactoryDataProvider); + } + else + { + ChipLogProgress(DeviceLayer, "Using example DAC provider"); + SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); + } + if (CONFIG_NETWORK_LAYER_BLE) { ConnectivityMgr().SetBLEAdvertisingEnabled(true); diff --git a/examples/light-switch-app/ameba/main/DeviceCallbacks.cpp b/examples/light-switch-app/ameba/main/DeviceCallbacks.cpp index cc855031952eda..b5fbaf1ece36c4 100644 --- a/examples/light-switch-app/ameba/main/DeviceCallbacks.cpp +++ b/examples/light-switch-app/ameba/main/DeviceCallbacks.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -103,6 +104,7 @@ void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_ case DeviceEventType::kCommissioningComplete: ChipLogProgress(DeviceLayer, "Commissioning Complete"); + chip::DeviceLayer::Internal::AmebaUtils::SetCurrentProvisionedNetwork(); break; } } @@ -142,8 +144,9 @@ void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event chip::app::DnssdServer::Instance().StartServer(); #if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR // Init OTA requestor only when we have gotten IPv6 address - if (OTAInitializer::Instance().CheckInit()) + if (!OTAInitializer::Instance().CheckInit()) { + ChipLogProgress(DeviceLayer, "Initializing OTA"); chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds32(kInitOTARequestorDelaySec), InitOTARequestorHandler, nullptr); } diff --git a/examples/light-switch-app/ameba/main/chipinterface.cpp b/examples/light-switch-app/ameba/main/chipinterface.cpp index 85e4c401514d99..7bc5c3efae4416 100644 --- a/examples/light-switch-app/ameba/main/chipinterface.cpp +++ b/examples/light-switch-app/ameba/main/chipinterface.cpp @@ -31,11 +31,8 @@ #include #include #include -#include -#include #include #include -#include #include #include #include @@ -51,7 +48,6 @@ #endif using namespace ::chip; -using namespace ::chip::Credentials; using namespace ::chip::DeviceManager; using namespace ::chip::DeviceLayer; using namespace ::chip::System; @@ -97,7 +93,6 @@ Identify gIdentify1 = { static DeviceCallbacks EchoCallbacks; chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; -chip::DeviceLayer::FactoryDataProvider mFactoryDataProvider; static void InitServer(intptr_t context) { @@ -132,10 +127,6 @@ extern "C" void ChipTest(void) initPref(); - mFactoryDataProvider.Init(); - SetCommissionableDataProvider(&mFactoryDataProvider); - SetDeviceAttestationCredentialsProvider(&mFactoryDataProvider); - CHIPDeviceManager & deviceMgr = CHIPDeviceManager::GetInstance(); err = deviceMgr.Init(&EchoCallbacks); @@ -148,10 +139,6 @@ extern "C" void ChipTest(void) ChipLogProgress(DeviceLayer, "DeviceManagerInit() - OK\r\n"); } - // Set DeviceInstanceInfoProvider after CHIPDeviceManager init - // CHIPDeviceManager init will set GenericDeviceInsanceInfoProvider first - SetDeviceInstanceInfoProvider(&mFactoryDataProvider); - chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, 0); statusLED1.Init(STATUS_LED_GPIO_NUM); 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 f34688d755e63b..2a8f9eeb4749f2 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 @@ -190,7 +190,7 @@ client cluster Scenes = 5 { readonly attribute group_id currentGroup = 2; readonly attribute boolean sceneValid = 3; readonly attribute bitmap8 nameSupport = 4; - readonly attribute nullable node_id lastConfiguredBy = 5; + readonly attribute optional nullable node_id lastConfiguredBy = 5; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -370,10 +370,10 @@ client cluster OnOff = 6 { } 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 optional boolean globalSceneControl = 16384; + attribute optional int16u onTime = 16385; + attribute optional int16u offWaitTime = 16386; + attribute access(write: manage) optional nullable OnOffStartUpOnOff startUpOnOff = 16387; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -1798,58 +1798,58 @@ client cluster ColorControl = 768 { kUpdateStartHue = 0x8; } - readonly attribute int8u currentHue = 0; - readonly attribute int8u currentSaturation = 1; - readonly attribute int16u remainingTime = 2; - readonly attribute int16u currentX = 3; - readonly attribute int16u currentY = 4; - readonly attribute enum8 driftCompensation = 5; - readonly attribute char_string<254> compensationText = 6; - readonly attribute int16u colorTemperatureMireds = 7; + readonly attribute optional int8u currentHue = 0; + readonly attribute optional int8u currentSaturation = 1; + readonly attribute optional int16u remainingTime = 2; + readonly attribute optional int16u currentX = 3; + readonly attribute optional int16u currentY = 4; + readonly attribute optional enum8 driftCompensation = 5; + readonly attribute optional char_string<254> compensationText = 6; + readonly attribute optional int16u colorTemperatureMireds = 7; readonly attribute enum8 colorMode = 8; attribute bitmap8 options = 15; readonly attribute nullable int8u numberOfPrimaries = 16; - readonly attribute int16u primary1X = 17; - readonly attribute int16u primary1Y = 18; - readonly attribute nullable int8u primary1Intensity = 19; - readonly attribute int16u primary2X = 21; - readonly attribute int16u primary2Y = 22; - readonly attribute nullable int8u primary2Intensity = 23; - readonly attribute int16u primary3X = 25; - readonly attribute int16u primary3Y = 26; - readonly attribute nullable int8u primary3Intensity = 27; - readonly attribute int16u primary4X = 32; - readonly attribute int16u primary4Y = 33; - readonly attribute nullable int8u primary4Intensity = 34; - readonly attribute int16u primary5X = 36; - readonly attribute int16u primary5Y = 37; - readonly attribute nullable int8u primary5Intensity = 38; - readonly attribute int16u primary6X = 40; - readonly attribute int16u primary6Y = 41; - readonly attribute nullable int8u primary6Intensity = 42; - attribute access(write: manage) int16u whitePointX = 48; - attribute access(write: manage) int16u whitePointY = 49; - attribute access(write: manage) int16u colorPointRX = 50; - attribute access(write: manage) int16u colorPointRY = 51; - attribute access(write: manage) nullable int8u colorPointRIntensity = 52; - attribute access(write: manage) int16u colorPointGX = 54; - attribute access(write: manage) int16u colorPointGY = 55; - attribute access(write: manage) nullable int8u colorPointGIntensity = 56; - attribute access(write: manage) int16u colorPointBX = 58; - attribute access(write: manage) int16u colorPointBY = 59; - attribute access(write: manage) nullable int8u colorPointBIntensity = 60; - readonly attribute int16u enhancedCurrentHue = 16384; + readonly attribute optional int16u primary1X = 17; + readonly attribute optional int16u primary1Y = 18; + readonly attribute optional nullable int8u primary1Intensity = 19; + readonly attribute optional int16u primary2X = 21; + readonly attribute optional int16u primary2Y = 22; + readonly attribute optional nullable int8u primary2Intensity = 23; + readonly attribute optional int16u primary3X = 25; + readonly attribute optional int16u primary3Y = 26; + readonly attribute optional nullable int8u primary3Intensity = 27; + readonly attribute optional int16u primary4X = 32; + readonly attribute optional int16u primary4Y = 33; + readonly attribute optional nullable int8u primary4Intensity = 34; + readonly attribute optional int16u primary5X = 36; + readonly attribute optional int16u primary5Y = 37; + readonly attribute optional nullable int8u primary5Intensity = 38; + readonly attribute optional int16u primary6X = 40; + readonly attribute optional int16u primary6Y = 41; + readonly attribute optional nullable int8u primary6Intensity = 42; + attribute access(write: manage) optional int16u whitePointX = 48; + attribute access(write: manage) optional int16u whitePointY = 49; + attribute access(write: manage) optional int16u colorPointRX = 50; + attribute access(write: manage) optional int16u colorPointRY = 51; + attribute access(write: manage) optional nullable int8u colorPointRIntensity = 52; + attribute access(write: manage) optional int16u colorPointGX = 54; + attribute access(write: manage) optional int16u colorPointGY = 55; + attribute access(write: manage) optional nullable int8u colorPointGIntensity = 56; + attribute access(write: manage) optional int16u colorPointBX = 58; + attribute access(write: manage) optional int16u colorPointBY = 59; + attribute access(write: manage) optional nullable int8u colorPointBIntensity = 60; + readonly attribute optional int16u enhancedCurrentHue = 16384; readonly attribute enum8 enhancedColorMode = 16385; - readonly attribute int8u colorLoopActive = 16386; - readonly attribute int8u colorLoopDirection = 16387; - readonly attribute int16u colorLoopTime = 16388; - readonly attribute int16u colorLoopStartEnhancedHue = 16389; - readonly attribute int16u colorLoopStoredEnhancedHue = 16390; + readonly attribute optional int8u colorLoopActive = 16386; + readonly attribute optional int8u colorLoopDirection = 16387; + readonly attribute optional int16u colorLoopTime = 16388; + readonly attribute optional int16u colorLoopStartEnhancedHue = 16389; + readonly attribute optional int16u colorLoopStoredEnhancedHue = 16390; readonly attribute bitmap16 colorCapabilities = 16394; - readonly attribute int16u colorTempPhysicalMinMireds = 16395; - readonly attribute int16u colorTempPhysicalMaxMireds = 16396; - readonly attribute int16u coupleColorTempToLevelMinMireds = 16397; - attribute access(write: manage) nullable int16u startUpColorTemperatureMireds = 16400; + readonly attribute optional int16u colorTempPhysicalMinMireds = 16395; + readonly attribute optional int16u colorTempPhysicalMaxMireds = 16396; + readonly attribute optional int16u coupleColorTempToLevelMinMireds = 16397; + attribute access(write: manage) optional nullable int16u startUpColorTemperatureMireds = 16400; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; diff --git a/examples/light-switch-app/silabs/SiWx917/README.md b/examples/light-switch-app/silabs/SiWx917/README.md index 476eebae403ae0..60f387b293bd04 100644 --- a/examples/light-switch-app/silabs/SiWx917/README.md +++ b/examples/light-switch-app/silabs/SiWx917/README.md @@ -79,7 +79,7 @@ Silicon Labs platform. * Build the example application: cd ~/connectedhomeip - ./scripts/examples/gn_efr32_example.sh ./examples/light-switch-app/silabs/SiWx917/ ./out/light-switch-app BRD4325B + ./scripts/examples/gn_efr32_example.sh ./examples/light-switch-app/silabs/SiWx917/ ./out/light-switch-app BRD4325B - To delete generated executable, libraries and object files use: diff --git a/examples/light-switch-app/silabs/efr32/README.md b/examples/light-switch-app/silabs/efr32/README.md index 67ec5bcd5cb692..144ad48a17ba1f 100644 --- a/examples/light-switch-app/silabs/efr32/README.md +++ b/examples/light-switch-app/silabs/efr32/README.md @@ -106,7 +106,7 @@ Silicon Labs platform. * Build the example application: cd ~/connectedhomeip - ./scripts/examples/gn_efr32_example.sh ./examples/light-switch-app/silabs/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: diff --git a/examples/lighting-app/ameba/main/CHIPDeviceManager.cpp b/examples/lighting-app/ameba/main/CHIPDeviceManager.cpp index 98c148f505ed31..01931850922b4c 100644 --- a/examples/lighting-app/ameba/main/CHIPDeviceManager.cpp +++ b/examples/lighting-app/ameba/main/CHIPDeviceManager.cpp @@ -26,6 +26,9 @@ #include "CHIPDeviceManager.h" #include +#include +#include +#include #include #include #include @@ -41,6 +44,7 @@ #include using namespace ::chip; +using namespace ::chip::Credentials; namespace chip { @@ -48,6 +52,8 @@ namespace DeviceManager { using namespace ::chip::DeviceLayer; +chip::DeviceLayer::FactoryDataProvider mFactoryDataProvider; + void CHIPDeviceManager::CommonDeviceEventHandler(const ChipDeviceEvent * event, intptr_t arg) { CHIPDeviceManagerCallbacks * cb = reinterpret_cast(arg); @@ -68,6 +74,19 @@ CHIP_ERROR CHIPDeviceManager::Init(CHIPDeviceManagerCallbacks * cb) err = PlatformMgr().InitChipStack(); SuccessOrExit(err); + err = mFactoryDataProvider.Init(); + if (err == CHIP_NO_ERROR) + { + SetCommissionableDataProvider(&mFactoryDataProvider); + SetDeviceAttestationCredentialsProvider(&mFactoryDataProvider); + SetDeviceInstanceInfoProvider(&mFactoryDataProvider); + } + else + { + ChipLogProgress(DeviceLayer, "Using example DAC provider"); + SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); + } + if (CONFIG_NETWORK_LAYER_BLE) { ConnectivityMgr().SetBLEAdvertisingEnabled(true); diff --git a/examples/lighting-app/ameba/main/DeviceCallbacks.cpp b/examples/lighting-app/ameba/main/DeviceCallbacks.cpp index d6fd23d9521451..abc6472d2c72b9 100644 --- a/examples/lighting-app/ameba/main/DeviceCallbacks.cpp +++ b/examples/lighting-app/ameba/main/DeviceCallbacks.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -101,6 +102,7 @@ void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_ case DeviceEventType::kCommissioningComplete: ChipLogProgress(DeviceLayer, "Commissioning Complete"); + chip::DeviceLayer::Internal::AmebaUtils::SetCurrentProvisionedNetwork(); break; } } @@ -122,8 +124,9 @@ void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event chip::app::DnssdServer::Instance().StartServer(); #if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR // Init OTA requestor only when we have gotten IPv6 address - if (OTAInitializer::Instance().CheckInit()) + if (!OTAInitializer::Instance().CheckInit()) { + ChipLogProgress(DeviceLayer, "Initializing OTA"); chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds32(kInitOTARequestorDelaySec), InitOTARequestorHandler, nullptr); } diff --git a/examples/lighting-app/ameba/main/chipinterface.cpp b/examples/lighting-app/ameba/main/chipinterface.cpp index f46fe7ad320557..e9ef017c97861a 100644 --- a/examples/lighting-app/ameba/main/chipinterface.cpp +++ b/examples/lighting-app/ameba/main/chipinterface.cpp @@ -25,8 +25,6 @@ #include #include "chip_porting.h" -#include -#include #include #include @@ -36,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -49,7 +46,6 @@ #endif using namespace ::chip; -using namespace ::chip::Credentials; using namespace ::chip::DeviceManager; using namespace ::chip::DeviceLayer; using namespace ::chip::System; @@ -81,7 +77,6 @@ void NetWorkCommissioningInstInit() static DeviceCallbacks EchoCallbacks; chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; -chip::DeviceLayer::FactoryDataProvider mFactoryDataProvider; void OnIdentifyStart(Identify *) { @@ -148,10 +143,6 @@ extern "C" void ChipTest(void) initPref(); - mFactoryDataProvider.Init(); - SetCommissionableDataProvider(&mFactoryDataProvider); - SetDeviceAttestationCredentialsProvider(&mFactoryDataProvider); - CHIPDeviceManager & deviceMgr = CHIPDeviceManager::GetInstance(); err = deviceMgr.Init(&EchoCallbacks); @@ -164,10 +155,6 @@ extern "C" void ChipTest(void) ChipLogProgress(DeviceLayer, "DeviceManagerInit() - OK\r\n"); } - // Set DeviceInstanceInfoProvider after CHIPDeviceManager init - // CHIPDeviceManager init will set GenericDeviceInsanceInfoProvider first - SetDeviceInstanceInfoProvider(&mFactoryDataProvider); - chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, 0); statusLED1.Init(STATUS_LED_GPIO_NUM); diff --git a/examples/lighting-app/bouffalolab/bl602/CHIPProjectConfig.h b/examples/lighting-app/bouffalolab/bl602/CHIPProjectConfig.h index 16439282d46ad9..18b7923935696a 100644 --- a/examples/lighting-app/bouffalolab/bl602/CHIPProjectConfig.h +++ b/examples/lighting-app/bouffalolab/bl602/CHIPProjectConfig.h @@ -57,19 +57,13 @@ /** * CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID * - * 0x235A: Chip's Vendor Id. - * 0xFFF1: Test vendor */ -//#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0x130D #define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0xFFF1 /** * CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID * - * 0x534B: BL602 lock-app - * TODO: 3R */ -//#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0xF001 #define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8005 /** @@ -140,3 +134,9 @@ #define CHIP_SYSTEM_CRYPTO_HEADER_RESERVE_SIZE 128 #define CHIP_BLE_DEVICE_NAME "MatterLight" + +/** Please contact Bouffalo Lab for how to use factory data provider */ +// #define CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE 1 +// uncomment out the following macro to use factory test data +// when CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE sets to 1 +// #define CONFIG_BOUFFALOLAB_FACTORY_DATA_TEST diff --git a/examples/lighting-app/bouffalolab/data_model/lighting-app-thread.matter b/examples/lighting-app/bouffalolab/data_model/lighting-app-thread.matter index e88b303e7d3c52..f8c8295607ab8f 100644 --- a/examples/lighting-app/bouffalolab/data_model/lighting-app-thread.matter +++ b/examples/lighting-app/bouffalolab/data_model/lighting-app-thread.matter @@ -1169,8 +1169,6 @@ server cluster ThreadNetworkDiagnostics = 53 { readonly attribute attrib_id attributeList[] = 65531; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; - - command ResetCounts(): DefaultSuccess = 0; } /** This cluster exposes interactions with a switch device, for the purpose of using those interactions by other devices. @@ -1557,6 +1555,24 @@ server cluster ColorControl = 768 { readonly attribute enum8 colorMode = 8; attribute bitmap8 options = 15; readonly attribute nullable int8u numberOfPrimaries = 16; + readonly attribute int16u primary1X = 17; + readonly attribute int16u primary1Y = 18; + readonly attribute nullable int8u primary1Intensity = 19; + readonly attribute int16u primary2X = 21; + readonly attribute int16u primary2Y = 22; + readonly attribute nullable int8u primary2Intensity = 23; + readonly attribute int16u primary3X = 25; + readonly attribute int16u primary3Y = 26; + readonly attribute nullable int8u primary3Intensity = 27; + readonly attribute int16u primary4X = 32; + readonly attribute int16u primary4Y = 33; + readonly attribute nullable int8u primary4Intensity = 34; + readonly attribute int16u primary5X = 36; + readonly attribute int16u primary5Y = 37; + readonly attribute nullable int8u primary5Intensity = 38; + readonly attribute int16u primary6X = 40; + readonly attribute int16u primary6Y = 41; + readonly attribute nullable int8u primary6Intensity = 42; readonly attribute int16u enhancedCurrentHue = 16384; readonly attribute enum8 enhancedColorMode = 16385; readonly attribute int8u colorLoopActive = 16386; @@ -2033,7 +2049,7 @@ endpoint 0 { } } endpoint 1 { - device type dimmablelight = 257, version 1; + device type extendedcolorlight = 269, version 1; server cluster Identify { ram attribute identifyTime default = 0x0000; @@ -2096,6 +2112,24 @@ endpoint 1 { ram attribute colorMode default = 0x01; ram attribute options default = 0x00; ram attribute numberOfPrimaries; + ram attribute primary1X; + ram attribute primary1Y; + ram attribute primary1Intensity; + ram attribute primary2X; + ram attribute primary2Y; + ram attribute primary2Intensity; + ram attribute primary3X; + ram attribute primary3Y; + ram attribute primary3Intensity; + ram attribute primary4X; + ram attribute primary4Y; + ram attribute primary4Intensity; + ram attribute primary5X; + ram attribute primary5Y; + ram attribute primary5Intensity; + ram attribute primary6X; + ram attribute primary6Y; + ram attribute primary6Intensity; ram attribute enhancedCurrentHue default = 0x0000; ram attribute enhancedColorMode default = 0x01; ram attribute colorLoopActive default = 0x00; diff --git a/examples/lighting-app/bouffalolab/data_model/lighting-app-thread.zap b/examples/lighting-app/bouffalolab/data_model/lighting-app-thread.zap index 84e31ba4ae3212..3678fd16460206 100644 --- a/examples/lighting-app/bouffalolab/data_model/lighting-app-thread.zap +++ b/examples/lighting-app/bouffalolab/data_model/lighting-app-thread.zap @@ -1,5 +1,5 @@ { - "featureLevel": 92, + "featureLevel": 95, "creator": "zap", "keyValuePairs": [ { @@ -3045,7 +3045,7 @@ "code": 0, "mfgCode": null, "source": "client", - "incoming": 1, + "incoming": 0, "outgoing": 0 } ], @@ -5438,7 +5438,7 @@ ] }, { - "name": "MA-dimmablelight", + "name": "MA-extendedcolorlight", "deviceTypeName": "MA-dimmablelight", "deviceTypeCode": 257, "deviceTypeProfileId": 259, @@ -7471,7 +7471,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7487,7 +7487,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7503,7 +7503,7 @@ "mfgCode": null, "side": "server", "type": "int8u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7519,7 +7519,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7535,7 +7535,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7551,7 +7551,7 @@ "mfgCode": null, "side": "server", "type": "int8u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7567,7 +7567,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7583,7 +7583,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7599,7 +7599,7 @@ "mfgCode": null, "side": "server", "type": "int8u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7615,7 +7615,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7631,7 +7631,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7647,7 +7647,7 @@ "mfgCode": null, "side": "server", "type": "int8u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7663,7 +7663,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7679,7 +7679,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7695,7 +7695,7 @@ "mfgCode": null, "side": "server", "type": "int8u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7711,7 +7711,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7727,7 +7727,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7743,7 +7743,7 @@ "mfgCode": null, "side": "server", "type": "int8u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -8333,13 +8333,14 @@ "deviceIdentifier": 22 }, { - "endpointTypeName": "MA-dimmablelight", + "endpointTypeName": "MA-extendedcolorlight", "endpointTypeIndex": 1, "profileId": 259, "endpointId": 1, "networkId": 0, "endpointVersion": 1, - "deviceIdentifier": 257 + "deviceIdentifier": 269 } - ] -} \ No newline at end of file + ], + "log": [] +} diff --git a/examples/lighting-app/bouffalolab/data_model/lighting-app-wifi.matter b/examples/lighting-app/bouffalolab/data_model/lighting-app-wifi.matter index b200f7dfdafb7b..d06449eb62ecd3 100644 --- a/examples/lighting-app/bouffalolab/data_model/lighting-app-wifi.matter +++ b/examples/lighting-app/bouffalolab/data_model/lighting-app-wifi.matter @@ -982,21 +982,12 @@ server cluster SoftwareDiagnostics = 52 { kWaterMarks = 0x1; } - struct ThreadMetricsStruct { - int64u id = 0; - optional char_string<8> name = 1; - optional int32u stackFreeCurrent = 2; - optional int32u stackFreeMinimum = 3; - optional int32u stackSize = 4; - } - info event SoftwareFault = 0 { INT64U id = 0; optional CHAR_STRING name = 1; optional OCTET_STRING faultRecording = 2; } - readonly attribute ThreadMetricsStruct threadMetrics[] = 0; readonly attribute int64u currentHeapFree = 1; readonly attribute int64u currentHeapUsed = 2; readonly attribute int64u currentHeapHighWatermark = 3; @@ -1465,6 +1456,24 @@ server cluster ColorControl = 768 { readonly attribute enum8 colorMode = 8; attribute bitmap8 options = 15; readonly attribute nullable int8u numberOfPrimaries = 16; + readonly attribute int16u primary1X = 17; + readonly attribute int16u primary1Y = 18; + readonly attribute nullable int8u primary1Intensity = 19; + readonly attribute int16u primary2X = 21; + readonly attribute int16u primary2Y = 22; + readonly attribute nullable int8u primary2Intensity = 23; + readonly attribute int16u primary3X = 25; + readonly attribute int16u primary3Y = 26; + readonly attribute nullable int8u primary3Intensity = 27; + readonly attribute int16u primary4X = 32; + readonly attribute int16u primary4Y = 33; + readonly attribute nullable int8u primary4Intensity = 34; + readonly attribute int16u primary5X = 36; + readonly attribute int16u primary5Y = 37; + readonly attribute nullable int8u primary5Intensity = 38; + readonly attribute int16u primary6X = 40; + readonly attribute int16u primary6Y = 41; + readonly attribute nullable int8u primary6Intensity = 42; readonly attribute int16u enhancedCurrentHue = 16384; readonly attribute enum8 enhancedColorMode = 16385; readonly attribute int8u colorLoopActive = 16386; @@ -1817,7 +1826,6 @@ endpoint 0 { } server cluster SoftwareDiagnostics { - callback attribute threadMetrics; callback attribute currentHeapFree default = 0x0000000000000000; callback attribute currentHeapUsed default = 0x0000000000000000; callback attribute currentHeapHighWatermark default = 0x0000000000000000; @@ -1894,7 +1902,7 @@ endpoint 0 { } } endpoint 1 { - device type dimmablelight = 257, version 1; + device type extendedcolorlight = 269, version 1; server cluster Identify { ram attribute identifyTime default = 0x0000; @@ -1957,6 +1965,24 @@ endpoint 1 { ram attribute colorMode default = 0x01; ram attribute options default = 0x00; ram attribute numberOfPrimaries; + ram attribute primary1X; + ram attribute primary1Y; + ram attribute primary1Intensity; + ram attribute primary2X; + ram attribute primary2Y; + ram attribute primary2Intensity; + ram attribute primary3X; + ram attribute primary3Y; + ram attribute primary3Intensity; + ram attribute primary4X; + ram attribute primary4Y; + ram attribute primary4Intensity; + ram attribute primary5X; + ram attribute primary5Y; + ram attribute primary5Intensity; + ram attribute primary6X; + ram attribute primary6Y; + ram attribute primary6Intensity; ram attribute enhancedCurrentHue default = 0x0000; ram attribute enhancedColorMode default = 0x01; ram attribute colorLoopActive default = 0x00; diff --git a/examples/lighting-app/bouffalolab/data_model/lighting-app-wifi.zap b/examples/lighting-app/bouffalolab/data_model/lighting-app-wifi.zap index fc2348e2cee121..cb6676170a79b3 100644 --- a/examples/lighting-app/bouffalolab/data_model/lighting-app-wifi.zap +++ b/examples/lighting-app/bouffalolab/data_model/lighting-app-wifi.zap @@ -1,5 +1,5 @@ { - "featureLevel": 94, + "featureLevel": 95, "creator": "zap", "keyValuePairs": [ { @@ -1795,22 +1795,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "GeneratedCommandList", - "code": 65528, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 0, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, { "name": "AttributeList", "code": 65531, @@ -2956,7 +2940,7 @@ "mfgCode": null, "side": "server", "type": "array", - "included": 1, + "included": 0, "storageOption": "External", "singleton": 0, "bounded": 0, @@ -4386,22 +4370,6 @@ "maxInterval": 65534, "reportableChange": 0 }, - { - "name": "AcceptedCommandList", - "code": 65529, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 0, - "storageOption": "External", - "singleton": 1, - "bounded": 1, - "defaultValue": "0", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, { "name": "FeatureMap", "code": 65532, @@ -5470,7 +5438,7 @@ ] }, { - "name": "MA-dimmablelight", + "name": "MA-extendedcolorlight", "deviceTypeName": "MA-dimmablelight", "deviceTypeCode": 257, "deviceTypeProfileId": 259, @@ -7503,7 +7471,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7519,7 +7487,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7535,7 +7503,7 @@ "mfgCode": null, "side": "server", "type": "int8u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7551,7 +7519,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7567,7 +7535,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7583,7 +7551,7 @@ "mfgCode": null, "side": "server", "type": "int8u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7599,7 +7567,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7615,7 +7583,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7631,7 +7599,7 @@ "mfgCode": null, "side": "server", "type": "int8u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7647,7 +7615,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7663,7 +7631,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7679,7 +7647,7 @@ "mfgCode": null, "side": "server", "type": "int8u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7695,7 +7663,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7711,7 +7679,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7727,7 +7695,7 @@ "mfgCode": null, "side": "server", "type": "int8u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7743,7 +7711,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7759,7 +7727,7 @@ "mfgCode": null, "side": "server", "type": "int16u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -7775,7 +7743,7 @@ "mfgCode": null, "side": "server", "type": "int8u", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -8365,14 +8333,14 @@ "deviceIdentifier": 22 }, { - "endpointTypeName": "MA-dimmablelight", + "endpointTypeName": "MA-extendedcolorlight", "endpointTypeIndex": 1, "profileId": 259, "endpointId": 1, "networkId": 0, "endpointVersion": 1, - "deviceIdentifier": 257 + "deviceIdentifier": 269 } ], "log": [] -} \ No newline at end of file +} diff --git a/examples/lighting-app/esp32/main/CMakeLists.txt b/examples/lighting-app/esp32/main/CMakeLists.txt index 9a7f8c26a16a34..6856a3582349dc 100644 --- a/examples/lighting-app/esp32/main/CMakeLists.txt +++ b/examples/lighting-app/esp32/main/CMakeLists.txt @@ -220,6 +220,7 @@ target_link_libraries(${COMPONENT_LIB} PUBLIC target_link_options(${COMPONENT_LIB} PUBLIC "-T${PIGWEED_ROOT}/pw_tokenizer/pw_tokenizer_linker_sections.ld" + "-L${PIGWEED_ROOT}/pw_tokenizer" ) target_compile_options(${COMPONENT_LIB} PRIVATE diff --git a/examples/lighting-app/esp32/main/main.cpp b/examples/lighting-app/esp32/main/main.cpp index 0d0244b7e00059..283140c0ca6f40 100644 --- a/examples/lighting-app/esp32/main/main.cpp +++ b/examples/lighting-app/esp32/main/main.cpp @@ -54,6 +54,10 @@ #include #endif // CONFIG_ENABLE_ESP32_DEVICE_INFO_PROVIDER +#if CONFIG_SEC_CERT_DAC_PROVIDER +#include +#endif + using namespace ::chip; using namespace ::chip::Credentials; using namespace ::chip::DeviceManager; @@ -74,6 +78,22 @@ DeviceLayer::ESP32DeviceInfoProvider gExampleDeviceInfoProvider; #else DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; #endif // CONFIG_ENABLE_ESP32_DEVICE_INFO_PROVIDER + +#if CONFIG_SEC_CERT_DAC_PROVIDER +DeviceLayer::ESP32SecureCertDACProvider gSecureCertDACProvider; +#endif // CONFIG_SEC_CERT_DAC_PROVIDER + +chip::Credentials::DeviceAttestationCredentialsProvider * get_dac_provider(void) +{ +#if CONFIG_SEC_CERT_DAC_PROVIDER + return &gSecureCertDACProvider; +#elif CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER + return &sFactoryDataProvider; +#else // EXAMPLE_DAC_PROVIDER + return chip::Credentials::Examples::GetExampleDACProvider(); +#endif +} + } // namespace static void InitServer(intptr_t context) @@ -131,14 +151,12 @@ extern "C" void app_main() #if CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER SetCommissionableDataProvider(&sFactoryDataProvider); - SetDeviceAttestationCredentialsProvider(&sFactoryDataProvider); #if CONFIG_ENABLE_ESP32_DEVICE_INSTANCE_INFO_PROVIDER SetDeviceInstanceInfoProvider(&sFactoryDataProvider); #endif -#else - SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); -#endif // CONFIG_ENABLE_ESP32_FACTORY_DATA_PROVIDER +#endif + SetDeviceAttestationCredentialsProvider(get_dac_provider()); #if CHIP_DEVICE_CONFIG_ENABLE_THREAD if (ThreadStackMgr().InitThreadStack() != CHIP_NO_ERROR) { diff --git a/examples/lighting-app/esp32/partitions.csv b/examples/lighting-app/esp32/partitions.csv index 9c801081f71c04..3753d8bcf13a35 100644 --- a/examples/lighting-app/esp32/partitions.csv +++ b/examples/lighting-app/esp32/partitions.csv @@ -1,7 +1,10 @@ # Name, Type, SubType, Offset, Size, Flags -# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap -nvs, data, nvs, , 0x6000, -otadata, data, ota, , 0x2000, -phy_init, data, phy, , 0x1000, -ota_0, app, ota_0, , 1500K, -ota_1, app, ota_1, , 1500K, +# Note: Firmware partition offset needs to be 64K aligned, initial 36K (9 sectors) are reserved for bootloader and partition table +esp_secure_cert, 0x3F, , 0xD000, 0x2000, encrypted +nvs, data, nvs, 0x10000, 0x6000, +nvs_keys, data, nvs_keys,, 0x1000, +otadata, data, ota, , 0x2000 +phy_init, data, phy, , 0x1000, +ota_0, app, ota_0, 0x20000, 0x1E0000, +ota_1, app, ota_1, 0x200000, 0x1E0000, +fctry, data, nvs, 0x3E0000, 0x6000 diff --git a/examples/lighting-app/esp32/sdkconfig.defaults b/examples/lighting-app/esp32/sdkconfig.defaults index bb74fc99f423d7..32b11db88fb2f9 100644 --- a/examples/lighting-app/esp32/sdkconfig.defaults +++ b/examples/lighting-app/esp32/sdkconfig.defaults @@ -53,5 +53,5 @@ 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 +# idf-v4.4.3 and idf-v5.0, so suppressing the warnings by setting below option CONFIG_RMT_SUPPRESS_DEPRECATE_WARN=y diff --git a/examples/lighting-app/silabs/SiWx917/README.md b/examples/lighting-app/silabs/SiWx917/README.md index db6699d6b465fc..a8d588271aae84 100644 --- a/examples/lighting-app/silabs/SiWx917/README.md +++ b/examples/lighting-app/silabs/SiWx917/README.md @@ -10,7 +10,7 @@ An example showing the use of CHIP on the Silicon Labs SiWx917. - [Flashing the Application](#flashing-the-application) - [Viewing Logging Output](#viewing-logging-output) - [Running the Complete Example](#running-the-complete-example) - - [Notes](#notes) + - [Notes](#notes) - [Memory settings](#memory-settings) - [Group Communication (Multicast)](#group-communication-multicast) - [Building options](#building-options) diff --git a/examples/lighting-app/silabs/efr32/README.md b/examples/lighting-app/silabs/efr32/README.md index 2d9fe56590d115..882f63f05fe00d 100644 --- a/examples/lighting-app/silabs/efr32/README.md +++ b/examples/lighting-app/silabs/efr32/README.md @@ -100,7 +100,7 @@ Silicon Labs platform. * Build the example application: cd ~/connectedhomeip - ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/silabs/efr32/ ./out/lighting-app BRD4161A + ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/silabs/efr32/ ./out/lighting-app BRD4161A - To delete generated executable, libraries and object files use: diff --git a/examples/lock-app/silabs/SiWx917/README.md b/examples/lock-app/silabs/SiWx917/README.md index 4aef51fe522b78..9f4c9f6a42005f 100644 --- a/examples/lock-app/silabs/SiWx917/README.md +++ b/examples/lock-app/silabs/SiWx917/README.md @@ -77,7 +77,7 @@ Mac OS X ``` cd ~/connectedhomeip - ./scripts/examples/gn_efr32_example.sh ./examples/lock-app/silabs/SiWx917/ ./out/lock_app BRD4325B + ./scripts/examples/gn_efr32_example.sh ./examples/lock-app/silabs/SiWx917/ ./out/lock_app BRD4325B ``` - To delete generated executable, libraries and object files use: diff --git a/examples/lock-app/silabs/efr32/README.md b/examples/lock-app/silabs/efr32/README.md index ec3c49e47961a0..e6ebd4028b49b5 100644 --- a/examples/lock-app/silabs/efr32/README.md +++ b/examples/lock-app/silabs/efr32/README.md @@ -102,7 +102,7 @@ Mac OS X ``` cd ~/connectedhomeip - ./scripts/examples/gn_efr32_example.sh ./examples/lock-app/silabs/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: 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 f5a55f78910ec9..3edbdc3a313251 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 @@ -86,7 +86,7 @@ client cluster AccessControl = 31 { } attribute access(read: administer, write: administer) AccessControlEntryStruct acl[] = 0; - attribute access(read: administer, write: administer) AccessControlExtensionStruct extension[] = 1; + attribute access(read: administer, write: administer) optional AccessControlExtensionStruct extension[] = 1; readonly attribute int16u subjectsPerAccessControlEntry = 2; readonly attribute int16u targetsPerAccessControlEntry = 3; readonly attribute int16u accessControlEntriesPerFabric = 4; diff --git a/examples/ota-requestor-app/ameba/main/CHIPDeviceManager.cpp b/examples/ota-requestor-app/ameba/main/CHIPDeviceManager.cpp index 4c1b55fbddb9fc..d0db78341501a5 100644 --- a/examples/ota-requestor-app/ameba/main/CHIPDeviceManager.cpp +++ b/examples/ota-requestor-app/ameba/main/CHIPDeviceManager.cpp @@ -28,11 +28,15 @@ #include "CHIPDeviceManager.h" #include #include +#include +#include +#include #include #include #include using namespace ::chip; +using namespace ::chip::Credentials; namespace chip { @@ -40,6 +44,8 @@ namespace DeviceManager { using namespace ::chip::DeviceLayer; +chip::DeviceLayer::FactoryDataProvider mFactoryDataProvider; + void CHIPDeviceManager::CommonDeviceEventHandler(const ChipDeviceEvent * event, intptr_t arg) { CHIPDeviceManagerCallbacks * cb = reinterpret_cast(arg); @@ -61,6 +67,19 @@ CHIP_ERROR CHIPDeviceManager::Init(CHIPDeviceManagerCallbacks * cb) err = PlatformMgr().InitChipStack(); SuccessOrExit(err); + err = mFactoryDataProvider.Init(); + if (err == CHIP_NO_ERROR) + { + SetCommissionableDataProvider(&mFactoryDataProvider); + SetDeviceAttestationCredentialsProvider(&mFactoryDataProvider); + SetDeviceInstanceInfoProvider(&mFactoryDataProvider); + } + else + { + ChipLogProgress(DeviceLayer, "Using example DAC provider"); + SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); + } + if (CONFIG_NETWORK_LAYER_BLE) { ConnectivityMgr().SetBLEAdvertisingEnabled(true); diff --git a/examples/ota-requestor-app/ameba/main/DeviceCallbacks.cpp b/examples/ota-requestor-app/ameba/main/DeviceCallbacks.cpp index baa7910e3030bf..67cb1ac8b9d747 100644 --- a/examples/ota-requestor-app/ameba/main/DeviceCallbacks.cpp +++ b/examples/ota-requestor-app/ameba/main/DeviceCallbacks.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -103,6 +104,7 @@ void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_ case DeviceEventType::kCommissioningComplete: ChipLogProgress(DeviceLayer, "Commissioning Complete"); + chip::DeviceLayer::Internal::AmebaUtils::SetCurrentProvisionedNetwork(); break; } } @@ -142,8 +144,9 @@ void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event chip::app::DnssdServer::Instance().StartServer(); #if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR // Init OTA requestor only when we have gotten IPv6 address - if (OTAInitializer::Instance().CheckInit()) + if (!OTAInitializer::Instance().CheckInit()) { + ChipLogProgress(DeviceLayer, "Initializing OTA"); chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds32(kInitOTARequestorDelaySec), InitOTARequestorHandler, nullptr); } diff --git a/examples/ota-requestor-app/ameba/main/chipinterface.cpp b/examples/ota-requestor-app/ameba/main/chipinterface.cpp index 2dd76a6dba308b..ee8e80086fbca4 100644 --- a/examples/ota-requestor-app/ameba/main/chipinterface.cpp +++ b/examples/ota-requestor-app/ameba/main/chipinterface.cpp @@ -25,12 +25,9 @@ #include #include #include -#include -#include #include #include -#include #include #include #include @@ -51,7 +48,6 @@ using namespace chip::Messaging; using namespace chip::app::Clusters::OtaSoftwareUpdateProvider::Commands; using namespace ::chip; -using namespace ::chip::Credentials; using namespace ::chip::DeviceManager; using namespace ::chip::DeviceLayer; @@ -74,7 +70,6 @@ void NetWorkCommissioningInstInit() static DeviceCallbacks EchoCallbacks; chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; -chip::DeviceLayer::FactoryDataProvider mFactoryDataProvider; static void InitServer(intptr_t context) { @@ -95,10 +90,6 @@ extern "C" void ChipTest(void) initPref(); - mFactoryDataProvider.Init(); - SetCommissionableDataProvider(&mFactoryDataProvider); - SetDeviceAttestationCredentialsProvider(&mFactoryDataProvider); - CHIPDeviceManager & deviceMgr = CHIPDeviceManager::GetInstance(); err = deviceMgr.Init(&EchoCallbacks); if (err != CHIP_NO_ERROR) @@ -110,9 +101,5 @@ extern "C" void ChipTest(void) ChipLogProgress(DeviceLayer, "DeviceManagerInit() - OK\r\n"); } - // Set DeviceInstanceInfoProvider after CHIPDeviceManager init - // CHIPDeviceManager init will set GenericDeviceInsanceInfoProvider first - SetDeviceInstanceInfoProvider(&mFactoryDataProvider); - chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, 0); } diff --git a/examples/ota-requestor-app/esp32/main/CMakeLists.txt b/examples/ota-requestor-app/esp32/main/CMakeLists.txt index 011d4a95c4d570..6a3633f442ac64 100644 --- a/examples/ota-requestor-app/esp32/main/CMakeLists.txt +++ b/examples/ota-requestor-app/esp32/main/CMakeLists.txt @@ -185,6 +185,7 @@ target_link_libraries(${COMPONENT_LIB} PUBLIC target_link_options(${COMPONENT_LIB} PUBLIC "-T${PIGWEED_ROOT}/pw_tokenizer/pw_tokenizer_linker_sections.ld" + "-L${PIGWEED_ROOT}/pw_tokenizer" ) target_compile_options(${COMPONENT_LIB} PRIVATE diff --git a/examples/placeholder/linux/apps/app1/config.matter b/examples/placeholder/linux/apps/app1/config.matter index 15cf0d03e782e2..4c382a43a7f48a 100644 --- a/examples/placeholder/linux/apps/app1/config.matter +++ b/examples/placeholder/linux/apps/app1/config.matter @@ -266,10 +266,10 @@ client cluster OnOff = 6 { } 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 optional boolean globalSceneControl = 16384; + attribute optional int16u onTime = 16385; + attribute optional int16u offWaitTime = 16386; + attribute access(write: manage) optional nullable OnOffStartUpOnOff startUpOnOff = 16387; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -767,7 +767,7 @@ client cluster UnitLocalization = 45 { kTemperatureUnit = 0x1; } - attribute TempUnitEnum temperatureUnit = 0; + attribute optional TempUnitEnum temperatureUnit = 0; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -1617,7 +1617,7 @@ client cluster Switch = 59 { readonly attribute int8u numberOfPositions = 0; readonly attribute int8u currentPosition = 1; - readonly attribute int8u multiPressMax = 2; + readonly attribute optional int8u multiPressMax = 2; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -2029,8 +2029,8 @@ client cluster ModeSelect = 80 { readonly attribute nullable enum16 standardNamespace = 1; readonly attribute ModeOptionStruct supportedModes[] = 2; readonly attribute int8u currentMode = 3; - attribute nullable int8u startUpMode = 4; - attribute nullable int8u onMode = 5; + attribute optional nullable int8u startUpMode = 4; + attribute optional nullable int8u onMode = 5; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -2438,7 +2438,7 @@ server cluster Thermostat = 513 { client cluster ThermostatUserInterfaceConfiguration = 516 { attribute enum8 temperatureDisplayMode = 0; attribute access(write: manage) enum8 keypadLockout = 1; - attribute access(write: manage) enum8 scheduleProgrammingVisibility = 2; + attribute access(write: manage) optional enum8 scheduleProgrammingVisibility = 2; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -2596,7 +2596,7 @@ client cluster TemperatureMeasurement = 1026 { readonly attribute nullable int16s measuredValue = 0; readonly attribute nullable int16s minMeasuredValue = 1; readonly attribute nullable int16s maxMeasuredValue = 2; - readonly attribute int16u tolerance = 3; + readonly attribute optional int16u tolerance = 3; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -2661,7 +2661,7 @@ client cluster RelativeHumidityMeasurement = 1029 { readonly attribute nullable int16u measuredValue = 0; readonly attribute nullable int16u minMeasuredValue = 1; readonly attribute nullable int16u maxMeasuredValue = 2; - readonly attribute int16u tolerance = 3; + readonly attribute optional int16u tolerance = 3; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -2737,7 +2737,7 @@ client cluster TargetNavigator = 1285 { } readonly attribute TargetInfoStruct targetList[] = 0; - readonly attribute int8u currentTarget = 1; + readonly attribute optional int8u currentTarget = 1; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -3113,8 +3113,8 @@ client cluster ContentLauncher = 1290 { optional StyleInformationStruct waterMark = 5; } - readonly attribute CHAR_STRING acceptHeader[] = 0; - attribute bitmap32 supportedStreamingProtocols = 1; + readonly attribute optional CHAR_STRING acceptHeader[] = 0; + attribute optional bitmap32 supportedStreamingProtocols = 1; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -3265,10 +3265,10 @@ client cluster ApplicationBasic = 1293 { char_string applicationID = 1; } - readonly attribute char_string<32> vendorName = 0; - readonly attribute vendor_id vendorID = 1; + readonly attribute optional char_string<32> vendorName = 0; + readonly attribute optional vendor_id vendorID = 1; readonly attribute char_string<32> applicationName = 2; - readonly attribute int16u productID = 3; + readonly attribute optional int16u productID = 3; readonly attribute ApplicationStruct application = 4; readonly attribute ApplicationStatusEnum status = 5; readonly attribute char_string<32> applicationVersion = 6; diff --git a/examples/placeholder/linux/apps/app2/config.matter b/examples/placeholder/linux/apps/app2/config.matter index 24f3b000f018d0..2aa3e240a7ab50 100644 --- a/examples/placeholder/linux/apps/app2/config.matter +++ b/examples/placeholder/linux/apps/app2/config.matter @@ -266,10 +266,10 @@ client cluster OnOff = 6 { } 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 optional boolean globalSceneControl = 16384; + attribute optional int16u onTime = 16385; + attribute optional int16u offWaitTime = 16386; + attribute access(write: manage) optional nullable OnOffStartUpOnOff startUpOnOff = 16387; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -1578,7 +1578,7 @@ client cluster Switch = 59 { readonly attribute int8u numberOfPositions = 0; readonly attribute int8u currentPosition = 1; - readonly attribute int8u multiPressMax = 2; + readonly attribute optional int8u multiPressMax = 2; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -1990,8 +1990,8 @@ client cluster ModeSelect = 80 { readonly attribute nullable enum16 standardNamespace = 1; readonly attribute ModeOptionStruct supportedModes[] = 2; readonly attribute int8u currentMode = 3; - attribute nullable int8u startUpMode = 4; - attribute nullable int8u onMode = 5; + attribute optional nullable int8u startUpMode = 4; + attribute optional nullable int8u onMode = 5; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -2399,7 +2399,7 @@ server cluster Thermostat = 513 { client cluster ThermostatUserInterfaceConfiguration = 516 { attribute enum8 temperatureDisplayMode = 0; attribute access(write: manage) enum8 keypadLockout = 1; - attribute access(write: manage) enum8 scheduleProgrammingVisibility = 2; + attribute access(write: manage) optional enum8 scheduleProgrammingVisibility = 2; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -2557,7 +2557,7 @@ client cluster TemperatureMeasurement = 1026 { readonly attribute nullable int16s measuredValue = 0; readonly attribute nullable int16s minMeasuredValue = 1; readonly attribute nullable int16s maxMeasuredValue = 2; - readonly attribute int16u tolerance = 3; + readonly attribute optional int16u tolerance = 3; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -2622,7 +2622,7 @@ client cluster RelativeHumidityMeasurement = 1029 { readonly attribute nullable int16u measuredValue = 0; readonly attribute nullable int16u minMeasuredValue = 1; readonly attribute nullable int16u maxMeasuredValue = 2; - readonly attribute int16u tolerance = 3; + readonly attribute optional int16u tolerance = 3; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -2698,7 +2698,7 @@ client cluster TargetNavigator = 1285 { } readonly attribute TargetInfoStruct targetList[] = 0; - readonly attribute int8u currentTarget = 1; + readonly attribute optional int8u currentTarget = 1; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -3074,8 +3074,8 @@ client cluster ContentLauncher = 1290 { optional StyleInformationStruct waterMark = 5; } - readonly attribute CHAR_STRING acceptHeader[] = 0; - attribute bitmap32 supportedStreamingProtocols = 1; + readonly attribute optional CHAR_STRING acceptHeader[] = 0; + attribute optional bitmap32 supportedStreamingProtocols = 1; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -3226,10 +3226,10 @@ client cluster ApplicationBasic = 1293 { char_string applicationID = 1; } - readonly attribute char_string<32> vendorName = 0; - readonly attribute vendor_id vendorID = 1; + readonly attribute optional char_string<32> vendorName = 0; + readonly attribute optional vendor_id vendorID = 1; readonly attribute char_string<32> applicationName = 2; - readonly attribute int16u productID = 3; + readonly attribute optional int16u productID = 3; readonly attribute ApplicationStruct application = 4; readonly attribute ApplicationStatusEnum status = 5; readonly attribute char_string<32> applicationVersion = 6; diff --git a/examples/placeholder/linux/args.gni b/examples/placeholder/linux/args.gni index a6463ca2c05fae..c38d497d4340cb 100644 --- a/examples/placeholder/linux/args.gni +++ b/examples/placeholder/linux/args.gni @@ -15,3 +15,10 @@ import("//build_overrides/chip.gni") import("${chip_root}/config/standalone/args.gni") + +chip_device_project_config_include = "" +chip_project_config_include = "" + +chip_project_config_include_dirs = + [ "${chip_root}/examples/placeholder/linux/include" ] +chip_project_config_include_dirs += [ "${chip_root}/config/standalone" ] diff --git a/examples/placeholder/linux/apps/app1/include/CHIPProjectConfig.h b/examples/placeholder/linux/include/CHIPProjectConfig.h similarity index 100% rename from examples/placeholder/linux/apps/app1/include/CHIPProjectConfig.h rename to examples/placeholder/linux/include/CHIPProjectConfig.h diff --git a/examples/platform/bouffalolab/bl602/flash_config/factory_data.dts b/examples/platform/bouffalolab/bl602/flash_config/factory_data.dts new file mode 100644 index 00000000000000..77eca2a07ad56d --- /dev/null +++ b/examples/platform/bouffalolab/bl602/flash_config/factory_data.dts @@ -0,0 +1,361 @@ +/dts-v1/; +/include/ "bl602_base.dtsi"; +// version: 17 +// last_comp_version: 16 +// boot_cpuid_phys: 0x0 + +/ { + model = "bl bl602 IOT board"; + compatible = "bl,bl602-sample", "bl,bl602-common"; + #address-cells = <0x1>; + #size-cells = <0x1>; + gpio { + #address-cells = <1>; + #size-cells = <1>; + max_num = <40>; + gpio0 { + status = "okay"; + pin = <5>; + feature = "led"; + active = "Hi"; //Hi or Lo + mode = "blink"; //blink or hearbeat + time = <100>; //duration for this mode + }; + gpio1 { + status = "disable"; + pin = <6>; + feature = "led"; + active = "Hi"; //Hi or Lo + mode = "blink"; //blink or hearbeat + time = <100>; //duration for this mode + }; + gpio2 { + status = "okay"; + pin = <2>; + feature = "button"; + active = "Hi"; + mode = "multipress"; + button { + debounce = <10>; + short_press_ms { + start = <100>; + end = <3000>; + kevent = <2>; + }; + long_press_ms { + start = <6000>; + end = <10000>; + kevent = <3>; + }; + longlong_press_ms { + start = <15000>; + kevent = <4>; + }; + trig_level = "Hi"; + }; + hbn_use = "disable"; + }; + }; + i2s { + #address-cells = <1>; + #size-cells = <1>; + i2s@40017000 { + status = "okay"; + compatible = "bl602_i2s"; + reg = <0x40017000 0x100>; + mclk_only = "okay"; + pin { + mclk = <11>; + }; + }; + i2s@40017100 { + status = "okay"; + compatible = "bl602_i2s"; + reg = <0x40017100 0x100>; + mclk_only = "disable"; + pin { + bclk = <12>; + fs = <29>; + do = <30>; + di = <31>; + }; + }; + }; + i2c { + #address-cells = <1>; + #size-cells = <1>; + i2c@40011000 { + status = "okay"; + compatible = "bl602_i2c"; + reg = <0x40011000 0x100>; + pin { + scl = <32>; + sda = <13>; + }; + devices { + list_addr = <0x18 0x21>; + list_driver = "i2c_es8311", "i2c_gc0308>"; + }; + }; + i2c@40011100 { + status = "disable"; + compatible = "bl602_i2c"; + reg = <0x40011100 0x100>; + pin { + /*empty here*/ + }; + }; + }; + timer { + #address-cells = <1>; + #size-cells = <1>; + timer@40014000 { + status = "disable"; + compatible = "bl602_timer"; + reg = <0x40014000 0x100>; + }; + timer@40014100 { + status = "disable"; + compatible = "bl602_timer"; + reg = <0x40014100 0x100>; + }; + }; + pwm { + #address-cells = <1>; + #size-cells = <1>; + pwm@4000A420 { + status = "okay"; + compatible = "bl602_pwm"; + reg = <0x4000A420 0x20>; + path = "/dev/pwm0"; + id = <0>; + pin = <0>; + freq = <800000>; + duty = <50>; + }; + pwm@4000A440 { + status = "disable"; + reg = <0x4000A440 0x20>; + path = "/dev/pwm1"; + id = <1>; + pin = <1>; + freq = <5000>; + duty = <50>; + }; + pwm@4000A460 { + status = "disable"; + reg = <0x4000A460 0x20>; + path = "/dev/pwm2"; + id = <2>; + pin = <2>; + freq = <5000>; + duty = <50>; + }; + pwm@4000A480 { + status = "disable"; + reg = <0x4000A480 0x20>; + path = "/dev/pwm3"; + id = <3>; + pin = <3>; + freq = <5000>; + duty = <50>; + }; + pwm@4000A4A0 { + status = "disable"; + reg = <0x4000A4A0 0x20>; + path = "/dev/pwm4"; + id = <4>; + pin = <4>; + freq = <5000>; + duty = <50>; + }; + }; + ir { + #address-cells = <1>; + #size-cells = <1>; + ctrltype = <0>; + tx { + status = "disable"; + pin = <11>; // only support 11 + mode = "NEC"; // NEC,ExtenedNEC,RC5,SWM + interval = <100>; // ms + active_mode = "Hi"; //Hi,Lo + }; + rx { + status = "okay"; + pin = <12>; // only support 12 13 + mode = "NEC"; // NEC,ExtenedNEC,RC5,SWM + active_mode = "Hi"; //Hi,Lo + data_check = <2>; //bit 0:check cmd, bit 1:check addr + }; + }; + uart { + #address-cells = <1>; + #size-cells = <1>; + uart@4000A000 { + status = "okay"; + id = <0>; + compatible = "bl602_uart"; + path = "/dev/ttyS0"; + baudrate = <2000000>; + pin { + rx = <7>; + tx = <16>; + }; + buf_size { + rx_size = <512>; + tx_size = <512>; + }; + feature { + tx = "okay"; + rx = "okay"; + cts = "disable"; + rts = "disable"; + }; + }; + uart@4000A100 { + status = "okay"; + id = <1>; + compatible = "bl602_uart"; + path = "/dev/ttyS1"; + baudrate = <115200>; + pin { + rx = <3>; + tx = <4>; + }; + buf_size { + rx_size = <512>; + tx_size = <512>; + }; + feature { + tx = "okay"; + rx = "okay"; + cts = "disable"; + rts = "disable"; + }; + }; + }; + spi { + #address-cells = <1>; + #size-cells = <1>; + spi@4000F000 { + status = "okay"; /* okay disable */ + mode = "master"; + reg = <0x4000F000 0x100>; /* 4KB */ + path = "/dev/spi0"; + port = <0>; + polar_phase = <1>; /* 0,1,2,3 */ + freq = <6000000>; + pin { + clk = <3>; + cs = <2>; + mosi = <1>; + miso = <0>; + }; + dma_cfg { + tx_dma_ch = <2>; + rx_dma_ch = <3>; + }; + }; + }; + gpip { + #address-cells = <1>; + #size-cells = <1>; + adc_key { + status = "disable"; + pin = <9>; + interrupt = <3>; + key_vol = <0 100 400 300 500>; + key_pcb = "SW1", "SW2", "SW3", "SW4","SW5"; + key_event = "Usr1", "Usr2", "Start", "Up", "Down"; + key_raw = <1 2 3 4 5>; + }; + }; + qspi { + #address-cells = <1>; + #size-cells = <1>; + qspi@4000A000 { + status = "disable"; + reg = <0x4000A000 0x1000>;/* 4KB */ + }; + }; + wifi { + #address-cells = <1>; + #size-cells = <1>; + region { + country_code = <86>; + }; + mac { + mode = "MBF"; + sta_mac_addr = [C8 43 57 82 73 40]; + ap_mac_addr = [C8 43 57 82 73 02]; + }; + sta { + ssid = "yourssid"; + pwd = "yourapssword"; + auto_connect_enable = <0>; + }; + ap { + ssid = "bl_test_005"; + pwd = "12345678"; + ap_channel = <11>; + auto_chan_detect = "disable"; + }; + brd_rf { + xtal_mode = "MF"; + xtal = <36 36 0 60 60>; + /* + pwr_table = < 4 3 3 186 + 4 3 4 176 + 4 3 5 167 + 3 3 0 159 + 3 3 1 149 + 3 3 2 140 + 3 3 3 129 + 3 3 4 119 + 3 3 5 110 + 2 3 0 101 + 2 3 1 91 + 2 3 2 82 + 2 3 3 72 + 2 3 4 62 + 2 3 5 52 + 1 3 3 10>; + */ + pwr_mode = "bf";//B: only use power offset in EFUSE; b: use power offset in EFUSE with incremental mode; F: only use power offset in Flash; f: use power offset in Flash with incremental mode + pwr_table_11b = <20 20 20 18>;//1Mbps 2Mbps 5.5Mbps 11Mbps + pwr_table_11g = <18 18 18 18 18 18 14 14>; //6Mbps 9Mbps 12Mbps 18MBps 24Mbps 36Mbps 48Mbps 54Mbps + pwr_table_11n = <18 18 18 18 18 16 14 14>; //MCS0 MCS1 MCS2 MCS3 MCS4 MCS5 MCS6 MCS7 + pwr_offset = <10 10 10 10 10 10 10 10 10 10 10 10 10 10>;//due to the limit of current DTC, negative value is used. So we work around by adding all the poweroffset with 10. so 8 represents -2; 10 represents 0; 13 represents 3 + }; + rf_temp { + en_tcal = <0>; + linear_or_follow = <1>; + Tchannels = <2412 2427 2442 2457 2472>; + Tchannel_os = <180 168 163 160 157>; + Tchannel_os_low = <199 186 170 165 160>; + Troom_os = <255>; + //negative value is NOT supported. So we use '256' for 0, '255' for -1, '257' for 1,'511' for 256 + }; + }; + bluetooth { + #address-cells = <1>; + #size-cells = <1>; + brd_rf { + pwr_table_ble = <13>; //range:0~15dbm + }; + }; + MFD { + vendor_name = "Bouffalo Lab"; + vendor_id = [0x0d 0x13]; + product_name = "Test Device"; + product_id = [0x01 0xf0]; + product_part_number = "Test Part Number"; + product_url = "Test Product URL"; + product_label = "Test Product Label"; + manufactoring_date = <2023 02 26>; + hardware_version = [0x01 0x00]; + hardware_version_string = "ver_0.1"; + }; +}; +}; diff --git a/examples/platform/bouffalolab/bl602/flash_config/partition_cfg_2M.toml b/examples/platform/bouffalolab/bl602/flash_config/partition_cfg_2M.toml index eb53723a9f8255..b7cf58abd724bc 100644 --- a/examples/platform/bouffalolab/bl602/flash_config/partition_cfg_2M.toml +++ b/examples/platform/bouffalolab/bl602/flash_config/partition_cfg_2M.toml @@ -29,7 +29,7 @@ len = 0 type = 3 name = "media" device = 0 -address0 = 0x1A2000 +address0 = 0x1A1000 size0 = 0x47000 address1 = 0 size1 = 0 @@ -40,7 +40,7 @@ len = 0 type = 4 name = "PSM" device = 0 -address0 = 0x1E9000 +address0 = 0x1E8000 size0 = 0x4000 address1 = 0 size1 = 0 @@ -51,7 +51,7 @@ len = 0 type = 5 name = "KEY" device = 0 -address0 = 0x1F1000 +address0 = 0x1F0000 size0 = 0x2000 address1 = 0 size1 = 0 @@ -62,7 +62,7 @@ len = 0 type = 6 name = "DATA" device = 0 -address0 = 0x1F3000 +address0 = 0x1F2000 size0 = 0x5000 address1 = 0 size1 = 0 @@ -74,16 +74,29 @@ len = 0 type = 7 name = "factory" device = 0 -address0 = 0x1F8000 +address0 = 0x1F7000 size0 = 0x7000 address1 = 0 size1 = 0 # compressed image must set len,normal image can left it to 0 len = 0 + +[[pt_entry]] +type = 8 +name = "MFD" +device = 0 +address0 = 0x1FE000 +size0 = 0x1000 +address1 = 0 +size1 = 0 +# compressed image must set len,normal image can left it to 0 +len = 0 + + #if user want to put RF calibration data on flash, uncomment following pt entry #[[pt_entry]] -#type = 8 +#type = 9 #name = "rf_para" #device = 0 #address0 = 0x1FF000 diff --git a/examples/platform/bouffalolab/bl602/flash_config/partition_cfg_4M.toml b/examples/platform/bouffalolab/bl602/flash_config/partition_cfg_4M.toml index ceb90cc3cb27a2..8fcdd55f3b53c8 100644 --- a/examples/platform/bouffalolab/bl602/flash_config/partition_cfg_4M.toml +++ b/examples/platform/bouffalolab/bl602/flash_config/partition_cfg_4M.toml @@ -41,7 +41,7 @@ type = 4 name = "PSM" device = 0 address0 = 0x3C3000 -size0 = 0x4000 +size0 = 0x8000 address1 = 0 size1 = 0 # compressed image must set len,normal image can left it to 0 @@ -51,7 +51,7 @@ len = 0 type = 5 name = "KEY" device = 0 -address0 = 0x3F6000 +address0 = 0x3F0000 size0 = 0x2000 address1 = 0 size1 = 0 @@ -62,7 +62,7 @@ len = 0 type = 6 name = "DATA" device = 0 -address0 = 0x3F8000 +address0 = 0x3F2000 size0 = 0x5000 address1 = 0 size1 = 0 @@ -74,19 +74,30 @@ len = 0 type = 7 name = "factory" device = 0 -address0 = 0x3FD000 +address0 = 0x3F7000 size0 = 0x7000 address1 = 0 size1 = 0 # compressed image must set len,normal image can left it to 0 len = 0 +[[pt_entry]] +type = 8 +name = "MFD" +device = 0 +address0 = 0x3FE000 +size0 = 0x1000 +address1 = 0 +size1 = 0 +# compressed image must set len,normal image can left it to 0 +len = 0 + #if user want to put RF calibration data on flash, uncomment following pt entry #[[pt_entry]] -#type = 8 +#type = 9 #name = "rf_para" #device = 0 -#address0 = 0x1FF000 +#address0 = 0x3FF000 #size0 = 0x1000 #address1 = 0 #size1 = 0 diff --git a/examples/platform/bouffalolab/bl602/ldscripts/flash_rom.ld b/examples/platform/bouffalolab/bl602/ldscripts/flash_rom.ld index 5ad35f1b9832b8..37c93f2e58d4a5 100644 --- a/examples/platform/bouffalolab/bl602/ldscripts/flash_rom.ld +++ b/examples/platform/bouffalolab/bl602/ldscripts/flash_rom.ld @@ -14,6 +14,9 @@ __RAM_END = 0x4200C000 + 256K - __EM_SIZE; /* leave 8K left for BLE */ __RAM_TCM_LEN = (16K + 16K + 48K + 64K + 64K - 16K - 16K); __RAM_WIFI_LEN = (__RAM_END - __RAM_START - __RAM_TCM_LEN); +__OCRAM_START_ADDRESS = 0x42030000 + 0x8000; +__OCRAM_SIZE = 112K; + MEMORY { rom (rxai!w) : ORIGIN = 0x21015000, LENGTH = 44K @@ -255,6 +258,8 @@ SECTIONS PROVIDE( _ld_ram_size2 = LENGTH(ram_wifi) ); PROVIDE( _ld_ram_addr2 = ORIGIN(ram_wifi) ); + PROVIDE(__ocram_start_addr = __OCRAM_START_ADDRESS); + PROVIDE(__ocram_size = __OCRAM_SIZE); /*BOOT2 sections*/ PROVIDE ( __boot2_pt_addr_src = BOOT2_PT_ADDR ); diff --git a/examples/platform/bouffalolab/bl702/flash_config/partition_cfg_2M.toml b/examples/platform/bouffalolab/bl702/flash_config/partition_cfg_2M.toml index f6a22deaf30a27..71aacc8cf753b2 100644 --- a/examples/platform/bouffalolab/bl702/flash_config/partition_cfg_2M.toml +++ b/examples/platform/bouffalolab/bl702/flash_config/partition_cfg_2M.toml @@ -8,9 +8,9 @@ type = 0 name = "FW" device = 0 address0 = 0x3000 -size0 = 0x12b000 -address1 = 0x12e000 -size1 = 0xC9000 +size0 = 0x134000 +address1 = 0x137000 +size1 = 0xBB000 # compressed image must set len,normal image can left it to 0 len = 0 activeindex = 0 @@ -20,8 +20,8 @@ age = 0 type = 1 name = "mfg" device = 0 -address0 = 0x12A000 -size0 = 0xC9000 +address0 = 0x137000 +size0 = 0xBB000 address1 = 0 size1 = 0 # compressed image must set len,normal image can left it to 0 @@ -33,8 +33,8 @@ age = 0 type = 2 name = "PSM" device = 0 -address0 = 0x1F7000 -size0 = 0x4000 +address0 = 0x1F2000 +size0 = 0x8000 address1 = 0 size1 = 0 # compressed image must set len,normal image can left it to 0 @@ -46,7 +46,7 @@ age = 0 type = 3 name = "media" device = 0 -address0 = 0x1FB000 +address0 = 0x1FA000 size0 = 0x4000 address1 = 0 size1 = 0 @@ -57,6 +57,19 @@ age = 0 [[pt_entry]] type = 4 +name = "MFD" +device = 0 +address0 = 0x1FE000 +size0 = 0x1000 +address1 = 0 +size1 = 0 +# compressed image must set len,normal image can left it to 0 +len = 0 +activeindex = 0 +age = 0 + +[[pt_entry]] +type = 5 name = "factory" device = 0 address0 = 0x1FF000 @@ -67,4 +80,3 @@ size1 = 0 len = 0 activeindex = 0 age = 0 - diff --git a/examples/platform/bouffalolab/common/plat/platform.cpp b/examples/platform/bouffalolab/common/plat/platform.cpp index 692b469eeb2c3b..50ed0de9c19a4d 100644 --- a/examples/platform/bouffalolab/common/plat/platform.cpp +++ b/examples/platform/bouffalolab/common/plat/platform.cpp @@ -59,6 +59,9 @@ #endif #include +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE || defined(CONFIG_BOUFFALOLAB_FACTORY_DATA_TEST) +#include +#endif #if CONFIG_ENABLE_CHIP_SHELL || PW_RPC_ENABLED #include "uart.h" @@ -81,6 +84,12 @@ chip::app::Clusters::NetworkCommissioning::Instance static chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE || defined(CONFIG_BOUFFALOLAB_FACTORY_DATA_TEST) +namespace { +FactoryDataProvider sFactoryDataProvider; +} +#endif + void ChipEventHandler(const ChipDeviceEvent * event, intptr_t arg) { switch (event->Type) @@ -196,10 +205,23 @@ CHIP_ERROR PlatformManagerImpl::PlatformInit(void) ReturnLogErrorOnFailure(sWiFiNetworkCommissioningInstance.Init()); #endif - chip::DeviceLayer::PlatformMgr().LockChipStack(); - // Initialize device attestation config +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE || defined(CONFIG_BOUFFALOLAB_FACTORY_DATA_TEST) + if (CHIP_NO_ERROR == sFactoryDataProvider.Init()) + { + SetDeviceInstanceInfoProvider(&sFactoryDataProvider); + SetDeviceAttestationCredentialsProvider(&sFactoryDataProvider); + SetCommissionableDataProvider(&sFactoryDataProvider); + } + else + { + ChipLogError(NotSpecified, "sFactoryDataProvider.Init() failed"); + } +#else SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); +#endif + + chip::DeviceLayer::PlatformMgr().LockChipStack(); #if CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY chip::app::DnssdServer::Instance().SetExtendedDiscoveryTimeoutSecs(EXT_DISCOVERY_TIMEOUT_SECS); diff --git a/examples/platform/silabs/SiWx917/LEDWidget.h b/examples/platform/silabs/SiWx917/LEDWidget.h index 44fb1937ee0f33..f033cb26c50f64 100644 --- a/examples/platform/silabs/SiWx917/LEDWidget.h +++ b/examples/platform/silabs/SiWx917/LEDWidget.h @@ -19,12 +19,9 @@ #pragma once +#include "rsi_board.h" #include -extern "C" void RSI_Board_LED_Set(int, bool); -extern "C" void RSI_Board_LED_Toggle(int); -extern "C" bool RSI_Board_LED_GetState(int); - class LEDWidget { public: diff --git a/examples/platform/silabs/SiWx917/SiWx917/rsi_if.c b/examples/platform/silabs/SiWx917/SiWx917/rsi_if.c index a09d5ea3dac3db..3ad6bad62a4b89 100644 --- a/examples/platform/silabs/SiWx917/SiWx917/rsi_if.c +++ b/examples/platform/silabs/SiWx917/SiWx917/rsi_if.c @@ -369,6 +369,13 @@ static void wfx_rsi_save_ap_info() /* * Scan is done - failed */ +#if WIFI_ENABLE_SECURITY_WPA3 + wfx_rsi.sec.security = WFX_SEC_WPA3; +#else /* !WIFI_ENABLE_SECURITY_WPA3 */ + wfx_rsi.sec.security = WFX_SEC_WPA2; +#endif /* WIFI_ENABLE_SECURITY_WPA3 */ + WFX_RSI_LOG("%s: warn: failed with status: %02x", status); + return; } else { diff --git a/examples/platform/silabs/SiWx917/uart.cpp b/examples/platform/silabs/SiWx917/uart.cpp index 850d9b643026f4..74e77f43f11ad4 100644 --- a/examples/platform/silabs/SiWx917/uart.cpp +++ b/examples/platform/silabs/SiWx917/uart.cpp @@ -33,13 +33,8 @@ extern ARM_DRIVER_USART Driver_USART0; static ARM_DRIVER_USART * UARTdrv = &Driver_USART0; ARM_USART_CAPABILITIES drv_capabilities; -ARM_USART_STATUS status; - -#define BUFFER_SIZE 1 -uint8_t rx_buffer; #define BAUD_VALUE 115200 - #define UART_CONSOLE_ERR -1 // Negative value in case of UART Console action failed. Triggers a failure for PW_RPC void ARM_USART_SignalEvent(uint32_t event); @@ -141,10 +136,6 @@ void uartConsoleInit(void) DEBUGOUT("\r\n Receives data success \r\n"); } - // Creating the receive event as a temp buffer - // this is not used anywhere - status = UARTdrv->Receive(&rx_buffer, 1); - NVIC_EnableIRQ(USART0_IRQn); NVIC_SetPriority(USART0_IRQn, 7); diff --git a/examples/platform/silabs/efr32/rs911x/rsi_if.c b/examples/platform/silabs/efr32/rs911x/rsi_if.c index 9b5ad8bcf4fe11..e76ab4386a8007 100644 --- a/examples/platform/silabs/efr32/rs911x/rsi_if.c +++ b/examples/platform/silabs/efr32/rs911x/rsi_if.c @@ -418,6 +418,13 @@ static void wfx_rsi_save_ap_info() // translation /* * Scan is done - failed */ +#if WIFI_ENABLE_SECURITY_WPA3 + wfx_rsi.sec.security = WFX_SEC_WPA3; +#else /* !WIFI_ENABLE_SECURITY_WPA3 */ + wfx_rsi.sec.security = WFX_SEC_WPA2; +#endif /* WIFI_ENABLE_SECURITY_WPA3 */ + WFX_RSI_LOG("%s: warn: failed with status: %02x", status); + return; } else { diff --git a/examples/pump-app/pump-common/pump-app.matter b/examples/pump-app/pump-common/pump-app.matter index 54dae44c7c2857..e45f1165bfa75f 100644 --- a/examples/pump-app/pump-common/pump-app.matter +++ b/examples/pump-app/pump-common/pump-app.matter @@ -1329,15 +1329,15 @@ client cluster OccupancySensing = 1030 { readonly attribute OccupancyBitmap occupancy = 0; readonly attribute OccupancySensorTypeEnum occupancySensorType = 1; readonly attribute OccupancySensorTypeBitmap occupancySensorTypeBitmap = 2; - attribute access(write: manage) int16u PIROccupiedToUnoccupiedDelay = 16; - attribute access(write: manage) int16u PIRUnoccupiedToOccupiedDelay = 17; - attribute access(write: manage) int8u PIRUnoccupiedToOccupiedThreshold = 18; - attribute access(write: manage) int16u ultrasonicOccupiedToUnoccupiedDelay = 32; - attribute access(write: manage) int16u ultrasonicUnoccupiedToOccupiedDelay = 33; - attribute access(write: manage) int8u ultrasonicUnoccupiedToOccupiedThreshold = 34; - attribute access(write: manage) int16u physicalContactOccupiedToUnoccupiedDelay = 48; - attribute access(write: manage) int16u physicalContactUnoccupiedToOccupiedDelay = 49; - attribute access(write: manage) int8u physicalContactUnoccupiedToOccupiedThreshold = 50; + attribute access(write: manage) optional int16u PIROccupiedToUnoccupiedDelay = 16; + attribute access(write: manage) optional int16u PIRUnoccupiedToOccupiedDelay = 17; + attribute access(write: manage) optional int8u PIRUnoccupiedToOccupiedThreshold = 18; + attribute access(write: manage) optional int16u ultrasonicOccupiedToUnoccupiedDelay = 32; + attribute access(write: manage) optional int16u ultrasonicUnoccupiedToOccupiedDelay = 33; + attribute access(write: manage) optional int8u ultrasonicUnoccupiedToOccupiedThreshold = 34; + attribute access(write: manage) optional int16u physicalContactOccupiedToUnoccupiedDelay = 48; + attribute access(write: manage) optional int16u physicalContactUnoccupiedToOccupiedDelay = 49; + attribute access(write: manage) optional int8u physicalContactUnoccupiedToOccupiedThreshold = 50; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; diff --git a/examples/pump-controller-app/pump-controller-common/pump-controller-app.matter b/examples/pump-controller-app/pump-controller-common/pump-controller-app.matter index 037120c80920ce..e41f06c1e2dc3f 100644 --- a/examples/pump-controller-app/pump-controller-common/pump-controller-app.matter +++ b/examples/pump-controller-app/pump-controller-common/pump-controller-app.matter @@ -73,10 +73,10 @@ client cluster OnOff = 6 { } 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 optional boolean globalSceneControl = 16384; + attribute optional int16u onTime = 16385; + attribute optional int16u offWaitTime = 16386; + attribute access(write: manage) optional nullable OnOffStartUpOnOff startUpOnOff = 16387; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -1153,26 +1153,26 @@ client 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 nullable int16s minCompPressure = 5; - readonly attribute nullable int16s maxCompPressure = 6; - readonly attribute nullable int16u minConstSpeed = 7; - readonly attribute nullable int16u maxConstSpeed = 8; - readonly attribute nullable int16u minConstFlow = 9; - readonly attribute nullable int16u maxConstFlow = 10; - readonly attribute nullable int16s minConstTemp = 11; - readonly attribute nullable int16s maxConstTemp = 12; - readonly attribute PumpStatusBitmap pumpStatus = 16; + readonly attribute optional nullable int16s minConstPressure = 3; + readonly attribute optional nullable int16s maxConstPressure = 4; + readonly attribute optional nullable int16s minCompPressure = 5; + readonly attribute optional nullable int16s maxCompPressure = 6; + readonly attribute optional nullable int16u minConstSpeed = 7; + readonly attribute optional nullable int16u maxConstSpeed = 8; + readonly attribute optional nullable int16u minConstFlow = 9; + readonly attribute optional nullable int16u maxConstFlow = 10; + readonly attribute optional nullable int16s minConstTemp = 11; + readonly attribute optional nullable int16s maxConstTemp = 12; + readonly attribute optional PumpStatusBitmap pumpStatus = 16; readonly attribute OperationModeEnum effectiveOperationMode = 17; readonly attribute ControlModeEnum effectiveControlMode = 18; readonly attribute nullable int16s capacity = 19; - readonly attribute nullable int16u speed = 20; - attribute access(write: manage) nullable int24u lifetimeRunningHours = 21; - readonly attribute nullable int24u power = 22; - attribute access(write: manage) nullable int32u lifetimeEnergyConsumed = 23; + readonly attribute optional nullable int16u speed = 20; + attribute access(write: manage) optional nullable int24u lifetimeRunningHours = 21; + readonly attribute optional nullable int24u power = 22; + attribute access(write: manage) optional nullable int32u lifetimeEnergyConsumed = 23; attribute access(write: manage) OperationModeEnum operationMode = 32; - attribute access(write: manage) ControlModeEnum controlMode = 33; + attribute access(write: manage) optional ControlModeEnum controlMode = 33; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -1186,7 +1186,7 @@ client cluster TemperatureMeasurement = 1026 { readonly attribute nullable int16s measuredValue = 0; readonly attribute nullable int16s minMeasuredValue = 1; readonly attribute nullable int16s maxMeasuredValue = 2; - readonly attribute int16u tolerance = 3; + readonly attribute optional int16u tolerance = 3; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -1204,12 +1204,12 @@ client cluster PressureMeasurement = 1027 { readonly attribute nullable int16s measuredValue = 0; readonly attribute nullable int16s minMeasuredValue = 1; readonly attribute nullable int16s maxMeasuredValue = 2; - readonly attribute int16u tolerance = 3; - readonly attribute nullable int16s scaledValue = 16; - readonly attribute nullable int16s minScaledValue = 17; - readonly attribute nullable int16s maxScaledValue = 18; - readonly attribute int16u scaledTolerance = 19; - readonly attribute int8s scale = 20; + readonly attribute optional int16u tolerance = 3; + readonly attribute optional nullable int16s scaledValue = 16; + readonly attribute optional nullable int16s minScaledValue = 17; + readonly attribute optional nullable int16s maxScaledValue = 18; + readonly attribute optional int16u scaledTolerance = 19; + readonly attribute optional int8s scale = 20; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -1223,7 +1223,7 @@ client cluster FlowMeasurement = 1028 { readonly attribute nullable int16u measuredValue = 0; readonly attribute nullable int16u minMeasuredValue = 1; readonly attribute nullable int16u maxMeasuredValue = 2; - readonly attribute int16u tolerance = 3; + readonly attribute optional int16u tolerance = 3; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; diff --git a/examples/temperature-measurement-app/esp32/main/CMakeLists.txt b/examples/temperature-measurement-app/esp32/main/CMakeLists.txt index 73636f69b2a9e9..6136d1583709bb 100644 --- a/examples/temperature-measurement-app/esp32/main/CMakeLists.txt +++ b/examples/temperature-measurement-app/esp32/main/CMakeLists.txt @@ -176,6 +176,7 @@ target_link_libraries(${COMPONENT_LIB} PUBLIC target_link_options(${COMPONENT_LIB} PUBLIC "-T${PIGWEED_ROOT}/pw_tokenizer/pw_tokenizer_linker_sections.ld" + "-L${PIGWEED_ROOT}/pw_tokenizer" ) target_compile_options(${COMPONENT_LIB} PRIVATE diff --git a/examples/thermostat/silabs/efr32/README.md b/examples/thermostat/silabs/efr32/README.md index 8d98f44e8b498b..9895b2b273f23e 100644 --- a/examples/thermostat/silabs/efr32/README.md +++ b/examples/thermostat/silabs/efr32/README.md @@ -106,7 +106,7 @@ Silicon Labs platform. * Build the example application: cd ~/connectedhomeip - ./scripts/examples/gn_efr32_example.sh ./examples/thermostat/silabs/efr32/ ./out/thermostat-app BRD4161A + ./scripts/examples/gn_efr32_example.sh ./examples/thermostat/silabs/efr32/ ./out/thermostat-app BRD4161A - To delete generated executable, libraries and object files use: diff --git a/examples/tv-app/android/java/JNIDACProvider.cpp b/examples/tv-app/android/java/JNIDACProvider.cpp index 19fb4dd64da1c1..2c4da223a5dbd3 100644 --- a/examples/tv-app/android/java/JNIDACProvider.cpp +++ b/examples/tv-app/android/java/JNIDACProvider.cpp @@ -69,30 +69,51 @@ JNIDACProvider::JNIDACProvider(jobject provider) env->ExceptionClear(); } - mGetDeviceAttestationCertPrivateKeyMethod = env->GetMethodID(JNIDACProviderClass, "GetDeviceAttestationCertPrivateKey", "()[B"); - if (mGetDeviceAttestationCertPrivateKeyMethod == nullptr) + mSignWithDeviceAttestationKeyMethod = env->GetMethodID(JNIDACProviderClass, "SignWithDeviceAttestationKey", "([B)[B"); + if (mSignWithDeviceAttestationKeyMethod == nullptr) { - ChipLogError(Zcl, "Failed to access JNIDACProvider 'GetDeviceAttestationCertPrivateKey' method"); + ChipLogError(Zcl, "Failed to access JNIDACProvider 'SignWithDeviceAttestationKey' method"); env->ExceptionClear(); } +} - mGetDeviceAttestationCertPublicKeyKeyMethod = - env->GetMethodID(JNIDACProviderClass, "GetDeviceAttestationCertPublicKeyKey", "()[B"); - if (mGetDeviceAttestationCertPublicKeyKeyMethod == nullptr) +CHIP_ERROR JNIDACProvider::GetJavaByteByMethod(jmethodID method, MutableByteSpan & out_buffer) +{ + JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + VerifyOrReturnLogError(mJNIDACProviderObject != nullptr, CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturnLogError(method != nullptr, CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturnLogError(env != nullptr, CHIP_JNI_ERROR_NO_ENV); + + jbyteArray outArray = (jbyteArray) env->CallObjectMethod(mJNIDACProviderObject, method); + if (env->ExceptionCheck()) { - ChipLogError(Zcl, "Failed to access JNIDACProvider 'GetDeviceAttestationCertPublicKeyKey' method"); + ChipLogError(Zcl, "Java exception in get Method"); + env->ExceptionDescribe(); env->ExceptionClear(); + return CHIP_ERROR_INCORRECT_STATE; } + + if (outArray == nullptr || env->GetArrayLength(outArray) <= 0) + { + out_buffer.reduce_size(0); + return CHIP_NO_ERROR; + } + + JniByteArray JniOutArray(env, outArray); + return CopySpanToMutableSpan(JniOutArray.byteSpan(), out_buffer); } -CHIP_ERROR JNIDACProvider::GetJavaByteByMethod(jmethodID method, MutableByteSpan & out_buffer) +CHIP_ERROR JNIDACProvider::GetJavaByteByMethod(jmethodID method, const ByteSpan & in_buffer, MutableByteSpan & out_buffer) { JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); VerifyOrReturnLogError(mJNIDACProviderObject != nullptr, CHIP_ERROR_INCORRECT_STATE); VerifyOrReturnLogError(method != nullptr, CHIP_ERROR_INCORRECT_STATE); VerifyOrReturnLogError(env != nullptr, CHIP_JNI_ERROR_NO_ENV); - jbyteArray outArray = (jbyteArray) env->CallObjectMethod(mJNIDACProviderObject, method); + jbyteArray in_buffer_jbyteArray = env->NewByteArray((jsize)(in_buffer.size())); + env->SetByteArrayRegion(in_buffer_jbyteArray, 0, (int) in_buffer.size(), reinterpret_cast(in_buffer.data())); + + jbyteArray outArray = (jbyteArray) env->CallObjectMethod(mJNIDACProviderObject, method, in_buffer_jbyteArray); if (env->ExceptionCheck()) { ChipLogError(Zcl, "Java exception in get Method"); @@ -101,6 +122,8 @@ CHIP_ERROR JNIDACProvider::GetJavaByteByMethod(jmethodID method, MutableByteSpan return CHIP_ERROR_INCORRECT_STATE; } + env->DeleteLocalRef(in_buffer_jbyteArray); + if (outArray == nullptr || env->GetArrayLength(outArray) <= 0) { out_buffer.reduce_size(0); @@ -135,38 +158,20 @@ CHIP_ERROR JNIDACProvider::GetProductAttestationIntermediateCert(MutableByteSpan return GetJavaByteByMethod(mGetProductAttestationIntermediateCertMethod, out_pai_buffer); } -// TODO: This should be moved to a method of P256Keypair -CHIP_ERROR LoadKeypairFromRaw(ByteSpan private_key, ByteSpan public_key, Crypto::P256Keypair & keypair) -{ - Crypto::P256SerializedKeypair serialized_keypair; - ReturnErrorOnFailure(serialized_keypair.SetLength(private_key.size() + public_key.size())); - memcpy(serialized_keypair.Bytes(), public_key.data(), public_key.size()); - memcpy(serialized_keypair.Bytes() + public_key.size(), private_key.data(), private_key.size()); - return keypair.Deserialize(serialized_keypair); -} - CHIP_ERROR JNIDACProvider::SignWithDeviceAttestationKey(const ByteSpan & message_to_sign, MutableByteSpan & out_signature_buffer) { ChipLogProgress(Zcl, "Received SignWithDeviceAttestationKey"); - Crypto::P256ECDSASignature signature; - Crypto::P256Keypair keypair; + uint8_t mAsn1SignatureBytes[73]; - VerifyOrReturnError(IsSpanUsable(out_signature_buffer), CHIP_ERROR_INVALID_ARGUMENT); - VerifyOrReturnError(IsSpanUsable(message_to_sign), CHIP_ERROR_INVALID_ARGUMENT); - VerifyOrReturnError(out_signature_buffer.size() >= signature.Capacity(), CHIP_ERROR_BUFFER_TOO_SMALL); + MutableByteSpan asn1_signature_buffer(mAsn1SignatureBytes, sizeof(mAsn1SignatureBytes)); - uint8_t privateKeyBuf[Crypto::kP256_PrivateKey_Length]; - MutableByteSpan privateKeyBufSpan(privateKeyBuf); - ReturnErrorOnFailure(GetJavaByteByMethod(mGetDeviceAttestationCertPrivateKeyMethod, privateKeyBufSpan)); - - uint8_t publicKeyBuf[Crypto::kP256_PublicKey_Length]; - MutableByteSpan publicKeyBufSpan(publicKeyBuf); - ReturnErrorOnFailure(GetJavaByteByMethod(mGetDeviceAttestationCertPublicKeyKeyMethod, publicKeyBufSpan)); - - // In a non-exemplary implementation, the public key is not needed here. It is used here merely because - // Crypto::P256Keypair is only (currently) constructable from raw keys if both private/public keys are present. - ReturnErrorOnFailure(LoadKeypairFromRaw(privateKeyBufSpan, publicKeyBufSpan, keypair)); - ReturnErrorOnFailure(keypair.ECDSA_sign_msg(message_to_sign.data(), message_to_sign.size(), signature)); + CHIP_ERROR error = GetJavaByteByMethod(mSignWithDeviceAttestationKeyMethod, message_to_sign, asn1_signature_buffer); + if (error != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "SignWithDeviceAttestationKey failed"); + return error; + } - return CopySpanToMutableSpan(ByteSpan{ signature.ConstBytes(), signature.Length() }, out_signature_buffer); + return chip::Crypto::EcdsaAsn1SignatureToRaw(32, ByteSpan(asn1_signature_buffer.data(), asn1_signature_buffer.size()), + out_signature_buffer); } diff --git a/examples/tv-app/android/java/JNIDACProvider.h b/examples/tv-app/android/java/JNIDACProvider.h index 1498eb66c07dcd..9c419367253c5f 100644 --- a/examples/tv-app/android/java/JNIDACProvider.h +++ b/examples/tv-app/android/java/JNIDACProvider.h @@ -33,11 +33,11 @@ class JNIDACProvider : public chip::Credentials::DeviceAttestationCredentialsPro private: CHIP_ERROR GetJavaByteByMethod(jmethodID method, chip::MutableByteSpan & out_buffer); + CHIP_ERROR GetJavaByteByMethod(jmethodID method, const chip::ByteSpan & in_buffer, chip::MutableByteSpan & out_buffer); jobject mJNIDACProviderObject = nullptr; jmethodID mGetCertificationDeclarationMethod = nullptr; jmethodID mGetFirmwareInformationMethod = nullptr; jmethodID mGetDeviceAttestationCertMethod = nullptr; jmethodID mGetProductAttestationIntermediateCertMethod = nullptr; - jmethodID mGetDeviceAttestationCertPrivateKeyMethod = nullptr; - jmethodID mGetDeviceAttestationCertPublicKeyKeyMethod = nullptr; + jmethodID mSignWithDeviceAttestationKeyMethod = nullptr; }; diff --git a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/DACProvider.java b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/DACProvider.java index 7b2e0786717dd1..1fc81b1cd7abc3 100644 --- a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/DACProvider.java +++ b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/DACProvider.java @@ -26,7 +26,14 @@ public interface DACProvider { byte[] GetProductAttestationIntermediateCert(); - byte[] GetDeviceAttestationCertPrivateKey(); - - byte[] GetDeviceAttestationCertPublicKeyKey(); + /** + * Sign a mesage with the device attestation key. + * + *

The signature should be a SHA256withECDSA Signature that's returned in the ECDSA X9.62 Asn1 + * format. This is the default behavior when using java.security.Signature with an EC P-256 curve. + * + * @param message The message to sign + * @return The signature in ECDSA X9.62 Asn1 format. + */ + byte[] SignWithDeviceAttestationKey(byte[] message); } diff --git a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/DACProviderStub.java b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/DACProviderStub.java index 2aead7ad66aaab..80b8b8a99c3a0a 100644 --- a/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/DACProviderStub.java +++ b/examples/tv-app/android/java/src/com/matter/tv/server/tvapp/DACProviderStub.java @@ -1,6 +1,14 @@ package com.matter.tv.server.tvapp; import android.util.Base64; +import java.math.BigInteger; +import java.security.AlgorithmParameters; +import java.security.KeyFactory; +import java.security.PrivateKey; +import java.security.Signature; +import java.security.spec.ECGenParameterSpec; +import java.security.spec.ECParameterSpec; +import java.security.spec.ECPrivateKeySpec; public class DACProviderStub implements DACProvider { @@ -46,12 +54,29 @@ public byte[] GetProductAttestationIntermediateCert() { } @Override - public byte[] GetDeviceAttestationCertPrivateKey() { - return Base64.decode(kDevelopmentDAC_PrivateKey_FFF1_8001, Base64.DEFAULT); - } + public byte[] SignWithDeviceAttestationKey(byte[] message) { - @Override - public byte[] GetDeviceAttestationCertPublicKeyKey() { - return Base64.decode(kDevelopmentDAC_PublicKey_FFF1_8001, Base64.DEFAULT); + try { + byte[] privateKeyBytes = Base64.decode(kDevelopmentDAC_PrivateKey_FFF1_8001, Base64.DEFAULT); + + AlgorithmParameters algorithmParameters = AlgorithmParameters.getInstance("EC"); + algorithmParameters.init(new ECGenParameterSpec("secp256r1")); + ECParameterSpec parameterSpec = algorithmParameters.getParameterSpec(ECParameterSpec.class); + ECPrivateKeySpec ecPrivateKeySpec = + new ECPrivateKeySpec(new BigInteger(1, privateKeyBytes), parameterSpec); + + KeyFactory keyFactory = KeyFactory.getInstance("EC"); + PrivateKey privateKey = keyFactory.generatePrivate(ecPrivateKeySpec); + + Signature signature = Signature.getInstance("SHA256withECDSA"); + signature.initSign(privateKey); + + signature.update(message); + + return signature.sign(); + + } catch (Exception e) { + return null; + } } } diff --git a/examples/tv-app/tv-common/tv-app.matter b/examples/tv-app/tv-common/tv-app.matter index 5749402b494025..1e41a51bb46186 100644 --- a/examples/tv-app/tv-common/tv-app.matter +++ b/examples/tv-app/tv-common/tv-app.matter @@ -689,8 +689,8 @@ client cluster NetworkCommissioning = 49 { readonly attribute access(read: administer) int8u maxNetworks = 0; readonly attribute access(read: administer) NetworkInfo networks[] = 1; - readonly attribute int8u scanMaxTimeSeconds = 2; - readonly attribute int8u connectMaxTimeSeconds = 3; + readonly attribute optional int8u scanMaxTimeSeconds = 2; + readonly attribute optional int8u connectMaxTimeSeconds = 3; attribute access(write: administer) boolean interfaceEnabled = 4; readonly attribute access(read: administer) nullable NetworkCommissioningStatus lastNetworkingStatus = 5; readonly attribute access(read: administer) nullable octet_string<32> lastNetworkID = 6; diff --git a/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/MainActivity.java b/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/MainActivity.java index 7ee7deecc2e7d8..db3725c99c6afb 100644 --- a/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/MainActivity.java +++ b/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/app/MainActivity.java @@ -1,15 +1,14 @@ package com.chip.casting.app; -import android.content.Context; import android.os.Bundle; import android.util.Log; import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentTransaction; import com.chip.casting.AppParameters; -import com.chip.casting.DACProviderStub; import com.chip.casting.DiscoveredNodeData; import com.chip.casting.TvCastingApp; +import com.chip.casting.util.DACProviderStub; import com.chip.casting.util.GlobalCastingConstants; import com.chip.casting.util.PreferencesConfigurationManager; import java.util.Random; @@ -79,7 +78,7 @@ public void handleDisconnect() { private boolean initJni() { tvCastingApp = new TvCastingApp(); - Context applicationContext = this.getApplicationContext(); + tvCastingApp.setDACProvider(new DACProviderStub()); AppParameters appParameters = new AppParameters(); appParameters.setConfigurationManager( @@ -89,10 +88,9 @@ private boolean initJni() { new byte[AppParameters.MIN_ROTATING_DEVICE_ID_UNIQUE_ID_LENGTH]; new Random().nextBytes(rotatingDeviceIdUniqueId); appParameters.setRotatingDeviceIdUniqueId(rotatingDeviceIdUniqueId); - appParameters.setDacProvider(new DACProviderStub()); appParameters.setSetupPasscode(GlobalCastingConstants.SetupPasscode); appParameters.setDiscriminator(GlobalCastingConstants.Discriminator); - return tvCastingApp.initApp(applicationContext, appParameters); + return tvCastingApp.initApp(this.getApplicationContext(), appParameters); } private void showFragment(Fragment fragment, boolean showOnBack) { diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/DACProviderStub.java b/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/util/DACProviderStub.java similarity index 72% rename from examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/DACProviderStub.java rename to examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/util/DACProviderStub.java index f8c7dfcc807eec..9dbae27c6e5982 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/DACProviderStub.java +++ b/examples/tv-casting-app/android/App/app/src/main/java/com/chip/casting/util/DACProviderStub.java @@ -1,6 +1,15 @@ -package com.chip.casting; +package com.chip.casting.util; import android.util.Base64; +import com.chip.casting.DACProvider; +import java.math.BigInteger; +import java.security.AlgorithmParameters; +import java.security.KeyFactory; +import java.security.PrivateKey; +import java.security.Signature; +import java.security.spec.ECGenParameterSpec; +import java.security.spec.ECParameterSpec; +import java.security.spec.ECPrivateKeySpec; public class DACProviderStub implements DACProvider { @@ -46,12 +55,29 @@ public byte[] GetProductAttestationIntermediateCert() { } @Override - public byte[] GetDeviceAttestationCertPrivateKey() { - return Base64.decode(kDevelopmentDAC_PrivateKey_FFF1_8001, Base64.DEFAULT); - } + public byte[] SignWithDeviceAttestationKey(byte[] message) { - @Override - public byte[] GetDeviceAttestationCertPublicKeyKey() { - return Base64.decode(kDevelopmentDAC_PublicKey_FFF1_8001, Base64.DEFAULT); + try { + byte[] privateKeyBytes = Base64.decode(kDevelopmentDAC_PrivateKey_FFF1_8001, Base64.DEFAULT); + + AlgorithmParameters algorithmParameters = AlgorithmParameters.getInstance("EC"); + algorithmParameters.init(new ECGenParameterSpec("secp256r1")); + ECParameterSpec parameterSpec = algorithmParameters.getParameterSpec(ECParameterSpec.class); + ECPrivateKeySpec ecPrivateKeySpec = + new ECPrivateKeySpec(new BigInteger(1, privateKeyBytes), parameterSpec); + + KeyFactory keyFactory = KeyFactory.getInstance("EC"); + PrivateKey privateKey = keyFactory.generatePrivate(ecPrivateKeySpec); + + Signature signature = Signature.getInstance("SHA256withECDSA"); + signature.initSign(privateKey); + + signature.update(message); + + return signature.sign(); + + } catch (Exception e) { + return null; + } } } diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/AppParameters.java b/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/AppParameters.java index 16fa5bd932888e..18c9a351f0e41a 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/AppParameters.java +++ b/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/AppParameters.java @@ -27,11 +27,9 @@ public class AppParameters { public static final int MIN_ROTATING_DEVICE_ID_UNIQUE_ID_LENGTH = 16; private static final int TEST_SETUP_PASSCODE = 20202021; private static final int TEST_DISCRIMINATOR = 0xF00; - private DACProvider TEST_DAC_PROVIDER = new DACProviderStub(); private ConfigurationManager configurationManager; private byte[] rotatingDeviceIdUniqueId; - private DACProvider dacProvider = TEST_DAC_PROVIDER; private String spake2pVerifierBase64; private String Spake2pSaltBase64; private int spake2pIterationCount; @@ -63,14 +61,6 @@ public byte[] getRotatingDeviceIdUniqueId() { return Arrays.copyOf(rotatingDeviceIdUniqueId, rotatingDeviceIdUniqueId.length); } - public DACProvider getDacProvider() { - return dacProvider; - } - - public void setDacProvider(DACProvider dacProvider) { - this.dacProvider = dacProvider; - } - public String getSpake2pVerifierBase64() { return spake2pVerifierBase64; } diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/DACProvider.java b/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/DACProvider.java index 64dd43be96c4ab..c49d73ab98c86e 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/DACProvider.java +++ b/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/DACProvider.java @@ -26,7 +26,14 @@ public interface DACProvider { byte[] GetProductAttestationIntermediateCert(); - byte[] GetDeviceAttestationCertPrivateKey(); - - byte[] GetDeviceAttestationCertPublicKeyKey(); + /** + * Sign a mesage with the device attestation key. + * + *

The signature should be a SHA256withECDSA Signature that's returned in the ECDSA X9.62 Asn1 + * format. This is the default behavior when using java.security.Signature with an EC P-256 curve. + * + * @param message The message to sign + * @return The signature in ECDSA X9.62 Asn1 format. + */ + byte[] SignWithDeviceAttestationKey(byte[] message); } diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/TvCastingApp.java b/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/TvCastingApp.java index 728a6cf0b8b466..f9efdb75c1ff2f 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/TvCastingApp.java +++ b/examples/tv-casting-app/android/App/app/src/main/jni/com/chip/casting/TvCastingApp.java @@ -94,11 +94,10 @@ public boolean initApp(Context applicationContext, AppParameters appParameters) return ret; } - setDACProvider(appParameters.getDacProvider()); return initJni(appParameters); } - private native void setDACProvider(DACProvider provider); + public native void setDACProvider(DACProvider provider); private native boolean preInitJni(AppParameters appParameters); diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/JNIDACProvider.cpp b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/JNIDACProvider.cpp index 19fb4dd64da1c1..2c4da223a5dbd3 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/JNIDACProvider.cpp +++ b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/JNIDACProvider.cpp @@ -69,30 +69,51 @@ JNIDACProvider::JNIDACProvider(jobject provider) env->ExceptionClear(); } - mGetDeviceAttestationCertPrivateKeyMethod = env->GetMethodID(JNIDACProviderClass, "GetDeviceAttestationCertPrivateKey", "()[B"); - if (mGetDeviceAttestationCertPrivateKeyMethod == nullptr) + mSignWithDeviceAttestationKeyMethod = env->GetMethodID(JNIDACProviderClass, "SignWithDeviceAttestationKey", "([B)[B"); + if (mSignWithDeviceAttestationKeyMethod == nullptr) { - ChipLogError(Zcl, "Failed to access JNIDACProvider 'GetDeviceAttestationCertPrivateKey' method"); + ChipLogError(Zcl, "Failed to access JNIDACProvider 'SignWithDeviceAttestationKey' method"); env->ExceptionClear(); } +} - mGetDeviceAttestationCertPublicKeyKeyMethod = - env->GetMethodID(JNIDACProviderClass, "GetDeviceAttestationCertPublicKeyKey", "()[B"); - if (mGetDeviceAttestationCertPublicKeyKeyMethod == nullptr) +CHIP_ERROR JNIDACProvider::GetJavaByteByMethod(jmethodID method, MutableByteSpan & out_buffer) +{ + JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + VerifyOrReturnLogError(mJNIDACProviderObject != nullptr, CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturnLogError(method != nullptr, CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturnLogError(env != nullptr, CHIP_JNI_ERROR_NO_ENV); + + jbyteArray outArray = (jbyteArray) env->CallObjectMethod(mJNIDACProviderObject, method); + if (env->ExceptionCheck()) { - ChipLogError(Zcl, "Failed to access JNIDACProvider 'GetDeviceAttestationCertPublicKeyKey' method"); + ChipLogError(Zcl, "Java exception in get Method"); + env->ExceptionDescribe(); env->ExceptionClear(); + return CHIP_ERROR_INCORRECT_STATE; } + + if (outArray == nullptr || env->GetArrayLength(outArray) <= 0) + { + out_buffer.reduce_size(0); + return CHIP_NO_ERROR; + } + + JniByteArray JniOutArray(env, outArray); + return CopySpanToMutableSpan(JniOutArray.byteSpan(), out_buffer); } -CHIP_ERROR JNIDACProvider::GetJavaByteByMethod(jmethodID method, MutableByteSpan & out_buffer) +CHIP_ERROR JNIDACProvider::GetJavaByteByMethod(jmethodID method, const ByteSpan & in_buffer, MutableByteSpan & out_buffer) { JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); VerifyOrReturnLogError(mJNIDACProviderObject != nullptr, CHIP_ERROR_INCORRECT_STATE); VerifyOrReturnLogError(method != nullptr, CHIP_ERROR_INCORRECT_STATE); VerifyOrReturnLogError(env != nullptr, CHIP_JNI_ERROR_NO_ENV); - jbyteArray outArray = (jbyteArray) env->CallObjectMethod(mJNIDACProviderObject, method); + jbyteArray in_buffer_jbyteArray = env->NewByteArray((jsize)(in_buffer.size())); + env->SetByteArrayRegion(in_buffer_jbyteArray, 0, (int) in_buffer.size(), reinterpret_cast(in_buffer.data())); + + jbyteArray outArray = (jbyteArray) env->CallObjectMethod(mJNIDACProviderObject, method, in_buffer_jbyteArray); if (env->ExceptionCheck()) { ChipLogError(Zcl, "Java exception in get Method"); @@ -101,6 +122,8 @@ CHIP_ERROR JNIDACProvider::GetJavaByteByMethod(jmethodID method, MutableByteSpan return CHIP_ERROR_INCORRECT_STATE; } + env->DeleteLocalRef(in_buffer_jbyteArray); + if (outArray == nullptr || env->GetArrayLength(outArray) <= 0) { out_buffer.reduce_size(0); @@ -135,38 +158,20 @@ CHIP_ERROR JNIDACProvider::GetProductAttestationIntermediateCert(MutableByteSpan return GetJavaByteByMethod(mGetProductAttestationIntermediateCertMethod, out_pai_buffer); } -// TODO: This should be moved to a method of P256Keypair -CHIP_ERROR LoadKeypairFromRaw(ByteSpan private_key, ByteSpan public_key, Crypto::P256Keypair & keypair) -{ - Crypto::P256SerializedKeypair serialized_keypair; - ReturnErrorOnFailure(serialized_keypair.SetLength(private_key.size() + public_key.size())); - memcpy(serialized_keypair.Bytes(), public_key.data(), public_key.size()); - memcpy(serialized_keypair.Bytes() + public_key.size(), private_key.data(), private_key.size()); - return keypair.Deserialize(serialized_keypair); -} - CHIP_ERROR JNIDACProvider::SignWithDeviceAttestationKey(const ByteSpan & message_to_sign, MutableByteSpan & out_signature_buffer) { ChipLogProgress(Zcl, "Received SignWithDeviceAttestationKey"); - Crypto::P256ECDSASignature signature; - Crypto::P256Keypair keypair; + uint8_t mAsn1SignatureBytes[73]; - VerifyOrReturnError(IsSpanUsable(out_signature_buffer), CHIP_ERROR_INVALID_ARGUMENT); - VerifyOrReturnError(IsSpanUsable(message_to_sign), CHIP_ERROR_INVALID_ARGUMENT); - VerifyOrReturnError(out_signature_buffer.size() >= signature.Capacity(), CHIP_ERROR_BUFFER_TOO_SMALL); + MutableByteSpan asn1_signature_buffer(mAsn1SignatureBytes, sizeof(mAsn1SignatureBytes)); - uint8_t privateKeyBuf[Crypto::kP256_PrivateKey_Length]; - MutableByteSpan privateKeyBufSpan(privateKeyBuf); - ReturnErrorOnFailure(GetJavaByteByMethod(mGetDeviceAttestationCertPrivateKeyMethod, privateKeyBufSpan)); - - uint8_t publicKeyBuf[Crypto::kP256_PublicKey_Length]; - MutableByteSpan publicKeyBufSpan(publicKeyBuf); - ReturnErrorOnFailure(GetJavaByteByMethod(mGetDeviceAttestationCertPublicKeyKeyMethod, publicKeyBufSpan)); - - // In a non-exemplary implementation, the public key is not needed here. It is used here merely because - // Crypto::P256Keypair is only (currently) constructable from raw keys if both private/public keys are present. - ReturnErrorOnFailure(LoadKeypairFromRaw(privateKeyBufSpan, publicKeyBufSpan, keypair)); - ReturnErrorOnFailure(keypair.ECDSA_sign_msg(message_to_sign.data(), message_to_sign.size(), signature)); + CHIP_ERROR error = GetJavaByteByMethod(mSignWithDeviceAttestationKeyMethod, message_to_sign, asn1_signature_buffer); + if (error != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "SignWithDeviceAttestationKey failed"); + return error; + } - return CopySpanToMutableSpan(ByteSpan{ signature.ConstBytes(), signature.Length() }, out_signature_buffer); + return chip::Crypto::EcdsaAsn1SignatureToRaw(32, ByteSpan(asn1_signature_buffer.data(), asn1_signature_buffer.size()), + out_signature_buffer); } diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/JNIDACProvider.h b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/JNIDACProvider.h index 1498eb66c07dcd..9c419367253c5f 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/JNIDACProvider.h +++ b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/JNIDACProvider.h @@ -33,11 +33,11 @@ class JNIDACProvider : public chip::Credentials::DeviceAttestationCredentialsPro private: CHIP_ERROR GetJavaByteByMethod(jmethodID method, chip::MutableByteSpan & out_buffer); + CHIP_ERROR GetJavaByteByMethod(jmethodID method, const chip::ByteSpan & in_buffer, chip::MutableByteSpan & out_buffer); jobject mJNIDACProviderObject = nullptr; jmethodID mGetCertificationDeclarationMethod = nullptr; jmethodID mGetFirmwareInformationMethod = nullptr; jmethodID mGetDeviceAttestationCertMethod = nullptr; jmethodID mGetProductAttestationIntermediateCertMethod = nullptr; - jmethodID mGetDeviceAttestationCertPrivateKeyMethod = nullptr; - jmethodID mGetDeviceAttestationCertPublicKeyKeyMethod = nullptr; + jmethodID mSignWithDeviceAttestationKeyMethod = nullptr; }; diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.cpp b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.cpp index 77d6c5e0e40fc1..c4af2c37add85c 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.cpp +++ b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/TvCastingApp-JNI.cpp @@ -105,11 +105,11 @@ JNI_METHOD(jboolean, initJni)(JNIEnv *, jobject, jobject jAppParameters) JNI_METHOD(void, setDACProvider)(JNIEnv *, jobject, jobject provider) { - if (!chip::Credentials::IsDeviceAttestationCredentialsProviderSet()) - { - JNIDACProvider * p = new JNIDACProvider(provider); - chip::Credentials::SetDeviceAttestationCredentialsProvider(p); - } + chip::DeviceLayer::StackLock lock; + ChipLogProgress(AppServer, "JNI_METHOD setDACProvider called"); + + JNIDACProvider * p = new JNIDACProvider(provider); + chip::Credentials::SetDeviceAttestationCredentialsProvider(p); } JNI_METHOD(jboolean, openBasicCommissioningWindow) diff --git a/examples/tv-casting-app/android/BUILD.gn b/examples/tv-casting-app/android/BUILD.gn index 35a77c84e027f3..7a12b9a9a3efa3 100644 --- a/examples/tv-casting-app/android/BUILD.gn +++ b/examples/tv-casting-app/android/BUILD.gn @@ -68,7 +68,6 @@ android_library("java") { "App/app/src/main/jni/com/chip/casting/ContentApp.java", "App/app/src/main/jni/com/chip/casting/ContentLauncherTypes.java", "App/app/src/main/jni/com/chip/casting/DACProvider.java", - "App/app/src/main/jni/com/chip/casting/DACProviderStub.java", "App/app/src/main/jni/com/chip/casting/DiscoveredNodeData.java", "App/app/src/main/jni/com/chip/casting/FailureCallback.java", "App/app/src/main/jni/com/chip/casting/MatterCallbackHandler.java", diff --git a/examples/tv-casting-app/android/README.md b/examples/tv-casting-app/android/README.md index 3b3138a0e2c61c..b9e2f716c84036 100644 --- a/examples/tv-casting-app/android/README.md +++ b/examples/tv-casting-app/android/README.md @@ -12,15 +12,15 @@ the TV. - [Matter TV Casting Android App Example](#matter-tv-casting-android-app-example) - [Requirements for building](#requirements-for-building) - [ABIs and TARGET_CPU](#abis-and-target_cpu) - - [Gradle & JDK Version](#gradle--jdk-version) + - [Gradle \& JDK Version](#gradle--jdk-version) - [Preparing for build](#preparing-for-build) - - [Building & Installing the app](#building--installing-the-app) + - [Building \& Installing the app](#building--installing-the-app)


## Requirements for building -You need Android SDK 21 & NDK downloaded to your machine. Set the +You need Android SDK 21 & NDK 23.2.8568313 downloaded to your machine. Set the `$ANDROID_HOME` environment variable to where the SDK is downloaded and the `$ANDROID_NDK_HOME` environment variable to point to where the NDK package is downloaded. diff --git a/examples/tv-casting-app/android/args.gni b/examples/tv-casting-app/android/args.gni index e3a20c5055dd91..cf7e1648cc6674 100644 --- a/examples/tv-casting-app/android/args.gni +++ b/examples/tv-casting-app/android/args.gni @@ -31,3 +31,5 @@ chip_enable_additional_data_advertising = true chip_enable_rotating_device_id = true chip_config_network_layer_ble = false + +chip_max_discovered_ip_addresses = 20 diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/AppParameters.h b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/AppParameters.h index 9e445e25fa63d7..34585289fb6d5c 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/AppParameters.h +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/AppParameters.h @@ -35,8 +35,6 @@ @property NSData * spake2pVerifierBase64; -@property DeviceAttestationCredentialsHolder * deviceAttestationCredentials; - @end #endif /* AppParameters_h */ diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.h b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.h index 234a92f905023f..98376a62ddd436 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.h +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.h @@ -37,6 +37,10 @@ clientQueue:(dispatch_queue_t _Nonnull)clientQueue initAppStatusHandler:(nullable void (^)(bool))initAppStatusHandler; +- (void)setDacHolder:(DeviceAttestationCredentialsHolder * _Nonnull)deviceAttestationCredentials + clientQueue:(dispatch_queue_t _Nonnull)clientQueue + setDacHolderStatus:(void (^_Nonnull)(MatterError * _Nonnull))setDacHolderStatus; + /*! @brief Browse for on-network commissioner TVs @@ -192,7 +196,7 @@ @param responseHandler Called when purgeCache completes */ -- (void)purgeCache:(dispatch_queue_t _Nonnull)clientQueue responseHandler:(void (^)(MatterError * _Nonnull))responseHandler; +- (void)purgeCache:(dispatch_queue_t _Nonnull)clientQueue responseHandler:(void (^_Nonnull)(MatterError * _Nonnull))responseHandler; /*! @brief Start the Matter server and reconnect to a previously connected Video Player (if any). This API is async diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.mm b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.mm index a665bb3d24f29d..bac90428ce2417 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.mm +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/CastingServerBridge.mm @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -129,7 +128,6 @@ - (MatterError *)initializeApp:(AppParameters * _Nullable)appParameters CHIP_ERROR err = CHIP_NO_ERROR; _commissionableDataProvider = new CommissionableDataProviderImpl(); - _deviceAttestationCredentialsProvider = chip::Credentials::Examples::GetExampleDACProvider(); _appParameters = appParameters; AppParams cppAppParams; @@ -171,45 +169,6 @@ - (MatterError *)initializeApp:(AppParameters * _Nullable)appParameters ChipLogError(AppServer, "Failed to initialize CommissionableDataProvider: %s", ErrorStr(err)); return [[MatterError alloc] initWithCode:err.AsInteger() message:[NSString stringWithUTF8String:err.AsString()]]; } - - if (_appParameters.deviceAttestationCredentials != nil) { - NSData * certificationDeclarationNsData = _appParameters.deviceAttestationCredentials.getCertificationDeclaration; - chip::MutableByteSpan certificationDeclaration - = chip::MutableByteSpan(const_cast(static_cast(certificationDeclarationNsData.bytes)), - certificationDeclarationNsData.length); - - NSData * firmwareInformationNsData = _appParameters.deviceAttestationCredentials.getFirmwareInformation; - chip::MutableByteSpan firmwareInformation - = chip::MutableByteSpan(const_cast(static_cast(firmwareInformationNsData.bytes)), - firmwareInformationNsData.length); - - NSData * deviceAttestationCertNsData = _appParameters.deviceAttestationCredentials.getDeviceAttestationCert; - chip::MutableByteSpan deviceAttestationCert - = chip::MutableByteSpan(const_cast(static_cast(deviceAttestationCertNsData.bytes)), - deviceAttestationCertNsData.length); - - NSData * productAttestationIntermediateCertNsData - = _appParameters.deviceAttestationCredentials.getProductAttestationIntermediateCert; - chip::MutableByteSpan productAttestationIntermediateCert = chip::MutableByteSpan( - const_cast(static_cast(productAttestationIntermediateCertNsData.bytes)), - productAttestationIntermediateCertNsData.length); - - NSData * deviceAttestationCertPrivateKeyNsData - = _appParameters.deviceAttestationCredentials.getDeviceAttestationCertPrivateKey; - chip::MutableByteSpan deviceAttestationCertPrivateKey = chip::MutableByteSpan( - const_cast(static_cast(deviceAttestationCertPrivateKeyNsData.bytes)), - deviceAttestationCertPrivateKeyNsData.length); - - NSData * deviceAttestationCertPublicKeyKeyNsData - = _appParameters.deviceAttestationCredentials.getDeviceAttestationCertPublicKeyKey; - chip::MutableByteSpan deviceAttestationCertPublicKeyKey = chip::MutableByteSpan( - const_cast(static_cast(deviceAttestationCertPublicKeyKeyNsData.bytes)), - deviceAttestationCertPublicKeyKeyNsData.length); - - _deviceAttestationCredentialsProvider = new DeviceAttestationCredentialsProviderImpl(&certificationDeclaration, - &firmwareInformation, &deviceAttestationCert, &productAttestationIntermediateCert, &deviceAttestationCertPrivateKey, - &deviceAttestationCertPublicKeyKey); - } } chip::DeviceLayer::SetCommissionableDataProvider(_commissionableDataProvider); @@ -217,9 +176,6 @@ - (MatterError *)initializeApp:(AppParameters * _Nullable)appParameters _commissionableDataProvider->GetSetupDiscriminator(setupDiscriminator); _onboardingPayload = [[OnboardingPayload alloc] initWithSetupPasscode:setupPasscode setupDiscriminator:setupDiscriminator]; - // Initialize device attestation config - SetDeviceAttestationCredentialsProvider(_deviceAttestationCredentialsProvider); - // Initialize device attestation verifier from a constant version { // TODO: Replace testingRootStore with a AttestationTrustStore that has the necessary official PAA roots available @@ -280,6 +236,43 @@ - (MatterError *)initializeApp:(AppParameters * _Nullable)appParameters message:[NSString stringWithUTF8String:CHIP_NO_ERROR.AsString()]]; } +- (void)setDacHolder:(DeviceAttestationCredentialsHolder * _Nonnull)deviceAttestationCredentials + clientQueue:(dispatch_queue_t _Nonnull)clientQueue + setDacHolderStatus:(void (^_Nonnull)(MatterError * _Nonnull))setDacHolderStatus +{ + dispatch_sync(_chipWorkQueue, ^{ + NSData * certificationDeclarationNsData = deviceAttestationCredentials.getCertificationDeclaration; + chip::MutableByteSpan certificationDeclaration + = chip::MutableByteSpan(const_cast(static_cast(certificationDeclarationNsData.bytes)), + certificationDeclarationNsData.length); + + NSData * firmwareInformationNsData = deviceAttestationCredentials.getFirmwareInformation; + chip::MutableByteSpan firmwareInformation = chip::MutableByteSpan( + const_cast(static_cast(firmwareInformationNsData.bytes)), firmwareInformationNsData.length); + + NSData * deviceAttestationCertNsData = deviceAttestationCredentials.getDeviceAttestationCert; + chip::MutableByteSpan deviceAttestationCert + = chip::MutableByteSpan(const_cast(static_cast(deviceAttestationCertNsData.bytes)), + deviceAttestationCertNsData.length); + + NSData * productAttestationIntermediateCertNsData = deviceAttestationCredentials.getProductAttestationIntermediateCert; + chip::MutableByteSpan productAttestationIntermediateCert = chip::MutableByteSpan( + const_cast(static_cast(productAttestationIntermediateCertNsData.bytes)), + productAttestationIntermediateCertNsData.length); + + self->_deviceAttestationCredentialsProvider + = new DeviceAttestationCredentialsProviderImpl(&certificationDeclaration, &firmwareInformation, &deviceAttestationCert, + &productAttestationIntermediateCert, deviceAttestationCredentials.getDeviceAttestationCertPrivateKeyRef); + + SetDeviceAttestationCredentialsProvider(self->_deviceAttestationCredentialsProvider); + + dispatch_async(clientQueue, ^{ + setDacHolderStatus([[MatterError alloc] initWithCode:CHIP_NO_ERROR.AsInteger() + message:[NSString stringWithUTF8String:CHIP_NO_ERROR.AsString()]]); + }); + }); +} + - (void)discoverCommissioners:(dispatch_queue_t _Nonnull)clientQueue discoveryRequestSentHandler:(nullable void (^)(bool))discoveryRequestSentHandler discoveredCommissionerHandler:(nullable void (^)(DiscoveredNodeData *))discoveredCommissionerHandler diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/ConversionUtils.mm b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/ConversionUtils.mm index 74f41c5203d022..a50195987c89ff 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/ConversionUtils.mm +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/ConversionUtils.mm @@ -137,7 +137,7 @@ + (DiscoveredNodeData *)convertToObjCDiscoveredNodeDataFrom:(const chip::Dnssd:: } for (size_t i = 0; i < cppDiscoveredNodedata->resolutionData.numIPs; i++) { char addrCString[chip::Inet::IPAddress::kMaxStringLength]; - cppDiscoveredNodedata->resolutionData.ipAddress->ToString(addrCString, chip::Inet::IPAddress::kMaxStringLength); + cppDiscoveredNodedata->resolutionData.ipAddress[i].ToString(addrCString, chip::Inet::IPAddress::kMaxStringLength); objCDiscoveredNodeData.ipAddresses[i] = [NSString stringWithCString:addrCString encoding:NSASCIIStringEncoding]; } return objCDiscoveredNodeData; diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/DeviceAttestationCredentialsHolder.h b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/DeviceAttestationCredentialsHolder.h index b8d8ea491c0ca6..44d4dee2169c43 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/DeviceAttestationCredentialsHolder.h +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/DeviceAttestationCredentialsHolder.h @@ -16,6 +16,7 @@ */ #import +#import #ifndef DeviceAttestationCredentialsHolder_h #define DeviceAttestationCredentialsHolder_h @@ -27,8 +28,7 @@ firmwareInformation:(NSData * _Nonnull)firmwareInformation deviceAttestationCert:(NSData * _Nonnull)deviceAttestationCert productAttestationIntermediateCert:(NSData * _Nonnull)productAttestationIntermediateCert - deviceAttestationCertPrivateKey:(NSData * _Nonnull)deviceAttestationCertPrivateKey - deviceAttestationCertPublicKeyKey:(NSData * _Nonnull)deviceAttestationCertPublicKeyKey; + deviceAttestationCertPrivateKeyRef:(SecKeyRef _Nonnull)deviceAttestationCertPrivateKeyRef; - (NSData * _Nonnull)getCertificationDeclaration; @@ -38,9 +38,7 @@ - (NSData * _Nonnull)getProductAttestationIntermediateCert; -- (NSData * _Nonnull)getDeviceAttestationCertPrivateKey; - -- (NSData * _Nonnull)getDeviceAttestationCertPublicKeyKey; +- (SecKeyRef _Nonnull)getDeviceAttestationCertPrivateKeyRef; @end diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/DeviceAttestationCredentialsHolder.m b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/DeviceAttestationCredentialsHolder.m index 54e19d55bfd4af..1f10ec47f7f185 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/DeviceAttestationCredentialsHolder.m +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/DeviceAttestationCredentialsHolder.m @@ -29,9 +29,7 @@ @interface DeviceAttestationCredentialsHolder () @property NSData * productAttestationIntermediateCert; -@property NSData * deviceAttestationCertPrivateKey; - -@property NSData * deviceAttestationCertPublicKeyKey; +@property SecKeyRef deviceAttestationCertPrivateKeyRef; @end @@ -42,8 +40,7 @@ @implementation DeviceAttestationCredentialsHolder firmwareInformation:(NSData * _Nonnull)firmwareInformation deviceAttestationCert:(NSData * _Nonnull)deviceAttestationCert productAttestationIntermediateCert:(NSData * _Nonnull)productAttestationIntermediateCert - deviceAttestationCertPrivateKey:(NSData * _Nonnull)deviceAttestationCertPrivateKey - deviceAttestationCertPublicKeyKey:(NSData * _Nonnull)deviceAttestationCertPublicKeyKey + deviceAttestationCertPrivateKeyRef:(SecKeyRef _Nonnull)deviceAttestationCertPrivateKeyRef { self = [super init]; if (self) { @@ -51,8 +48,7 @@ @implementation DeviceAttestationCredentialsHolder _firmwareInformation = firmwareInformation; _deviceAttestationCert = deviceAttestationCert; _productAttestationIntermediateCert = productAttestationIntermediateCert; - _deviceAttestationCertPrivateKey = deviceAttestationCertPrivateKey; - _deviceAttestationCertPublicKeyKey = deviceAttestationCertPublicKeyKey; + _deviceAttestationCertPrivateKeyRef = deviceAttestationCertPrivateKeyRef; } return self; } @@ -62,28 +58,24 @@ - (NSData * _Nonnull)getCertificationDeclaration return _certificationDeclaration; } -- (NSData * _Nonnull)getFirmwareInformation; +- (NSData * _Nonnull)getFirmwareInformation { return _firmwareInformation; } -- (NSData * _Nonnull)getDeviceAttestationCert; +- (NSData * _Nonnull)getDeviceAttestationCert { return _deviceAttestationCert; } -- (NSData * _Nonnull)getProductAttestationIntermediateCert; +- (NSData * _Nonnull)getProductAttestationIntermediateCert { return _productAttestationIntermediateCert; } -- (NSData * _Nonnull)getDeviceAttestationCertPrivateKey; +- (SecKeyRef)getDeviceAttestationCertPrivateKeyRef { - return _deviceAttestationCertPrivateKey; + return _deviceAttestationCertPrivateKeyRef; } -- (NSData * _Nonnull)getDeviceAttestationCertPublicKeyKey; -{ - return _deviceAttestationCertPublicKeyKey; -} @end diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/DeviceAttestationCredentialsProviderImpl.hpp b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/DeviceAttestationCredentialsProviderImpl.hpp index ba3558f400560a..21d63ba88d2d05 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/DeviceAttestationCredentialsProviderImpl.hpp +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/DeviceAttestationCredentialsProviderImpl.hpp @@ -21,6 +21,8 @@ #include #include +#include + class DeviceAttestationCredentialsProviderImpl : public chip::Credentials::DeviceAttestationCredentialsProvider { public: @@ -28,8 +30,7 @@ class DeviceAttestationCredentialsProviderImpl : public chip::Credentials::Devic chip::MutableByteSpan * firmwareInformation, chip::MutableByteSpan * deviceAttestationCert, chip::MutableByteSpan * productAttestationIntermediateCert, - chip::MutableByteSpan * deviceAttestationCertPrivateKey, - chip::MutableByteSpan * deviceAttestationCertPublicKeyKey); + SecKeyRef deviceAttestationCertPrivateKeyRef); CHIP_ERROR GetCertificationDeclaration(chip::MutableByteSpan & outCertificationDeclaration) override; CHIP_ERROR GetFirmwareInformation(chip::MutableByteSpan & outFirmwareInformation) override; @@ -43,15 +44,5 @@ class DeviceAttestationCredentialsProviderImpl : public chip::Credentials::Devic chip::MutableByteSpan mFirmwareInformation; chip::MutableByteSpan mDeviceAttestationCert; chip::MutableByteSpan mProductAttestationIntermediateCert; - chip::MutableByteSpan mDeviceAttestationCertPrivateKey; - chip::MutableByteSpan mDeviceAttestationCertPublicKeyKey; - - CHIP_ERROR LoadKeypairFromRaw(chip::ByteSpan privateKey, chip::ByteSpan publicKey, chip::Crypto::P256Keypair & keypair) - { - chip::Crypto::P256SerializedKeypair serialized_keypair; - ReturnErrorOnFailure(serialized_keypair.SetLength(privateKey.size() + publicKey.size())); - memcpy(serialized_keypair.Bytes(), publicKey.data(), publicKey.size()); - memcpy(serialized_keypair.Bytes() + publicKey.size(), privateKey.data(), privateKey.size()); - return keypair.Deserialize(serialized_keypair); - } + SecKeyRef mDeviceAttestationCertPrivateKeyRef; }; diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/DeviceAttestationCredentialsProviderImpl.mm b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/DeviceAttestationCredentialsProviderImpl.mm index 59a0a70f88e0f5..7008ffba969e72 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/DeviceAttestationCredentialsProviderImpl.mm +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/DeviceAttestationCredentialsProviderImpl.mm @@ -18,11 +18,11 @@ #include "DeviceAttestationCredentialsProviderImpl.hpp" #import +#import DeviceAttestationCredentialsProviderImpl::DeviceAttestationCredentialsProviderImpl(chip::MutableByteSpan * certificationDeclaration, chip::MutableByteSpan * firmwareInformation, chip::MutableByteSpan * deviceAttestationCert, - chip::MutableByteSpan * productAttestationIntermediateCert, chip::MutableByteSpan * deviceAttestationCertPrivateKey, - chip::MutableByteSpan * deviceAttestationCertPublicKeyKey) + chip::MutableByteSpan * productAttestationIntermediateCert, SecKeyRef deviceAttestationCertPrivateKeyRef) { if (certificationDeclaration != nullptr) { mCertificationDeclaration @@ -47,19 +47,7 @@ productAttestationIntermediateCert->size()); } - if (deviceAttestationCertPrivateKey != nullptr) { - mDeviceAttestationCertPrivateKey - = chip::MutableByteSpan(new uint8_t[deviceAttestationCertPrivateKey->size()], deviceAttestationCertPrivateKey->size()); - memcpy(mDeviceAttestationCertPrivateKey.data(), deviceAttestationCertPrivateKey->data(), - deviceAttestationCertPrivateKey->size()); - } - - if (deviceAttestationCertPublicKeyKey != nullptr) { - mDeviceAttestationCertPublicKeyKey = chip::MutableByteSpan( - new uint8_t[deviceAttestationCertPublicKeyKey->size()], deviceAttestationCertPublicKeyKey->size()); - memcpy(mDeviceAttestationCertPublicKeyKey.data(), deviceAttestationCertPublicKeyKey->data(), - deviceAttestationCertPublicKeyKey->size()); - } + mDeviceAttestationCertPrivateKeyRef = deviceAttestationCertPrivateKeyRef; } CHIP_ERROR DeviceAttestationCredentialsProviderImpl::GetCertificationDeclaration( @@ -121,17 +109,56 @@ const chip::ByteSpan & messageToSign, chip::MutableByteSpan & outSignatureBuffer) { ChipLogProgress(AppServer, "DeviceAttestationCredentialsProviderImpl::SignWithDeviceAttestationKey called"); - chip::Crypto::P256ECDSASignature signature; - chip::Crypto::P256Keypair keypair; - VerifyOrReturnError(IsSpanUsable(outSignatureBuffer), CHIP_ERROR_INVALID_ARGUMENT); - VerifyOrReturnError(IsSpanUsable(messageToSign), CHIP_ERROR_INVALID_ARGUMENT); - VerifyOrReturnError(outSignatureBuffer.size() >= signature.Capacity(), CHIP_ERROR_BUFFER_TOO_SMALL); + CHIP_ERROR result = CHIP_NO_ERROR; + CFDataRef dataToSign = nil; + CFDataRef asn1SignatureData = nil; + uint8_t mAsn1SignatureBytes[256]; + chip::MutableByteSpan asn1SignatureByteSpan = chip::MutableByteSpan(mAsn1SignatureBytes, sizeof(mAsn1SignatureBytes)); + CFErrorRef error = nil; + size_t signatureLen = 0; + + do { + dataToSign = CFDataCreate(CFAllocatorGetDefault(), messageToSign.data(), messageToSign.size()); + if (nil == dataToSign) { + ChipLogError( + AppServer, "DeviceAttestationCredentialsProviderImpl::SignWithDeviceAttestationKey failed to create buffer"); + result = CHIP_ERROR_NO_MEMORY; + break; + } + + asn1SignatureData = SecKeyCreateSignature( + mDeviceAttestationCertPrivateKeyRef, kSecKeyAlgorithmECDSASignatureMessageX962SHA256, dataToSign, &error); + if (nil != error || nil == asn1SignatureData) { + ChipLogError(AppServer, + "DeviceAttestationCredentialsProviderImpl::SignWithDeviceAttestationKey failed to sign the message. error = %lu", + CFErrorGetCode(error)); + result = CHIP_ERROR_INVALID_ARGUMENT; + break; + } + + signatureLen = CFDataGetLength(asn1SignatureData); - // In a non-exemplary implementation, the public key is not needed here. It is used here merely because - // Crypto::P256Keypair is only (currently) constructable from raw keys if both private/public keys are present. - ReturnErrorOnFailure(LoadKeypairFromRaw(mDeviceAttestationCertPrivateKey, mDeviceAttestationCertPublicKeyKey, keypair)); - ReturnErrorOnFailure(keypair.ECDSA_sign_msg(messageToSign.data(), messageToSign.size(), signature)); + CFDataGetBytes(asn1SignatureData, CFRangeMake(0, signatureLen), asn1SignatureByteSpan.data()); + asn1SignatureByteSpan.reduce_size(signatureLen); + + CHIP_ERROR conversionError = chip::Crypto::EcdsaAsn1SignatureToRaw( + 32, chip::ByteSpan(asn1SignatureByteSpan.data(), asn1SignatureByteSpan.size()), outSignatureBuffer); + if (CHIP_NO_ERROR != conversionError) { + ChipLogError(AppServer, + "DeviceAttestationCredentialsProviderImpl::SignWithDeviceAttestationKey failed to convert to raw signature."); + result = conversionError; + break; + } + } while (0); + + if (dataToSign != nil) { + CFRelease(dataToSign); + } + + if (asn1SignatureData != nil) { + CFRelease(asn1SignatureData); + } - return CopySpanToMutableSpan(chip::ByteSpan { signature.ConstBytes(), signature.Length() }, outSignatureBuffer); + return result; } diff --git a/examples/tv-casting-app/darwin/TvCasting/TvCasting.xcodeproj/project.pbxproj b/examples/tv-casting-app/darwin/TvCasting/TvCasting.xcodeproj/project.pbxproj index 28e88cc4b6dad2..68c5808353ab5a 100644 --- a/examples/tv-casting-app/darwin/TvCasting/TvCasting.xcodeproj/project.pbxproj +++ b/examples/tv-casting-app/darwin/TvCasting/TvCasting.xcodeproj/project.pbxproj @@ -14,6 +14,7 @@ 3CA1CA7A28E281080023ED44 /* ClusterSelectorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CA1CA7928E281080023ED44 /* ClusterSelectorView.swift */; }; 3CA1CA7C28E282150023ED44 /* MediaPlaybackView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CA1CA7B28E282150023ED44 /* MediaPlaybackView.swift */; }; 3CA1CA7E28E284950023ED44 /* MediaPlaybackViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CA1CA7D28E284950023ED44 /* MediaPlaybackViewModel.swift */; }; + 3CAC955B29BA948700BEA5C3 /* ExampleDAC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CAC955A29BA948700BEA5C3 /* ExampleDAC.swift */; }; 3CC0E8FA2841DD3400EC6A18 /* TvCastingApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CC0E8F92841DD3400EC6A18 /* TvCastingApp.swift */; }; 3CC0E8FC2841DD3400EC6A18 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CC0E8FB2841DD3400EC6A18 /* ContentView.swift */; }; 3CC0E8FE2841DD3500EC6A18 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3CC0E8FD2841DD3500EC6A18 /* Assets.xcassets */; }; @@ -59,6 +60,7 @@ 3CA1CA7928E281080023ED44 /* ClusterSelectorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClusterSelectorView.swift; sourceTree = ""; }; 3CA1CA7B28E282150023ED44 /* MediaPlaybackView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaPlaybackView.swift; sourceTree = ""; }; 3CA1CA7D28E284950023ED44 /* MediaPlaybackViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaPlaybackViewModel.swift; sourceTree = ""; }; + 3CAC955A29BA948700BEA5C3 /* ExampleDAC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleDAC.swift; sourceTree = ""; }; 3CC0E8F62841DD3400EC6A18 /* TvCasting.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TvCasting.app; sourceTree = BUILT_PRODUCTS_DIR; }; 3CC0E8F92841DD3400EC6A18 /* TvCastingApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TvCastingApp.swift; sourceTree = ""; }; 3CC0E8FB2841DD3400EC6A18 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; @@ -125,6 +127,7 @@ 3C7507B62853A3AD00D7DB3A /* CommissionerDiscoveryViewModel.swift */, 3C7507AE28529A5F00D7DB3A /* CommissioningView.swift */, 3C7507B82853EFF000D7DB3A /* CommissioningViewModel.swift */, + 3CAC955A29BA948700BEA5C3 /* ExampleDAC.swift */, 3CA1CA7928E281080023ED44 /* ClusterSelectorView.swift */, 3CA19434285BA780004768D5 /* ContentLauncherView.swift */, 3CA19436285BA877004768D5 /* ContentLauncherViewModel.swift */, @@ -235,6 +238,7 @@ EAF14299296D561900E17793 /* CertTestView.swift in Sources */, 3CCB8747286A5D0F00771BAD /* CommissioningView.swift in Sources */, 3CCB8748286A5D0F00771BAD /* CommissioningViewModel.swift in Sources */, + 3CAC955B29BA948700BEA5C3 /* ExampleDAC.swift in Sources */, 3CA1CA7E28E284950023ED44 /* MediaPlaybackViewModel.swift in Sources */, 3CCB8749286A5D0F00771BAD /* ContentLauncherView.swift in Sources */, 3CCB874A286A5D0F00771BAD /* ContentLauncherViewModel.swift in Sources */, diff --git a/examples/tv-casting-app/darwin/TvCasting/TvCasting/CommissioningViewModel.swift b/examples/tv-casting-app/darwin/TvCasting/TvCasting/CommissioningViewModel.swift index 1c2feaa3aac024..a0d41633a750fa 100644 --- a/examples/tv-casting-app/darwin/TvCasting/TvCasting/CommissioningViewModel.swift +++ b/examples/tv-casting-app/darwin/TvCasting/TvCasting/CommissioningViewModel.swift @@ -34,6 +34,27 @@ class CommissioningViewModel: ObservableObject { @Published var connectionStatus: String?; func prepareForCommissioning(selectedCommissioner: DiscoveredNodeData?) { + if let castingServerBridge = CastingServerBridge.getSharedInstance() + { + castingServerBridge.setDacHolder(ExampleDAC(), clientQueue: DispatchQueue.main, setDacHolderStatus: { (error: MatterError) -> () in + DispatchQueue.main.async { + self.Log.info("CommissioningViewModel.setDacHolder status was \(error)") + if(error.code == 0) + { + self.openBasicCommissioningWindow() + } + } + }) + } + + // Send User directed commissioning request if a commissioner with a known IP addr was selected + if(selectedCommissioner != nil && selectedCommissioner!.numIPs > 0) + { + sendUserDirectedCommissioningRequest(selectedCommissioner: selectedCommissioner) + } + } + + private func openBasicCommissioningWindow() { if let castingServerBridge = CastingServerBridge.getSharedInstance() { castingServerBridge.openBasicCommissioningWindow(DispatchQueue.main, @@ -52,14 +73,14 @@ class CommissioningViewModel: ObservableObject { DispatchQueue.main.async { self.connectionSuccess = true self.connectionStatus = "Connected to \(String(describing: videoPlayer))" - self.Log.info("ConnectionViewModel.verifyOrEstablishConnection.onConnectionSuccessCallback called with \(videoPlayer.nodeId)") + self.Log.info("CommissioningViewModel.verifyOrEstablishConnection.onConnectionSuccessCallback called with \(videoPlayer.nodeId)") } }, onConnectionFailureCallback: { (error: MatterError) -> () in DispatchQueue.main.async { self.connectionSuccess = false self.connectionStatus = "Failed to connect to video player!" - self.Log.info("ConnectionViewModel.verifyOrEstablishConnection.onConnectionFailureCallback called with \(error)") + self.Log.info("CommissioningViewModel.verifyOrEstablishConnection.onConnectionFailureCallback called with \(error)") } }, onNewOrUpdatedEndpointCallback: { (contentApp: ContentApp) -> () in @@ -68,12 +89,7 @@ class CommissioningViewModel: ObservableObject { } }) } - - // Send User directed commissioning request if a commissioner with a known IP addr was selected - if(selectedCommissioner != nil && selectedCommissioner!.numIPs > 0) - { - sendUserDirectedCommissioningRequest(selectedCommissioner: selectedCommissioner) - } + } private func sendUserDirectedCommissioningRequest(selectedCommissioner: DiscoveredNodeData?) { diff --git a/examples/tv-casting-app/darwin/TvCasting/TvCasting/ExampleDAC.swift b/examples/tv-casting-app/darwin/TvCasting/TvCasting/ExampleDAC.swift new file mode 100644 index 00000000000000..d05423b711292c --- /dev/null +++ b/examples/tv-casting-app/darwin/TvCasting/TvCasting/ExampleDAC.swift @@ -0,0 +1,60 @@ +/** + * + * Copyright (c) 2020-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. + * 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 Foundation +import os.log + +class ExampleDAC : DeviceAttestationCredentialsHolder { + let kDevelopmentDAC_Cert_FFF1_8001: Data = Data(base64Encoded: "MIIB5zCCAY6gAwIBAgIIac3xDenlTtEwCgYIKoZIzj0EAwIwPTElMCMGA1UEAwwcTWF0dGVyIERldiBQQUkgMHhGRkYxIG5vIFBJRDEUMBIGCisGAQQBgqJ8AgEMBEZGRjEwIBcNMjIwMjA1MDAwMDAwWhgPOTk5OTEyMzEyMzU5NTlaMFMxJTAjBgNVBAMMHE1hdHRlciBEZXYgREFDIDB4RkZGMS8weDgwMDExFDASBgorBgEEAYKifAIBDARGRkYxMRQwEgYKKwYBBAGConwCAgwEODAwMTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABEY6xpNCkQoOVYj8b/Vrtj5i7M7LFI99TrA+5VJgFBV2fRalxmP3k+SRIyYLgpenzX58/HsxaznZjpDSk3dzjoKjYDBeMAwGA1UdEwEB/wQCMAAwDgYDVR0PAQH/BAQDAgeAMB0GA1UdDgQWBBSI3eezADgpMs/3NMBGJIEPRBaKbzAfBgNVHSMEGDAWgBRjVA5H9kscONE4hKRi0WwZXY/7PDAKBggqhkjOPQQDAgNHADBEAiABJ6J7S0RhDuL83E0reIVWNmC8D3bxchntagjfsrPBzQIga1ngr0Xz6yqFuRnTVzFSjGAoxBUjlUXhCOTlTnCXE1M=")!; + let kDevelopmentDAC_PrivateKey_FFF1_8001: Data = Data(base64Encoded: "qrYAroroqrfXNifCF7fCBHCcppRq9fL3UwgzpStE+/8=")!; + let kDevelopmentDAC_PublicKey_FFF1_8001: Data = Data(base64Encoded: "BEY6xpNCkQoOVYj8b/Vrtj5i7M7LFI99TrA+5VJgFBV2fRalxmP3k+SRIyYLgpenzX58/HsxaznZjpDSk3dzjoI=")!; + let KPAI_FFF1_8000_Cert_Array: Data = Data(base64Encoded: "MIIByzCCAXGgAwIBAgIIVq2CIq2UW2QwCgYIKoZIzj0EAwIwMDEYMBYGA1UEAwwPTWF0dGVyIFRlc3QgUEFBMRQwEgYKKwYBBAGConwCAQwERkZGMTAgFw0yMjAyMDUwMDAwMDBaGA85OTk5MTIzMTIzNTk1OVowPTElMCMGA1UEAwwcTWF0dGVyIERldiBQQUkgMHhGRkYxIG5vIFBJRDEUMBIGCisGAQQBgqJ8AgEMBEZGRjEwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAARBmpMVwhc+DIyHbQPM/JRIUmR/f+xeUIL0BZko7KiUxZQVEwmsYx5MsDOSr2hLC6+35ls7gWLC9Sv5MbjneqqCo2YwZDASBgNVHRMBAf8ECDAGAQH/AgEAMA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUY1QOR/ZLHDjROISkYtFsGV2P+zwwHwYDVR0jBBgwFoAUav0idx9RH+y/FkGXZxDc3DGhcX4wCgYIKoZIzj0EAwIDSAAwRQIhALLvJ/Sa6bUPuR7qyUxNC9u415KcbLiPrOUpNo0SBUwMAiBlXckrhr2QmIKmxiF3uCXX0F7b58Ivn+pxIg5+pwP4kQ==")!; + let kCertificationDeclaration: Data = Data(base64Encoded: "MIICGQYJKoZIhvcNAQcCoIICCjCCAgYCAQMxDTALBglghkgBZQMEAgEwggFxBgkqhkiG9w0BBwGgggFiBIIBXhUkAAElAfH/NgIFAIAFAYAFAoAFA4AFBIAFBYAFBoAFB4AFCIAFCYAFCoAFC4AFDIAFDYAFDoAFD4AFEIAFEYAFEoAFE4AFFIAFFYAFFoAFF4AFGIAFGYAFGoAFG4AFHIAFHYAFHoAFH4AFIIAFIYAFIoAFI4AFJIAFJYAFJoAFJ4AFKIAFKYAFKoAFK4AFLIAFLYAFLoAFL4AFMIAFMYAFMoAFM4AFNIAFNYAFNoAFN4AFOIAFOYAFOoAFO4AFPIAFPYAFPoAFP4AFQIAFQYAFQoAFQ4AFRIAFRYAFRoAFR4AFSIAFSYAFSoAFS4AFTIAFTYAFToAFT4AFUIAFUYAFUoAFU4AFVIAFVYAFVoAFV4AFWIAFWYAFWoAFW4AFXIAFXYAFXoAFX4AFYIAFYYAFYoAFY4AYJAMWLAQTWklHMjAxNDJaQjMzMDAwMy0yNCQFACQGACUHlCYkCAAYMX0wewIBA4AUYvqCM1ms+qmWPhz6FArd9QTzcWAwCwYJYIZIAWUDBAIBMAoGCCqGSM49BAMCBEcwRQIgJOXR9Hp9ew0gaibvaZt8l1e3LUaQid4xkuZ4x0Xn9gwCIQD4qi+nEfy3m5fjl87aZnuuRk4r0//fw8zteqjKX0wafA==")!; + + + override func getCertificationDeclaration() -> Data { + return kCertificationDeclaration + } + + override func getFirmwareInformation() -> Data { + return Data() + } + + override func getDeviceAttestationCert() -> Data { + return kDevelopmentDAC_Cert_FFF1_8001 + } + + override func getProductAttestationIntermediateCert() -> Data { + return KPAI_FFF1_8000_Cert_Array + } + + override func getDeviceAttestationCertPrivateKeyRef() -> Unmanaged { + var privateKey = Data() + privateKey.append(kDevelopmentDAC_PublicKey_FFF1_8001); + privateKey.append(kDevelopmentDAC_PrivateKey_FFF1_8001); + + let privateKeyRef: SecKey = SecKeyCreateWithData(privateKey as NSData, + [ + kSecAttrKeyType: kSecAttrKeyTypeECSECPrimeRandom, + kSecAttrKeyClass: kSecAttrKeyClassPrivate, + kSecAttrKeySizeInBits: 256 + ] as NSDictionary, nil)! + + return Unmanaged.passRetained(privateKeyRef); + } +} diff --git a/examples/tv-casting-app/darwin/args.gni b/examples/tv-casting-app/darwin/args.gni index 64353389c5285f..6a8033ab8ac9d0 100644 --- a/examples/tv-casting-app/darwin/args.gni +++ b/examples/tv-casting-app/darwin/args.gni @@ -26,8 +26,13 @@ chip_project_config_include_dirs += [ "${chip_root}/config/ios" ] chip_build_libshell = true +# Example Credentials like ExampleDAC.h/cpp are not required for the tv-casting-app +chip_build_example_creds = false + chip_enable_additional_data_advertising = true chip_enable_rotating_device_id = true chip_config_network_layer_ble = false + +chip_max_discovered_ip_addresses = 20 diff --git a/examples/tv-casting-app/linux/args.gni b/examples/tv-casting-app/linux/args.gni index 3175a832930e5e..f882ed23024643 100644 --- a/examples/tv-casting-app/linux/args.gni +++ b/examples/tv-casting-app/linux/args.gni @@ -29,3 +29,5 @@ chip_build_libshell = true chip_enable_additional_data_advertising = true chip_enable_rotating_device_id = true + +chip_max_discovered_ip_addresses = 20 diff --git a/examples/tv-casting-app/tv-casting-common/include/CHIPProjectAppConfig.h b/examples/tv-casting-app/tv-casting-common/include/CHIPProjectAppConfig.h index 748c048730c7ce..11f82cf6434c9b 100644 --- a/examples/tv-casting-app/tv-casting-common/include/CHIPProjectAppConfig.h +++ b/examples/tv-casting-app/tv-casting-common/include/CHIPProjectAppConfig.h @@ -41,7 +41,7 @@ #define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONABLE_DEVICE_TYPE 1 -#define CHIP_DEVICE_CONFIG_DEVICE_TYPE 35 // 0x0023 = 35 = Video Player +#define CHIP_DEVICE_CONFIG_DEVICE_TYPE 41 // 0x0029 = 41 = Video Client #define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONABLE_DEVICE_NAME 1 diff --git a/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter b/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter index 0b4a0aec6eea00..17f0d76851cc67 100644 --- a/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter +++ b/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter @@ -1,9 +1,9 @@ // This IDL was generated automatically by ZAP. // It is for view/code review purposes only. -struct LabelStruct { - char_string<16> label = 0; - char_string<16> value = 1; +struct ApplicationStruct { + int16u catalogVendorID = 0; + char_string applicationID = 1; } /** Attributes and commands for putting a device into Identification mode (e.g. flashing a light). */ @@ -111,123 +111,6 @@ server cluster Groups = 4 { fabric command access(invoke: manage) AddGroupIfIdentifying(AddGroupIfIdentifyingRequest): DefaultSuccess = 5; } -/** Attributes and commands for scene configuration and manipulation. */ -server cluster Scenes = 5 { - bitmap ScenesCopyMode : BITMAP8 { - kCopyAllScenes = 0x1; - } - - bitmap ScenesFeature : BITMAP32 { - kSceneNames = 0x1; - } - - struct ExtensionFieldSet { - cluster_id clusterID = 0; - AttributeValuePair attributeValueList[] = 1; - } - - struct AttributeValuePair { - optional attrib_id attributeID = 0; - int8u attributeValue[] = 1; - } - - readonly attribute int8u sceneCount = 0; - readonly attribute int8u currentScene = 1; - readonly attribute group_id currentGroup = 2; - readonly attribute boolean sceneValid = 3; - readonly attribute bitmap8 nameSupport = 4; - readonly attribute command_id generatedCommandList[] = 65528; - readonly attribute command_id acceptedCommandList[] = 65529; - readonly attribute event_id eventList[] = 65530; - readonly attribute attrib_id attributeList[] = 65531; - readonly attribute bitmap32 featureMap = 65532; - readonly attribute int16u clusterRevision = 65533; - - request struct AddSceneRequest { - 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; - } - - request struct RemoveSceneRequest { - group_id groupID = 0; - INT8U sceneID = 1; - } - - request struct RemoveAllScenesRequest { - group_id groupID = 0; - } - - request struct StoreSceneRequest { - group_id groupID = 0; - INT8U sceneID = 1; - } - - request struct RecallSceneRequest { - group_id groupID = 0; - INT8U sceneID = 1; - optional nullable INT16U transitionTime = 2; - } - - request struct GetSceneMembershipRequest { - group_id groupID = 0; - } - - response struct AddSceneResponse = 0 { - ENUM8 status = 0; - group_id groupID = 1; - INT8U sceneID = 2; - } - - response struct ViewSceneResponse = 1 { - ENUM8 status = 0; - group_id groupID = 1; - INT8U sceneID = 2; - optional INT16U transitionTime = 3; - optional CHAR_STRING sceneName = 4; - optional ExtensionFieldSet extensionFieldSets[] = 5; - } - - response struct RemoveSceneResponse = 2 { - ENUM8 status = 0; - group_id groupID = 1; - INT8U sceneID = 2; - } - - response struct RemoveAllScenesResponse = 3 { - ENUM8 status = 0; - group_id groupID = 1; - } - - response struct StoreSceneResponse = 4 { - ENUM8 status = 0; - group_id groupID = 1; - INT8U sceneID = 2; - } - - response struct GetSceneMembershipResponse = 6 { - ENUM8 status = 0; - nullable INT8U capacity = 1; - group_id groupID = 2; - optional INT8U sceneList[] = 3; - } - - fabric command access(invoke: manage) AddScene(AddSceneRequest): AddSceneResponse = 0; - fabric command ViewScene(ViewSceneRequest): ViewSceneResponse = 1; - fabric command access(invoke: manage) RemoveScene(RemoveSceneRequest): RemoveSceneResponse = 2; - fabric command access(invoke: manage) RemoveAllScenes(RemoveAllScenesRequest): RemoveAllScenesResponse = 3; - fabric command access(invoke: manage) StoreScene(StoreSceneRequest): StoreSceneResponse = 4; - fabric command RecallScene(RecallSceneRequest): DefaultSuccess = 5; - fabric command GetSceneMembership(GetSceneMembershipRequest): GetSceneMembershipResponse = 6; -} - /** Attributes and commands for switching devices between 'On' and 'Off' states. */ client cluster OnOff = 6 { enum OnOffDelayedAllOffEffectVariant : ENUM8 { @@ -260,10 +143,10 @@ client cluster OnOff = 6 { } 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 optional boolean globalSceneControl = 16384; + attribute optional int16u onTime = 16385; + attribute optional int16u offWaitTime = 16386; + attribute access(write: manage) optional nullable OnOffStartUpOnOff startUpOnOff = 16387; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -296,54 +179,6 @@ client cluster OnOff = 6 { command OnWithTimedOff(OnWithTimedOffRequest): DefaultSuccess = 66; } -/** Attributes and commands for switching devices between 'On' and 'Off' states. */ -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; - readonly attribute boolean globalSceneControl = 16384; - attribute int16u onTime = 16385; - attribute int16u offWaitTime = 16386; - attribute access(write: manage) nullable OnOffStartUpOnOff startUpOnOff = 16387; - readonly attribute command_id generatedCommandList[] = 65528; - readonly attribute command_id acceptedCommandList[] = 65529; - readonly attribute event_id eventList[] = 65530; - readonly attribute attrib_id attributeList[] = 65531; - readonly attribute bitmap32 featureMap = 65532; - readonly attribute int16u clusterRevision = 65533; - - command Off(): DefaultSuccess = 0; - command On(): DefaultSuccess = 1; - command Toggle(): DefaultSuccess = 2; -} - /** Attributes and commands for controlling devices that can be set to a level between fully 'On' and fully 'Off.' */ client cluster LevelControl = 8 { enum MoveMode : ENUM8 { @@ -368,19 +203,19 @@ client cluster LevelControl = 8 { } readonly attribute nullable int8u currentLevel = 0; - readonly attribute int16u remainingTime = 1; - readonly attribute int8u minLevel = 2; - readonly attribute int8u maxLevel = 3; - readonly attribute int16u currentFrequency = 4; - readonly attribute int16u minFrequency = 5; - readonly attribute int16u maxFrequency = 6; + readonly attribute optional int16u remainingTime = 1; + readonly attribute optional int8u minLevel = 2; + readonly attribute optional int8u maxLevel = 3; + readonly attribute optional int16u currentFrequency = 4; + readonly attribute optional int16u minFrequency = 5; + readonly attribute optional int16u maxFrequency = 6; attribute LevelControlOptions options = 15; - attribute int16u onOffTransitionTime = 16; + attribute optional int16u onOffTransitionTime = 16; attribute nullable int8u onLevel = 17; - attribute nullable int16u onTransitionTime = 18; - attribute nullable int16u offTransitionTime = 19; - attribute nullable int8u defaultMoveRate = 20; - attribute access(write: manage) nullable int8u startUpCurrentLevel = 16384; + attribute optional nullable int16u onTransitionTime = 18; + attribute optional nullable int16u offTransitionTime = 19; + attribute optional nullable int8u defaultMoveRate = 20; + attribute access(write: manage) optional nullable int8u startUpCurrentLevel = 16384; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -467,114 +302,6 @@ client cluster LevelControl = 8 { command MoveToClosestFrequency(MoveToClosestFrequencyRequest): DefaultSuccess = 8; } -/** Attributes and commands for controlling devices that can be set to a level between fully 'On' and fully 'Off.' */ -server cluster LevelControl = 8 { - enum MoveMode : ENUM8 { - kUp = 0; - kDown = 1; - } - - enum StepMode : ENUM8 { - kUp = 0; - kDown = 1; - } - - bitmap LevelControlFeature : BITMAP32 { - kOnOff = 0x1; - kLighting = 0x2; - kFrequency = 0x4; - } - - bitmap LevelControlOptions : BITMAP8 { - kExecuteIfOff = 0x1; - kCoupleColorTempToLevel = 0x2; - } - - readonly attribute nullable int8u currentLevel = 0; - readonly attribute int16u remainingTime = 1; - readonly attribute int8u minLevel = 2; - readonly attribute int8u maxLevel = 3; - readonly attribute int16u currentFrequency = 4; - readonly attribute int16u minFrequency = 5; - readonly attribute int16u maxFrequency = 6; - attribute LevelControlOptions options = 15; - attribute int16u onOffTransitionTime = 16; - attribute nullable int8u onLevel = 17; - attribute nullable int16u onTransitionTime = 18; - attribute nullable int16u offTransitionTime = 19; - attribute nullable int8u defaultMoveRate = 20; - attribute access(write: manage) nullable int8u startUpCurrentLevel = 16384; - readonly attribute command_id generatedCommandList[] = 65528; - readonly attribute command_id acceptedCommandList[] = 65529; - readonly attribute event_id eventList[] = 65530; - readonly attribute attrib_id attributeList[] = 65531; - readonly attribute bitmap32 featureMap = 65532; - readonly attribute int16u clusterRevision = 65533; - - request struct MoveToLevelRequest { - INT8U level = 0; - nullable INT16U transitionTime = 1; - LevelControlOptions optionsMask = 2; - LevelControlOptions optionsOverride = 3; - } - - request struct MoveRequest { - MoveMode moveMode = 0; - nullable INT8U rate = 1; - LevelControlOptions optionsMask = 2; - LevelControlOptions optionsOverride = 3; - } - - request struct StepRequest { - StepMode stepMode = 0; - INT8U stepSize = 1; - nullable INT16U transitionTime = 2; - LevelControlOptions optionsMask = 3; - LevelControlOptions optionsOverride = 4; - } - - request struct StopRequest { - LevelControlOptions optionsMask = 0; - LevelControlOptions optionsOverride = 1; - } - - request struct MoveToLevelWithOnOffRequest { - INT8U level = 0; - nullable INT16U transitionTime = 1; - LevelControlOptions optionsMask = 2; - LevelControlOptions optionsOverride = 3; - } - - request struct MoveWithOnOffRequest { - MoveMode moveMode = 0; - nullable INT8U rate = 1; - LevelControlOptions optionsMask = 2; - LevelControlOptions optionsOverride = 3; - } - - request struct StepWithOnOffRequest { - StepMode stepMode = 0; - INT8U stepSize = 1; - nullable INT16U transitionTime = 2; - LevelControlOptions optionsMask = 3; - LevelControlOptions optionsOverride = 4; - } - - request struct StopWithOnOffRequest { - LevelControlOptions optionsMask = 0; - LevelControlOptions optionsOverride = 1; - } - - command MoveToLevel(MoveToLevelRequest): DefaultSuccess = 0; - command Move(MoveRequest): DefaultSuccess = 1; - command Step(StepRequest): DefaultSuccess = 2; - command Stop(StopRequest): DefaultSuccess = 3; - command MoveToLevelWithOnOff(MoveToLevelWithOnOffRequest): DefaultSuccess = 4; - command MoveWithOnOff(MoveWithOnOffRequest): DefaultSuccess = 5; - command StepWithOnOff(StepWithOnOffRequest): DefaultSuccess = 6; - command StopWithOnOff(StopWithOnOffRequest): DefaultSuccess = 7; -} - /** An interface for reading the value of a binary measurement and accessing various characteristics of that measurement. */ server cluster BinaryInputBasic = 15 { attribute boolean outOfService = 81; @@ -770,77 +497,6 @@ server cluster BasicInformation = 40 { readonly attribute int16u clusterRevision = 65533; } -/** Provides an interface for providing OTA software updates */ -server cluster OtaSoftwareUpdateProvider = 41 { - enum OTAApplyUpdateAction : ENUM8 { - kProceed = 0; - kAwaitNextAction = 1; - kDiscontinue = 2; - } - - enum OTADownloadProtocol : ENUM8 { - kBDXSynchronous = 0; - kBDXAsynchronous = 1; - kHttps = 2; - kVendorSpecific = 3; - } - - enum OTAQueryStatus : ENUM8 { - kUpdateAvailable = 0; - kBusy = 1; - kNotAvailable = 2; - kDownloadProtocolNotSupported = 3; - } - - readonly attribute command_id generatedCommandList[] = 65528; - readonly attribute command_id acceptedCommandList[] = 65529; - readonly attribute event_id eventList[] = 65530; - readonly attribute attrib_id attributeList[] = 65531; - readonly attribute bitmap32 featureMap = 65532; - readonly attribute int16u clusterRevision = 65533; - - request struct QueryImageRequest { - vendor_id vendorID = 0; - INT16U productID = 1; - INT32U softwareVersion = 2; - OTADownloadProtocol protocolsSupported[] = 3; - optional INT16U hardwareVersion = 4; - optional CHAR_STRING<2> location = 5; - optional BOOLEAN requestorCanConsent = 6; - optional OCTET_STRING<512> metadataForProvider = 7; - } - - request struct ApplyUpdateRequestRequest { - OCTET_STRING<32> updateToken = 0; - INT32U newVersion = 1; - } - - request struct NotifyUpdateAppliedRequest { - OCTET_STRING<32> updateToken = 0; - INT32U softwareVersion = 1; - } - - response struct QueryImageResponse = 1 { - OTAQueryStatus status = 0; - optional INT32U delayedActionTime = 1; - optional CHAR_STRING<256> imageURI = 2; - optional INT32U softwareVersion = 3; - optional CHAR_STRING<64> softwareVersionString = 4; - optional OCTET_STRING<32> updateToken = 5; - optional BOOLEAN userConsentNeeded = 6; - optional OCTET_STRING<512> metadataForRequestor = 7; - } - - response struct ApplyUpdateResponse = 3 { - OTAApplyUpdateAction action = 0; - INT32U delayedActionTime = 1; - } - - command QueryImage(QueryImageRequest): QueryImageResponse = 0; - command ApplyUpdateRequest(ApplyUpdateRequestRequest): ApplyUpdateResponse = 2; - command NotifyUpdateApplied(NotifyUpdateAppliedRequest): DefaultSuccess = 4; -} - /** Nodes should be expected to be deployed to any and all regions of the world. These global regions may have differing common languages, units of measurements, and numerical formatting standards. As such, Nodes that visually or audibly convey information need a mechanism by which @@ -1119,43 +775,6 @@ server cluster NetworkCommissioning = 49 { command access(invoke: administer) ReorderNetwork(ReorderNetworkRequest): NetworkConfigResponse = 8; } -/** The cluster provides commands for retrieving unstructured diagnostic logs from a Node that may be used to aid in diagnostics. */ -server cluster DiagnosticLogs = 50 { - enum IntentEnum : ENUM8 { - kEndUserSupport = 0; - kNetworkDiag = 1; - kCrashLogs = 2; - } - - enum StatusEnum : ENUM8 { - kSuccess = 0; - kExhausted = 1; - kNoLogs = 2; - kBusy = 3; - kDenied = 4; - } - - enum TransferProtocolEnum : ENUM8 { - kResponsePayload = 0; - kBdx = 1; - } - - readonly attribute command_id generatedCommandList[] = 65528; - readonly attribute command_id acceptedCommandList[] = 65529; - readonly attribute event_id eventList[] = 65530; - readonly attribute attrib_id attributeList[] = 65531; - readonly attribute bitmap32 featureMap = 65532; - readonly attribute int16u clusterRevision = 65533; - - request struct RetrieveLogsRequestRequest { - IntentEnum intent = 0; - TransferProtocolEnum requestedProtocol = 1; - optional CHAR_STRING<32> transferFileDesignator = 2; - } - - command RetrieveLogsRequest(RetrieveLogsRequestRequest): RetrieveLogsResponse = 0; -} - /** The General Diagnostics Cluster, along with other diagnostics clusters, provide a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ server cluster GeneralDiagnostics = 51 { enum BootReasonEnum : ENUM8 { @@ -1293,167 +912,6 @@ server cluster SoftwareDiagnostics = 52 { readonly attribute int16u clusterRevision = 65533; } -/** The Thread Network Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems */ -server cluster ThreadNetworkDiagnostics = 53 { - enum ConnectionStatusEnum : ENUM8 { - kConnected = 0; - kNotConnected = 1; - } - - enum NetworkFault : ENUM8 { - kUnspecified = 0; - kLinkDown = 1; - kHardwareFailure = 2; - kNetworkJammed = 3; - } - - enum RoutingRole : ENUM8 { - kUnspecified = 0; - kUnassigned = 1; - kSleepyEndDevice = 2; - kEndDevice = 3; - kReed = 4; - kRouter = 5; - kLeader = 6; - } - - bitmap ThreadNetworkDiagnosticsFeature : BITMAP32 { - kPacketCounts = 0x1; - kErrorCounts = 0x2; - kMLECounts = 0x4; - kMACCounts = 0x8; - } - - struct NeighborTable { - int64u extAddress = 0; - int32u age = 1; - int16u rloc16 = 2; - int32u linkFrameCounter = 3; - int32u mleFrameCounter = 4; - int8u lqi = 5; - nullable int8s averageRssi = 6; - nullable int8s lastRssi = 7; - int8u frameErrorRate = 8; - int8u messageErrorRate = 9; - boolean rxOnWhenIdle = 10; - boolean fullThreadDevice = 11; - boolean fullNetworkData = 12; - boolean isChild = 13; - } - - struct RouteTable { - int64u extAddress = 0; - int16u rloc16 = 1; - int8u routerId = 2; - int8u nextHop = 3; - int8u pathCost = 4; - int8u LQIIn = 5; - int8u LQIOut = 6; - int8u age = 7; - boolean allocated = 8; - boolean linkEstablished = 9; - } - - struct SecurityPolicy { - int16u rotationTime = 0; - int16u flags = 1; - } - - struct OperationalDatasetComponents { - boolean activeTimestampPresent = 0; - boolean pendingTimestampPresent = 1; - boolean masterKeyPresent = 2; - boolean networkNamePresent = 3; - boolean extendedPanIdPresent = 4; - boolean meshLocalPrefixPresent = 5; - boolean delayPresent = 6; - boolean panIdPresent = 7; - boolean channelPresent = 8; - boolean pskcPresent = 9; - boolean securityPolicyPresent = 10; - boolean channelMaskPresent = 11; - } - - info event ConnectionStatus = 0 { - ConnectionStatusEnum connectionStatus = 0; - } - - info event NetworkFaultChange = 1 { - NetworkFault current[] = 0; - NetworkFault previous[] = 1; - } - - readonly attribute nullable int16u channel = 0; - readonly attribute nullable RoutingRole routingRole = 1; - readonly attribute nullable char_string<16> networkName = 2; - readonly attribute nullable int16u panId = 3; - readonly attribute nullable int64u extendedPanId = 4; - readonly attribute nullable octet_string<17> meshLocalPrefix = 5; - readonly attribute int64u overrunCount = 6; - readonly attribute NeighborTable neighborTable[] = 7; - readonly attribute RouteTable routeTable[] = 8; - readonly attribute nullable int32u partitionId = 9; - readonly attribute nullable int8u weighting = 10; - readonly attribute nullable int8u dataVersion = 11; - readonly attribute nullable int8u stableDataVersion = 12; - readonly attribute nullable int8u leaderRouterId = 13; - readonly attribute int16u detachedRoleCount = 14; - readonly attribute int16u childRoleCount = 15; - readonly attribute int16u routerRoleCount = 16; - readonly attribute int16u leaderRoleCount = 17; - readonly attribute int16u attachAttemptCount = 18; - readonly attribute int16u partitionIdChangeCount = 19; - readonly attribute int16u betterPartitionAttachAttemptCount = 20; - readonly attribute int16u parentChangeCount = 21; - readonly attribute int32u txTotalCount = 22; - readonly attribute int32u txUnicastCount = 23; - readonly attribute int32u txBroadcastCount = 24; - readonly attribute int32u txAckRequestedCount = 25; - readonly attribute int32u txAckedCount = 26; - readonly attribute int32u txNoAckRequestedCount = 27; - readonly attribute int32u txDataCount = 28; - readonly attribute int32u txDataPollCount = 29; - readonly attribute int32u txBeaconCount = 30; - readonly attribute int32u txBeaconRequestCount = 31; - readonly attribute int32u txOtherCount = 32; - readonly attribute int32u txRetryCount = 33; - readonly attribute int32u txDirectMaxRetryExpiryCount = 34; - readonly attribute int32u txIndirectMaxRetryExpiryCount = 35; - readonly attribute int32u txErrCcaCount = 36; - readonly attribute int32u txErrAbortCount = 37; - readonly attribute int32u txErrBusyChannelCount = 38; - readonly attribute int32u rxTotalCount = 39; - readonly attribute int32u rxUnicastCount = 40; - readonly attribute int32u rxBroadcastCount = 41; - readonly attribute int32u rxDataCount = 42; - readonly attribute int32u rxDataPollCount = 43; - readonly attribute int32u rxBeaconCount = 44; - readonly attribute int32u rxBeaconRequestCount = 45; - readonly attribute int32u rxOtherCount = 46; - readonly attribute int32u rxAddressFilteredCount = 47; - readonly attribute int32u rxDestAddrFilteredCount = 48; - readonly attribute int32u rxDuplicatedCount = 49; - readonly attribute int32u rxErrNoFrameCount = 50; - readonly attribute int32u rxErrUnknownNeighborCount = 51; - readonly attribute int32u rxErrInvalidSrcAddrCount = 52; - readonly attribute int32u rxErrSecCount = 53; - readonly attribute int32u rxErrFcsCount = 54; - readonly attribute int32u rxErrOtherCount = 55; - readonly attribute nullable int64u activeTimestamp = 56; - readonly attribute nullable int64u pendingTimestamp = 57; - readonly attribute nullable int32u delay = 58; - readonly attribute nullable SecurityPolicy securityPolicy = 59; - readonly attribute nullable octet_string<4> channelPage0Mask = 60; - readonly attribute nullable OperationalDatasetComponents operationalDatasetComponents = 61; - readonly attribute NetworkFault activeNetworkFaultsList[] = 62; - readonly attribute command_id generatedCommandList[] = 65528; - readonly attribute command_id acceptedCommandList[] = 65529; - readonly attribute event_id eventList[] = 65530; - readonly attribute attrib_id attributeList[] = 65531; - readonly attribute bitmap32 featureMap = 65532; - readonly attribute int16u clusterRevision = 65533; -} - /** The Wi-Fi Network Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ server cluster WiFiNetworkDiagnostics = 54 { enum AssociationFailureCauseEnum : ENUM8 { @@ -1564,58 +1022,6 @@ server cluster EthernetNetworkDiagnostics = 55 { command ResetCounts(): DefaultSuccess = 0; } -/** This cluster exposes interactions with a switch device, for the purpose of using those interactions by other devices. -Two types of switch devices are supported: latching switch (e.g. rocker switch) and momentary switch (e.g. push button), distinguished with their feature flags. -Interactions with the switch device are exposed as attributes (for the latching switch) and as events (for both types of switches). An interested party MAY subscribe to these attributes/events and thus be informed of the interactions, and can perform actions based on this, for example by sending commands to perform an action such as controlling a light or a window shade. */ -server cluster Switch = 59 { - bitmap SwitchFeature : BITMAP32 { - kLatchingSwitch = 0x1; - kMomentarySwitch = 0x2; - kMomentarySwitchRelease = 0x4; - kMomentarySwitchLongPress = 0x8; - kMomentarySwitchMultiPress = 0x10; - } - - info event SwitchLatched = 0 { - INT8U newPosition = 0; - } - - info event InitialPress = 1 { - INT8U newPosition = 0; - } - - info event LongPress = 2 { - INT8U newPosition = 0; - } - - info event ShortRelease = 3 { - INT8U previousPosition = 0; - } - - info event LongRelease = 4 { - INT8U previousPosition = 0; - } - - info event MultiPressOngoing = 5 { - INT8U newPosition = 0; - INT8U currentNumberOfPressesCounted = 1; - } - - info event MultiPressComplete = 6 { - INT8U previousPosition = 0; - INT8U totalNumberOfPressesCounted = 1; - } - - readonly attribute int8u numberOfPositions = 0; - readonly attribute int8u currentPosition = 1; - readonly attribute command_id generatedCommandList[] = 65528; - readonly attribute command_id acceptedCommandList[] = 65529; - readonly attribute event_id eventList[] = 65530; - readonly attribute attrib_id attributeList[] = 65531; - readonly attribute bitmap32 featureMap = 65532; - readonly attribute int16u clusterRevision = 65533; -} - /** Commands to trigger a Node to allow a new Administrator to commission it. */ server cluster AdministratorCommissioning = 60 { enum CommissioningWindowStatusEnum : ENUM8 { @@ -1840,18 +1246,12 @@ server cluster GroupKeyManagement = 63 { /** The Fixed Label Cluster provides a feature for the device to tag an endpoint with zero or more read only labels. */ server cluster FixedLabel = 64 { - readonly attribute LabelStruct labelList[] = 0; - readonly attribute command_id generatedCommandList[] = 65528; - readonly attribute command_id acceptedCommandList[] = 65529; - readonly attribute event_id eventList[] = 65530; - readonly attribute attrib_id attributeList[] = 65531; - readonly attribute bitmap32 featureMap = 65532; - readonly attribute int16u clusterRevision = 65533; -} + struct LabelStruct { + char_string<16> label = 0; + char_string<16> value = 1; + } -/** The User Label Cluster provides a feature to tag an endpoint with zero or more labels. */ -server cluster UserLabel = 65 { - attribute access(write: manage) LabelStruct labelList[] = 0; + readonly attribute LabelStruct labelList[] = 0; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -1860,30 +1260,9 @@ server cluster UserLabel = 65 { readonly attribute int16u clusterRevision = 65533; } -/** This cluster provides control of a barrier (garage door). */ -server cluster BarrierControl = 259 { - readonly attribute enum8 barrierMovingState = 1; - readonly attribute bitmap16 barrierSafetyStatus = 2; - readonly attribute bitmap8 barrierCapabilities = 3; - readonly attribute int8u barrierPosition = 10; - readonly attribute command_id generatedCommandList[] = 65528; - readonly attribute command_id acceptedCommandList[] = 65529; - readonly attribute event_id eventList[] = 65530; - readonly attribute attrib_id attributeList[] = 65531; - readonly attribute bitmap32 featureMap = 65532; - readonly attribute int16u clusterRevision = 65533; - - request struct BarrierControlGoToPercentRequest { - INT8U percentOpen = 0; - } - - command BarrierControlGoToPercent(BarrierControlGoToPercentRequest): DefaultSuccess = 0; - command BarrierControlStop(): DefaultSuccess = 1; -} - /** This cluster provides an interface for managing low power mode on a device that supports the Wake On LAN protocol. */ -server cluster WakeOnLan = 1283 { - readonly attribute char_string<32> MACAddress = 0; +client cluster WakeOnLan = 1283 { + readonly attribute optional char_string<32> MACAddress = 0; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -1924,9 +1303,9 @@ client cluster Channel = 1284 { LineupInfoTypeEnum lineupInfoType = 3; } - readonly attribute ChannelInfoStruct channelList[] = 0; - readonly attribute nullable LineupInfoStruct lineup = 1; - readonly attribute nullable ChannelInfoStruct currentChannel = 2; + readonly attribute optional ChannelInfoStruct channelList[] = 0; + readonly attribute optional nullable LineupInfoStruct lineup = 1; + readonly attribute optional nullable ChannelInfoStruct currentChannel = 2; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -1974,7 +1353,7 @@ client cluster TargetNavigator = 1285 { } readonly attribute TargetInfoStruct targetList[] = 0; - readonly attribute int8u currentTarget = 1; + readonly attribute optional int8u currentTarget = 1; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -2025,12 +1404,12 @@ client cluster MediaPlayback = 1286 { } readonly attribute PlaybackStateEnum currentState = 0; - readonly attribute nullable epoch_us startTime = 1; - readonly attribute nullable int64u duration = 2; - readonly attribute nullable PlaybackPositionStruct sampledPosition = 3; - readonly attribute single playbackSpeed = 4; - readonly attribute nullable int64u seekRangeEnd = 5; - readonly attribute nullable int64u seekRangeStart = 6; + readonly attribute optional nullable epoch_us startTime = 1; + readonly attribute optional nullable int64u duration = 2; + readonly attribute optional nullable PlaybackPositionStruct sampledPosition = 3; + readonly attribute optional single playbackSpeed = 4; + readonly attribute optional nullable int64u seekRangeEnd = 5; + readonly attribute optional nullable int64u seekRangeStart = 6; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -2135,6 +1514,19 @@ client cluster MediaInput = 1287 { command RenameInput(RenameInputRequest): DefaultSuccess = 3; } +/** This cluster provides an interface for managing low power mode on a device. */ +client cluster LowPower = 1288 { + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + /** This command shall put the device into low power mode. */ + command Sleep(): DefaultSuccess = 0; +} + /** This cluster provides an interface for controlling a device like a TV using action commands such as UP, DOWN, and SELECT. */ client cluster KeypadInput = 1289 { enum CecKeyCode : ENUM8 { @@ -2333,8 +1725,8 @@ client cluster ContentLauncher = 1290 { optional StyleInformationStruct waterMark = 5; } - readonly attribute CHAR_STRING acceptHeader[] = 0; - attribute bitmap32 supportedStreamingProtocols = 1; + readonly attribute optional CHAR_STRING acceptHeader[] = 0; + attribute optional bitmap32 supportedStreamingProtocols = 1; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -2387,7 +1779,7 @@ client cluster AudioOutput = 1291 { } readonly attribute OutputInfoStruct outputList[] = 0; - readonly attribute int8u currentOutput = 1; + readonly attribute optional int8u currentOutput = 1; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -2432,8 +1824,8 @@ client cluster ApplicationLauncher = 1292 { optional endpoint_no endpoint = 1; } - readonly attribute INT16U catalogList[] = 0; - attribute nullable ApplicationEPStruct currentApp = 1; + readonly attribute optional INT16U catalogList[] = 0; + attribute optional nullable ApplicationEPStruct currentApp = 1; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -2481,10 +1873,10 @@ client cluster ApplicationBasic = 1293 { char_string applicationID = 1; } - readonly attribute char_string<32> vendorName = 0; - readonly attribute vendor_id vendorID = 1; + readonly attribute optional char_string<32> vendorName = 0; + readonly attribute optional vendor_id vendorID = 1; readonly attribute char_string<32> applicationName = 2; - readonly attribute int16u productID = 3; + readonly attribute optional int16u productID = 3; readonly attribute ApplicationStruct application = 4; readonly attribute ApplicationStatusEnum status = 5; readonly attribute char_string<32> applicationVersion = 6; @@ -2586,11 +1978,6 @@ endpoint 0 { ram attribute clusterRevision default = 1; } - server cluster OtaSoftwareUpdateProvider { - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 1; - } - server cluster LocalizationConfiguration { persist attribute activeLocale default = "en-US"; callback attribute supportedLocales; @@ -2631,12 +2018,7 @@ endpoint 0 { ram attribute lastNetworkingStatus; ram attribute lastNetworkID; ram attribute lastConnectErrorValue; - ram attribute featureMap default = 2; - ram attribute clusterRevision default = 1; - } - - server cluster DiagnosticLogs { - ram attribute featureMap default = 0; + ram attribute featureMap default = 5; ram attribute clusterRevision default = 1; } @@ -2664,74 +2046,6 @@ endpoint 0 { ram attribute clusterRevision default = 1; } - server cluster ThreadNetworkDiagnostics { - callback attribute channel; - callback attribute routingRole; - callback attribute networkName default = "0"; - callback attribute panId default = 0x0000; - callback attribute extendedPanId default = 0x0000000000000000; - callback attribute meshLocalPrefix; - callback attribute overrunCount default = 0x0000000000000000; - callback attribute neighborTable; - callback attribute routeTable; - callback attribute partitionId; - callback attribute weighting; - callback attribute dataVersion; - callback attribute stableDataVersion; - callback attribute leaderRouterId; - callback attribute detachedRoleCount default = 0x0000; - callback attribute childRoleCount default = 0x0000; - callback attribute routerRoleCount default = 0x0000; - callback attribute leaderRoleCount default = 0x0000; - callback attribute attachAttemptCount default = 0x0000; - callback attribute partitionIdChangeCount default = 0x0000; - callback attribute betterPartitionAttachAttemptCount default = 0x0000; - callback attribute parentChangeCount default = 0x0000; - callback attribute txTotalCount default = 0x0000; - callback attribute txUnicastCount default = 0x0000; - callback attribute txBroadcastCount default = 0x0000; - callback attribute txAckRequestedCount default = 0x0000; - callback attribute txAckedCount default = 0x0000; - callback attribute txNoAckRequestedCount default = 0x0000; - callback attribute txDataCount default = 0x0000; - callback attribute txDataPollCount default = 0x0000; - callback attribute txBeaconCount default = 0x0000; - callback attribute txBeaconRequestCount default = 0x0000; - callback attribute txOtherCount default = 0x0000; - callback attribute txRetryCount default = 0x0000; - callback attribute txDirectMaxRetryExpiryCount default = 0x0000; - callback attribute txIndirectMaxRetryExpiryCount default = 0x0000; - callback attribute txErrCcaCount default = 0x0000; - callback attribute txErrAbortCount default = 0x0000; - callback attribute txErrBusyChannelCount default = 0x0000; - callback attribute rxTotalCount default = 0x0000; - callback attribute rxUnicastCount default = 0x0000; - callback attribute rxBroadcastCount default = 0x0000; - callback attribute rxDataCount default = 0x0000; - callback attribute rxDataPollCount default = 0x0000; - callback attribute rxBeaconCount default = 0x0000; - callback attribute rxBeaconRequestCount default = 0x0000; - callback attribute rxOtherCount default = 0x0000; - callback attribute rxAddressFilteredCount default = 0x0000; - callback attribute rxDestAddrFilteredCount default = 0x0000; - callback attribute rxDuplicatedCount default = 0x0000; - callback attribute rxErrNoFrameCount default = 0x0000; - callback attribute rxErrUnknownNeighborCount default = 0x0000; - callback attribute rxErrInvalidSrcAddrCount default = 0x0000; - callback attribute rxErrSecCount default = 0x0000; - callback attribute rxErrFcsCount default = 0x0000; - callback attribute rxErrOtherCount default = 0x0000; - callback attribute activeTimestamp default = 0x0000000000000000; - callback attribute pendingTimestamp default = 0x0000000000000000; - callback attribute delay default = 0x0000; - callback attribute securityPolicy; - callback attribute channelPage0Mask default = "0x0000"; - callback attribute operationalDatasetComponents; - callback attribute activeNetworkFaultsList; - ram attribute featureMap default = 0x000F; - ram attribute clusterRevision default = 1; - } - server cluster WiFiNetworkDiagnostics { emits event Disconnection; emits event AssociationFailure; @@ -2794,28 +2108,18 @@ endpoint 0 { ram attribute featureMap default = 0; ram attribute clusterRevision default = 1; } - - server cluster FixedLabel { - callback attribute labelList; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 1; - } - - server cluster UserLabel { - callback attribute labelList; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 1; - } } endpoint 1 { - device type videoplayer = 35, version 1; + device type videoplayer = 41, version 1; binding cluster OnOff; binding cluster LevelControl; binding cluster Descriptor; + binding cluster WakeOnLan; binding cluster Channel; binding cluster TargetNavigator; binding cluster MediaPlayback; binding cluster MediaInput; + binding cluster LowPower; binding cluster KeypadInput; binding cluster ContentLauncher; binding cluster AudioOutput; @@ -2836,45 +2140,6 @@ endpoint 1 { ram attribute clusterRevision default = 4; } - server cluster Scenes { - ram attribute sceneCount default = 0x00; - ram attribute currentScene default = 0x00; - ram attribute currentGroup default = 0x0000; - ram attribute sceneValid default = 0x00; - ram attribute nameSupport; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 4; - } - - server cluster OnOff { - ram attribute onOff default = 0x00; - ram attribute globalSceneControl default = 0x01; - ram attribute onTime default = 0x0000; - ram attribute offWaitTime default = 0x0000; - ram attribute startUpOnOff; - ram attribute featureMap default = 0x0000; - ram attribute clusterRevision default = 4; - } - - server cluster LevelControl { - persist attribute currentLevel default = 0x00; - ram attribute remainingTime default = 0x0000; - ram attribute minLevel default = 0x00; - ram attribute maxLevel default = 0xFF; - ram attribute currentFrequency default = 0x0000; - ram attribute minFrequency default = 0x0000; - ram attribute maxFrequency default = 0x0000; - ram attribute options default = 0x00; - ram attribute onOffTransitionTime default = 0x0000; - ram attribute onLevel default = 0xFE; - ram attribute onTransitionTime; - ram attribute offTransitionTime; - ram attribute defaultMoveRate; - persist attribute startUpCurrentLevel default = 255; - ram attribute featureMap default = 1; - ram attribute clusterRevision default = 5; - } - server cluster BinaryInputBasic { ram attribute outOfService default = 0x00; ram attribute presentValue; @@ -2888,19 +2153,20 @@ endpoint 1 { callback attribute serverList; callback attribute clientList; callback attribute partsList; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute eventList; + callback attribute attributeList; ram attribute featureMap default = 0; callback attribute clusterRevision default = 1; } server cluster Binding { callback attribute binding; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 1; - } - - server cluster Switch { - ram attribute numberOfPositions default = 2; - ram attribute currentPosition; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute eventList; + callback attribute attributeList; ram attribute featureMap default = 0; ram attribute clusterRevision default = 1; } @@ -2910,39 +2176,6 @@ endpoint 1 { ram attribute featureMap default = 0; ram attribute clusterRevision default = 1; } - - server cluster BarrierControl { - ram attribute barrierMovingState; - ram attribute barrierSafetyStatus; - ram attribute barrierCapabilities; - ram attribute barrierPosition; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 1; - } - - server cluster WakeOnLan { - ram attribute MACAddress; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 1; - } -} -endpoint 2 { - device type occupancysensor = 263, version 1; - - server cluster OnOff { - ram attribute onOff default = 0x00; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 4; - } - - server cluster Descriptor { - callback attribute deviceTypeList; - callback attribute serverList; - callback attribute clientList; - callback attribute partsList; - ram attribute featureMap default = 0; - callback attribute clusterRevision default = 1; - } } diff --git a/examples/tv-casting-app/tv-casting-common/tv-casting-app.zap b/examples/tv-casting-app/tv-casting-common/tv-casting-app.zap index a4f8afd300aa3c..7fa8a0aed5e58c 100644 --- a/examples/tv-casting-app/tv-casting-common/tv-casting-app.zap +++ b/examples/tv-casting-app/tv-casting-common/tv-casting-app.zap @@ -1,5 +1,5 @@ { - "featureLevel": 92, + "featureLevel": 95, "creator": "zap", "keyValuePairs": [ { @@ -1565,7 +1565,7 @@ "mfgCode": null, "define": "OTA_SOFTWARE_UPDATE_PROVIDER_CLUSTER", "side": "server", - "enabled": 1, + "enabled": 0, "commands": [ { "name": "QueryImageResponse", @@ -2313,7 +2313,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "2", + "defaultValue": "5", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -2337,13 +2337,65 @@ } ] }, + { + "name": "Diagnostic Logs", + "code": 50, + "mfgCode": null, + "define": "DIAGNOSTIC_LOGS_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "RetrieveLogsRequest", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 0, + "outgoing": 1 + } + ], + "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": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, { "name": "Diagnostic Logs", "code": 50, "mfgCode": null, "define": "DIAGNOSTIC_LOGS_CLUSTER", "side": "server", - "enabled": 1, + "enabled": 0, "commands": [ { "name": "RetrieveLogsRequest", @@ -2352,9 +2404,81 @@ "source": "client", "incoming": 1, "outgoing": 0 + }, + { + "name": "RetrieveLogsResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 0 } ], "attributes": [ + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "RAM", + "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": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EventList", + "code": 65530, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "RAM", + "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": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "FeatureMap", "code": 65532, @@ -2762,13 +2886,55 @@ } ] }, + { + "name": "Thread Network Diagnostics", + "code": 53, + "mfgCode": null, + "define": "THREAD_NETWORK_DIAGNOSTICS_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": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, { "name": "Thread Network Diagnostics", "code": 53, "mfgCode": null, "define": "THREAD_NETWORK_DIAGNOSTICS_CLUSTER", "side": "server", - "enabled": 1, + "enabled": 0, "attributes": [ { "name": "Channel", @@ -3778,6 +3944,70 @@ "maxInterval": 65344, "reportableChange": 0 }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "RAM", + "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": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EventList", + "code": 65530, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "RAM", + "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": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "FeatureMap", "code": 65532, @@ -5019,7 +5249,7 @@ "mfgCode": null, "define": "FIXED_LABEL_CLUSTER", "side": "server", - "enabled": 1, + "enabled": 0, "attributes": [ { "name": "LabelList", @@ -5085,7 +5315,7 @@ "mfgCode": null, "define": "USER_LABEL_CLUSTER", "side": "server", - "enabled": 1, + "enabled": 0, "attributes": [ { "name": "LabelList", @@ -6831,8 +7061,8 @@ }, { "name": "MA-videoplayer", - "deviceTypeName": "MA-casting-videoplayer", - "deviceTypeCode": 35, + "deviceTypeName": "MA-casting-videoclient", + "deviceTypeCode": 41, "deviceTypeProfileId": 259, "clusters": [ { @@ -7203,7 +7433,7 @@ "mfgCode": null, "define": "SCENES_CLUSTER", "side": "server", - "enabled": 1, + "enabled": 0, "commands": [ { "name": "AddSceneResponse", @@ -7403,6 +7633,22 @@ } ], "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, @@ -7427,7 +7673,7 @@ "mfgCode": null, "define": "ON_OFF_CLUSTER", "side": "server", - "enabled": 1, + "enabled": 0, "attributes": [ { "name": "OnOff", @@ -7510,18 +7756,82 @@ "reportableChange": 0 }, { - "name": "FeatureMap", - "code": 65532, + "name": "GeneratedCommandList", + "code": 65528, "mfgCode": null, "side": "server", - "type": "bitmap32", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "", "reportable": 1, - "minInterval": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EventList", + "code": 65530, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "RAM", + "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": "RAM", + "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": "0x0000", + "reportable": 1, + "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, @@ -7617,6 +7927,22 @@ } ], "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, @@ -7641,7 +7967,7 @@ "mfgCode": null, "define": "LEVEL_CONTROL_CLUSTER", "side": "server", - "enabled": 1, + "enabled": 0, "attributes": [ { "name": "CurrentLevel", @@ -7867,6 +8193,70 @@ "maxInterval": 65534, "reportableChange": 0 }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "RAM", + "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": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EventList", + "code": 65530, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "RAM", + "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": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "FeatureMap", "code": 65532, @@ -8025,6 +8415,22 @@ "side": "client", "enabled": 1, "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, @@ -8078,7 +8484,7 @@ "singleton": 0, "bounded": 0, "defaultValue": "", - "reportable": 1, + "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 @@ -8094,7 +8500,7 @@ "singleton": 0, "bounded": 0, "defaultValue": "", - "reportable": 1, + "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 @@ -8110,87 +8516,67 @@ "singleton": 0, "bounded": 0, "defaultValue": "", - "reportable": 1, + "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "FeatureMap", - "code": 65532, + "name": "GeneratedCommandList", + "code": 65528, "mfgCode": null, "side": "server", - "type": "bitmap32", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": "", "reportable": 1, "minInterval": 1, "maxInterval": 65534, "reportableChange": 0 }, { - "name": "ClusterRevision", - "code": 65533, + "name": "AcceptedCommandList", + "code": 65529, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "array", "included": 1, - "storageOption": "External", + "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "1", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 - } - ] - }, - { - "name": "Binding", - "code": 30, - "mfgCode": null, - "define": "BINDING_CLUSTER", - "side": "client", - "enabled": 0, - "attributes": [ + }, { - "name": "ClusterRevision", - "code": 65533, + "name": "EventList", + "code": 65530, "mfgCode": null, - "side": "client", - "type": "int16u", + "side": "server", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "1", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 - } - ] - }, - { - "name": "Binding", - "code": 30, - "mfgCode": null, - "define": "BINDING_CLUSTER", - "side": "server", - "enabled": 1, - "attributes": [ + }, { - "name": "Binding", - "code": 0, + "name": "AttributeList", + "code": 65531, "mfgCode": null, "side": "server", "type": "array", "included": 1, - "storageOption": "External", + "storageOption": "RAM", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -8222,7 +8608,7 @@ "side": "server", "type": "int16u", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "1", @@ -8234,13 +8620,29 @@ ] }, { - "name": "Basic Information", - "code": 40, + "name": "Binding", + "code": 30, "mfgCode": null, - "define": "BASIC_INFORMATION_CLUSTER", + "define": "BINDING_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, @@ -8249,7 +8651,7 @@ "type": "int16u", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, "defaultValue": "1", "reportable": 1, @@ -8260,22 +8662,170 @@ ] }, { - "name": "Basic Information", - "code": 40, + "name": "Binding", + "code": 30, "mfgCode": null, - "define": "BASIC_INFORMATION_CLUSTER", + "define": "BINDING_CLUSTER", "side": "server", - "enabled": 0, + "enabled": 1, "attributes": [ { - "name": "DataModelRevision", + "name": "Binding", "code": 0, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "array", "included": 1, "storageOption": "External", - "singleton": 1, + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "RAM", + "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": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EventList", + "code": 65530, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "RAM", + "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": "RAM", + "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": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Basic Information", + "code": 40, + "mfgCode": null, + "define": "BASIC_INFORMATION_CLUSTER", + "side": "client", + "enabled": 0, + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Basic Information", + "code": 40, + "mfgCode": null, + "define": "BASIC_INFORMATION_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ + { + "name": "DataModelRevision", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 1, "bounded": 0, "defaultValue": "10", "reportable": 1, @@ -9025,7 +9575,7 @@ "mfgCode": null, "define": "SWITCH_CLUSTER", "side": "server", - "enabled": 1, + "enabled": 0, "attributes": [ { "name": "NumberOfPositions", @@ -10301,7 +10851,7 @@ "mfgCode": null, "define": "BARRIER_CONTROL_CLUSTER", "side": "server", - "enabled": 1, + "enabled": 0, "attributes": [ { "name": "barrier moving state", @@ -12305,8 +12855,24 @@ "mfgCode": null, "define": "WAKE_ON_LAN_CLUSTER", "side": "client", - "enabled": 0, + "enabled": 1, "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, @@ -12331,7 +12897,7 @@ "mfgCode": null, "define": "WAKE_ON_LAN_CLUSTER", "side": "server", - "enabled": 1, + "enabled": 0, "attributes": [ { "name": "MACAddress", @@ -12349,6 +12915,70 @@ "maxInterval": 65344, "reportableChange": 0 }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "RAM", + "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": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EventList", + "code": 65530, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "RAM", + "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": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "FeatureMap", "code": 65532, @@ -12423,7 +13053,7 @@ "mfgCode": null, "side": "client", "type": "bitmap32", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -12508,48 +13138,128 @@ "reportableChange": 0 }, { - "name": "ClusterRevision", - "code": 65533, + "name": "GeneratedCommandList", + "code": 65528, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "1", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 - } - ] - }, - { - "name": "Target Navigator", - "code": 1285, - "mfgCode": null, - "define": "TARGET_NAVIGATOR_CLUSTER", - "side": "client", - "enabled": 1, - "commands": [ + }, { - "name": "NavigateTarget", - "code": 0, + "name": "AcceptedCommandList", + "code": 65529, "mfgCode": null, - "source": "client", - "incoming": 0, - "outgoing": 1 - } - ], - "attributes": [ + "side": "server", + "type": "array", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EventList", + "code": 65530, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "RAM", + "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": "RAM", + "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": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Target Navigator", + "code": 1285, + "mfgCode": null, + "define": "TARGET_NAVIGATOR_CLUSTER", + "side": "client", + "enabled": 1, + "commands": [ + { + "name": "NavigateTarget", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 0, + "outgoing": 1 + } + ], + "attributes": [ { "name": "FeatureMap", "code": 65532, "mfgCode": null, "side": "client", "type": "bitmap32", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -12584,6 +13294,16 @@ "define": "TARGET_NAVIGATOR_CLUSTER", "side": "server", "enabled": 0, + "commands": [ + { + "name": "NavigateTargetResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 0 + } + ], "attributes": [ { "name": "TargetList", @@ -12601,6 +13321,102 @@ "maxInterval": 65344, "reportableChange": 0 }, + { + "name": "CurrentTarget", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "RAM", + "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": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EventList", + "code": 65530, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "RAM", + "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": "RAM", + "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, @@ -12723,7 +13539,7 @@ "mfgCode": null, "side": "client", "type": "bitmap32", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -12758,73 +13574,55 @@ "define": "MEDIA_PLAYBACK_CLUSTER", "side": "server", "enabled": 0, + "commands": [ + { + "name": "PlaybackResponse", + "code": 10, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 0 + } + ], "attributes": [ { - "name": "ClusterRevision", - "code": 65533, + "name": "CurrentState", + "code": 0, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "PlaybackStateEnum", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "1", + "defaultValue": "0x00", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 - } - ] - }, - { - "name": "Media Input", - "code": 1287, - "mfgCode": null, - "define": "MEDIA_INPUT_CLUSTER", - "side": "client", - "enabled": 1, - "commands": [ - { - "name": "SelectInput", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 0, - "outgoing": 1 }, { - "name": "ShowInputStatus", + "name": "StartTime", "code": 1, "mfgCode": null, - "source": "client", - "incoming": 0, - "outgoing": 1 + "side": "server", + "type": "epoch_us", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 }, { - "name": "HideInputStatus", + "name": "Duration", "code": 2, "mfgCode": null, - "source": "client", - "incoming": 0, - "outgoing": 1 - }, - { - "name": "RenameInput", - "code": 3, - "mfgCode": null, - "source": "client", - "incoming": 0, - "outgoing": 1 - } - ], - "attributes": [ - { - "name": "FeatureMap", - "code": 65532, - "mfgCode": null, - "side": "client", - "type": "bitmap32", + "side": "server", + "type": "int64u", "included": 0, "storageOption": "RAM", "singleton": 0, @@ -12836,230 +13634,136 @@ "reportableChange": 0 }, { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "client", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "1", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "Media Input", - "code": 1287, - "mfgCode": null, - "define": "MEDIA_INPUT_CLUSTER", - "side": "server", - "enabled": 0, - "attributes": [ - { - "name": "InputList", - "code": 0, + "name": "SampledPosition", + "code": 3, "mfgCode": null, "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", + "type": "PlaybackPositionStruct", + "included": 0, + "storageOption": "RAM", "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "ClusterRevision", - "code": 65533, + "name": "PlaybackSpeed", + "code": 4, "mfgCode": null, "side": "server", - "type": "int16u", - "included": 1, + "type": "single", + "included": 0, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "1", + "defaultValue": "0", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 - } - ] - }, - { - "name": "Keypad Input", - "code": 1289, - "mfgCode": null, - "define": "KEYPAD_INPUT_CLUSTER", - "side": "client", - "enabled": 1, - "commands": [ - { - "name": "SendKey", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 0, - "outgoing": 1 - } - ], - "attributes": [ + }, { - "name": "FeatureMap", - "code": 65532, + "name": "SeekRangeEnd", + "code": 5, "mfgCode": null, - "side": "client", - "type": "bitmap32", + "side": "server", + "type": "int64u", "included": 0, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": "", "reportable": 1, "minInterval": 1, "maxInterval": 65534, "reportableChange": 0 }, { - "name": "ClusterRevision", - "code": 65533, + "name": "SeekRangeStart", + "code": 6, "mfgCode": null, - "side": "client", - "type": "int16u", - "included": 1, + "side": "server", + "type": "int64u", + "included": 0, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "1", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 - } - ] - }, - { - "name": "Keypad Input", - "code": 1289, - "mfgCode": null, - "define": "KEYPAD_INPUT_CLUSTER", - "side": "server", - "enabled": 0, - "attributes": [ + }, { - "name": "ClusterRevision", - "code": 65533, + "name": "GeneratedCommandList", + "code": 65528, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "1", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 - } - ] - }, - { - "name": "Content Launcher", - "code": 1290, - "mfgCode": null, - "define": "CONTENT_LAUNCHER_CLUSTER", - "side": "client", - "enabled": 1, - "commands": [ - { - "name": "LaunchContent", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 0, - "outgoing": 1 }, { - "name": "LaunchURL", - "code": 1, - "mfgCode": null, - "source": "client", - "incoming": 0, - "outgoing": 1 - } - ], - "attributes": [ - { - "name": "FeatureMap", - "code": 65532, + "name": "AcceptedCommandList", + "code": 65529, "mfgCode": null, - "side": "client", - "type": "bitmap32", - "included": 0, + "side": "server", + "type": "array", + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": "", "reportable": 1, "minInterval": 1, "maxInterval": 65534, "reportableChange": 0 }, { - "name": "ClusterRevision", - "code": 65533, + "name": "EventList", + "code": 65530, "mfgCode": null, - "side": "client", - "type": "int16u", + "side": "server", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "1", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 - } - ] - }, - { - "name": "Content Launcher", - "code": 1290, - "mfgCode": null, - "define": "CONTENT_LAUNCHER_CLUSTER", - "side": "server", - "enabled": 0, - "attributes": [ + }, { - "name": "AcceptHeader", - "code": 0, + "name": "AttributeList", + "code": 65531, "mfgCode": null, "side": "server", "type": "array", "included": 1, - "storageOption": "External", + "storageOption": "RAM", "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "SupportedStreamingProtocols", - "code": 1, + "name": "FeatureMap", + "code": 65532, "mfgCode": null, "side": "server", "type": "bitmap32", @@ -13067,10 +13771,10 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "0", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { @@ -13092,15 +13796,15 @@ ] }, { - "name": "Audio Output", - "code": 1291, + "name": "Media Input", + "code": 1287, "mfgCode": null, - "define": "AUDIO_OUTPUT_CLUSTER", + "define": "MEDIA_INPUT_CLUSTER", "side": "client", "enabled": 1, "commands": [ { - "name": "SelectOutput", + "name": "SelectInput", "code": 0, "mfgCode": null, "source": "client", @@ -13108,12 +13812,28 @@ "outgoing": 1 }, { - "name": "RenameOutput", + "name": "ShowInputStatus", "code": 1, "mfgCode": null, "source": "client", "incoming": 0, "outgoing": 1 + }, + { + "name": "HideInputStatus", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "RenameInput", + "code": 3, + "mfgCode": null, + "source": "client", + "incoming": 0, + "outgoing": 1 } ], "attributes": [ @@ -13123,7 +13843,7 @@ "mfgCode": null, "side": "client", "type": "bitmap32", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -13152,15 +13872,15 @@ ] }, { - "name": "Audio Output", - "code": 1291, + "name": "Media Input", + "code": 1287, "mfgCode": null, - "define": "AUDIO_OUTPUT_CLUSTER", + "define": "MEDIA_INPUT_CLUSTER", "side": "server", "enabled": 0, "attributes": [ { - "name": "OutputList", + "name": "InputList", "code": 0, "mfgCode": null, "side": "server", @@ -13176,113 +13896,99 @@ "reportableChange": 0 }, { - "name": "ClusterRevision", - "code": 65533, + "name": "CurrentInput", + "code": 1, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "int8u", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "1", + "defaultValue": "0x00", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 - } - ] - }, - { - "name": "Application Launcher", - "code": 1292, - "mfgCode": null, - "define": "APPLICATION_LAUNCHER_CLUSTER", - "side": "client", - "enabled": 1, - "commands": [ - { - "name": "LaunchApp", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 0, - "outgoing": 1 }, { - "name": "StopApp", - "code": 1, + "name": "GeneratedCommandList", + "code": 65528, "mfgCode": null, - "source": "client", - "incoming": 0, - "outgoing": 1 + "side": "server", + "type": "array", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 }, { - "name": "HideApp", - "code": 2, - "mfgCode": null, - "source": "client", - "incoming": 0, - "outgoing": 1 - } - ], - "attributes": [ - { - "name": "FeatureMap", - "code": 65532, + "name": "AcceptedCommandList", + "code": 65529, "mfgCode": null, - "side": "client", - "type": "bitmap32", - "included": 0, + "side": "server", + "type": "array", + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": "", "reportable": 1, "minInterval": 1, "maxInterval": 65534, "reportableChange": 0 }, { - "name": "ClusterRevision", - "code": 65533, + "name": "EventList", + "code": 65530, "mfgCode": null, - "side": "client", - "type": "int16u", + "side": "server", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "1", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 - } - ] - }, - { - "name": "Application Launcher", - "code": 1292, - "mfgCode": null, - "define": "APPLICATION_LAUNCHER_CLUSTER", - "side": "server", - "enabled": 0, - "attributes": [ + }, { - "name": "CatalogList", - "code": 0, + "name": "AttributeList", + "code": 65531, "mfgCode": null, "side": "server", "type": "array", "included": 1, - "storageOption": "External", + "storageOption": "RAM", "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "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 }, { @@ -13304,12 +14010,22 @@ ] }, { - "name": "Application Basic", - "code": 1293, + "name": "Low Power", + "code": 1288, "mfgCode": null, - "define": "APPLICATION_BASIC_CLUSTER", + "define": "LOW_POWER_CLUSTER", "side": "client", "enabled": 1, + "commands": [ + { + "name": "Sleep", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 0, + "outgoing": 1 + } + ], "attributes": [ { "name": "FeatureMap", @@ -13317,7 +14033,7 @@ "mfgCode": null, "side": "client", "type": "bitmap32", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -13339,114 +14055,98 @@ "bounded": 0, "defaultValue": "1", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 } ] }, { - "name": "Application Basic", - "code": 1293, + "name": "Low Power", + "code": 1288, "mfgCode": null, - "define": "APPLICATION_BASIC_CLUSTER", + "define": "LOW_POWER_CLUSTER", "side": "server", "enabled": 0, "attributes": [ { - "name": "VendorName", - "code": 0, - "mfgCode": null, - "side": "server", - "type": "char_string", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "VendorID", - "code": 1, + "name": "GeneratedCommandList", + "code": 65528, "mfgCode": null, "side": "server", - "type": "vendor_id", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "ApplicationName", - "code": 2, + "name": "AcceptedCommandList", + "code": 65529, "mfgCode": null, "side": "server", - "type": "char_string", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "ProductID", - "code": 3, + "name": "EventList", + "code": 65530, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "Status", - "code": 5, + "name": "AttributeList", + "code": 65531, "mfgCode": null, "side": "server", - "type": "ApplicationStatusEnum", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "ApplicationVersion", - "code": 6, + "name": "FeatureMap", + "code": 65532, "mfgCode": null, "side": "server", - "type": "char_string", + "type": "bitmap32", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "0", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { @@ -13461,43 +14161,27 @@ "bounded": 0, "defaultValue": "1", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 } ] }, { - "name": "Account Login", - "code": 1294, + "name": "Keypad Input", + "code": 1289, "mfgCode": null, - "define": "ACCOUNT_LOGIN_CLUSTER", + "define": "KEYPAD_INPUT_CLUSTER", "side": "client", "enabled": 1, "commands": [ { - "name": "GetSetupPIN", + "name": "SendKey", "code": 0, "mfgCode": null, "source": "client", "incoming": 0, "outgoing": 1 - }, - { - "name": "Login", - "code": 2, - "mfgCode": null, - "source": "client", - "incoming": 0, - "outgoing": 1 - }, - { - "name": "Logout", - "code": 3, - "mfgCode": null, - "source": "client", - "incoming": 0, - "outgoing": 1 } ], "attributes": [ @@ -13507,7 +14191,7 @@ "mfgCode": null, "side": "client", "type": "bitmap32", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, @@ -13536,2113 +14220,197 @@ ] }, { - "name": "Account Login", - "code": 1294, + "name": "Keypad Input", + "code": 1289, "mfgCode": null, - "define": "ACCOUNT_LOGIN_CLUSTER", + "define": "KEYPAD_INPUT_CLUSTER", "side": "server", "enabled": 0, + "commands": [ + { + "name": "SendKeyResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 0 + } + ], "attributes": [ { - "name": "ClusterRevision", - "code": 65533, + "name": "GeneratedCommandList", + "code": 65528, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "1", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - } - ] - }, - { - "name": "MA-occupancysensor", - "deviceTypeName": "MA-occupancysensor", - "deviceTypeCode": 263, - "deviceTypeProfileId": 259, - "clusters": [ - { - "name": "Identify", - "code": 3, - "mfgCode": null, - "define": "IDENTIFY_CLUSTER", - "side": "client", - "enabled": 0, - "commands": [ - { - "name": "Identify", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - } - ], - "attributes": [ - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "client", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "4", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "Identify", - "code": 3, - "mfgCode": null, - "define": "IDENTIFY_CLUSTER", - "side": "server", - "enabled": 0, - "attributes": [ - { - "name": "IdentifyTime", - "code": 0, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "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": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "Groups", - "code": 4, - "mfgCode": null, - "define": "GROUPS_CLUSTER", - "side": "client", - "enabled": 0, - "commands": [ - { - "name": "AddGroup", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "ViewGroup", - "code": 1, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "GetGroupMembership", - "code": 2, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "RemoveGroup", - "code": 3, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "RemoveAllGroups", - "code": 4, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "AddGroupIfIdentifying", - "code": 5, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - } - ], - "attributes": [ - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "client", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "4", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "Groups", - "code": 4, - "mfgCode": null, - "define": "GROUPS_CLUSTER", - "side": "server", - "enabled": 0, - "commands": [ - { - "name": "AddGroupResponse", - "code": 0, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "ViewGroupResponse", - "code": 1, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "GetGroupMembershipResponse", - "code": 2, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "RemoveGroupResponse", - "code": 3, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - } - ], - "attributes": [ - { - "name": "NameSupport", - "code": 0, - "mfgCode": null, - "side": "server", - "type": "bitmap8", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "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": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "Scenes", - "code": 5, - "mfgCode": null, - "define": "SCENES_CLUSTER", - "side": "client", - "enabled": 0, - "commands": [ - { - "name": "AddScene", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "ViewScene", - "code": 1, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "RemoveScene", - "code": 2, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "RemoveAllScenes", - "code": 3, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "StoreScene", - "code": 4, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "RecallScene", - "code": 5, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "GetSceneMembership", - "code": 6, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - } - ], - "attributes": [ - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "client", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "4", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "Scenes", - "code": 5, - "mfgCode": null, - "define": "SCENES_CLUSTER", - "side": "server", - "enabled": 0, - "commands": [ - { - "name": "AddSceneResponse", - "code": 0, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "ViewSceneResponse", - "code": 1, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "RemoveSceneResponse", - "code": 2, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "RemoveAllScenesResponse", - "code": 3, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "StoreSceneResponse", - "code": 4, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "GetSceneMembershipResponse", - "code": 6, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - } - ], - "attributes": [ - { - "name": "SceneCount", - "code": 0, - "mfgCode": null, - "side": "server", - "type": "int8u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "CurrentScene", - "code": 1, - "mfgCode": null, - "side": "server", - "type": "int8u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "CurrentGroup", - "code": 2, - "mfgCode": null, - "side": "server", - "type": "group_id", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "SceneValid", - "code": 3, - "mfgCode": null, - "side": "server", - "type": "boolean", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "NameSupport", - "code": 4, - "mfgCode": null, - "side": "server", - "type": "bitmap8", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "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": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "On/Off", - "code": 6, - "mfgCode": null, - "define": "ON_OFF_CLUSTER", - "side": "client", - "enabled": 0, - "commands": [ - { - "name": "Off", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "On", - "code": 1, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "Toggle", - "code": 2, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - } - ], - "attributes": [ - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "client", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "4", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "On/Off", - "code": 6, - "mfgCode": null, - "define": "ON_OFF_CLUSTER", - "side": "server", - "enabled": 1, - "attributes": [ - { - "name": "OnOff", - "code": 0, - "mfgCode": null, - "side": "server", - "type": "boolean", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "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": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "Level Control", - "code": 8, - "mfgCode": null, - "define": "LEVEL_CONTROL_CLUSTER", - "side": "client", - "enabled": 0, - "commands": [ - { - "name": "MoveToLevel", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "Move", - "code": 1, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "Step", - "code": 2, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "Stop", - "code": 3, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "MoveToLevelWithOnOff", - "code": 4, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "MoveWithOnOff", - "code": 5, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "StepWithOnOff", - "code": 6, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "StopWithOnOff", - "code": 7, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - } - ], - "attributes": [ - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "client", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "5", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "Level Control", - "code": 8, - "mfgCode": null, - "define": "LEVEL_CONTROL_CLUSTER", - "side": "server", - "enabled": 0, - "attributes": [ - { - "name": "CurrentLevel", - "code": 0, - "mfgCode": null, - "side": "server", - "type": "int8u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "5", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "Descriptor", - "code": 29, - "mfgCode": null, - "define": "DESCRIPTOR_CLUSTER", - "side": "client", - "enabled": 0, - "attributes": [ - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "client", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "1", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - } - ] - }, - { - "name": "Descriptor", - "code": 29, - "mfgCode": null, - "define": "DESCRIPTOR_CLUSTER", - "side": "server", - "enabled": 1, - "attributes": [ - { - "name": "DeviceTypeList", - "code": 0, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "ServerList", - "code": 1, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "ClientList", - "code": 2, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "PartsList", - "code": 3, - "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": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "1", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - } - ] - }, - { - "name": "Basic Information", - "code": 40, - "mfgCode": null, - "define": "BASIC_INFORMATION_CLUSTER", - "side": "client", - "enabled": 0, - "attributes": [ - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "client", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "1", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "Basic Information", - "code": 40, - "mfgCode": null, - "define": "BASIC_INFORMATION_CLUSTER", - "side": "server", - "enabled": 0, - "attributes": [ - { - "name": "DataModelRevision", - "code": 0, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "External", - "singleton": 1, - "bounded": 0, - "defaultValue": "10", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "VendorName", - "code": 1, - "mfgCode": null, - "side": "server", - "type": "char_string", - "included": 1, - "storageOption": "External", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "VendorID", - "code": 2, - "mfgCode": null, - "side": "server", - "type": "vendor_id", - "included": 1, - "storageOption": "External", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "ProductName", - "code": 3, - "mfgCode": null, - "side": "server", - "type": "char_string", - "included": 1, - "storageOption": "External", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "ProductID", - "code": 4, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "External", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "NodeLabel", - "code": 5, - "mfgCode": null, - "side": "server", - "type": "char_string", - "included": 1, - "storageOption": "NVM", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "Location", - "code": 6, - "mfgCode": null, - "side": "server", - "type": "char_string", - "included": 1, - "storageOption": "External", - "singleton": 1, - "bounded": 0, - "defaultValue": "XX", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "HardwareVersion", - "code": 7, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "External", - "singleton": 1, - "bounded": 0, - "defaultValue": "0", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "HardwareVersionString", - "code": 8, - "mfgCode": null, - "side": "server", - "type": "char_string", - "included": 1, - "storageOption": "External", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "SoftwareVersion", - "code": 9, - "mfgCode": null, - "side": "server", - "type": "int32u", - "included": 1, - "storageOption": "External", - "singleton": 1, - "bounded": 0, - "defaultValue": "0", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "SoftwareVersionString", - "code": 10, - "mfgCode": null, - "side": "server", - "type": "char_string", - "included": 1, - "storageOption": "External", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "ManufacturingDate", - "code": 11, - "mfgCode": null, - "side": "server", - "type": "char_string", - "included": 1, - "storageOption": "External", - "singleton": 1, - "bounded": 0, - "defaultValue": "20210614123456ZZ", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "PartNumber", - "code": 12, - "mfgCode": null, - "side": "server", - "type": "char_string", - "included": 1, - "storageOption": "External", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "ProductURL", - "code": 13, - "mfgCode": null, - "side": "server", - "type": "long_char_string", - "included": 1, - "storageOption": "External", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "ProductLabel", - "code": 14, - "mfgCode": null, - "side": "server", - "type": "char_string", - "included": 1, - "storageOption": "External", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "SerialNumber", - "code": 15, - "mfgCode": null, - "side": "server", - "type": "char_string", - "included": 1, - "storageOption": "External", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "LocalConfigDisabled", - "code": 16, - "mfgCode": null, - "side": "server", - "type": "boolean", - "included": 1, - "storageOption": "NVM", - "singleton": 1, - "bounded": 0, - "defaultValue": "0", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "Reachable", - "code": 17, - "mfgCode": null, - "side": "server", - "type": "boolean", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "1", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "UniqueID", - "code": 18, - "mfgCode": null, - "side": "server", - "type": "char_string", - "included": 1, - "storageOption": "External", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "CapabilityMinima", - "code": 19, - "mfgCode": null, - "side": "server", - "type": "CapabilityMinimaStruct", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "1", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "Door Lock", - "code": 257, - "mfgCode": null, - "define": "DOOR_LOCK_CLUSTER", - "side": "client", - "enabled": 0, - "commands": [ - { - "name": "LockDoor", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "UnlockDoor", - "code": 1, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - } - ], - "attributes": [ - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "client", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "6", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "Door Lock", - "code": 257, - "mfgCode": null, - "define": "DOOR_LOCK_CLUSTER", - "side": "server", - "enabled": 0, - "attributes": [ - { - "name": "LockState", - "code": 0, - "mfgCode": null, - "side": "server", - "type": "DlLockState", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "LockType", - "code": 1, - "mfgCode": null, - "side": "server", - "type": "DlLockType", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "ActuatorEnabled", - "code": 2, - "mfgCode": null, - "side": "server", - "type": "boolean", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "DoorState", - "code": 3, - "mfgCode": null, - "side": "server", - "type": "DoorStateEnum", - "included": 0, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "Language", - "code": 33, - "mfgCode": null, - "side": "server", - "type": "char_string", - "included": 0, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "LEDSettings", - "code": 34, - "mfgCode": null, - "side": "server", - "type": "int8u", - "included": 0, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "AutoRelockTime", - "code": 35, - "mfgCode": null, - "side": "server", - "type": "int32u", - "included": 0, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "SoundVolume", - "code": 36, - "mfgCode": null, - "side": "server", - "type": "int8u", - "included": 0, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "OperatingMode", - "code": 37, - "mfgCode": null, - "side": "server", - "type": "OperatingModeEnum", - "included": 0, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "DefaultConfigurationRegister", - "code": 39, - "mfgCode": null, - "side": "server", - "type": "DlDefaultConfigurationRegister", - "included": 0, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "EnableLocalProgramming", - "code": 40, - "mfgCode": null, - "side": "server", - "type": "boolean", - "included": 0, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x01", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "EnableOneTouchLocking", - "code": 41, - "mfgCode": null, - "side": "server", - "type": "boolean", - "included": 0, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "EnableInsideStatusLED", - "code": 42, - "mfgCode": null, - "side": "server", - "type": "boolean", - "included": 0, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "EnablePrivacyModeButton", - "code": 43, - "mfgCode": null, - "side": "server", - "type": "boolean", - "included": 0, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "WrongCodeEntryLimit", - "code": 48, - "mfgCode": null, - "side": "server", - "type": "int8u", - "included": 0, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "UserCodeTemporaryDisableTime", - "code": 49, - "mfgCode": null, - "side": "server", - "type": "int8u", - "included": 0, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "SendPINOverTheAir", - "code": 50, - "mfgCode": null, - "side": "server", - "type": "boolean", - "included": 0, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "RequirePINforRemoteOperation", - "code": 51, - "mfgCode": null, - "side": "server", - "type": "boolean", - "included": 0, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "6", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "Barrier Control", - "code": 259, - "mfgCode": null, - "define": "BARRIER_CONTROL_CLUSTER", - "side": "client", - "enabled": 0, - "commands": [ - { - "name": "BarrierControlGoToPercent", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "BarrierControlStop", - "code": 1, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - } - ], - "attributes": [ - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "client", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "1", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "Barrier Control", - "code": 259, - "mfgCode": null, - "define": "BARRIER_CONTROL_CLUSTER", - "side": "server", - "enabled": 0, - "attributes": [ - { - "name": "barrier moving state", - "code": 1, - "mfgCode": null, - "side": "server", - "type": "enum8", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "barrier safety status", - "code": 2, - "mfgCode": null, - "side": "server", - "type": "bitmap16", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "barrier capabilities", - "code": 3, - "mfgCode": null, - "side": "server", - "type": "bitmap8", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "barrier position", - "code": 10, - "mfgCode": null, - "side": "server", - "type": "int8u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "1", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "Color Control", - "code": 768, - "mfgCode": null, - "define": "COLOR_CONTROL_CLUSTER", - "side": "client", - "enabled": 0, - "commands": [ - { - "name": "MoveToHue", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "MoveHue", - "code": 1, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "StepHue", - "code": 2, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "MoveToSaturation", - "code": 3, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "MoveSaturation", - "code": 4, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "StepSaturation", - "code": 5, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "MoveToHueAndSaturation", - "code": 6, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "MoveToColor", - "code": 7, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "MoveColor", - "code": 8, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "StepColor", - "code": 9, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "MoveToColorTemperature", - "code": 10, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "StopMoveStep", - "code": 71, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "MoveColorTemperature", - "code": 75, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "StepColorTemperature", - "code": 76, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - } - ], - "attributes": [ - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "client", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "5", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "Color Control", - "code": 768, - "mfgCode": null, - "define": "COLOR_CONTROL_CLUSTER", - "side": "server", - "enabled": 0, - "attributes": [ - { - "name": "CurrentHue", - "code": 0, - "mfgCode": null, - "side": "server", - "type": "int8u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "CurrentSaturation", - "code": 1, - "mfgCode": null, - "side": "server", - "type": "int8u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "RemainingTime", - "code": 2, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "CurrentX", - "code": 3, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x616B", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "CurrentY", - "code": 4, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x607D", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "DriftCompensation", - "code": 5, + "name": "AcceptedCommandList", + "code": 65529, "mfgCode": null, "side": "server", - "type": "enum8", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "CompensationText", - "code": 6, + "name": "EventList", + "code": 65530, "mfgCode": null, "side": "server", - "type": "char_string", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "ColorTemperatureMireds", - "code": 7, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00FA", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "ColorMode", - "code": 8, + "name": "AttributeList", + "code": 65531, "mfgCode": null, "side": "server", - "type": "enum8", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x01", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "Options", - "code": 15, + "name": "FeatureMap", + "code": 65532, "mfgCode": null, "side": "server", - "type": "bitmap8", + "type": "bitmap32", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x00", + "defaultValue": "0", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "NumberOfPrimaries", - "code": 16, + "name": "ClusterRevision", + "code": 65533, "mfgCode": null, "side": "server", - "type": "int8u", + "type": "int16u", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "1", "reportable": 1, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 + } + ] + }, + { + "name": "Content Launcher", + "code": 1290, + "mfgCode": null, + "define": "CONTENT_LAUNCHER_CLUSTER", + "side": "client", + "enabled": 1, + "commands": [ + { + "name": "LaunchContent", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 0, + "outgoing": 1 }, { - "name": "Primary1X", - "code": 17, + "name": "LaunchURL", + "code": 1, "mfgCode": null, - "side": "server", - "type": "int16u", + "source": "client", + "incoming": 0, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "client", + "type": "bitmap32", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "0", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "Primary1Y", - "code": 18, + "name": "ClusterRevision", + "code": 65533, "mfgCode": null, - "side": "server", + "side": "client", "type": "int16u", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "1", "reportable": 1, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 - }, + } + ] + }, + { + "name": "Content Launcher", + "code": 1290, + "mfgCode": null, + "define": "CONTENT_LAUNCHER_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ { - "name": "Primary1Intensity", - "code": 19, + "name": "AcceptHeader", + "code": 0, "mfgCode": null, "side": "server", - "type": "int8u", + "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -15652,11 +14420,11 @@ "reportableChange": 0 }, { - "name": "Primary2X", - "code": 21, + "name": "SupportedStreamingProtocols", + "code": 1, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "bitmap32", "included": 1, "storageOption": "RAM", "singleton": 0, @@ -15668,88 +14436,88 @@ "reportableChange": 0 }, { - "name": "Primary2Y", - "code": 22, + "name": "GeneratedCommandList", + "code": 65528, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "Primary2Intensity", - "code": 23, + "name": "AcceptedCommandList", + "code": 65529, "mfgCode": null, "side": "server", - "type": "int8u", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "Primary3X", - "code": 25, + "name": "EventList", + "code": 65530, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "Primary3Y", - "code": 26, + "name": "AttributeList", + "code": 65531, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "Primary3Intensity", - "code": 27, + "name": "FeatureMap", + "code": 65532, "mfgCode": null, "side": "server", - "type": "int8u", + "type": "bitmap32", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "0", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "Primary4X", - "code": 32, + "name": "ClusterRevision", + "code": 65533, "mfgCode": null, "side": "server", "type": "int16u", @@ -15757,52 +14525,90 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "1", "reportable": 1, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 + } + ] + }, + { + "name": "Audio Output", + "code": 1291, + "mfgCode": null, + "define": "AUDIO_OUTPUT_CLUSTER", + "side": "client", + "enabled": 1, + "commands": [ + { + "name": "SelectOutput", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 0, + "outgoing": 1 }, { - "name": "Primary4Y", - "code": 33, + "name": "RenameOutput", + "code": 1, "mfgCode": null, - "side": "server", - "type": "int16u", + "source": "client", + "incoming": 0, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "client", + "type": "bitmap32", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "0", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "Primary4Intensity", - "code": 34, + "name": "ClusterRevision", + "code": 65533, "mfgCode": null, - "side": "server", - "type": "int8u", + "side": "client", + "type": "int16u", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "1", "reportable": 1, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 - }, + } + ] + }, + { + "name": "Audio Output", + "code": 1291, + "mfgCode": null, + "define": "AUDIO_OUTPUT_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ { - "name": "Primary5X", - "code": 36, + "name": "OutputList", + "code": 0, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -15812,104 +14618,104 @@ "reportableChange": 0 }, { - "name": "Primary5Y", - "code": 37, + "name": "CurrentOutput", + "code": 1, "mfgCode": null, "side": "server", - "type": "int16u", - "included": 1, + "type": "int8u", + "included": 0, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "0x00", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "Primary5Intensity", - "code": 38, + "name": "GeneratedCommandList", + "code": 65528, "mfgCode": null, "side": "server", - "type": "int8u", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "Primary6X", - "code": 40, + "name": "AcceptedCommandList", + "code": 65529, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "Primary6Y", - "code": 41, + "name": "EventList", + "code": 65530, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "Primary6Intensity", - "code": 42, + "name": "AttributeList", + "code": 65531, "mfgCode": null, "side": "server", - "type": "int8u", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "WhitePointX", - "code": 48, + "name": "FeatureMap", + "code": 65532, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "bitmap32", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "0", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "WhitePointY", - "code": 49, + "name": "ClusterRevision", + "code": 65533, "mfgCode": null, "side": "server", "type": "int16u", @@ -15917,52 +14723,108 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "1", "reportable": 1, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 + } + ] + }, + { + "name": "Application Launcher", + "code": 1292, + "mfgCode": null, + "define": "APPLICATION_LAUNCHER_CLUSTER", + "side": "client", + "enabled": 1, + "commands": [ + { + "name": "LaunchApp", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 0, + "outgoing": 1 }, { - "name": "ColorPointRX", - "code": 50, + "name": "StopApp", + "code": 1, "mfgCode": null, - "side": "server", - "type": "int16u", + "source": "client", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "HideApp", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 0, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "client", + "type": "bitmap32", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "0", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "ColorPointRY", - "code": 51, + "name": "ClusterRevision", + "code": 65533, "mfgCode": null, - "side": "server", + "side": "client", "type": "int16u", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "1", "reportable": 1, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 - }, + } + ] + }, + { + "name": "Application Launcher", + "code": 1292, + "mfgCode": null, + "define": "APPLICATION_LAUNCHER_CLUSTER", + "side": "server", + "enabled": 0, + "commands": [ { - "name": "ColorPointRIntensity", - "code": 52, + "name": "LauncherResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "CatalogList", + "code": 0, "mfgCode": null, "side": "server", - "type": "int8u", + "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -15972,104 +14834,104 @@ "reportableChange": 0 }, { - "name": "ColorPointGX", - "code": 54, + "name": "CurrentApp", + "code": 1, "mfgCode": null, "side": "server", - "type": "int16u", - "included": 1, + "type": "ApplicationEPStruct", + "included": 0, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "0x0", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "ColorPointGY", - "code": 55, + "name": "GeneratedCommandList", + "code": 65528, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "ColorPointGIntensity", - "code": 56, + "name": "AcceptedCommandList", + "code": 65529, "mfgCode": null, "side": "server", - "type": "int8u", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "ColorPointBX", - "code": 58, + "name": "EventList", + "code": 65530, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "ColorPointBY", - "code": 59, + "name": "AttributeList", + "code": 65531, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "ColorPointBIntensity", - "code": 60, + "name": "FeatureMap", + "code": 65532, "mfgCode": null, "side": "server", - "type": "int8u", + "type": "bitmap32", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "0", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "EnhancedCurrentHue", - "code": 16384, + "name": "ClusterRevision", + "code": 65533, "mfgCode": null, "side": "server", "type": "int16u", @@ -16077,95 +14939,115 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "1", "reportable": 1, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 - }, + } + ] + }, + { + "name": "Application Basic", + "code": 1293, + "mfgCode": null, + "define": "APPLICATION_BASIC_CLUSTER", + "side": "client", + "enabled": 1, + "attributes": [ { - "name": "EnhancedColorMode", - "code": 16385, + "name": "FeatureMap", + "code": 65532, "mfgCode": null, - "side": "server", - "type": "enum8", + "side": "client", + "type": "bitmap32", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x01", + "defaultValue": "0", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "ColorLoopActive", - "code": 16386, + "name": "ClusterRevision", + "code": 65533, "mfgCode": null, - "side": "server", - "type": "int8u", + "side": "client", + "type": "int16u", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x00", + "defaultValue": "1", "reportable": 1, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 - }, + } + ] + }, + { + "name": "Application Basic", + "code": 1293, + "mfgCode": null, + "define": "APPLICATION_BASIC_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ { - "name": "ColorLoopDirection", - "code": 16387, + "name": "VendorName", + "code": 0, "mfgCode": null, "side": "server", - "type": "int8u", + "type": "char_string", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x00", + "defaultValue": "", "reportable": 1, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "ColorLoopTime", - "code": 16388, + "name": "VendorID", + "code": 1, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "vendor_id", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x0019", + "defaultValue": "", "reportable": 1, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "ColorCapabilities", - "code": 16394, + "name": "ApplicationName", + "code": 2, "mfgCode": null, "side": "server", - "type": "bitmap16", + "type": "char_string", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "", "reportable": 1, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "ColorTempPhysicalMinMireds", - "code": 16395, + "name": "ProductID", + "code": 3, "mfgCode": null, "side": "server", "type": "int16u", @@ -16173,34 +15055,34 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "", "reportable": 1, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "ColorTempPhysicalMaxMireds", - "code": 16396, + "name": "Application", + "code": 4, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "ApplicationStruct", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0xFEFF", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "CoupleColorTempToLevelMinMireds", - "code": 16397, + "name": "Status", + "code": 5, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "ApplicationStatusEnum", "included": 1, "storageOption": "RAM", "singleton": 0, @@ -16212,11 +15094,11 @@ "reportableChange": 0 }, { - "name": "StartUpColorTemperatureMireds", - "code": 16400, + "name": "ApplicationVersion", + "code": 6, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "char_string", "included": 1, "storageOption": "RAM", "singleton": 0, @@ -16228,119 +15110,99 @@ "reportableChange": 0 }, { - "name": "ClusterRevision", - "code": 65533, + "name": "AllowedVendorList", + "code": 7, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "5", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 - } - ] - }, - { - "name": "Temperature Measurement", - "code": 1026, - "mfgCode": null, - "define": "TEMPERATURE_MEASUREMENT_CLUSTER", - "side": "client", - "enabled": 0, - "attributes": [ + }, { - "name": "ClusterRevision", - "code": 65533, + "name": "GeneratedCommandList", + "code": 65528, "mfgCode": null, - "side": "client", - "type": "int16u", + "side": "server", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "4", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 - } - ] - }, - { - "name": "Temperature Measurement", - "code": 1026, - "mfgCode": null, - "define": "TEMPERATURE_MEASUREMENT_CLUSTER", - "side": "server", - "enabled": 0, - "attributes": [ + }, { - "name": "MeasuredValue", - "code": 0, + "name": "AcceptedCommandList", + "code": 65529, "mfgCode": null, "side": "server", - "type": "int16s", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x8000", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "MinMeasuredValue", - "code": 1, + "name": "EventList", + "code": 65530, "mfgCode": null, "side": "server", - "type": "int16s", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x8000", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "MaxMeasuredValue", - "code": 2, + "name": "AttributeList", + "code": 65531, "mfgCode": null, "side": "server", - "type": "int16s", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x8000", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "Tolerance", - "code": 3, + "name": "FeatureMap", + "code": 65532, "mfgCode": null, "side": "server", - "type": "int16u", - "included": 0, + "type": "bitmap32", + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "0", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { @@ -16353,7 +15215,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "4", + "defaultValue": "1", "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -16362,13 +15224,55 @@ ] }, { - "name": "Occupancy Sensing", - "code": 1030, + "name": "Account Login", + "code": 1294, "mfgCode": null, - "define": "OCCUPANCY_SENSING_CLUSTER", + "define": "ACCOUNT_LOGIN_CLUSTER", "side": "client", - "enabled": 0, + "enabled": 1, + "commands": [ + { + "name": "GetSetupPIN", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "Login", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "Logout", + "code": 3, + "mfgCode": null, + "source": "client", + "incoming": 0, + "outgoing": 1 + } + ], "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, @@ -16379,7 +15283,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "1", "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -16388,59 +15292,101 @@ ] }, { - "name": "Occupancy Sensing", - "code": 1030, + "name": "Account Login", + "code": 1294, "mfgCode": null, - "define": "OCCUPANCY_SENSING_CLUSTER", + "define": "ACCOUNT_LOGIN_CLUSTER", "side": "server", "enabled": 0, + "commands": [ + { + "name": "GetSetupPINResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 0 + } + ], "attributes": [ { - "name": "Occupancy", - "code": 0, + "name": "GeneratedCommandList", + "code": 65528, "mfgCode": null, "side": "server", - "type": "OccupancyBitmap", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "OccupancySensorType", - "code": 1, + "name": "AcceptedCommandList", + "code": 65529, "mfgCode": null, "side": "server", - "type": "OccupancySensorTypeEnum", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "OccupancySensorTypeBitmap", - "code": 2, + "name": "EventList", + "code": 65530, "mfgCode": null, "side": "server", - "type": "OccupancySensorTypeBitmap", + "type": "array", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "RAM", + "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 }, { @@ -16453,7 +15399,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "1", "reportable": 1, "minInterval": 0, "maxInterval": 65344, @@ -16481,16 +15427,8 @@ "endpointId": 1, "networkId": 0, "endpointVersion": 1, - "deviceIdentifier": 35 - }, - { - "endpointTypeName": "MA-occupancysensor", - "endpointTypeIndex": 2, - "profileId": 259, - "endpointId": 2, - "networkId": 0, - "endpointVersion": 1, - "deviceIdentifier": 263 + "deviceIdentifier": 41 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/window-app/telink/CMakeLists.txt b/examples/window-app/telink/CMakeLists.txt index 73d2a710037b54..ad23d3201a455b 100644 --- a/examples/window-app/telink/CMakeLists.txt +++ b/examples/window-app/telink/CMakeLists.txt @@ -241,6 +241,7 @@ target_link_libraries(app PRIVATE target_link_options(app PUBLIC "-T${PIGWEED_ROOT}/pw_tokenizer/pw_tokenizer_linker_sections.ld" + "-L${PIGWEED_ROOT}/pw_tokenizer" ) endif(CONFIG_CHIP_PW_RPC) diff --git a/integrations/docker/ci-only-images/chip-cirque-device-base/build.sh b/integrations/docker/ci-only-images/chip-cirque-device-base/build.sh index 768a71b5c0e9e9..7c8856c3d6189d 100755 --- a/integrations/docker/ci-only-images/chip-cirque-device-base/build.sh +++ b/integrations/docker/ci-only-images/chip-cirque-device-base/build.sh @@ -24,6 +24,7 @@ set -xe +me=$(basename "$0") SOURCE=${BASH_SOURCE[0]} cd "$(dirname "$SOURCE")" @@ -41,7 +42,7 @@ GITHUB_ACTION_RUN=${GITHUB_ACTION_RUN:-"0"} REPO_DIR="$SOURCE_DIR/../../../../" -if [[ "x$GITHUB_ACTION_RUN" = "x1" ]]; then +if [[ "$GITHUB_ACTION_RUN" = "1" ]]; then # Note: This script will be invoked in docker on CI, We should ensure CHIP repo to safe directory to silent git error messages. git config --global --add safe.directory /home/runner/work/connectedhomeip/connectedhomeip fi @@ -98,7 +99,7 @@ fi docker build -t "$ORG/$IMAGE" -f "$SOURCE_DIR/Dockerfile" "${BUILD_ARGS[@]}" --build-arg OT_BR_POSIX_CHECKOUT="$OT_BR_POSIX_CHECKOUT" "$SOURCE_DIR" -if [[ -n GITHUB_ACTION_RUN ]]; then +if [[ "$GITHUB_ACTION_RUN" = "1" ]]; then # Save cache mkdir -p "$CIRQUE_CACHE_PATH" docker save -o "$IMAGE_SAVE_PATH" "$ORG/$IMAGE" diff --git a/integrations/docker/images/chip-cert-bins/Dockerfile b/integrations/docker/images/chip-cert-bins/Dockerfile index bc7317f5f7adc2..d1d9c5d081f829 100644 --- a/integrations/docker/images/chip-cert-bins/Dockerfile +++ b/integrations/docker/images/chip-cert-bins/Dockerfile @@ -7,7 +7,7 @@ ARG COMMITHASH=7b99e6399c6069037c613782d78132c69b9dcabb # ZAP Development install, so that it runs on both x64 and arm64 # Generally this should match with the ZAP version that is used for codegen within the # specified SHA -ARG ZAP_VERSION=v2023.03.30-nightly +ARG ZAP_VERSION=v2023.04.05-nightly # Ensure TARGETPLATFORM is set RUN case ${TARGETPLATFORM} in \ diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index 904dd81e0d063f..8c2a1cd15ef722 100755 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -547,6 +547,7 @@ def BuildTelinkTarget(): target.AppendFixedTargets([ TargetPart('all-clusters', app=TelinkApp.ALL_CLUSTERS), TargetPart('all-clusters-minimal', app=TelinkApp.ALL_CLUSTERS_MINIMAL), + TargetPart('bridge', app=TelinkApp.BRIDGE), TargetPart('contact-sensor', app=TelinkApp.CONTACT_SENSOR), TargetPart('light', app=TelinkApp.LIGHT), TargetPart('light-switch', app=TelinkApp.SWITCH), diff --git a/scripts/build/builders/telink.py b/scripts/build/builders/telink.py index 9dc580016fbf7e..aec767a764100d 100644 --- a/scripts/build/builders/telink.py +++ b/scripts/build/builders/telink.py @@ -23,6 +23,7 @@ class TelinkApp(Enum): ALL_CLUSTERS = auto() ALL_CLUSTERS_MINIMAL = auto() + BRIDGE = auto() CONTACT_SENSOR = auto() LIGHT = auto() SWITCH = auto() @@ -39,6 +40,8 @@ def ExampleName(self): return 'all-clusters-app' elif self == TelinkApp.ALL_CLUSTERS_MINIMAL: return 'all-clusters-minimal-app' + elif self == TelinkApp.BRIDGE: + return 'bridge-app' elif self == TelinkApp.CONTACT_SENSOR: return 'contact-sensor-app' elif self == TelinkApp.LIGHT: @@ -67,6 +70,8 @@ def AppNamePrefix(self): return 'chip-telink-all-clusters-example' elif self == TelinkApp.ALL_CLUSTERS_MINIMAL: return 'chip-telink-all-clusters-minimal-example' + elif self == TelinkApp.BRIDGE: + return 'chip-telink-bridge-example' elif self == TelinkApp.CONTACT_SENSOR: return 'chip-telink-contact-sensor-example' elif self == TelinkApp.LIGHT: diff --git a/scripts/build/testdata/all_targets_linux_x64.txt b/scripts/build/testdata/all_targets_linux_x64.txt index a162653f1efc62..fb7005b2a3c818 100644 --- a/scripts/build/testdata/all_targets_linux_x64.txt +++ b/scripts/build/testdata/all_targets_linux_x64.txt @@ -19,5 +19,5 @@ nrf-{nrf5340dk,nrf52840dk,nrf52840dongle}-{all-clusters,all-clusters-minimal,loc nrf-native-posix-64-tests qpg-qpg6105-{lock,light,shell,persistent-storage} tizen-arm-{all-clusters,all-clusters-minimal,chip-tool,light,tests}[-no-ble][-no-wifi][-asan][-ubsan] -telink-tlsr9518adk80d-{all-clusters,all-clusters-minimal,contact-sensor,light,light-switch,lock,ota-requestor,pump,pump-controller,temperature-measurement,thermostat,window-covering}[-rpc][-factory-data] +telink-tlsr9518adk80d-{all-clusters,all-clusters-minimal,bridge,contact-sensor,light,light-switch,lock,ota-requestor,pump,pump-controller,temperature-measurement,thermostat,window-covering}[-rpc][-factory-data] openiotsdk-{shell,lock} diff --git a/scripts/codepregen.py b/scripts/codepregen.py index 7c5bfd747295cd..43de8fc21c4dc1 100755 --- a/scripts/codepregen.py +++ b/scripts/codepregen.py @@ -85,8 +85,13 @@ def _ParallelGenerateOne(arg): '--sdk-root', default=None, help='Path to the SDK root (where .zap/.matter files exist).') +@click.option( + '--external-root', + default=None, + multiple=True, + help='Path to an external app root (where .zap/.matter files exist).') @click.argument('output_dir') -def main(log_level, parallel, dry_run, generator, input_glob, sdk_root, output_dir): +def main(log_level, parallel, dry_run, generator, input_glob, sdk_root, external_root, output_dir): if _has_coloredlogs: coloredlogs.install(level=__LOG_LEVELS__[ log_level], fmt='%(asctime)s %(levelname)-7s %(message)s') @@ -122,7 +127,7 @@ def main(log_level, parallel, dry_run, generator, input_glob, sdk_root, output_d elif generator == 'codegen': filter.file_type = IdlFileType.MATTER - targets = FindPregenerationTargets(sdk_root, filter, runner) + targets = FindPregenerationTargets(sdk_root, external_root, filter, runner) runner.ensure_directory_exists(output_dir) if parallel: diff --git a/scripts/flashing/bouffalolab_firmware_utils.py b/scripts/flashing/bouffalolab_firmware_utils.py index c968c90f2f839c..2e7596892da94a 100644 --- a/scripts/flashing/bouffalolab_firmware_utils.py +++ b/scripts/flashing/bouffalolab_firmware_utils.py @@ -86,6 +86,29 @@ 'type': pathlib.Path } }, + 'pk': { + 'help': 'public key to sign and encrypt firmware. Available for OTA image building.', + 'default': None, + 'argparse': { + 'metavar': 'path', + 'type': pathlib.Path + } + }, + 'sk': { + 'help': 'private key to sign and encrypt firmware. Available for OTA image building.', + 'default': None, + 'argparse': { + 'metavar': 'path', + 'type': pathlib.Path + } + }, + 'boot2': { + 'help': 'boot2 image.', + 'default': None, + 'argparse': { + 'metavar': 'path', + } + } }, } @@ -98,16 +121,20 @@ def __init__(self, **options): super().__init__(platform=None, module=__name__, **options) self.define_options(BOUFFALO_OPTIONS) - def get_boot_image(self, config_path): + def get_boot_image(self, config_path, boot2_image): boot_image_guess = None for root, dirs, files in os.walk(config_path, topdown=False): for name in files: - if name == "boot2_isp_release.bin": - return os.path.join(root, name) - elif not boot_image_guess and name.find("release") >= 0: - boot_image_guess = os.path.join(root, name) + print("get_boot_image", root, boot2_image) + if boot2_image: + return os.path.join(root, boot2_image) + else: + if name == "boot2_isp_release.bin": + return os.path.join(root, name) + elif not boot_image_guess and name.find("release") >= 0: + boot_image_guess = os.path.join(root, name) return boot_image_guess @@ -147,10 +174,17 @@ def actions(self): chip_name = None chip_config_path = None - boot_image = None + boot2_image = None dts_path = None xtal_value = None + is_for_ota_image_building = False + is_for_programming = False + has_private_key = False + has_public_key = False + + boot2_image = None + command_args = {} for (key, value) in dict(vars(self.option)).items(): @@ -164,6 +198,9 @@ def actions(self): if key == "application": key = "firmware" work_dir = os.path.dirname(os.path.join(os.getcwd(), str(value))) + elif key == "boot2": + boot2_image = value + continue elif key in options_keys: pass else: @@ -183,11 +220,32 @@ def actions(self): xtal_value = value elif key == "dts": dts_path = value + elif "port" == key: + if value: + is_for_programming = True + elif "build" == key: + if value: + is_for_ota_image_building = True + elif "pk" == key: + if value: + has_public_key = True + elif "sk" == key: + if value: + has_private_key = True arguments.append(arg) print(key, value) + if is_for_ota_image_building and is_for_programming: + print("ota imge build can't work with image programming") + return self + + if is_for_ota_image_building: + if (has_private_key is not has_public_key) and (has_private_key or has_public_key): + print("For ota image signature, key pair must be used together") + return self + print(dts_path, xtal_value) if not dts_path and xtal_value: chip_config_path = os.path.join(tool_path, "chips", chip_name, "device_tree") @@ -195,14 +253,20 @@ def actions(self): arguments.append("--dts") arguments.append(dts_path) - if self.option.erase: - arguments.append("--erase") - - if chip_name == "bl602": - chip_config_path = os.path.join(tool_path, "chips", chip_name, "builtin_imgs") - boot_image = self.get_boot_image(chip_config_path) - arguments.append("--boot2") - arguments.append(boot_image) + if boot2_image: + chip_config_path = os.path.join(tool_path, "chips", chip_name, "builtin_imgs") + boot2_image = self.get_boot_image(chip_config_path, boot2_image) + arguments.append("--boot2") + arguments.append(boot2_image) + else: + if self.option.erase: + arguments.append("--erase") + + if chip_name == "bl602": + chip_config_path = os.path.join(tool_path, "chips", chip_name, "builtin_imgs") + boot2_image = self.get_boot_image(chip_config_path, boot2_image) + arguments.append("--boot2") + arguments.append(boot2_image) os.chdir(work_dir) arguments[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', arguments[0]) diff --git a/scripts/pregenerate/__init__.py b/scripts/pregenerate/__init__.py index f664f5745b81dc..8cdf56719f28a6 100644 --- a/scripts/pregenerate/__init__.py +++ b/scripts/pregenerate/__init__.py @@ -25,7 +25,20 @@ from .using_zap import ZapApplicationPregenerator -def FindAllIdls(sdk_root: str) -> Iterator[InputIdlFile]: +def _IdlsInDirectory(top_directory_name: str, truncate_length: int): + for root, dirs, files in os.walk(top_directory_name): + for file in files: + if file.endswith('.zap'): + yield InputIdlFile(file_type=IdlFileType.ZAP, + full_path=os.path.join(root, file), + relative_path=os.path.join(root[truncate_length:], file)) + if file.endswith('.matter'): + yield InputIdlFile(file_type=IdlFileType.MATTER, + full_path=os.path.join(root, file), + relative_path=os.path.join(root[truncate_length:], file)) + + +def _FindAllIdls(sdk_root: str, external_roots: Optional[List[str]]) -> Iterator[InputIdlFile]: relevant_subdirs = [ 'examples', # all example apps 'src', # realistically only controller/data_model @@ -35,17 +48,19 @@ def FindAllIdls(sdk_root: str) -> Iterator[InputIdlFile]: sdk_root = sdk_root[:-1] sdk_root_length = len(sdk_root) + # first go over SDK items for subdir_name in relevant_subdirs: top_directory_name = os.path.join(sdk_root, subdir_name) logging.debug(f"Searching {top_directory_name}") - for root, dirs, files in os.walk(top_directory_name): - for file in files: - if file.endswith('.zap'): - yield InputIdlFile(file_type=IdlFileType.ZAP, - relative_path=os.path.join(root[sdk_root_length+1:], file)) - if file.endswith('.matter'): - yield InputIdlFile(file_type=IdlFileType.MATTER, - relative_path=os.path.join(root[sdk_root_length+1:], file)) + for idl in _IdlsInDirectory(top_directory_name, sdk_root_length+1): + yield idl + + # next external roots + if external_roots: + for root in external_roots: + root = os.path.normpath(root) + for idl in _IdlsInDirectory(root, len(root) + 1): + yield idl @dataclass @@ -67,7 +82,7 @@ def matches(self, s: str): return fnmatch.fnmatch(s, self.pattern) -def FindPregenerationTargets(sdk_root: str, filter: TargetFilter, runner): +def FindPregenerationTargets(sdk_root: str, external_roots: Optional[List[str]], filter: TargetFilter, runner): """Finds all relevand pre-generation targets in the given SDK root. @@ -88,7 +103,7 @@ def FindPregenerationTargets(sdk_root: str, filter: TargetFilter, runner): path_matchers = [GlobMatcher(pattern) for pattern in filter.path_glob] - for idl in FindAllIdls(sdk_root): + for idl in _FindAllIdls(sdk_root, external_roots): if filter.file_type is not None: if idl.file_type != filter.file_type: logging.debug(f"Will not process file of type {idl.file_type}: {idl.relative_path}") diff --git a/scripts/pregenerate/types.py b/scripts/pregenerate/types.py index 7f7d601e09a3e8..4e4f58bc4a0df7 100644 --- a/scripts/pregenerate/types.py +++ b/scripts/pregenerate/types.py @@ -26,6 +26,7 @@ class IdlFileType(Enum): class InputIdlFile: file_type: IdlFileType relative_path: str + full_path: str @property def pregen_subdir(self): diff --git a/scripts/pregenerate/using_codegen.py b/scripts/pregenerate/using_codegen.py index 5de358a0f483b1..13e5b71b388661 100644 --- a/scripts/pregenerate/using_codegen.py +++ b/scripts/pregenerate/using_codegen.py @@ -44,14 +44,14 @@ def Generate(self, output_root: str): output_root, self.idl.pregen_subdir, self.generator) logging.info( - f"Generating: {self.generator}:{self.idl.relative_path} into {output_dir}") + f"Generating: {self.generator}:{self.idl.full_path} into {output_dir}") cmd = [ CODEGEN_PY_PATH, '--log-level', 'fatal', '--generator', self.generator, '--output-dir', output_dir, - os.path.join(self.sdk_root, self.idl.relative_path) + self.idl.full_path ] logging.debug(f"Executing {cmd}") diff --git a/scripts/pregenerate/using_zap.py b/scripts/pregenerate/using_zap.py index 4d28f213370655..57df8ec42f7890 100644 --- a/scripts/pregenerate/using_zap.py +++ b/scripts/pregenerate/using_zap.py @@ -56,16 +56,21 @@ def Generate(self, output_root: str): output_dir = os.path.join(output_root, self.idl.pregen_subdir, self.generation_type.subdir) - logging.info(f"Generating: {self.generation_type}:{self.idl.relative_path} into {output_dir}") + logging.info(f"Generating: {self.generation_type}:{self.idl.full_path} into {output_dir}") self.runner.ensure_directory_exists(output_dir) + if self.idl.full_path.startswith(self.sdk_root): + idl_path = self.idl.relative_path + else: + idl_path = self.idl.full_path + cmd = [ ZAP_GENERATE_PATH, '--templates', self.generation_type.generation_template, '--output-dir', output_dir, '--parallel', - self.idl.relative_path + idl_path ] logging.debug(f"Executing {cmd}") self.runner.run(cmd, cwd=self.sdk_root) diff --git a/scripts/py_matter_idl/matter_idl/generators/java/__init__.py b/scripts/py_matter_idl/matter_idl/generators/java/__init__.py index 7bf11f76949574..21726a7c7baebe 100644 --- a/scripts/py_matter_idl/matter_idl/generators/java/__init__.py +++ b/scripts/py_matter_idl/matter_idl/generators/java/__init__.py @@ -97,9 +97,6 @@ def FieldToGlobalName(field: Field, context: TypeLookupContext) -> Union[str, No if FieldQuality.NULLABLE & field.qualities: return None - if FieldQuality.OPTIONAL & field.qualities: - return None - return _UnderlyingType(field, context) diff --git a/scripts/setup/requirements.esp32.txt b/scripts/setup/requirements.esp32.txt index 73e9883005c7ee..44fd20ce9d6e7d 100644 --- a/scripts/setup/requirements.esp32.txt +++ b/scripts/setup/requirements.esp32.txt @@ -10,5 +10,3 @@ kconfiglib==13.7.1 construct==2.10.54 python-socketio<5 gdbgui==0.13.2.0 ; platform_machine != 'aarch64' and sys_platform == 'linux' -jinja2<3.1 -itsdangerous<2.1 diff --git a/scripts/setup/zap.json b/scripts/setup/zap.json index a9a13342a3b79b..88209409ae83d1 100644 --- a/scripts/setup/zap.json +++ b/scripts/setup/zap.json @@ -8,7 +8,7 @@ "mac-arm64", "windows-amd64" ], - "tags": ["version:2@v2023.03.30-nightly.1"] + "tags": ["version:2@v2023.04.05-nightly.1"] } ] } diff --git a/scripts/tests/cirque_tests.sh b/scripts/tests/cirque_tests.sh index 6f8f41215ce391..87e6c1e3475787 100755 --- a/scripts/tests/cirque_tests.sh +++ b/scripts/tests/cirque_tests.sh @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# Don't warn about unreachable commands in this file: +# shellcheck disable=SC2317 SOURCE=${BASH_SOURCE[0]} SOURCE_DIR=$(cd "$(dirname "$SOURCE")" >/dev/null 2>&1 && pwd) @@ -76,6 +78,7 @@ function __cirquetest_clean_flask() { function __cirquetest_build_ot() { echo -e "[$BOLD_YELLOW_TEXT""INFO""$RESET_COLOR] Cache miss, build openthread simulation." script/cmake-build simulation -DOT_THREAD_VERSION=1.2 -DOT_MTD=OFF -DOT_FTD=OFF -DWEB_GUI=0 -DNETWORK_MANAGER=0 -DREST_API=0 -DNAT64=0 + mkdir -p "$(dirname "$OT_SIMULATION_CACHE")" tar czf "$OT_SIMULATION_CACHE" build echo "$OPENTHREAD_CHECKOUT" >"$OT_SIMULATION_CACHE_STAMP_FILE" } @@ -113,7 +116,7 @@ function cirquetest_bootstrap() { make NO_GRPC=1 install -j - if [[ "x$GITHUB_ACTION_RUN" = "x1" ]]; then + if [[ "$GITHUB_ACTION_RUN" = "1" ]]; then # Note: This script will be invoked in docker on CI, We should add CHIP repo to safe directory to silent git error messages. git config --global --add safe.directory /home/runner/work/connectedhomeip/connectedhomeip fi @@ -140,7 +143,7 @@ function cirquetest_run_test() { # After test finished, the container is perserved and networks will not be deleted # This is useful when running tests on local workstation, but not for CI. - if [[ "x$CLEANUP_DOCKER_FOR_CI" = "x1" ]]; then + if [[ "$CLEANUP_DOCKER_FOR_CI" = "1" ]]; then echo "Do docker container and network prune" # TODO: Filter cirque containers ? if ! grep docker.sock /proc/1/mountinfo; then @@ -169,7 +172,7 @@ function cirquetest_run_all_tests() { fi done - if [[ "x$GITHUB_ACTION_RUN" = "x1" ]]; then + if [[ "$GITHUB_ACTION_RUN" = "1" ]]; then echo -e "[$BOLD_YELLOW_TEXT""INFO""$RESET_COLOR] Logs will be uploaded to artifacts." fi diff --git a/scripts/tests/yaml/chiptool.py b/scripts/tests/yaml/chiptool.py index 9218832ea8c0f5..c5d6724b1459cd 100755 --- a/scripts/tests/yaml/chiptool.py +++ b/scripts/tests/yaml/chiptool.py @@ -29,12 +29,19 @@ @click.pass_context -def send_yaml_command(ctx, test_name: str, server_path: str, server_arguments: str, pics: str): - parser_builder_config = ctx.invoke(runner_base, test_name=test_name, pics=pics) +def send_yaml_command(ctx, test_name: str, server_path: str, server_arguments: str, pics: str, commands: list[str]): + kwargs = {'test_name': test_name, 'pics': pics} + + index = 0 + while len(commands) - index > 1: + kwargs[commands[index].replace('--', '')] = commands[index+1] + index += 2 + ctx.invoke(runner_base, **kwargs) del ctx.params['commands'] del ctx.params['pics'] - return ctx.forward(chiptool, parser_builder_config) + + return ctx.forward(chiptool) def send_raw_command(command: str, server_path: str, server_arguments: str): @@ -88,7 +95,7 @@ def chiptool_py(ctx, commands: list[str], server_path: str, server_name: str, se success = False if len(commands) > 1 and commands[0] == 'tests': - success = send_yaml_command(commands[1], server_path, server_arguments, pics) + success = send_yaml_command(commands[1], server_path, server_arguments, pics, commands[2:]) else: if server_path is None and server_name: paths_finder = PathsFinder() diff --git a/scripts/tools/generate_esp32_chip_factory_bin.py b/scripts/tools/generate_esp32_chip_factory_bin.py index b7dd96eb0d2d07..fac1c274e70a67 100755 --- a/scripts/tools/generate_esp32_chip_factory_bin.py +++ b/scripts/tools/generate_esp32_chip_factory_bin.py @@ -400,22 +400,17 @@ def generate_nvs_csv(out_csv_filename): def generate_nvs_bin(encrypt, size, csv_filename, bin_filename): + nvs_args = SimpleNamespace(version=2, + outdir=os.getcwd(), + input=csv_filename, + output=bin_filename, + size=hex(size)) if encrypt: - nvs_args = SimpleNamespace(version=2, - keygen=True, - keyfile=NVS_KEY_PARTITION_BIN, - inputkey=None, - outdir=os.getcwd(), - input=csv_filename, - output=bin_filename, - size=hex(size)) + nvs_args.keygen = True + nvs_args.keyfile = NVS_KEY_PARTITION_BIN + nvs_args.inputkey = None, nvs_partition_gen.encrypt(nvs_args) else: - nvs_args = SimpleNamespace(input=csv_filename, - output=bin_filename, - size=hex(size), - outdir=os.getcwd(), - version=2) nvs_partition_gen.generate(nvs_args) diff --git a/scripts/tools/zap/zap_execution.py b/scripts/tools/zap/zap_execution.py index 4beb061e32fc3f..cfc4fcfc588281 100644 --- a/scripts/tools/zap/zap_execution.py +++ b/scripts/tools/zap/zap_execution.py @@ -23,7 +23,7 @@ # Use scripts/tools/zap/version_update.py to manage ZAP versioning as many # files may need updating for versions # -MIN_ZAP_VERSION = '2023.3.30' +MIN_ZAP_VERSION = '2023.4.5' class ZapTool: diff --git a/src/app/OperationalSessionSetup.cpp b/src/app/OperationalSessionSetup.cpp index 2e9d572a18618e..f0cbece56cffae 100644 --- a/src/app/OperationalSessionSetup.cpp +++ b/src/app/OperationalSessionSetup.cpp @@ -442,6 +442,10 @@ CHIP_ERROR OperationalSessionSetup::LookupPeerAddress() { ++mAttemptsDone; } + if (mResolveAttemptsAllowed > 0) + { + --mResolveAttemptsAllowed; + } #endif // CHIP_DEVICE_CONFIG_ENABLE_AUTOMATIC_CASE_RETRIES // NOTE: This is public API that can be used to update our stored peer @@ -502,9 +506,44 @@ void OperationalSessionSetup::OnNodeAddressResolutionFailed(const PeerId & peerI ChipLogError(Discovery, "OperationalSessionSetup[%u:" ChipLogFormatX64 "]: operational discovery failed: %" CHIP_ERROR_FORMAT, mPeerId.GetFabricIndex(), ChipLogValueX64(mPeerId.GetNodeId()), reason.Format()); - // Does it make sense to ScheduleSessionSetupReattempt() here? DNS-SD - // resolution has its own retry/backoff mechanisms, so if it's failed we - // have already done a lot of that. +#if CHIP_DEVICE_CONFIG_ENABLE_AUTOMATIC_CASE_RETRIES + // If we're in a mode where we would generally retry CASE, retry operational + // discovery once. That allows us to more-gracefully handle broken networks + // where multicast DNS does not actually work and hence only the initial + // unicast DNS-SD queries get a response. + // + // We check for State::ResolvingAddress just in case in the meantime + // something weird happened and we are no longer trying to resolve an + // address. + if (mState == State::ResolvingAddress && mResolveAttemptsAllowed > 0) + { + ChipLogProgress(Discovery, "Retrying operational DNS-SD discovery. Attempts remaining: %u", mResolveAttemptsAllowed); + + // Pretend like our previous attempt (i.e. call to LookupPeerAddress) + // has not happened for purposes of the generic attempt counters, so we + // don't mess up the counters for our actual CASE retry logic. + if (mRemainingAttempts < UINT8_MAX) + { + ++mRemainingAttempts; + } + if (mAttemptsDone > 0) + { + --mAttemptsDone; + } + + CHIP_ERROR err = LookupPeerAddress(); + if (err == CHIP_NO_ERROR) + { + // We need to notify our consumer that the resolve will take more + // time, but we don't actually know how much time it will take, + // because the resolver does not expose that information. Just use + // one minute to be safe. + using namespace chip::System::Clock::Literals; + NotifyRetryHandlers(reason, 60_s16); + return; + } + } +#endif // No need to modify any variables in `this` since call below releases `this`. DequeueConnectionCallbacks(reason); @@ -531,6 +570,11 @@ void OperationalSessionSetup::UpdateAttemptCount(uint8_t attemptCount) { mRemainingAttempts = attemptCount; } + + if (attemptCount > mResolveAttemptsAllowed) + { + mResolveAttemptsAllowed = attemptCount; + } } CHIP_ERROR OperationalSessionSetup::ScheduleSessionSetupReattempt(System::Clock::Seconds16 & timerDelay) @@ -619,11 +663,16 @@ void OperationalSessionSetup::NotifyRetryHandlers(CHIP_ERROR error, const Reliab System::Clock::Timeout messageTimeout = CASESession::ComputeSigma1ResponseTimeout(remoteMrpConfig); auto timeoutSecs = std::chrono::duration_cast(messageTimeout); // Add 1 second in case we had fractional milliseconds in messageTimeout. - timeoutSecs += System::Clock::Seconds16(1); + using namespace chip::System::Clock::Literals; + NotifyRetryHandlers(error, timeoutSecs + 1_s16 + retryDelay); +} + +void OperationalSessionSetup::NotifyRetryHandlers(CHIP_ERROR error, System::Clock::Seconds16 timeoutEstimate) +{ for (auto * item = mConnectionRetry.First(); item && item != &mConnectionRetry; item = item->mNext) { auto cb = Callback::Callback::FromCancelable(item); - cb->mCall(cb->mContext, mPeerId, error, timeoutSecs + retryDelay); + cb->mCall(cb->mContext, mPeerId, error, timeoutEstimate); } } #endif // CHIP_DEVICE_CONFIG_ENABLE_AUTOMATIC_CASE_RETRIES diff --git a/src/app/OperationalSessionSetup.h b/src/app/OperationalSessionSetup.h index 60f0f0ecaba5b7..e7522d5d62e978 100644 --- a/src/app/OperationalSessionSetup.h +++ b/src/app/OperationalSessionSetup.h @@ -286,6 +286,8 @@ class DLL_EXPORT OperationalSessionSetup : public SessionDelegate, uint8_t mRemainingAttempts = 0; uint8_t mAttemptsDone = 0; + uint8_t mResolveAttemptsAllowed = 0; + Callback::CallbackDeque mConnectionRetry; #endif // CHIP_DEVICE_CONFIG_ENABLE_AUTOMATIC_CASE_RETRIES @@ -354,6 +356,12 @@ class DLL_EXPORT OperationalSessionSetup : public SessionDelegate, */ void NotifyRetryHandlers(CHIP_ERROR error, const ReliableMessageProtocolConfig & remoteMrpConfig, System::Clock::Seconds16 retryDelay); + + /** + * A version of NotifyRetryHandlers that passes in a retry timeout estimate + * directly. + */ + void NotifyRetryHandlers(CHIP_ERROR error, System::Clock::Seconds16 timeoutEstimate); #endif // CHIP_DEVICE_CONFIG_ENABLE_AUTOMATIC_CASE_RETRIES }; diff --git a/src/app/ReadHandler.cpp b/src/app/ReadHandler.cpp index b393edad4fc01e..5dc2ce668fec09 100644 --- a/src/app/ReadHandler.cpp +++ b/src/app/ReadHandler.cpp @@ -142,7 +142,7 @@ ReadHandler::~ReadHandler() void ReadHandler::Close(CloseOptions options) { #if CHIP_CONFIG_PERSIST_SUBSCRIPTIONS - if (options == CloseOptions::kDropPersistedSubscription) + if (IsType(InteractionType::Subscribe) && options == CloseOptions::kDropPersistedSubscription) { auto * subscriptionResumptionStorage = InteractionModelEngine::GetInstance()->GetSubscriptionResumptionStorage(); if (subscriptionResumptionStorage) @@ -177,7 +177,12 @@ void ReadHandler::OnInitialRequest(System::PacketBufferHandle && aPayload) status = StatusIB(err).mStatus; } StatusResponse::Send(status, mExchangeCtx.Get(), /* aExpectResponse = */ false); - Close(); + // At this point we can't have a persisted subscription, since that + // happens only when ProcessSubscribeRequest returns success. And our + // subscription id is almost certainly not actually useful at this + // point, either. So don't try to mess with persisted subscriptions in + // Close(). + Close(CloseOptions::kKeepPersistedSubscription); } else { diff --git a/src/app/clusters/groups-server/groups-server.cpp b/src/app/clusters/groups-server/groups-server.cpp index 20bca62bde156b..9a5604dd3b6838 100644 --- a/src/app/clusters/groups-server/groups-server.cpp +++ b/src/app/clusters/groups-server/groups-server.cpp @@ -75,7 +75,7 @@ static bool KeyExists(FabricIndex fabricIndex, GroupId groupId) static Status GroupAdd(FabricIndex fabricIndex, EndpointId endpointId, GroupId groupId, const CharSpan & groupName) { - VerifyOrReturnError(IsFabricGroupId(groupId), Status::ConstraintError); + VerifyOrReturnError(IsValidGroupId(groupId), Status::ConstraintError); GroupDataProvider * provider = GetGroupDataProvider(); VerifyOrReturnError(nullptr != provider, Status::NotFound); @@ -99,7 +99,7 @@ static Status GroupAdd(FabricIndex fabricIndex, EndpointId endpointId, GroupId g static EmberAfStatus GroupRemove(FabricIndex fabricIndex, EndpointId endpointId, GroupId groupId) { - VerifyOrReturnError(IsFabricGroupId(groupId), EMBER_ZCL_STATUS_CONSTRAINT_ERROR); + VerifyOrReturnError(IsValidGroupId(groupId), EMBER_ZCL_STATUS_CONSTRAINT_ERROR); VerifyOrReturnError(GroupExists(fabricIndex, endpointId, groupId), EMBER_ZCL_STATUS_NOT_FOUND); GroupDataProvider * provider = GetGroupDataProvider(); @@ -159,7 +159,7 @@ bool emberAfGroupsClusterViewGroupCallback(app::CommandHandler * commandObj, con CHIP_ERROR err = CHIP_NO_ERROR; EmberAfStatus status = EMBER_ZCL_STATUS_NOT_FOUND; - VerifyOrExit(IsFabricGroupId(groupId), status = EMBER_ZCL_STATUS_CONSTRAINT_ERROR); + VerifyOrExit(IsValidGroupId(groupId), status = EMBER_ZCL_STATUS_CONSTRAINT_ERROR); VerifyOrExit(nullptr != provider, status = EMBER_ZCL_STATUS_FAILURE); VerifyOrExit(provider->HasEndpoint(fabricIndex, groupId, commandPath.mEndpointId), status = EMBER_ZCL_STATUS_NOT_FOUND); diff --git a/src/app/clusters/window-covering-server/window-covering-server.cpp b/src/app/clusters/window-covering-server/window-covering-server.cpp index 29e8b7070ad5b9..7e9661f6fecd46 100644 --- a/src/app/clusters/window-covering-server/window-covering-server.cpp +++ b/src/app/clusters/window-covering-server/window-covering-server.cpp @@ -735,26 +735,39 @@ bool emberAfWindowCoveringClusterStopMotionCallback(app::CommandHandler * comman return true; } + bool changeTarget = true; + Delegate * delegate = GetDelegate(endpoint); if (delegate) { - LogErrorOnFailure(delegate->HandleStopMotion()); + CHIP_ERROR err = delegate->HandleStopMotion(); + if (err == CHIP_ERROR_IN_PROGRESS) + { + changeTarget = false; + } + else + { + LogErrorOnFailure(err); + } } else { emberAfWindowCoveringClusterPrint("WindowCovering has no delegate set for endpoint:%u", endpoint); } - if (HasFeaturePaLift(endpoint)) + if (changeTarget) { - (void) Attributes::CurrentPositionLiftPercent100ths::Get(endpoint, current); - (void) Attributes::TargetPositionLiftPercent100ths::Set(endpoint, current); - } + if (HasFeaturePaLift(endpoint)) + { + (void) Attributes::CurrentPositionLiftPercent100ths::Get(endpoint, current); + (void) Attributes::TargetPositionLiftPercent100ths::Set(endpoint, current); + } - if (HasFeaturePaTilt(endpoint)) - { - (void) Attributes::CurrentPositionTiltPercent100ths::Get(endpoint, current); - (void) Attributes::TargetPositionTiltPercent100ths::Set(endpoint, current); + if (HasFeaturePaTilt(endpoint)) + { + (void) Attributes::CurrentPositionTiltPercent100ths::Get(endpoint, current); + (void) Attributes::TargetPositionTiltPercent100ths::Set(endpoint, current); + } } return CHIP_NO_ERROR == commandObj->AddStatus(commandPath, Status::Success); diff --git a/src/app/util/af.h b/src/app/util/af.h index f59d36c1fcb126..2acece42a97de9 100644 --- a/src/app/util/af.h +++ b/src/app/util/af.h @@ -153,8 +153,34 @@ uint16_t emberAfIndexFromEndpoint(chip::EndpointId endpoint); uint16_t emberAfIndexFromEndpointIncludingDisabledEndpoints(chip::EndpointId endpoint); /** - * Returns the endpoint index within a given cluster (Server-side), - * looking only for standard clusters. + * Returns the index of the given endpoint in the list of all defined endpoints + * (including disabled ones) that support the given cluster. + * + * Returns kEmberInvalidEndpointIndex if the given endpoint does not support the + * given cluster. + * + * For fixed endpoints, the returned value never changes, but for dynamic + * endpoints it can change if a dynamic endpoint is defined at a lower index + * that also supports the given cluster. + * + * For example, if a device has 4 fixed endpoints (ids 0-3) and 2 dynamic + * endpoints, and cluster X is supported on endpoints 1 and 3, then: + * + * 1) emberAfFindClusterServerEndpointIndex(0, X) returns kEmberInvalidEndpointIndex + * 2) emberAfFindClusterServerEndpointIndex(1, X) returns 0 + * 3) emberAfFindClusterServerEndpointIndex(2, X) returns kEmberInvalidEndpointIndex + * 4) emberAfFindClusterServerEndpointIndex(3, X) returns 1 + * + * If the second dynamic endpoint is defined (via + * emberAfSetDynamicEndpoint(1, 7, ...)) to + * have endpoint id 7, and supports cluster X, but the first dynamic endpoint is + * not defined, then emberAfFindClusterServerEndpointIndex(7, X) returns 2. + * + * If now the first dynamic endpoint is defined (via + * emberAfSetDynamicEndpoint(0, 9, ...)) + * to have endpoint id 9, and supports cluster X, then + * emberAfFindClusterServerEndpointIndex(7, X) starts returning 3 and + * emberAfFindClusterServerEndpointIndex(9, X) returns 2. */ uint16_t emberAfFindClusterServerEndpointIndex(chip::EndpointId endpoint, chip::ClusterId clusterId); diff --git a/src/app/zap-templates/partials/idl/attribute_definition.zapt b/src/app/zap-templates/partials/idl/attribute_definition.zapt index 4a43ea95ef082f..2fee7aa0e79320 100644 --- a/src/app/zap-templates/partials/idl/attribute_definition.zapt +++ b/src/app/zap-templates/partials/idl/attribute_definition.zapt @@ -12,16 +12,19 @@ {{~#chip_access_elements entity="attribute"~}} {{~#first~}}access({{~/first~}} {{~#not_first~}}, {{/not_first~}} - {{operation}}: {{role}} + {{operation}}: {{role}} {{~#last}}) {{/last~}} {{~/chip_access_elements~}} + {{#if isOptional~}} + optional {{!marker to place a space even with whitespace removal~}} + {{~/if~}} {{~#if isNullable~}} nullable {{!marker to place a space even with whitespace removal~}} {{~/if~}} {{type}} {{~#unless isArray~}} {{~#if (isString type)~}} - {{~#if maxLength~}} - <{{maxLength}}> + {{~#if maxLength~}} + <{{maxLength}}> {{~/if~}} {{~/if~}} {{/unless}} {{asLowerCamelCase name~}} diff --git a/src/app/zap-templates/templates/app/CHIPClientCallbacks.zapt b/src/app/zap-templates/templates/app/CHIPClientCallbacks.zapt index 2bcc81a319eca2..d28b45a8f2032d 100644 --- a/src/app/zap-templates/templates/app/CHIPClientCallbacks.zapt +++ b/src/app/zap-templates/templates/app/CHIPClientCallbacks.zapt @@ -1,6 +1,6 @@ {{> header}} -{{#if (chip_has_client_clusters)}} +{{#if_enabled_clusters side='client'}} #pragma once #include @@ -21,4 +21,4 @@ typedef void (*{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}ListAttr {{/zcl_attributes_server}} {{/all_user_clusters}} -{{/if}} \ No newline at end of file +{{/if_enabled_clusters}} \ No newline at end of file diff --git a/src/app/zap-templates/templates/app/CHIPClusters.zapt b/src/app/zap-templates/templates/app/CHIPClusters.zapt index a1ce28b71469a9..2bf93e2c728fe2 100644 --- a/src/app/zap-templates/templates/app/CHIPClusters.zapt +++ b/src/app/zap-templates/templates/app/CHIPClusters.zapt @@ -1,6 +1,6 @@ {{> header}} -{{#if (chip_has_client_clusters)}} +{{#if_enabled_clusters side='client'}} // Prevent multiple inclusion #pragma once @@ -25,4 +25,4 @@ public: {{/all_user_clusters}} } // namespace Controller } // namespace chip -{{/if}} +{{/if_enabled_clusters}} diff --git a/src/app/zap-templates/templates/app/MatterIDL.zapt b/src/app/zap-templates/templates/app/MatterIDL.zapt index 61e2ffaf3d876c..7cb1d55149d14f 100644 --- a/src/app/zap-templates/templates/app/MatterIDL.zapt +++ b/src/app/zap-templates/templates/app/MatterIDL.zapt @@ -40,7 +40,7 @@ {{~#chip_access_elements entity="event"~}} {{~#first~}}access({{~/first~}} {{~#not_first~}}, {{/not_first~}} - {{operation}}: {{role}} + {{operation}}: {{role}} {{~#last}}) {{/last~}} {{~/chip_access_elements~}} {{asUpperCamelCase name}} = {{code}} { @@ -53,7 +53,9 @@ {{/zcl_events}} {{#if (is_client side)}} {{#zcl_attributes_server}} + {{#if clusterRef}} {{! ensure indent }}{{>idl_attribute_definition}} + {{/if}} {{/zcl_attributes_server}} {{~else}} @@ -63,17 +65,18 @@ {{/unless}} {{/enabled_attributes_for_cluster_and_side~}} + {{~/if}} {{~!--Global attributes: spec 7.13 describes these as mandatory --}} + {{~!TODO(26053): global attributes are marked as optional, + hence the exclusion above and re-add here.}} readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; readonly attribute attrib_id attributeList[] = 65531; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; - {{~/if}} {{!--Open:Generating command request structs for all incoming commands into server side--~}} {{#if (is_server side)}} - {{#all_incoming_commands_for_cluster name side}} {{~>idl_command_request_struct}} {{/all_incoming_commands_for_cluster}} diff --git a/src/app/zap-templates/templates/app/access.zapt b/src/app/zap-templates/templates/app/access.zapt index fca0bd9b4a20d1..483de62bce4c60 100644 --- a/src/app/zap-templates/templates/app/access.zapt +++ b/src/app/zap-templates/templates/app/access.zapt @@ -10,7 +10,7 @@ //////////////////////////////////////////////////////////////////////////////// -{{#chip_server_clusters}} +{{#all_user_clusters side='server'}} {{#first}} // Parallel array data (*cluster*, attribute, privilege) for read attribute #define GENERATED_ACCESS_READ_ATTRIBUTE__CLUSTER { \ @@ -41,9 +41,9 @@ {{#last}} } {{/last}} -{{/chip_server_clusters}} +{{/all_user_clusters}} -{{#chip_server_clusters}} +{{#all_user_clusters side='server'}} {{#first}} // Parallel array data (cluster, *attribute*, privilege) for read attribute #define GENERATED_ACCESS_READ_ATTRIBUTE__ATTRIBUTE { \ @@ -74,9 +74,9 @@ {{#last}} } {{/last}} -{{/chip_server_clusters}} +{{/all_user_clusters}} -{{#chip_server_clusters}} +{{#all_user_clusters side='server'}} {{#first}} // Parallel array data (cluster, attribute, *privilege*) for read attribute #define GENERATED_ACCESS_READ_ATTRIBUTE__PRIVILEGE { \ @@ -107,11 +107,11 @@ {{#last}} } {{/last}} -{{/chip_server_clusters}} +{{/all_user_clusters}} //////////////////////////////////////////////////////////////////////////////// -{{#chip_server_clusters}} +{{#all_user_clusters side='server'}} {{#first}} // Parallel array data (*cluster*, attribute, privilege) for write attribute #define GENERATED_ACCESS_WRITE_ATTRIBUTE__CLUSTER { \ @@ -142,9 +142,9 @@ {{#last}} } {{/last}} -{{/chip_server_clusters}} +{{/all_user_clusters}} -{{#chip_server_clusters}} +{{#all_user_clusters side='server'}} {{#first}} // Parallel array data (cluster, *attribute*, privilege) for write attribute #define GENERATED_ACCESS_WRITE_ATTRIBUTE__ATTRIBUTE { \ @@ -175,9 +175,9 @@ {{#last}} } {{/last}} -{{/chip_server_clusters}} +{{/all_user_clusters}} -{{#chip_server_clusters}} +{{#all_user_clusters side='server'}} {{#first}} // Parallel array data (cluster, attribute, *privilege*) for write attribute #define GENERATED_ACCESS_WRITE_ATTRIBUTE__PRIVILEGE { \ @@ -208,11 +208,11 @@ {{#last}} } {{/last}} -{{/chip_server_clusters}} +{{/all_user_clusters}} //////////////////////////////////////////////////////////////////////////////// -{{#chip_server_clusters}} +{{#all_user_clusters side='server'}} {{#first}} // Parallel array data (*cluster*, command, privilege) for invoke command #define GENERATED_ACCESS_INVOKE_COMMAND__CLUSTER { \ @@ -243,9 +243,9 @@ {{#last}} } {{/last}} -{{/chip_server_clusters}} +{{/all_user_clusters}} -{{#chip_server_clusters}} +{{#all_user_clusters side='server'}} {{#first}} // Parallel array data (cluster, *command*, privilege) for invoke command #define GENERATED_ACCESS_INVOKE_COMMAND__COMMAND { \ @@ -276,9 +276,9 @@ {{#last}} } {{/last}} -{{/chip_server_clusters}} +{{/all_user_clusters}} -{{#chip_server_clusters}} +{{#all_user_clusters side='server'}} {{#first}} // Parallel array data (cluster, command, *privilege*) for invoke command #define GENERATED_ACCESS_INVOKE_COMMAND__PRIVILEGE { \ @@ -309,11 +309,11 @@ {{#last}} } {{/last}} -{{/chip_server_clusters}} +{{/all_user_clusters}} //////////////////////////////////////////////////////////////////////////////// -{{#chip_server_clusters}} +{{#all_user_clusters side='server'}} {{#first}} // Parallel array data (*cluster*, event, privilege) for read event #define GENERATED_ACCESS_READ_EVENT__CLUSTER { \ @@ -344,9 +344,9 @@ {{#last}} } {{/last}} -{{/chip_server_clusters}} +{{/all_user_clusters}} -{{#chip_server_clusters}} +{{#all_user_clusters side='server'}} {{#first}} // Parallel array data (cluster, *event*, privilege) for read event #define GENERATED_ACCESS_READ_EVENT__EVENT { \ @@ -377,9 +377,9 @@ {{#last}} } {{/last}} -{{/chip_server_clusters}} +{{/all_user_clusters}} -{{#chip_server_clusters}} +{{#all_user_clusters side='server'}} {{#first}} // Parallel array data (cluster, event, *privilege*) for read event #define GENERATED_ACCESS_READ_EVENT__PRIVILEGE { \ @@ -410,7 +410,7 @@ {{#last}} } {{/last}} -{{/chip_server_clusters}} +{{/all_user_clusters}} //////////////////////////////////////////////////////////////////////////////// diff --git a/src/controller/CHIPDeviceController.cpp b/src/controller/CHIPDeviceController.cpp index dd776940654462..2ae83b320839db 100644 --- a/src/controller/CHIPDeviceController.cpp +++ b/src/controller/CHIPDeviceController.cpp @@ -143,6 +143,8 @@ CHIP_ERROR DeviceController::Init(ControllerInitParams params) mSystemState = params.systemState->Retain(); mState = State::Initialized; + mRemoveFromFabricTableOnShutdown = params.removeFromFabricTableOnShutdown; + if (GetFabricIndex() != kUndefinedFabricIndex) { ChipLogProgress(Controller, @@ -348,10 +350,13 @@ void DeviceController::Shutdown() // existing sessions too? mSystemState->SessionMgr()->ExpireAllSessionsForFabric(mFabricIndex); - FabricTable * fabricTable = mSystemState->Fabrics(); - if (fabricTable != nullptr) + if (mRemoveFromFabricTableOnShutdown) { - fabricTable->Forget(mFabricIndex); + FabricTable * fabricTable = mSystemState->Fabrics(); + if (fabricTable != nullptr) + { + fabricTable->Forget(mFabricIndex); + } } } diff --git a/src/controller/CHIPDeviceController.h b/src/controller/CHIPDeviceController.h index 04c24db25a0eea..c3f6cd3ff49f41 100644 --- a/src/controller/CHIPDeviceController.h +++ b/src/controller/CHIPDeviceController.h @@ -128,6 +128,17 @@ struct ControllerInitParams // bool enableServerInteractions = false; + /** + * Controls whether shutdown of the controller removes the corresponding + * entry from the fabric table. For now the removal is just from the + * in-memory table, not from storage, which means that after controller + * shutdown the storage and the in-memory fabric table will be out of sync. + * This is acceptable for implementations that don't actually store any of + * the fabric table information, but if someone wants a true removal at some + * point another option will need to be added here. + */ + bool removeFromFabricTableOnShutdown = true; + chip::VendorId controllerVendorId; }; @@ -330,6 +341,8 @@ class DLL_EXPORT DeviceController : public AbstractDnssdDiscoveryController FabricIndex mFabricIndex = kUndefinedFabricIndex; + bool mRemoveFromFabricTableOnShutdown = true; + // TODO(cecille): Make this configuarable. static constexpr int kMaxCommissionableNodes = 10; Dnssd::DiscoveredNodeData mCommissionableNodes[kMaxCommissionableNodes]; diff --git a/src/controller/CHIPDeviceControllerFactory.cpp b/src/controller/CHIPDeviceControllerFactory.cpp index 7180566e36507c..4cc20bfc3f10a7 100644 --- a/src/controller/CHIPDeviceControllerFactory.cpp +++ b/src/controller/CHIPDeviceControllerFactory.cpp @@ -286,6 +286,7 @@ void DeviceControllerFactory::PopulateInitParams(ControllerInitParams & controll controllerParams.controllerICAC = params.controllerICAC; controllerParams.controllerRCAC = params.controllerRCAC; controllerParams.permitMultiControllerFabrics = params.permitMultiControllerFabrics; + controllerParams.removeFromFabricTableOnShutdown = params.removeFromFabricTableOnShutdown; controllerParams.systemState = mSystemState; controllerParams.controllerVendorId = params.controllerVendorId; diff --git a/src/controller/CHIPDeviceControllerFactory.h b/src/controller/CHIPDeviceControllerFactory.h index fd77c3779017a9..1fa0563b6bd8e1 100644 --- a/src/controller/CHIPDeviceControllerFactory.h +++ b/src/controller/CHIPDeviceControllerFactory.h @@ -90,6 +90,17 @@ struct SetupParams // bool enableServerInteractions = false; + /** + * Controls whether shutdown of the controller removes the corresponding + * entry from the fabric table. For now the removal is just from the + * in-memory table, not from storage, which means that after controller + * shutdown the storage and the in-memory fabric table will be out of sync. + * This is acceptable for implementations that don't actually store any of + * the fabric table information, but if someone wants a true removal at some + * point another option will need to be added here. + */ + bool removeFromFabricTableOnShutdown = true; + Credentials::DeviceAttestationVerifier * deviceAttestationVerifier = nullptr; CommissioningDelegate * defaultCommissioner = nullptr; }; diff --git a/src/controller/data_model/controller-clusters.matter b/src/controller/data_model/controller-clusters.matter index a0a33ddd8f8fb4..a728b838846eca 100644 --- a/src/controller/data_model/controller-clusters.matter +++ b/src/controller/data_model/controller-clusters.matter @@ -155,7 +155,7 @@ client cluster Scenes = 5 { readonly attribute group_id currentGroup = 2; readonly attribute boolean sceneValid = 3; readonly attribute bitmap8 nameSupport = 4; - readonly attribute nullable node_id lastConfiguredBy = 5; + readonly attribute optional nullable node_id lastConfiguredBy = 5; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -335,10 +335,10 @@ client cluster OnOff = 6 { } 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 optional boolean globalSceneControl = 16384; + attribute optional int16u onTime = 16385; + attribute optional int16u offWaitTime = 16386; + attribute access(write: manage) optional nullable OnOffStartUpOnOff startUpOnOff = 16387; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -407,19 +407,19 @@ client cluster LevelControl = 8 { } readonly attribute nullable int8u currentLevel = 0; - readonly attribute int16u remainingTime = 1; - readonly attribute int8u minLevel = 2; - readonly attribute int8u maxLevel = 3; - readonly attribute int16u currentFrequency = 4; - readonly attribute int16u minFrequency = 5; - readonly attribute int16u maxFrequency = 6; + readonly attribute optional int16u remainingTime = 1; + readonly attribute optional int8u minLevel = 2; + readonly attribute optional int8u maxLevel = 3; + readonly attribute optional int16u currentFrequency = 4; + readonly attribute optional int16u minFrequency = 5; + readonly attribute optional int16u maxFrequency = 6; attribute LevelControlOptions options = 15; - attribute int16u onOffTransitionTime = 16; + attribute optional int16u onOffTransitionTime = 16; attribute nullable int8u onLevel = 17; - attribute nullable int16u onTransitionTime = 18; - attribute nullable int16u offTransitionTime = 19; - attribute nullable int8u defaultMoveRate = 20; - attribute access(write: manage) nullable int8u startUpCurrentLevel = 16384; + attribute optional nullable int16u onTransitionTime = 18; + attribute optional nullable int16u offTransitionTime = 19; + attribute optional nullable int8u defaultMoveRate = 20; + attribute access(write: manage) optional nullable int8u startUpCurrentLevel = 16384; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -508,15 +508,15 @@ client cluster LevelControl = 8 { /** An interface for reading the value of a binary measurement and accessing various characteristics of that measurement. */ client cluster BinaryInputBasic = 15 { - attribute char_string<16> activeText = 4; - attribute char_string<16> description = 28; - attribute char_string<16> inactiveText = 46; + attribute optional char_string<16> activeText = 4; + attribute optional char_string<16> description = 28; + attribute optional char_string<16> inactiveText = 46; attribute boolean outOfService = 81; - readonly attribute enum8 polarity = 84; + readonly attribute optional enum8 polarity = 84; attribute boolean presentValue = 85; - attribute enum8 reliability = 103; + attribute optional enum8 reliability = 103; readonly attribute bitmap8 statusFlags = 111; - readonly attribute int32u applicationType = 256; + readonly attribute optional int32u applicationType = 256; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -624,7 +624,7 @@ client cluster AccessControl = 31 { } attribute access(read: administer, write: administer) AccessControlEntryStruct acl[] = 0; - attribute access(read: administer, write: administer) AccessControlExtensionStruct extension[] = 1; + attribute access(read: administer, write: administer) optional AccessControlExtensionStruct extension[] = 1; readonly attribute int16u subjectsPerAccessControlEntry = 2; readonly attribute int16u targetsPerAccessControlEntry = 3; readonly attribute int16u accessControlEntriesPerFabric = 4; @@ -712,7 +712,7 @@ client cluster Actions = 37 { readonly attribute ActionStruct actionList[] = 0; readonly attribute EndpointListStruct endpointLists[] = 1; - readonly attribute long_char_string<512> setupURL = 2; + readonly attribute optional long_char_string<512> setupURL = 2; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -846,14 +846,14 @@ client cluster BasicInformation = 40 { readonly attribute char_string<64> hardwareVersionString = 8; readonly attribute int32u softwareVersion = 9; readonly attribute char_string<64> softwareVersionString = 10; - readonly attribute char_string<16> manufacturingDate = 11; - readonly attribute char_string<32> partNumber = 12; - readonly attribute long_char_string<256> productURL = 13; - readonly attribute char_string<64> productLabel = 14; - readonly attribute char_string<32> serialNumber = 15; - attribute access(write: manage) boolean localConfigDisabled = 16; - readonly attribute boolean reachable = 17; - readonly attribute char_string<32> uniqueID = 18; + readonly attribute optional char_string<16> manufacturingDate = 11; + readonly attribute optional char_string<32> partNumber = 12; + readonly attribute optional long_char_string<256> productURL = 13; + readonly attribute optional char_string<64> productLabel = 14; + readonly attribute optional char_string<32> serialNumber = 15; + attribute access(write: manage) optional boolean localConfigDisabled = 16; + readonly attribute optional boolean reachable = 17; + readonly attribute optional char_string<32> uniqueID = 18; readonly attribute CapabilityMinimaStruct capabilityMinima = 19; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; @@ -1056,8 +1056,8 @@ client cluster TimeFormatLocalization = 44 { } attribute HourFormatEnum hourFormat = 0; - attribute CalendarTypeEnum activeCalendarType = 1; - readonly attribute CalendarTypeEnum supportedCalendarTypes[] = 2; + attribute optional CalendarTypeEnum activeCalendarType = 1; + readonly attribute optional CalendarTypeEnum supportedCalendarTypes[] = 2; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -1081,7 +1081,7 @@ client cluster UnitLocalization = 45 { kTemperatureUnit = 0x1; } - attribute TempUnitEnum temperatureUnit = 0; + attribute optional TempUnitEnum temperatureUnit = 0; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -1321,34 +1321,34 @@ client cluster PowerSource = 47 { readonly attribute PowerSourceStatusEnum status = 0; readonly attribute int8u order = 1; readonly attribute char_string<60> description = 2; - readonly attribute nullable int32u wiredAssessedInputVoltage = 3; - readonly attribute nullable int16u wiredAssessedInputFrequency = 4; - readonly attribute WiredCurrentTypeEnum wiredCurrentType = 5; - readonly attribute nullable int32u wiredAssessedCurrent = 6; - readonly attribute int32u wiredNominalVoltage = 7; - readonly attribute int32u wiredMaximumCurrent = 8; - readonly attribute boolean wiredPresent = 9; - readonly attribute WiredFaultEnum activeWiredFaults[] = 10; - readonly attribute nullable int32u batVoltage = 11; - readonly attribute nullable int8u batPercentRemaining = 12; - readonly attribute nullable int32u batTimeRemaining = 13; - readonly attribute BatChargeLevelEnum batChargeLevel = 14; - readonly attribute boolean batReplacementNeeded = 15; - readonly attribute BatReplaceabilityEnum batReplaceability = 16; - readonly attribute boolean batPresent = 17; - readonly attribute BatFaultEnum activeBatFaults[] = 18; - readonly attribute char_string<60> batReplacementDescription = 19; - readonly attribute BatCommonDesignationEnum batCommonDesignation = 20; - readonly attribute char_string<20> batANSIDesignation = 21; - readonly attribute char_string<20> batIECDesignation = 22; - readonly attribute BatApprovedChemistryEnum batApprovedChemistry = 23; - readonly attribute int32u batCapacity = 24; - readonly attribute int8u batQuantity = 25; - readonly attribute BatChargeStateEnum batChargeState = 26; - readonly attribute nullable int32u batTimeToFullCharge = 27; - readonly attribute boolean batFunctionalWhileCharging = 28; - readonly attribute nullable int32u batChargingCurrent = 29; - readonly attribute BatChargeFaultEnum activeBatChargeFaults[] = 30; + readonly attribute optional nullable int32u wiredAssessedInputVoltage = 3; + readonly attribute optional nullable int16u wiredAssessedInputFrequency = 4; + readonly attribute optional WiredCurrentTypeEnum wiredCurrentType = 5; + readonly attribute optional nullable int32u wiredAssessedCurrent = 6; + readonly attribute optional int32u wiredNominalVoltage = 7; + readonly attribute optional int32u wiredMaximumCurrent = 8; + readonly attribute optional boolean wiredPresent = 9; + readonly attribute optional WiredFaultEnum activeWiredFaults[] = 10; + readonly attribute optional nullable int32u batVoltage = 11; + readonly attribute optional nullable int8u batPercentRemaining = 12; + readonly attribute optional nullable int32u batTimeRemaining = 13; + readonly attribute optional BatChargeLevelEnum batChargeLevel = 14; + readonly attribute optional boolean batReplacementNeeded = 15; + readonly attribute optional BatReplaceabilityEnum batReplaceability = 16; + readonly attribute optional boolean batPresent = 17; + readonly attribute optional BatFaultEnum activeBatFaults[] = 18; + readonly attribute optional char_string<60> batReplacementDescription = 19; + readonly attribute optional BatCommonDesignationEnum batCommonDesignation = 20; + readonly attribute optional char_string<20> batANSIDesignation = 21; + readonly attribute optional char_string<20> batIECDesignation = 22; + readonly attribute optional BatApprovedChemistryEnum batApprovedChemistry = 23; + readonly attribute optional int32u batCapacity = 24; + readonly attribute optional int8u batQuantity = 25; + readonly attribute optional BatChargeStateEnum batChargeState = 26; + readonly attribute optional nullable int32u batTimeToFullCharge = 27; + readonly attribute optional boolean batFunctionalWhileCharging = 28; + readonly attribute optional nullable int32u batChargingCurrent = 29; + readonly attribute optional BatChargeFaultEnum activeBatChargeFaults[] = 30; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -1491,8 +1491,8 @@ client cluster NetworkCommissioning = 49 { readonly attribute access(read: administer) int8u maxNetworks = 0; readonly attribute access(read: administer) NetworkInfo networks[] = 1; - readonly attribute int8u scanMaxTimeSeconds = 2; - readonly attribute int8u connectMaxTimeSeconds = 3; + readonly attribute optional int8u scanMaxTimeSeconds = 2; + readonly attribute optional int8u connectMaxTimeSeconds = 3; attribute access(write: administer) boolean interfaceEnabled = 4; readonly attribute access(read: administer) nullable NetworkCommissioningStatus lastNetworkingStatus = 5; readonly attribute access(read: administer) nullable octet_string<32> lastNetworkID = 6; @@ -1697,12 +1697,12 @@ client cluster GeneralDiagnostics = 51 { readonly attribute NetworkInterface networkInterfaces[] = 0; readonly attribute int16u rebootCount = 1; - readonly attribute int64u upTime = 2; - readonly attribute int32u totalOperationalHours = 3; - readonly attribute BootReasonEnum bootReason = 4; - readonly attribute HardwareFaultEnum activeHardwareFaults[] = 5; - readonly attribute RadioFaultEnum activeRadioFaults[] = 6; - readonly attribute NetworkFaultEnum activeNetworkFaults[] = 7; + readonly attribute optional int64u upTime = 2; + readonly attribute optional int32u totalOperationalHours = 3; + readonly attribute optional BootReasonEnum bootReason = 4; + readonly attribute optional HardwareFaultEnum activeHardwareFaults[] = 5; + readonly attribute optional RadioFaultEnum activeRadioFaults[] = 6; + readonly attribute optional NetworkFaultEnum activeNetworkFaults[] = 7; readonly attribute boolean testEventTriggersEnabled = 8; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; @@ -1740,10 +1740,10 @@ client cluster SoftwareDiagnostics = 52 { optional OCTET_STRING faultRecording = 2; } - readonly attribute ThreadMetricsStruct threadMetrics[] = 0; - readonly attribute int64u currentHeapFree = 1; - readonly attribute int64u currentHeapUsed = 2; - readonly attribute int64u currentHeapHighWatermark = 3; + readonly attribute optional ThreadMetricsStruct threadMetrics[] = 0; + readonly attribute optional int64u currentHeapFree = 1; + readonly attribute optional int64u currentHeapUsed = 2; + readonly attribute optional int64u currentHeapHighWatermark = 3; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -1851,7 +1851,7 @@ client cluster ThreadNetworkDiagnostics = 53 { readonly attribute nullable int16u panId = 3; readonly attribute nullable int64u extendedPanId = 4; readonly attribute nullable octet_string<17> meshLocalPrefix = 5; - readonly attribute int64u overrunCount = 6; + readonly attribute optional int64u overrunCount = 6; readonly attribute NeighborTable neighborTable[] = 7; readonly attribute RouteTable routeTable[] = 8; readonly attribute nullable int32u partitionId = 9; @@ -1859,51 +1859,51 @@ client cluster ThreadNetworkDiagnostics = 53 { readonly attribute nullable int8u dataVersion = 11; readonly attribute nullable int8u stableDataVersion = 12; readonly attribute nullable int8u leaderRouterId = 13; - readonly attribute int16u detachedRoleCount = 14; - readonly attribute int16u childRoleCount = 15; - readonly attribute int16u routerRoleCount = 16; - readonly attribute int16u leaderRoleCount = 17; - readonly attribute int16u attachAttemptCount = 18; - readonly attribute int16u partitionIdChangeCount = 19; - readonly attribute int16u betterPartitionAttachAttemptCount = 20; - readonly attribute int16u parentChangeCount = 21; - readonly attribute int32u txTotalCount = 22; - readonly attribute int32u txUnicastCount = 23; - readonly attribute int32u txBroadcastCount = 24; - readonly attribute int32u txAckRequestedCount = 25; - readonly attribute int32u txAckedCount = 26; - readonly attribute int32u txNoAckRequestedCount = 27; - readonly attribute int32u txDataCount = 28; - readonly attribute int32u txDataPollCount = 29; - readonly attribute int32u txBeaconCount = 30; - readonly attribute int32u txBeaconRequestCount = 31; - readonly attribute int32u txOtherCount = 32; - readonly attribute int32u txRetryCount = 33; - readonly attribute int32u txDirectMaxRetryExpiryCount = 34; - readonly attribute int32u txIndirectMaxRetryExpiryCount = 35; - readonly attribute int32u txErrCcaCount = 36; - readonly attribute int32u txErrAbortCount = 37; - readonly attribute int32u txErrBusyChannelCount = 38; - readonly attribute int32u rxTotalCount = 39; - readonly attribute int32u rxUnicastCount = 40; - readonly attribute int32u rxBroadcastCount = 41; - readonly attribute int32u rxDataCount = 42; - readonly attribute int32u rxDataPollCount = 43; - readonly attribute int32u rxBeaconCount = 44; - readonly attribute int32u rxBeaconRequestCount = 45; - readonly attribute int32u rxOtherCount = 46; - readonly attribute int32u rxAddressFilteredCount = 47; - readonly attribute int32u rxDestAddrFilteredCount = 48; - readonly attribute int32u rxDuplicatedCount = 49; - readonly attribute int32u rxErrNoFrameCount = 50; - readonly attribute int32u rxErrUnknownNeighborCount = 51; - readonly attribute int32u rxErrInvalidSrcAddrCount = 52; - readonly attribute int32u rxErrSecCount = 53; - readonly attribute int32u rxErrFcsCount = 54; - readonly attribute int32u rxErrOtherCount = 55; - readonly attribute nullable int64u activeTimestamp = 56; - readonly attribute nullable int64u pendingTimestamp = 57; - readonly attribute nullable int32u delay = 58; + readonly attribute optional int16u detachedRoleCount = 14; + readonly attribute optional int16u childRoleCount = 15; + readonly attribute optional int16u routerRoleCount = 16; + readonly attribute optional int16u leaderRoleCount = 17; + readonly attribute optional int16u attachAttemptCount = 18; + readonly attribute optional int16u partitionIdChangeCount = 19; + readonly attribute optional int16u betterPartitionAttachAttemptCount = 20; + readonly attribute optional int16u parentChangeCount = 21; + readonly attribute optional int32u txTotalCount = 22; + readonly attribute optional int32u txUnicastCount = 23; + readonly attribute optional int32u txBroadcastCount = 24; + readonly attribute optional int32u txAckRequestedCount = 25; + readonly attribute optional int32u txAckedCount = 26; + readonly attribute optional int32u txNoAckRequestedCount = 27; + readonly attribute optional int32u txDataCount = 28; + readonly attribute optional int32u txDataPollCount = 29; + readonly attribute optional int32u txBeaconCount = 30; + readonly attribute optional int32u txBeaconRequestCount = 31; + readonly attribute optional int32u txOtherCount = 32; + readonly attribute optional int32u txRetryCount = 33; + readonly attribute optional int32u txDirectMaxRetryExpiryCount = 34; + readonly attribute optional int32u txIndirectMaxRetryExpiryCount = 35; + readonly attribute optional int32u txErrCcaCount = 36; + readonly attribute optional int32u txErrAbortCount = 37; + readonly attribute optional int32u txErrBusyChannelCount = 38; + readonly attribute optional int32u rxTotalCount = 39; + readonly attribute optional int32u rxUnicastCount = 40; + readonly attribute optional int32u rxBroadcastCount = 41; + readonly attribute optional int32u rxDataCount = 42; + readonly attribute optional int32u rxDataPollCount = 43; + readonly attribute optional int32u rxBeaconCount = 44; + readonly attribute optional int32u rxBeaconRequestCount = 45; + readonly attribute optional int32u rxOtherCount = 46; + readonly attribute optional int32u rxAddressFilteredCount = 47; + readonly attribute optional int32u rxDestAddrFilteredCount = 48; + readonly attribute optional int32u rxDuplicatedCount = 49; + readonly attribute optional int32u rxErrNoFrameCount = 50; + readonly attribute optional int32u rxErrUnknownNeighborCount = 51; + readonly attribute optional int32u rxErrInvalidSrcAddrCount = 52; + readonly attribute optional int32u rxErrSecCount = 53; + readonly attribute optional int32u rxErrFcsCount = 54; + readonly attribute optional int32u rxErrOtherCount = 55; + readonly attribute optional nullable int64u activeTimestamp = 56; + readonly attribute optional nullable int64u pendingTimestamp = 57; + readonly attribute optional nullable int32u delay = 58; readonly attribute nullable SecurityPolicy securityPolicy = 59; readonly attribute nullable octet_string<4> channelPage0Mask = 60; readonly attribute nullable OperationalDatasetComponents operationalDatasetComponents = 61; @@ -1974,14 +1974,14 @@ client cluster WiFiNetworkDiagnostics = 54 { readonly attribute nullable WiFiVersionEnum wiFiVersion = 2; readonly attribute nullable int16u channelNumber = 3; readonly attribute nullable int8s rssi = 4; - readonly attribute nullable int32u beaconLostCount = 5; - readonly attribute nullable int32u beaconRxCount = 6; - readonly attribute nullable int32u packetMulticastRxCount = 7; - readonly attribute nullable int32u packetMulticastTxCount = 8; - readonly attribute nullable int32u packetUnicastRxCount = 9; - readonly attribute nullable int32u packetUnicastTxCount = 10; - readonly attribute nullable int64u currentMaxRate = 11; - readonly attribute nullable int64u overrunCount = 12; + readonly attribute optional nullable int32u beaconLostCount = 5; + readonly attribute optional nullable int32u beaconRxCount = 6; + readonly attribute optional nullable int32u packetMulticastRxCount = 7; + readonly attribute optional nullable int32u packetMulticastTxCount = 8; + readonly attribute optional nullable int32u packetUnicastRxCount = 9; + readonly attribute optional nullable int32u packetUnicastTxCount = 10; + readonly attribute optional nullable int64u currentMaxRate = 11; + readonly attribute optional nullable int64u overrunCount = 12; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -2013,15 +2013,15 @@ client cluster EthernetNetworkDiagnostics = 55 { kErrorCounts = 0x2; } - readonly attribute nullable PHYRateEnum PHYRate = 0; - readonly attribute nullable boolean fullDuplex = 1; - readonly attribute int64u packetRxCount = 2; - readonly attribute int64u packetTxCount = 3; - readonly attribute int64u txErrCount = 4; - readonly attribute int64u collisionCount = 5; - readonly attribute int64u overrunCount = 6; - readonly attribute nullable boolean carrierDetect = 7; - readonly attribute int64u timeSinceReset = 8; + readonly attribute optional nullable PHYRateEnum PHYRate = 0; + readonly attribute optional nullable boolean fullDuplex = 1; + readonly attribute optional int64u packetRxCount = 2; + readonly attribute optional int64u packetTxCount = 3; + readonly attribute optional int64u txErrCount = 4; + readonly attribute optional int64u collisionCount = 5; + readonly attribute optional int64u overrunCount = 6; + readonly attribute optional nullable boolean carrierDetect = 7; + readonly attribute optional int64u timeSinceReset = 8; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -2052,21 +2052,21 @@ client cluster BridgedDeviceBasicInformation = 57 { boolean reachableNewValue = 0; } - readonly attribute char_string<32> vendorName = 1; - readonly attribute vendor_id vendorID = 2; - readonly attribute char_string<32> productName = 3; - attribute char_string<32> nodeLabel = 5; - readonly attribute int16u hardwareVersion = 7; - readonly attribute char_string<64> hardwareVersionString = 8; - readonly attribute int32u softwareVersion = 9; - readonly attribute char_string<64> softwareVersionString = 10; - readonly attribute char_string<16> manufacturingDate = 11; - readonly attribute char_string<32> partNumber = 12; - readonly attribute long_char_string<256> productURL = 13; - readonly attribute char_string<64> productLabel = 14; - readonly attribute char_string<32> serialNumber = 15; + readonly attribute optional char_string<32> vendorName = 1; + readonly attribute optional vendor_id vendorID = 2; + readonly attribute optional char_string<32> productName = 3; + attribute optional char_string<32> nodeLabel = 5; + readonly attribute optional int16u hardwareVersion = 7; + readonly attribute optional char_string<64> hardwareVersionString = 8; + readonly attribute optional int32u softwareVersion = 9; + readonly attribute optional char_string<64> softwareVersionString = 10; + readonly attribute optional char_string<16> manufacturingDate = 11; + readonly attribute optional char_string<32> partNumber = 12; + readonly attribute optional long_char_string<256> productURL = 13; + readonly attribute optional char_string<64> productLabel = 14; + readonly attribute optional char_string<32> serialNumber = 15; readonly attribute boolean reachable = 17; - readonly attribute char_string<32> uniqueID = 18; + readonly attribute optional char_string<32> uniqueID = 18; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -2119,7 +2119,7 @@ client cluster Switch = 59 { readonly attribute int8u numberOfPositions = 0; readonly attribute int8u currentPosition = 1; - readonly attribute int8u multiPressMax = 2; + readonly attribute optional int8u multiPressMax = 2; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -2441,8 +2441,8 @@ client cluster ModeSelect = 80 { readonly attribute nullable enum16 standardNamespace = 1; readonly attribute ModeOptionStruct supportedModes[] = 2; readonly attribute int8u currentMode = 3; - attribute nullable int8u startUpMode = 4; - attribute nullable int8u onMode = 5; + attribute optional nullable int8u startUpMode = 4; + attribute optional nullable int8u onMode = 5; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -2836,39 +2836,39 @@ client cluster DoorLock = 257 { readonly attribute nullable DlLockState lockState = 0; readonly attribute DlLockType lockType = 1; readonly attribute boolean actuatorEnabled = 2; - 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; - readonly attribute int16u numberOfTotalUsersSupported = 17; - readonly attribute int16u numberOfPINUsersSupported = 18; - readonly attribute int16u numberOfRFIDUsersSupported = 19; - readonly attribute int8u numberOfWeekDaySchedulesSupportedPerUser = 20; - readonly attribute int8u numberOfYearDaySchedulesSupportedPerUser = 21; - readonly attribute int8u numberOfHolidaySchedulesSupported = 22; - readonly attribute int8u maxPINCodeLength = 23; - readonly attribute int8u minPINCodeLength = 24; - readonly attribute int8u maxRFIDCodeLength = 25; - readonly attribute int8u minRFIDCodeLength = 26; - readonly attribute DlCredentialRuleMask credentialRulesSupport = 27; - readonly attribute int8u numberOfCredentialsSupportedPerUser = 28; - attribute access(write: manage) char_string<3> language = 33; - attribute access(write: manage) int8u LEDSettings = 34; + readonly attribute optional nullable DoorStateEnum doorState = 3; + attribute access(write: manage) optional int32u doorOpenEvents = 4; + attribute access(write: manage) optional int32u doorClosedEvents = 5; + attribute access(write: manage) optional int16u openPeriod = 6; + readonly attribute optional int16u numberOfTotalUsersSupported = 17; + readonly attribute optional int16u numberOfPINUsersSupported = 18; + readonly attribute optional int16u numberOfRFIDUsersSupported = 19; + readonly attribute optional int8u numberOfWeekDaySchedulesSupportedPerUser = 20; + readonly attribute optional int8u numberOfYearDaySchedulesSupportedPerUser = 21; + readonly attribute optional int8u numberOfHolidaySchedulesSupported = 22; + readonly attribute optional int8u maxPINCodeLength = 23; + readonly attribute optional int8u minPINCodeLength = 24; + readonly attribute optional int8u maxRFIDCodeLength = 25; + readonly attribute optional int8u minRFIDCodeLength = 26; + readonly attribute optional DlCredentialRuleMask credentialRulesSupport = 27; + readonly attribute optional int8u numberOfCredentialsSupportedPerUser = 28; + attribute access(write: manage) optional char_string<3> language = 33; + attribute access(write: manage) optional int8u LEDSettings = 34; attribute access(write: manage) int32u autoRelockTime = 35; - attribute access(write: manage) int8u soundVolume = 36; + attribute access(write: manage) optional int8u soundVolume = 36; attribute access(write: manage) OperatingModeEnum operatingMode = 37; readonly attribute DlSupportedOperatingModes supportedOperatingModes = 38; - readonly attribute DlDefaultConfigurationRegister defaultConfigurationRegister = 39; - attribute access(write: administer) boolean enableLocalProgramming = 40; - attribute access(write: manage) boolean enableOneTouchLocking = 41; - attribute access(write: manage) boolean enableInsideStatusLED = 42; - attribute access(write: manage) boolean enablePrivacyModeButton = 43; - attribute access(write: administer) DlLocalProgrammingFeatures localProgrammingFeatures = 44; - attribute access(write: administer) int8u wrongCodeEntryLimit = 48; - attribute access(write: administer) int8u userCodeTemporaryDisableTime = 49; - attribute access(write: administer) boolean sendPINOverTheAir = 50; - attribute access(write: administer) boolean requirePINforRemoteOperation = 51; - attribute access(write: administer) int16u expiringUserTimeout = 53; + readonly attribute optional DlDefaultConfigurationRegister defaultConfigurationRegister = 39; + attribute access(write: administer) optional boolean enableLocalProgramming = 40; + attribute access(write: manage) optional boolean enableOneTouchLocking = 41; + attribute access(write: manage) optional boolean enableInsideStatusLED = 42; + attribute access(write: manage) optional boolean enablePrivacyModeButton = 43; + attribute access(write: administer) optional DlLocalProgrammingFeatures localProgrammingFeatures = 44; + attribute access(write: administer) optional int8u wrongCodeEntryLimit = 48; + attribute access(write: administer) optional int8u userCodeTemporaryDisableTime = 49; + attribute access(write: administer) optional boolean sendPINOverTheAir = 50; + attribute access(write: administer) optional boolean requirePINforRemoteOperation = 51; + attribute access(write: administer) optional int16u expiringUserTimeout = 53; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -3159,27 +3159,27 @@ client cluster WindowCovering = 258 { } readonly attribute Type type = 0; - readonly attribute int16u physicalClosedLimitLift = 1; - readonly attribute int16u physicalClosedLimitTilt = 2; - readonly attribute nullable int16u currentPositionLift = 3; - readonly attribute nullable int16u currentPositionTilt = 4; - readonly attribute int16u numberOfActuationsLift = 5; - readonly attribute int16u numberOfActuationsTilt = 6; + readonly attribute optional int16u physicalClosedLimitLift = 1; + readonly attribute optional int16u physicalClosedLimitTilt = 2; + readonly attribute optional nullable int16u currentPositionLift = 3; + readonly attribute optional nullable int16u currentPositionTilt = 4; + readonly attribute optional int16u numberOfActuationsLift = 5; + readonly attribute optional int16u numberOfActuationsTilt = 6; readonly attribute ConfigStatus configStatus = 7; - readonly attribute nullable Percent currentPositionLiftPercentage = 8; - readonly attribute nullable Percent currentPositionTiltPercentage = 9; + readonly attribute optional nullable Percent currentPositionLiftPercentage = 8; + readonly attribute optional nullable Percent currentPositionTiltPercentage = 9; readonly attribute OperationalStatus operationalStatus = 10; - readonly attribute nullable Percent100ths targetPositionLiftPercent100ths = 11; - readonly attribute nullable Percent100ths targetPositionTiltPercent100ths = 12; + readonly attribute optional nullable Percent100ths targetPositionLiftPercent100ths = 11; + readonly attribute optional nullable Percent100ths targetPositionTiltPercent100ths = 12; readonly attribute EndProductType endProductType = 13; - readonly attribute nullable Percent100ths currentPositionLiftPercent100ths = 14; - readonly attribute nullable Percent100ths currentPositionTiltPercent100ths = 15; - readonly attribute int16u installedOpenLimitLift = 16; - readonly attribute int16u installedClosedLimitLift = 17; - readonly attribute int16u installedOpenLimitTilt = 18; - readonly attribute int16u installedClosedLimitTilt = 19; + readonly attribute optional nullable Percent100ths currentPositionLiftPercent100ths = 14; + readonly attribute optional nullable Percent100ths currentPositionTiltPercent100ths = 15; + readonly attribute optional int16u installedOpenLimitLift = 16; + readonly attribute optional int16u installedClosedLimitLift = 17; + readonly attribute optional int16u installedOpenLimitTilt = 18; + readonly attribute optional int16u installedClosedLimitTilt = 19; attribute access(write: manage) Mode mode = 23; - readonly attribute SafetyStatus safetyStatus = 26; + readonly attribute optional SafetyStatus safetyStatus = 26; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -3224,12 +3224,12 @@ client cluster BarrierControl = 259 { readonly attribute enum8 barrierMovingState = 1; readonly attribute bitmap16 barrierSafetyStatus = 2; readonly attribute bitmap8 barrierCapabilities = 3; - attribute int16u barrierOpenEvents = 4; - attribute int16u barrierCloseEvents = 5; - attribute int16u barrierCommandOpenEvents = 6; - attribute int16u barrierCommandCloseEvents = 7; - attribute int16u barrierOpenPeriod = 8; - attribute int16u barrierClosePeriod = 9; + attribute optional int16u barrierOpenEvents = 4; + attribute optional int16u barrierCloseEvents = 5; + attribute optional int16u barrierCommandOpenEvents = 6; + attribute optional int16u barrierCommandCloseEvents = 7; + attribute optional int16u barrierOpenPeriod = 8; + attribute optional int16u barrierClosePeriod = 9; readonly attribute int8u barrierPosition = 10; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; @@ -3342,26 +3342,26 @@ client 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 nullable int16s minCompPressure = 5; - readonly attribute nullable int16s maxCompPressure = 6; - readonly attribute nullable int16u minConstSpeed = 7; - readonly attribute nullable int16u maxConstSpeed = 8; - readonly attribute nullable int16u minConstFlow = 9; - readonly attribute nullable int16u maxConstFlow = 10; - readonly attribute nullable int16s minConstTemp = 11; - readonly attribute nullable int16s maxConstTemp = 12; - readonly attribute PumpStatusBitmap pumpStatus = 16; + readonly attribute optional nullable int16s minConstPressure = 3; + readonly attribute optional nullable int16s maxConstPressure = 4; + readonly attribute optional nullable int16s minCompPressure = 5; + readonly attribute optional nullable int16s maxCompPressure = 6; + readonly attribute optional nullable int16u minConstSpeed = 7; + readonly attribute optional nullable int16u maxConstSpeed = 8; + readonly attribute optional nullable int16u minConstFlow = 9; + readonly attribute optional nullable int16u maxConstFlow = 10; + readonly attribute optional nullable int16s minConstTemp = 11; + readonly attribute optional nullable int16s maxConstTemp = 12; + readonly attribute optional PumpStatusBitmap pumpStatus = 16; readonly attribute OperationModeEnum effectiveOperationMode = 17; readonly attribute ControlModeEnum effectiveControlMode = 18; readonly attribute nullable int16s capacity = 19; - readonly attribute nullable int16u speed = 20; - attribute access(write: manage) nullable int24u lifetimeRunningHours = 21; - readonly attribute nullable int24u power = 22; - attribute access(write: manage) nullable int32u lifetimeEnergyConsumed = 23; + readonly attribute optional nullable int16u speed = 20; + attribute access(write: manage) optional nullable int24u lifetimeRunningHours = 21; + readonly attribute optional nullable int24u power = 22; + attribute access(write: manage) optional nullable int32u lifetimeEnergyConsumed = 23; attribute access(write: manage) OperationModeEnum operationMode = 32; - attribute access(write: manage) ControlModeEnum controlMode = 33; + attribute access(write: manage) optional ControlModeEnum controlMode = 33; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -3437,54 +3437,54 @@ client cluster Thermostat = 513 { } readonly attribute nullable int16s localTemperature = 0; - readonly attribute nullable int16s outdoorTemperature = 1; - readonly attribute bitmap8 occupancy = 2; - readonly attribute int16s absMinHeatSetpointLimit = 3; - readonly attribute int16s absMaxHeatSetpointLimit = 4; - readonly attribute int16s absMinCoolSetpointLimit = 5; - readonly attribute int16s absMaxCoolSetpointLimit = 6; - readonly attribute int8u PICoolingDemand = 7; - readonly attribute int8u PIHeatingDemand = 8; - attribute access(write: manage) bitmap8 HVACSystemTypeConfiguration = 9; - attribute access(write: manage) int8s localTemperatureCalibration = 16; - attribute int16s occupiedCoolingSetpoint = 17; - attribute int16s occupiedHeatingSetpoint = 18; - attribute int16s unoccupiedCoolingSetpoint = 19; - attribute int16s unoccupiedHeatingSetpoint = 20; - attribute access(write: manage) int16s minHeatSetpointLimit = 21; - attribute access(write: manage) int16s maxHeatSetpointLimit = 22; - attribute access(write: manage) int16s minCoolSetpointLimit = 23; - attribute access(write: manage) int16s maxCoolSetpointLimit = 24; - attribute access(write: manage) int8s minSetpointDeadBand = 25; - attribute access(write: manage) bitmap8 remoteSensing = 26; + readonly attribute optional nullable int16s outdoorTemperature = 1; + readonly attribute optional bitmap8 occupancy = 2; + readonly attribute optional int16s absMinHeatSetpointLimit = 3; + readonly attribute optional int16s absMaxHeatSetpointLimit = 4; + readonly attribute optional int16s absMinCoolSetpointLimit = 5; + readonly attribute optional int16s absMaxCoolSetpointLimit = 6; + readonly attribute optional int8u PICoolingDemand = 7; + readonly attribute optional int8u PIHeatingDemand = 8; + attribute access(write: manage) optional bitmap8 HVACSystemTypeConfiguration = 9; + attribute access(write: manage) optional int8s localTemperatureCalibration = 16; + attribute optional int16s occupiedCoolingSetpoint = 17; + attribute optional int16s occupiedHeatingSetpoint = 18; + attribute optional int16s unoccupiedCoolingSetpoint = 19; + attribute optional int16s unoccupiedHeatingSetpoint = 20; + attribute access(write: manage) optional int16s minHeatSetpointLimit = 21; + attribute access(write: manage) optional int16s maxHeatSetpointLimit = 22; + attribute access(write: manage) optional int16s minCoolSetpointLimit = 23; + attribute access(write: manage) optional int16s maxCoolSetpointLimit = 24; + attribute access(write: manage) optional int8s minSetpointDeadBand = 25; + attribute access(write: manage) optional bitmap8 remoteSensing = 26; attribute access(write: manage) ThermostatControlSequence controlSequenceOfOperation = 27; attribute access(write: manage) enum8 systemMode = 28; - readonly attribute enum8 thermostatRunningMode = 30; - readonly attribute enum8 startOfWeek = 32; - readonly attribute int8u numberOfWeeklyTransitions = 33; - readonly attribute int8u numberOfDailyTransitions = 34; - attribute access(write: manage) enum8 temperatureSetpointHold = 35; - attribute access(write: manage) nullable int16u temperatureSetpointHoldDuration = 36; - attribute access(write: manage) bitmap8 thermostatProgrammingOperationMode = 37; - readonly attribute bitmap16 thermostatRunningState = 41; - readonly attribute enum8 setpointChangeSource = 48; - readonly attribute nullable int16s setpointChangeAmount = 49; - readonly attribute epoch_s setpointChangeSourceTimestamp = 50; - attribute access(write: manage) nullable int8u occupiedSetback = 52; - readonly attribute nullable int8u occupiedSetbackMin = 53; - readonly attribute nullable int8u occupiedSetbackMax = 54; - attribute access(write: manage) nullable int8u unoccupiedSetback = 55; - readonly attribute nullable int8u unoccupiedSetbackMin = 56; - readonly attribute nullable int8u unoccupiedSetbackMax = 57; - attribute access(write: manage) int8u emergencyHeatDelta = 58; - attribute access(write: manage) enum8 ACType = 64; - attribute access(write: manage) int16u ACCapacity = 65; - attribute access(write: manage) enum8 ACRefrigerantType = 66; - attribute access(write: manage) enum8 ACCompressorType = 67; - attribute access(write: manage) bitmap32 ACErrorCode = 68; - attribute access(write: manage) enum8 ACLouverPosition = 69; - readonly attribute nullable int16s ACCoilTemperature = 70; - attribute access(write: manage) enum8 ACCapacityformat = 71; + readonly attribute optional enum8 thermostatRunningMode = 30; + readonly attribute optional enum8 startOfWeek = 32; + readonly attribute optional int8u numberOfWeeklyTransitions = 33; + readonly attribute optional int8u numberOfDailyTransitions = 34; + attribute access(write: manage) optional enum8 temperatureSetpointHold = 35; + attribute access(write: manage) optional nullable int16u temperatureSetpointHoldDuration = 36; + attribute access(write: manage) optional bitmap8 thermostatProgrammingOperationMode = 37; + readonly attribute optional bitmap16 thermostatRunningState = 41; + readonly attribute optional enum8 setpointChangeSource = 48; + readonly attribute optional nullable int16s setpointChangeAmount = 49; + readonly attribute optional epoch_s setpointChangeSourceTimestamp = 50; + attribute access(write: manage) optional nullable int8u occupiedSetback = 52; + readonly attribute optional nullable int8u occupiedSetbackMin = 53; + readonly attribute optional nullable int8u occupiedSetbackMax = 54; + attribute access(write: manage) optional nullable int8u unoccupiedSetback = 55; + readonly attribute optional nullable int8u unoccupiedSetbackMin = 56; + readonly attribute optional nullable int8u unoccupiedSetbackMax = 57; + attribute access(write: manage) optional int8u emergencyHeatDelta = 58; + attribute access(write: manage) optional enum8 ACType = 64; + attribute access(write: manage) optional int16u ACCapacity = 65; + attribute access(write: manage) optional enum8 ACRefrigerantType = 66; + attribute access(write: manage) optional enum8 ACCompressorType = 67; + attribute access(write: manage) optional bitmap32 ACErrorCode = 68; + attribute access(write: manage) optional enum8 ACLouverPosition = 69; + readonly attribute optional nullable int16s ACCoilTemperature = 70; + attribute access(write: manage) optional enum8 ACCapacityformat = 71; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -3574,13 +3574,13 @@ client cluster FanControl = 514 { attribute FanModeSequenceType fanModeSequence = 1; attribute nullable int8u percentSetting = 2; readonly attribute int8u percentCurrent = 3; - readonly attribute int8u speedMax = 4; - attribute nullable int8u speedSetting = 5; - readonly attribute int8u speedCurrent = 6; - readonly attribute bitmap8 rockSupport = 7; - attribute bitmap8 rockSetting = 8; - readonly attribute bitmap8 windSupport = 9; - attribute bitmap8 windSetting = 10; + readonly attribute optional int8u speedMax = 4; + attribute optional nullable int8u speedSetting = 5; + readonly attribute optional int8u speedCurrent = 6; + readonly attribute optional bitmap8 rockSupport = 7; + attribute optional bitmap8 rockSetting = 8; + readonly attribute optional bitmap8 windSupport = 9; + attribute optional bitmap8 windSetting = 10; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -3593,7 +3593,7 @@ client cluster FanControl = 514 { client cluster ThermostatUserInterfaceConfiguration = 516 { attribute enum8 temperatureDisplayMode = 0; attribute access(write: manage) enum8 keypadLockout = 1; - attribute access(write: manage) enum8 scheduleProgrammingVisibility = 2; + attribute access(write: manage) optional enum8 scheduleProgrammingVisibility = 2; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -3673,58 +3673,58 @@ client cluster ColorControl = 768 { kUpdateStartHue = 0x8; } - readonly attribute int8u currentHue = 0; - readonly attribute int8u currentSaturation = 1; - readonly attribute int16u remainingTime = 2; - readonly attribute int16u currentX = 3; - readonly attribute int16u currentY = 4; - readonly attribute enum8 driftCompensation = 5; - readonly attribute char_string<254> compensationText = 6; - readonly attribute int16u colorTemperatureMireds = 7; + readonly attribute optional int8u currentHue = 0; + readonly attribute optional int8u currentSaturation = 1; + readonly attribute optional int16u remainingTime = 2; + readonly attribute optional int16u currentX = 3; + readonly attribute optional int16u currentY = 4; + readonly attribute optional enum8 driftCompensation = 5; + readonly attribute optional char_string<254> compensationText = 6; + readonly attribute optional int16u colorTemperatureMireds = 7; readonly attribute enum8 colorMode = 8; attribute bitmap8 options = 15; readonly attribute nullable int8u numberOfPrimaries = 16; - readonly attribute int16u primary1X = 17; - readonly attribute int16u primary1Y = 18; - readonly attribute nullable int8u primary1Intensity = 19; - readonly attribute int16u primary2X = 21; - readonly attribute int16u primary2Y = 22; - readonly attribute nullable int8u primary2Intensity = 23; - readonly attribute int16u primary3X = 25; - readonly attribute int16u primary3Y = 26; - readonly attribute nullable int8u primary3Intensity = 27; - readonly attribute int16u primary4X = 32; - readonly attribute int16u primary4Y = 33; - readonly attribute nullable int8u primary4Intensity = 34; - readonly attribute int16u primary5X = 36; - readonly attribute int16u primary5Y = 37; - readonly attribute nullable int8u primary5Intensity = 38; - readonly attribute int16u primary6X = 40; - readonly attribute int16u primary6Y = 41; - readonly attribute nullable int8u primary6Intensity = 42; - attribute access(write: manage) int16u whitePointX = 48; - attribute access(write: manage) int16u whitePointY = 49; - attribute access(write: manage) int16u colorPointRX = 50; - attribute access(write: manage) int16u colorPointRY = 51; - attribute access(write: manage) nullable int8u colorPointRIntensity = 52; - attribute access(write: manage) int16u colorPointGX = 54; - attribute access(write: manage) int16u colorPointGY = 55; - attribute access(write: manage) nullable int8u colorPointGIntensity = 56; - attribute access(write: manage) int16u colorPointBX = 58; - attribute access(write: manage) int16u colorPointBY = 59; - attribute access(write: manage) nullable int8u colorPointBIntensity = 60; - readonly attribute int16u enhancedCurrentHue = 16384; + readonly attribute optional int16u primary1X = 17; + readonly attribute optional int16u primary1Y = 18; + readonly attribute optional nullable int8u primary1Intensity = 19; + readonly attribute optional int16u primary2X = 21; + readonly attribute optional int16u primary2Y = 22; + readonly attribute optional nullable int8u primary2Intensity = 23; + readonly attribute optional int16u primary3X = 25; + readonly attribute optional int16u primary3Y = 26; + readonly attribute optional nullable int8u primary3Intensity = 27; + readonly attribute optional int16u primary4X = 32; + readonly attribute optional int16u primary4Y = 33; + readonly attribute optional nullable int8u primary4Intensity = 34; + readonly attribute optional int16u primary5X = 36; + readonly attribute optional int16u primary5Y = 37; + readonly attribute optional nullable int8u primary5Intensity = 38; + readonly attribute optional int16u primary6X = 40; + readonly attribute optional int16u primary6Y = 41; + readonly attribute optional nullable int8u primary6Intensity = 42; + attribute access(write: manage) optional int16u whitePointX = 48; + attribute access(write: manage) optional int16u whitePointY = 49; + attribute access(write: manage) optional int16u colorPointRX = 50; + attribute access(write: manage) optional int16u colorPointRY = 51; + attribute access(write: manage) optional nullable int8u colorPointRIntensity = 52; + attribute access(write: manage) optional int16u colorPointGX = 54; + attribute access(write: manage) optional int16u colorPointGY = 55; + attribute access(write: manage) optional nullable int8u colorPointGIntensity = 56; + attribute access(write: manage) optional int16u colorPointBX = 58; + attribute access(write: manage) optional int16u colorPointBY = 59; + attribute access(write: manage) optional nullable int8u colorPointBIntensity = 60; + readonly attribute optional int16u enhancedCurrentHue = 16384; readonly attribute enum8 enhancedColorMode = 16385; - readonly attribute int8u colorLoopActive = 16386; - readonly attribute int8u colorLoopDirection = 16387; - readonly attribute int16u colorLoopTime = 16388; - readonly attribute int16u colorLoopStartEnhancedHue = 16389; - readonly attribute int16u colorLoopStoredEnhancedHue = 16390; + readonly attribute optional int8u colorLoopActive = 16386; + readonly attribute optional int8u colorLoopDirection = 16387; + readonly attribute optional int16u colorLoopTime = 16388; + readonly attribute optional int16u colorLoopStartEnhancedHue = 16389; + readonly attribute optional int16u colorLoopStoredEnhancedHue = 16390; readonly attribute bitmap16 colorCapabilities = 16394; - readonly attribute int16u colorTempPhysicalMinMireds = 16395; - readonly attribute int16u colorTempPhysicalMaxMireds = 16396; - readonly attribute int16u coupleColorTempToLevelMinMireds = 16397; - attribute access(write: manage) nullable int16u startUpColorTemperatureMireds = 16400; + readonly attribute optional int16u colorTempPhysicalMinMireds = 16395; + readonly attribute optional int16u colorTempPhysicalMaxMireds = 16396; + readonly attribute optional int16u coupleColorTempToLevelMinMireds = 16397; + attribute access(write: manage) optional nullable int16u startUpColorTemperatureMireds = 16400; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -3924,18 +3924,18 @@ client cluster ColorControl = 768 { client cluster BallastConfiguration = 769 { readonly attribute int8u physicalMinLevel = 0; readonly attribute int8u physicalMaxLevel = 1; - readonly attribute bitmap8 ballastStatus = 2; + readonly attribute optional bitmap8 ballastStatus = 2; attribute int8u minLevel = 16; attribute int8u maxLevel = 17; - attribute nullable int8u intrinsicBallastFactor = 20; - attribute nullable int8u ballastFactorAdjustment = 21; + attribute optional nullable int8u intrinsicBallastFactor = 20; + attribute optional 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; + attribute optional char_string<16> lampType = 48; + attribute optional char_string<16> lampManufacturer = 49; + attribute optional nullable int24u lampRatedHours = 50; + attribute optional nullable int24u lampBurnHours = 51; + attribute optional bitmap8 lampAlarmMode = 52; + attribute optional nullable int24u lampBurnHoursTripPoint = 53; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -3954,8 +3954,8 @@ client cluster IlluminanceMeasurement = 1024 { readonly attribute nullable int16u measuredValue = 0; readonly attribute nullable int16u minMeasuredValue = 1; readonly attribute nullable int16u maxMeasuredValue = 2; - readonly attribute int16u tolerance = 3; - readonly attribute nullable enum8 lightSensorType = 4; + readonly attribute optional int16u tolerance = 3; + readonly attribute optional nullable enum8 lightSensorType = 4; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -3969,7 +3969,7 @@ client cluster TemperatureMeasurement = 1026 { readonly attribute nullable int16s measuredValue = 0; readonly attribute nullable int16s minMeasuredValue = 1; readonly attribute nullable int16s maxMeasuredValue = 2; - readonly attribute int16u tolerance = 3; + readonly attribute optional int16u tolerance = 3; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -3987,12 +3987,12 @@ client cluster PressureMeasurement = 1027 { readonly attribute nullable int16s measuredValue = 0; readonly attribute nullable int16s minMeasuredValue = 1; readonly attribute nullable int16s maxMeasuredValue = 2; - readonly attribute int16u tolerance = 3; - readonly attribute nullable int16s scaledValue = 16; - readonly attribute nullable int16s minScaledValue = 17; - readonly attribute nullable int16s maxScaledValue = 18; - readonly attribute int16u scaledTolerance = 19; - readonly attribute int8s scale = 20; + readonly attribute optional int16u tolerance = 3; + readonly attribute optional nullable int16s scaledValue = 16; + readonly attribute optional nullable int16s minScaledValue = 17; + readonly attribute optional nullable int16s maxScaledValue = 18; + readonly attribute optional int16u scaledTolerance = 19; + readonly attribute optional int8s scale = 20; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -4006,7 +4006,7 @@ client cluster FlowMeasurement = 1028 { readonly attribute nullable int16u measuredValue = 0; readonly attribute nullable int16u minMeasuredValue = 1; readonly attribute nullable int16u maxMeasuredValue = 2; - readonly attribute int16u tolerance = 3; + readonly attribute optional int16u tolerance = 3; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -4020,7 +4020,7 @@ client cluster RelativeHumidityMeasurement = 1029 { readonly attribute nullable int16u measuredValue = 0; readonly attribute nullable int16u minMeasuredValue = 1; readonly attribute nullable int16u maxMeasuredValue = 2; - readonly attribute int16u tolerance = 3; + readonly attribute optional int16u tolerance = 3; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -4051,15 +4051,15 @@ client cluster OccupancySensing = 1030 { readonly attribute OccupancyBitmap occupancy = 0; readonly attribute OccupancySensorTypeEnum occupancySensorType = 1; readonly attribute OccupancySensorTypeBitmap occupancySensorTypeBitmap = 2; - attribute access(write: manage) int16u PIROccupiedToUnoccupiedDelay = 16; - attribute access(write: manage) int16u PIRUnoccupiedToOccupiedDelay = 17; - attribute access(write: manage) int8u PIRUnoccupiedToOccupiedThreshold = 18; - attribute access(write: manage) int16u ultrasonicOccupiedToUnoccupiedDelay = 32; - attribute access(write: manage) int16u ultrasonicUnoccupiedToOccupiedDelay = 33; - attribute access(write: manage) int8u ultrasonicUnoccupiedToOccupiedThreshold = 34; - attribute access(write: manage) int16u physicalContactOccupiedToUnoccupiedDelay = 48; - attribute access(write: manage) int16u physicalContactUnoccupiedToOccupiedDelay = 49; - attribute access(write: manage) int8u physicalContactUnoccupiedToOccupiedThreshold = 50; + attribute access(write: manage) optional int16u PIROccupiedToUnoccupiedDelay = 16; + attribute access(write: manage) optional int16u PIRUnoccupiedToOccupiedDelay = 17; + attribute access(write: manage) optional int8u PIRUnoccupiedToOccupiedThreshold = 18; + attribute access(write: manage) optional int16u ultrasonicOccupiedToUnoccupiedDelay = 32; + attribute access(write: manage) optional int16u ultrasonicUnoccupiedToOccupiedDelay = 33; + attribute access(write: manage) optional int8u ultrasonicUnoccupiedToOccupiedThreshold = 34; + attribute access(write: manage) optional int16u physicalContactOccupiedToUnoccupiedDelay = 48; + attribute access(write: manage) optional int16u physicalContactUnoccupiedToOccupiedDelay = 49; + attribute access(write: manage) optional int8u physicalContactUnoccupiedToOccupiedThreshold = 50; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -4070,7 +4070,7 @@ client cluster OccupancySensing = 1030 { /** This cluster provides an interface for managing low power mode on a device that supports the Wake On LAN protocol. */ client cluster WakeOnLan = 1283 { - readonly attribute char_string<32> MACAddress = 0; + readonly attribute optional char_string<32> MACAddress = 0; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -4111,9 +4111,9 @@ client cluster Channel = 1284 { LineupInfoTypeEnum lineupInfoType = 3; } - readonly attribute ChannelInfoStruct channelList[] = 0; - readonly attribute nullable LineupInfoStruct lineup = 1; - readonly attribute nullable ChannelInfoStruct currentChannel = 2; + readonly attribute optional ChannelInfoStruct channelList[] = 0; + readonly attribute optional nullable LineupInfoStruct lineup = 1; + readonly attribute optional nullable ChannelInfoStruct currentChannel = 2; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -4161,7 +4161,7 @@ client cluster TargetNavigator = 1285 { } readonly attribute TargetInfoStruct targetList[] = 0; - readonly attribute int8u currentTarget = 1; + readonly attribute optional int8u currentTarget = 1; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -4212,12 +4212,12 @@ client cluster MediaPlayback = 1286 { } readonly attribute PlaybackStateEnum currentState = 0; - readonly attribute nullable epoch_us startTime = 1; - readonly attribute nullable int64u duration = 2; - readonly attribute nullable PlaybackPositionStruct sampledPosition = 3; - readonly attribute single playbackSpeed = 4; - readonly attribute nullable int64u seekRangeEnd = 5; - readonly attribute nullable int64u seekRangeStart = 6; + readonly attribute optional nullable epoch_us startTime = 1; + readonly attribute optional nullable int64u duration = 2; + readonly attribute optional nullable PlaybackPositionStruct sampledPosition = 3; + readonly attribute optional single playbackSpeed = 4; + readonly attribute optional nullable int64u seekRangeEnd = 5; + readonly attribute optional nullable int64u seekRangeStart = 6; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -4533,8 +4533,8 @@ client cluster ContentLauncher = 1290 { optional StyleInformationStruct waterMark = 5; } - readonly attribute CHAR_STRING acceptHeader[] = 0; - attribute bitmap32 supportedStreamingProtocols = 1; + readonly attribute optional CHAR_STRING acceptHeader[] = 0; + attribute optional bitmap32 supportedStreamingProtocols = 1; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -4587,7 +4587,7 @@ client cluster AudioOutput = 1291 { } readonly attribute OutputInfoStruct outputList[] = 0; - readonly attribute int8u currentOutput = 1; + readonly attribute optional int8u currentOutput = 1; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -4632,8 +4632,8 @@ client cluster ApplicationLauncher = 1292 { optional endpoint_no endpoint = 1; } - readonly attribute INT16U catalogList[] = 0; - attribute nullable ApplicationEPStruct currentApp = 1; + readonly attribute optional INT16U catalogList[] = 0; + attribute optional nullable ApplicationEPStruct currentApp = 1; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -4681,10 +4681,10 @@ client cluster ApplicationBasic = 1293 { char_string applicationID = 1; } - readonly attribute char_string<32> vendorName = 0; - readonly attribute vendor_id vendorID = 1; + readonly attribute optional char_string<32> vendorName = 0; + readonly attribute optional vendor_id vendorID = 1; readonly attribute char_string<32> applicationName = 2; - readonly attribute int16u productID = 3; + readonly attribute optional int16u productID = 3; readonly attribute ApplicationStruct application = 4; readonly attribute ApplicationStatusEnum status = 5; readonly attribute char_string<32> applicationVersion = 6; @@ -4729,134 +4729,134 @@ client cluster AccountLogin = 1294 { /** Attributes related to the electrical properties of a device. This cluster is used by power outlets and other devices that need to provide instantaneous data as opposed to metrology data which should be retrieved from the metering cluster.. */ client cluster ElectricalMeasurement = 2820 { - readonly attribute bitmap32 measurementType = 0; - readonly attribute int16s dcVoltage = 256; - readonly attribute int16s dcVoltageMin = 257; - readonly attribute int16s dcVoltageMax = 258; - readonly attribute int16s dcCurrent = 259; - readonly attribute int16s dcCurrentMin = 260; - readonly attribute int16s dcCurrentMax = 261; - readonly attribute int16s dcPower = 262; - readonly attribute int16s dcPowerMin = 263; - readonly attribute int16s dcPowerMax = 264; - readonly attribute int16u dcVoltageMultiplier = 512; - readonly attribute int16u dcVoltageDivisor = 513; - readonly attribute int16u dcCurrentMultiplier = 514; - readonly attribute int16u dcCurrentDivisor = 515; - readonly attribute int16u dcPowerMultiplier = 516; - readonly attribute int16u dcPowerDivisor = 517; - readonly attribute int16u acFrequency = 768; - readonly attribute int16u acFrequencyMin = 769; - readonly attribute int16u acFrequencyMax = 770; - readonly attribute int16u neutralCurrent = 771; - readonly attribute int32s totalActivePower = 772; - readonly attribute int32s totalReactivePower = 773; - readonly attribute int32u totalApparentPower = 774; - readonly attribute int16s measured1stHarmonicCurrent = 775; - readonly attribute int16s measured3rdHarmonicCurrent = 776; - readonly attribute int16s measured5thHarmonicCurrent = 777; - readonly attribute int16s measured7thHarmonicCurrent = 778; - readonly attribute int16s measured9thHarmonicCurrent = 779; - readonly attribute int16s measured11thHarmonicCurrent = 780; - readonly attribute int16s measuredPhase1stHarmonicCurrent = 781; - readonly attribute int16s measuredPhase3rdHarmonicCurrent = 782; - readonly attribute int16s measuredPhase5thHarmonicCurrent = 783; - readonly attribute int16s measuredPhase7thHarmonicCurrent = 784; - readonly attribute int16s measuredPhase9thHarmonicCurrent = 785; - readonly attribute int16s measuredPhase11thHarmonicCurrent = 786; - readonly attribute int16u acFrequencyMultiplier = 1024; - readonly attribute int16u acFrequencyDivisor = 1025; - readonly attribute int32u powerMultiplier = 1026; - readonly attribute int32u powerDivisor = 1027; - readonly attribute int8s harmonicCurrentMultiplier = 1028; - readonly attribute int8s phaseHarmonicCurrentMultiplier = 1029; - readonly attribute int16s instantaneousVoltage = 1280; - readonly attribute int16u instantaneousLineCurrent = 1281; - readonly attribute int16s instantaneousActiveCurrent = 1282; - readonly attribute int16s instantaneousReactiveCurrent = 1283; - readonly attribute int16s instantaneousPower = 1284; - readonly attribute int16u rmsVoltage = 1285; - readonly attribute int16u rmsVoltageMin = 1286; - readonly attribute int16u rmsVoltageMax = 1287; - readonly attribute int16u rmsCurrent = 1288; - readonly attribute int16u rmsCurrentMin = 1289; - readonly attribute int16u rmsCurrentMax = 1290; - readonly attribute int16s activePower = 1291; - readonly attribute int16s activePowerMin = 1292; - readonly attribute int16s activePowerMax = 1293; - readonly attribute int16s reactivePower = 1294; - readonly attribute int16u apparentPower = 1295; - readonly attribute int8s powerFactor = 1296; - attribute int16u averageRmsVoltageMeasurementPeriod = 1297; - attribute int16u averageRmsUnderVoltageCounter = 1299; - attribute int16u rmsExtremeOverVoltagePeriod = 1300; - attribute int16u rmsExtremeUnderVoltagePeriod = 1301; - attribute int16u rmsVoltageSagPeriod = 1302; - attribute int16u rmsVoltageSwellPeriod = 1303; - readonly attribute int16u acVoltageMultiplier = 1536; - readonly attribute int16u acVoltageDivisor = 1537; - readonly attribute int16u acCurrentMultiplier = 1538; - readonly attribute int16u acCurrentDivisor = 1539; - readonly attribute int16u acPowerMultiplier = 1540; - readonly attribute int16u acPowerDivisor = 1541; - attribute bitmap8 overloadAlarmsMask = 1792; - readonly attribute int16s voltageOverload = 1793; - readonly attribute int16s currentOverload = 1794; - attribute bitmap16 acOverloadAlarmsMask = 2048; - readonly attribute int16s acVoltageOverload = 2049; - readonly attribute int16s acCurrentOverload = 2050; - readonly attribute int16s acActivePowerOverload = 2051; - readonly attribute int16s acReactivePowerOverload = 2052; - readonly attribute int16s averageRmsOverVoltage = 2053; - readonly attribute int16s averageRmsUnderVoltage = 2054; - readonly attribute int16s rmsExtremeOverVoltage = 2055; - readonly attribute int16s rmsExtremeUnderVoltage = 2056; - readonly attribute int16s rmsVoltageSag = 2057; - readonly attribute int16s rmsVoltageSwell = 2058; - readonly attribute int16u lineCurrentPhaseB = 2305; - readonly attribute int16s activeCurrentPhaseB = 2306; - readonly attribute int16s reactiveCurrentPhaseB = 2307; - readonly attribute int16u rmsVoltagePhaseB = 2309; - readonly attribute int16u rmsVoltageMinPhaseB = 2310; - readonly attribute int16u rmsVoltageMaxPhaseB = 2311; - readonly attribute int16u rmsCurrentPhaseB = 2312; - readonly attribute int16u rmsCurrentMinPhaseB = 2313; - readonly attribute int16u rmsCurrentMaxPhaseB = 2314; - readonly attribute int16s activePowerPhaseB = 2315; - readonly attribute int16s activePowerMinPhaseB = 2316; - readonly attribute int16s activePowerMaxPhaseB = 2317; - readonly attribute int16s reactivePowerPhaseB = 2318; - readonly attribute int16u apparentPowerPhaseB = 2319; - readonly attribute int8s powerFactorPhaseB = 2320; - readonly attribute int16u averageRmsVoltageMeasurementPeriodPhaseB = 2321; - readonly attribute int16u averageRmsOverVoltageCounterPhaseB = 2322; - readonly attribute int16u averageRmsUnderVoltageCounterPhaseB = 2323; - readonly attribute int16u rmsExtremeOverVoltagePeriodPhaseB = 2324; - readonly attribute int16u rmsExtremeUnderVoltagePeriodPhaseB = 2325; - readonly attribute int16u rmsVoltageSagPeriodPhaseB = 2326; - readonly attribute int16u rmsVoltageSwellPeriodPhaseB = 2327; - readonly attribute int16u lineCurrentPhaseC = 2561; - readonly attribute int16s activeCurrentPhaseC = 2562; - readonly attribute int16s reactiveCurrentPhaseC = 2563; - readonly attribute int16u rmsVoltagePhaseC = 2565; - readonly attribute int16u rmsVoltageMinPhaseC = 2566; - readonly attribute int16u rmsVoltageMaxPhaseC = 2567; - readonly attribute int16u rmsCurrentPhaseC = 2568; - readonly attribute int16u rmsCurrentMinPhaseC = 2569; - readonly attribute int16u rmsCurrentMaxPhaseC = 2570; - readonly attribute int16s activePowerPhaseC = 2571; - readonly attribute int16s activePowerMinPhaseC = 2572; - readonly attribute int16s activePowerMaxPhaseC = 2573; - readonly attribute int16s reactivePowerPhaseC = 2574; - readonly attribute int16u apparentPowerPhaseC = 2575; - readonly attribute int8s powerFactorPhaseC = 2576; - readonly attribute int16u averageRmsVoltageMeasurementPeriodPhaseC = 2577; - readonly attribute int16u averageRmsOverVoltageCounterPhaseC = 2578; - readonly attribute int16u averageRmsUnderVoltageCounterPhaseC = 2579; - readonly attribute int16u rmsExtremeOverVoltagePeriodPhaseC = 2580; - readonly attribute int16u rmsExtremeUnderVoltagePeriodPhaseC = 2581; - readonly attribute int16u rmsVoltageSagPeriodPhaseC = 2582; - readonly attribute int16u rmsVoltageSwellPeriodPhaseC = 2583; + readonly attribute optional bitmap32 measurementType = 0; + readonly attribute optional int16s dcVoltage = 256; + readonly attribute optional int16s dcVoltageMin = 257; + readonly attribute optional int16s dcVoltageMax = 258; + readonly attribute optional int16s dcCurrent = 259; + readonly attribute optional int16s dcCurrentMin = 260; + readonly attribute optional int16s dcCurrentMax = 261; + readonly attribute optional int16s dcPower = 262; + readonly attribute optional int16s dcPowerMin = 263; + readonly attribute optional int16s dcPowerMax = 264; + readonly attribute optional int16u dcVoltageMultiplier = 512; + readonly attribute optional int16u dcVoltageDivisor = 513; + readonly attribute optional int16u dcCurrentMultiplier = 514; + readonly attribute optional int16u dcCurrentDivisor = 515; + readonly attribute optional int16u dcPowerMultiplier = 516; + readonly attribute optional int16u dcPowerDivisor = 517; + readonly attribute optional int16u acFrequency = 768; + readonly attribute optional int16u acFrequencyMin = 769; + readonly attribute optional int16u acFrequencyMax = 770; + readonly attribute optional int16u neutralCurrent = 771; + readonly attribute optional int32s totalActivePower = 772; + readonly attribute optional int32s totalReactivePower = 773; + readonly attribute optional int32u totalApparentPower = 774; + readonly attribute optional int16s measured1stHarmonicCurrent = 775; + readonly attribute optional int16s measured3rdHarmonicCurrent = 776; + readonly attribute optional int16s measured5thHarmonicCurrent = 777; + readonly attribute optional int16s measured7thHarmonicCurrent = 778; + readonly attribute optional int16s measured9thHarmonicCurrent = 779; + readonly attribute optional int16s measured11thHarmonicCurrent = 780; + readonly attribute optional int16s measuredPhase1stHarmonicCurrent = 781; + readonly attribute optional int16s measuredPhase3rdHarmonicCurrent = 782; + readonly attribute optional int16s measuredPhase5thHarmonicCurrent = 783; + readonly attribute optional int16s measuredPhase7thHarmonicCurrent = 784; + readonly attribute optional int16s measuredPhase9thHarmonicCurrent = 785; + readonly attribute optional int16s measuredPhase11thHarmonicCurrent = 786; + readonly attribute optional int16u acFrequencyMultiplier = 1024; + readonly attribute optional int16u acFrequencyDivisor = 1025; + readonly attribute optional int32u powerMultiplier = 1026; + readonly attribute optional int32u powerDivisor = 1027; + readonly attribute optional int8s harmonicCurrentMultiplier = 1028; + readonly attribute optional int8s phaseHarmonicCurrentMultiplier = 1029; + readonly attribute optional int16s instantaneousVoltage = 1280; + readonly attribute optional int16u instantaneousLineCurrent = 1281; + readonly attribute optional int16s instantaneousActiveCurrent = 1282; + readonly attribute optional int16s instantaneousReactiveCurrent = 1283; + readonly attribute optional int16s instantaneousPower = 1284; + readonly attribute optional int16u rmsVoltage = 1285; + readonly attribute optional int16u rmsVoltageMin = 1286; + readonly attribute optional int16u rmsVoltageMax = 1287; + readonly attribute optional int16u rmsCurrent = 1288; + readonly attribute optional int16u rmsCurrentMin = 1289; + readonly attribute optional int16u rmsCurrentMax = 1290; + readonly attribute optional int16s activePower = 1291; + readonly attribute optional int16s activePowerMin = 1292; + readonly attribute optional int16s activePowerMax = 1293; + readonly attribute optional int16s reactivePower = 1294; + readonly attribute optional int16u apparentPower = 1295; + readonly attribute optional int8s powerFactor = 1296; + attribute optional int16u averageRmsVoltageMeasurementPeriod = 1297; + attribute optional int16u averageRmsUnderVoltageCounter = 1299; + attribute optional int16u rmsExtremeOverVoltagePeriod = 1300; + attribute optional int16u rmsExtremeUnderVoltagePeriod = 1301; + attribute optional int16u rmsVoltageSagPeriod = 1302; + attribute optional int16u rmsVoltageSwellPeriod = 1303; + readonly attribute optional int16u acVoltageMultiplier = 1536; + readonly attribute optional int16u acVoltageDivisor = 1537; + readonly attribute optional int16u acCurrentMultiplier = 1538; + readonly attribute optional int16u acCurrentDivisor = 1539; + readonly attribute optional int16u acPowerMultiplier = 1540; + readonly attribute optional int16u acPowerDivisor = 1541; + attribute optional bitmap8 overloadAlarmsMask = 1792; + readonly attribute optional int16s voltageOverload = 1793; + readonly attribute optional int16s currentOverload = 1794; + attribute optional bitmap16 acOverloadAlarmsMask = 2048; + readonly attribute optional int16s acVoltageOverload = 2049; + readonly attribute optional int16s acCurrentOverload = 2050; + readonly attribute optional int16s acActivePowerOverload = 2051; + readonly attribute optional int16s acReactivePowerOverload = 2052; + readonly attribute optional int16s averageRmsOverVoltage = 2053; + readonly attribute optional int16s averageRmsUnderVoltage = 2054; + readonly attribute optional int16s rmsExtremeOverVoltage = 2055; + readonly attribute optional int16s rmsExtremeUnderVoltage = 2056; + readonly attribute optional int16s rmsVoltageSag = 2057; + readonly attribute optional int16s rmsVoltageSwell = 2058; + readonly attribute optional int16u lineCurrentPhaseB = 2305; + readonly attribute optional int16s activeCurrentPhaseB = 2306; + readonly attribute optional int16s reactiveCurrentPhaseB = 2307; + readonly attribute optional int16u rmsVoltagePhaseB = 2309; + readonly attribute optional int16u rmsVoltageMinPhaseB = 2310; + readonly attribute optional int16u rmsVoltageMaxPhaseB = 2311; + readonly attribute optional int16u rmsCurrentPhaseB = 2312; + readonly attribute optional int16u rmsCurrentMinPhaseB = 2313; + readonly attribute optional int16u rmsCurrentMaxPhaseB = 2314; + readonly attribute optional int16s activePowerPhaseB = 2315; + readonly attribute optional int16s activePowerMinPhaseB = 2316; + readonly attribute optional int16s activePowerMaxPhaseB = 2317; + readonly attribute optional int16s reactivePowerPhaseB = 2318; + readonly attribute optional int16u apparentPowerPhaseB = 2319; + readonly attribute optional int8s powerFactorPhaseB = 2320; + readonly attribute optional int16u averageRmsVoltageMeasurementPeriodPhaseB = 2321; + readonly attribute optional int16u averageRmsOverVoltageCounterPhaseB = 2322; + readonly attribute optional int16u averageRmsUnderVoltageCounterPhaseB = 2323; + readonly attribute optional int16u rmsExtremeOverVoltagePeriodPhaseB = 2324; + readonly attribute optional int16u rmsExtremeUnderVoltagePeriodPhaseB = 2325; + readonly attribute optional int16u rmsVoltageSagPeriodPhaseB = 2326; + readonly attribute optional int16u rmsVoltageSwellPeriodPhaseB = 2327; + readonly attribute optional int16u lineCurrentPhaseC = 2561; + readonly attribute optional int16s activeCurrentPhaseC = 2562; + readonly attribute optional int16s reactiveCurrentPhaseC = 2563; + readonly attribute optional int16u rmsVoltagePhaseC = 2565; + readonly attribute optional int16u rmsVoltageMinPhaseC = 2566; + readonly attribute optional int16u rmsVoltageMaxPhaseC = 2567; + readonly attribute optional int16u rmsCurrentPhaseC = 2568; + readonly attribute optional int16u rmsCurrentMinPhaseC = 2569; + readonly attribute optional int16u rmsCurrentMaxPhaseC = 2570; + readonly attribute optional int16s activePowerPhaseC = 2571; + readonly attribute optional int16s activePowerMinPhaseC = 2572; + readonly attribute optional int16s activePowerMaxPhaseC = 2573; + readonly attribute optional int16s reactivePowerPhaseC = 2574; + readonly attribute optional int16u apparentPowerPhaseC = 2575; + readonly attribute optional int8s powerFactorPhaseC = 2576; + readonly attribute optional int16u averageRmsVoltageMeasurementPeriodPhaseC = 2577; + readonly attribute optional int16u averageRmsOverVoltageCounterPhaseC = 2578; + readonly attribute optional int16u averageRmsUnderVoltageCounterPhaseC = 2579; + readonly attribute optional int16u rmsExtremeOverVoltagePeriodPhaseC = 2580; + readonly attribute optional int16u rmsExtremeUnderVoltagePeriodPhaseC = 2581; + readonly attribute optional int16u rmsVoltageSagPeriodPhaseC = 2582; + readonly attribute optional int16u rmsVoltageSwellPeriodPhaseC = 2583; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -5094,7 +5094,7 @@ client cluster UnitTesting = 4294048773 { timedwrite attribute boolean timedWriteBoolean = 48; attribute boolean generalErrorBoolean = 49; attribute boolean clusterErrorBoolean = 50; - attribute boolean unsupported = 255; + attribute optional boolean unsupported = 255; attribute nullable boolean nullableBoolean = 16384; attribute nullable Bitmap8MaskMap nullableBitmap8 = 16385; attribute nullable Bitmap16MaskMap nullableBitmap16 = 16386; @@ -5128,7 +5128,7 @@ client cluster UnitTesting = 4294048773 { attribute nullable int8s nullableRangeRestrictedInt8s = 16423; attribute nullable int16u nullableRangeRestrictedInt16u = 16424; attribute nullable int16s nullableRangeRestrictedInt16s = 16425; - attribute int8u writeOnlyInt8u = 16426; + attribute optional int8u writeOnlyInt8u = 16426; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; diff --git a/src/controller/java/templates/CHIPClustersWrite-JNI.zapt b/src/controller/java/templates/CHIPClustersWrite-JNI.zapt index 23d49866ca04ea..9be7cfb69dcd39 100644 --- a/src/controller/java/templates/CHIPClustersWrite-JNI.zapt +++ b/src/controller/java/templates/CHIPClustersWrite-JNI.zapt @@ -1,5 +1,5 @@ {{> header}} -{{#if (chip_has_client_clusters)}} +{{#if_enabled_clusters side='client'}} #include #include #include "CHIPInvokeCallbacks.h" @@ -78,6 +78,6 @@ JNI_METHOD(void, {{asUpperCamelCase ../name}}Cluster, write{{asUpperCamelCase na {{/if_unsupported_attribute_callback}} {{/zcl_attributes_server}} {{/all_user_clusters}} -{{/if}} +{{/if_enabled_clusters}} #pragma clang diagnostic pop diff --git a/src/controller/java/templates/CHIPInvokeCallbacks.zapt b/src/controller/java/templates/CHIPInvokeCallbacks.zapt index 81fe85ffc713f0..59adcfe73961f0 100644 --- a/src/controller/java/templates/CHIPInvokeCallbacks.zapt +++ b/src/controller/java/templates/CHIPInvokeCallbacks.zapt @@ -1,5 +1,5 @@ {{> header}} -{{#if (chip_has_client_clusters)}} +{{#if_enabled_clusters side='client'}} #include #include @@ -26,4 +26,4 @@ private: {{/zcl_commands_source_server}} {{/all_user_clusters}} } // namespace chip -{{/if}} +{{/if_enabled_clusters}} diff --git a/src/controller/java/templates/CHIPReadCallbacks-src.zapt b/src/controller/java/templates/CHIPReadCallbacks-src.zapt index 3a7ce97c8e68e6..60bc0b09447780 100644 --- a/src/controller/java/templates/CHIPReadCallbacks-src.zapt +++ b/src/controller/java/templates/CHIPReadCallbacks-src.zapt @@ -1,5 +1,5 @@ {{> header}} -{{#if (chip_has_client_clusters)}} +{{#if_enabled_clusters side='client'}} #include #include @@ -175,4 +175,4 @@ void CHIP{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}AttributeCallb {{/zcl_attributes_server}} {{/all_user_clusters}} -{{/if}} +{{/if_enabled_clusters}} diff --git a/src/controller/java/templates/ChipClusters-java.zapt b/src/controller/java/templates/ChipClusters-java.zapt index 655b547864a4af..d46005ce04ff9b 100644 --- a/src/controller/java/templates/ChipClusters-java.zapt +++ b/src/controller/java/templates/ChipClusters-java.zapt @@ -1,5 +1,5 @@ {{> header}} -{{#if (chip_has_client_clusters)}} +{{#if_enabled_clusters side='client'}} package chip.devicecontroller; @@ -247,4 +247,4 @@ public class ChipClusters { {{/not_last}} {{/all_user_clusters}} } -{{/if}} +{{/if_enabled_clusters}} diff --git a/src/controller/java/templates/ChipEventStructs-java.zapt b/src/controller/java/templates/ChipEventStructs-java.zapt index 4737bd19b2648b..e180b3c3a75b70 100644 --- a/src/controller/java/templates/ChipEventStructs-java.zapt +++ b/src/controller/java/templates/ChipEventStructs-java.zapt @@ -1,16 +1,16 @@ {{> header}} package chip.devicecontroller; -{{#if (chip_has_client_clusters)}} +{{#if_enabled_clusters side='client'}} import javax.annotation.Nullable; import java.util.ArrayList; import java.util.Arrays; import java.util.Optional; -{{/if}} +{{/if_enabled_clusters}} {{! TODO: Use AutoValue for inner classes. }} public class ChipEventStructs { -{{#if (chip_has_client_clusters)}} +{{#if_enabled_clusters side='client'}} {{#all_user_clusters side='client'}} {{#zcl_events}} public static class {{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase name}}Event { @@ -55,5 +55,5 @@ public {{asJavaType type null parent.parent.name includeAnnotations=true}} {{asL {{/zcl_events}} {{/all_user_clusters}} -{{/if}} +{{/if_enabled_clusters}} } \ No newline at end of file diff --git a/src/controller/java/templates/ChipIdLookup-java.zapt b/src/controller/java/templates/ChipIdLookup-java.zapt index 18bea3b747cb37..aa744a98cd94ac 100644 --- a/src/controller/java/templates/ChipIdLookup-java.zapt +++ b/src/controller/java/templates/ChipIdLookup-java.zapt @@ -1,5 +1,5 @@ {{> header}} -{{#if (chip_has_client_clusters)}} +{{#if_enabled_clusters side='client'}} package chip.devicecontroller; @@ -42,15 +42,15 @@ public final class ChipIdLookup { public static String eventIdToName(long clusterId, long eventId) { {{#all_user_clusters side='client'}} if (clusterId == {{code}}L) { - {{#chip_server_cluster_events}} + {{#zcl_events}} if (eventId == {{code}}L) { return "{{asUpperCamelCase name}}"; } - {{/chip_server_cluster_events}} + {{/zcl_events}} return ""; } {{/all_user_clusters}} return ""; } } -{{/if}} \ No newline at end of file +{{/if_enabled_clusters}} \ No newline at end of file diff --git a/src/controller/java/templates/ChipStructs-java.zapt b/src/controller/java/templates/ChipStructs-java.zapt index 19771c7bdd2bad..595b47afa42830 100644 --- a/src/controller/java/templates/ChipStructs-java.zapt +++ b/src/controller/java/templates/ChipStructs-java.zapt @@ -1,16 +1,16 @@ {{> header}} package chip.devicecontroller; -{{#if (chip_has_client_clusters)}} +{{#if_enabled_clusters side='client'}} import javax.annotation.Nullable; import java.util.ArrayList; import java.util.Arrays; import java.util.Optional; -{{/if}} +{{/if_enabled_clusters}} {{! TODO: Use AutoValue for inner classes. }} public class ChipStructs { -{{#if (chip_has_client_clusters)}} +{{#if_enabled_clusters side='client'}} {{#all_user_clusters side='client'}} {{#zcl_structs}} {{#if itemCnt}} @@ -53,5 +53,5 @@ public {{asJavaType type null parent.parent.name includeAnnotations=true}} {{asL {{/zcl_structs}} {{/all_user_clusters}} -{{/if}} +{{/if_enabled_clusters}} } \ No newline at end of file diff --git a/src/controller/java/templates/ClusterInfo-java.zapt b/src/controller/java/templates/ClusterInfo-java.zapt index 63cf5cbfba106e..45234bd42a1b39 100644 --- a/src/controller/java/templates/ClusterInfo-java.zapt +++ b/src/controller/java/templates/ClusterInfo-java.zapt @@ -1,5 +1,5 @@ {{> header}} -{{#if (chip_has_client_clusters)}} +{{#if_enabled_clusters side='client'}} package chip.devicecontroller; @@ -373,4 +373,4 @@ public class ClusterInfoMapping { } -{{/if}} \ No newline at end of file +{{/if_enabled_clusters}} \ No newline at end of file diff --git a/src/controller/java/templates/partials/decode_value.zapt b/src/controller/java/templates/partials/decode_value.zapt index a6fa4ab3cd2e3c..d1c51b5edeee33 100644 --- a/src/controller/java/templates/partials/decode_value.zapt +++ b/src/controller/java/templates/partials/decode_value.zapt @@ -60,7 +60,7 @@ if ({{source}}.IsNull()) { env->SetByteArrayRegion({{target}}ByteArray, 0, static_cast({{source}}.size()), reinterpret_cast({{source}}.data())); {{target}} = {{target}}ByteArray; {{else if (isCharString type)}} - {{target}} = env->NewStringUTF(std::string({{source}}.data(), {{source}}.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF({{source}}, {{target}})); {{else}} std::string {{target}}ClassName = "{{asJniClassName type null cluster}}"; std::string {{target}}CtorSignature = "({{asJniSignature type null cluster false}})V"; diff --git a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp index f435fdbdf3cc66..4e02a196cc0db1 100644 --- a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp +++ b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp @@ -1372,7 +1372,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::Description::Id: { @@ -1384,7 +1384,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::InactiveText::Id: { @@ -1396,7 +1396,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::OutOfService::Id: { @@ -2540,7 +2540,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR newElement_0_actionIDCtorSignature.c_str(), entry_0.actionID, newElement_0_actionID); jobject newElement_0_name; - newElement_0_name = env->NewStringUTF(std::string(entry_0.name.data(), entry_0.name.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.name, newElement_0_name)); jobject newElement_0_type; std::string newElement_0_typeClassName = "java/lang/Integer"; std::string newElement_0_typeCtorSignature = "(I)V"; @@ -2614,7 +2614,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR newElement_0_endpointListIDCtorSignature.c_str(), entry_0.endpointListID, newElement_0_endpointListID); jobject newElement_0_name; - newElement_0_name = env->NewStringUTF(std::string(entry_0.name.data(), entry_0.name.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.name, newElement_0_name)); jobject newElement_0_type; std::string newElement_0_typeClassName = "java/lang/Integer"; std::string newElement_0_typeCtorSignature = "(I)V"; @@ -2669,7 +2669,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::GeneratedCommandList::Id: { @@ -2832,7 +2832,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::VendorID::Id: { @@ -2859,7 +2859,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::ProductID::Id: { @@ -2886,7 +2886,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::Location::Id: { @@ -2898,7 +2898,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::HardwareVersion::Id: { @@ -2925,7 +2925,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::SoftwareVersion::Id: { @@ -2952,7 +2952,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::ManufacturingDate::Id: { @@ -2964,7 +2964,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::PartNumber::Id: { @@ -2976,7 +2976,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::ProductURL::Id: { @@ -2988,7 +2988,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::ProductLabel::Id: { @@ -3000,7 +3000,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::SerialNumber::Id: { @@ -3012,7 +3012,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::LocalConfigDisabled::Id: { @@ -3054,7 +3054,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::CapabilityMinima::Id: { @@ -3627,7 +3627,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::SupportedLocales::Id: { @@ -3646,7 +3646,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR { auto & entry_0 = iter_value_0.GetValue(); jobject newElement_0; - newElement_0 = env->NewStringUTF(std::string(entry_0.data(), entry_0.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0, newElement_0)); chip::JniReferences::GetInstance().AddToList(value, newElement_0); } return value; @@ -4327,7 +4327,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::WiredAssessedInputVoltage::Id: { @@ -4639,7 +4639,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::BatCommonDesignation::Id: { @@ -4666,7 +4666,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::BatIECDesignation::Id: { @@ -4678,7 +4678,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::BatApprovedChemistry::Id: { @@ -5664,7 +5664,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR auto & entry_0 = iter_value_0.GetValue(); jobject newElement_0; jobject newElement_0_name; - newElement_0_name = env->NewStringUTF(std::string(entry_0.name.data(), entry_0.name.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.name, newElement_0_name)); jobject newElement_0_isOperational; std::string newElement_0_isOperationalClassName = "java/lang/Boolean"; std::string newElement_0_isOperationalCtorSignature = "(Z)V"; @@ -6080,8 +6080,8 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR else { jobject newElement_0_nameInsideOptional; - newElement_0_nameInsideOptional = - env->NewStringUTF(std::string(entry_0.name.Value().data(), entry_0.name.Value().size()).c_str()); + LogErrorOnFailure( + chip::JniReferences::GetInstance().CharToStringUTF(entry_0.name.Value(), newElement_0_nameInsideOptional)); chip::JniReferences::GetInstance().CreateOptional(newElement_0_nameInsideOptional, newElement_0_name); } jobject newElement_0_stackFreeCurrent; @@ -6400,7 +6400,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } else { - value = env->NewStringUTF(std::string(cppValue.Value().data(), cppValue.Value().size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue.Value(), value)); } return value; } @@ -8606,7 +8606,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::VendorID::Id: { @@ -8633,7 +8633,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::NodeLabel::Id: { @@ -8645,7 +8645,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::HardwareVersion::Id: { @@ -8672,7 +8672,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::SoftwareVersion::Id: { @@ -8699,7 +8699,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::ManufacturingDate::Id: { @@ -8711,7 +8711,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::PartNumber::Id: { @@ -8723,7 +8723,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::ProductURL::Id: { @@ -8735,7 +8735,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::ProductLabel::Id: { @@ -8747,7 +8747,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::SerialNumber::Id: { @@ -8759,7 +8759,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::Reachable::Id: { @@ -8786,7 +8786,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::GeneratedCommandList::Id: { @@ -9403,7 +9403,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR newElement_0_nodeIDCtorSignature.c_str(), entry_0.nodeID, newElement_0_nodeID); jobject newElement_0_label; - newElement_0_label = env->NewStringUTF(std::string(entry_0.label.data(), entry_0.label.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.label, newElement_0_label)); jobject newElement_0_fabricIndex; std::string newElement_0_fabricIndexClassName = "java/lang/Integer"; std::string newElement_0_fabricIndexCtorSignature = "(I)V"; @@ -9743,8 +9743,8 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR else { jobject newElement_0_groupNameInsideOptional; - newElement_0_groupNameInsideOptional = - env->NewStringUTF(std::string(entry_0.groupName.Value().data(), entry_0.groupName.Value().size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.groupName.Value(), + newElement_0_groupNameInsideOptional)); chip::JniReferences::GetInstance().CreateOptional(newElement_0_groupNameInsideOptional, newElement_0_groupName); } jobject newElement_0_fabricIndex; @@ -9961,9 +9961,9 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR auto & entry_0 = iter_value_0.GetValue(); jobject newElement_0; jobject newElement_0_label; - newElement_0_label = env->NewStringUTF(std::string(entry_0.label.data(), entry_0.label.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.label, newElement_0_label)); jobject newElement_0_value; - newElement_0_value = env->NewStringUTF(std::string(entry_0.value.data(), entry_0.value.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.value, newElement_0_value)); jclass labelStructStructClass_1; err = chip::JniReferences::GetInstance().GetClassRef( @@ -10140,9 +10140,9 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR auto & entry_0 = iter_value_0.GetValue(); jobject newElement_0; jobject newElement_0_label; - newElement_0_label = env->NewStringUTF(std::string(entry_0.label.data(), entry_0.label.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.label, newElement_0_label)); jobject newElement_0_value; - newElement_0_value = env->NewStringUTF(std::string(entry_0.value.data(), entry_0.value.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.value, newElement_0_value)); jclass labelStructStructClass_1; err = chip::JniReferences::GetInstance().GetClassRef( @@ -10462,7 +10462,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::StandardNamespace::Id: { @@ -10504,7 +10504,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR auto & entry_0 = iter_value_0.GetValue(); jobject newElement_0; jobject newElement_0_label; - newElement_0_label = env->NewStringUTF(std::string(entry_0.label.data(), entry_0.label.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.label, newElement_0_label)); jobject newElement_0_mode; std::string newElement_0_modeClassName = "java/lang/Integer"; std::string newElement_0_modeCtorSignature = "(I)V"; @@ -11078,7 +11078,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::LEDSettings::Id: { @@ -14415,7 +14415,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::ColorTemperatureMireds::Id: { @@ -15449,7 +15449,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::LampManufacturer::Id: { @@ -15461,7 +15461,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::LampRatedHours::Id: { @@ -17209,7 +17209,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::GeneratedCommandList::Id: { @@ -17384,8 +17384,8 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR else { jobject newElement_0_nameInsideOptional; - newElement_0_nameInsideOptional = - env->NewStringUTF(std::string(entry_0.name.Value().data(), entry_0.name.Value().size()).c_str()); + LogErrorOnFailure( + chip::JniReferences::GetInstance().CharToStringUTF(entry_0.name.Value(), newElement_0_nameInsideOptional)); chip::JniReferences::GetInstance().CreateOptional(newElement_0_nameInsideOptional, newElement_0_name); } jobject newElement_0_callSign; @@ -17396,8 +17396,8 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR else { jobject newElement_0_callSignInsideOptional; - newElement_0_callSignInsideOptional = - env->NewStringUTF(std::string(entry_0.callSign.Value().data(), entry_0.callSign.Value().size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.callSign.Value(), + newElement_0_callSignInsideOptional)); chip::JniReferences::GetInstance().CreateOptional(newElement_0_callSignInsideOptional, newElement_0_callSign); } jobject newElement_0_affiliateCallSign; @@ -17408,8 +17408,8 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR else { jobject newElement_0_affiliateCallSignInsideOptional; - newElement_0_affiliateCallSignInsideOptional = env->NewStringUTF( - std::string(entry_0.affiliateCallSign.Value().data(), entry_0.affiliateCallSign.Value().size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( + entry_0.affiliateCallSign.Value(), newElement_0_affiliateCallSignInsideOptional)); chip::JniReferences::GetInstance().CreateOptional(newElement_0_affiliateCallSignInsideOptional, newElement_0_affiliateCallSign); } @@ -17454,8 +17454,8 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR else { jobject value_operatorName; - value_operatorName = env->NewStringUTF( - std::string(cppValue.Value().operatorName.data(), cppValue.Value().operatorName.size()).c_str()); + LogErrorOnFailure( + chip::JniReferences::GetInstance().CharToStringUTF(cppValue.Value().operatorName, value_operatorName)); jobject value_lineupName; if (!cppValue.Value().lineupName.HasValue()) { @@ -17464,9 +17464,8 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR else { jobject value_lineupNameInsideOptional; - value_lineupNameInsideOptional = env->NewStringUTF( - std::string(cppValue.Value().lineupName.Value().data(), cppValue.Value().lineupName.Value().size()) - .c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue.Value().lineupName.Value(), + value_lineupNameInsideOptional)); chip::JniReferences::GetInstance().CreateOptional(value_lineupNameInsideOptional, value_lineupName); } jobject value_postalCode; @@ -17477,9 +17476,8 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR else { jobject value_postalCodeInsideOptional; - value_postalCodeInsideOptional = env->NewStringUTF( - std::string(cppValue.Value().postalCode.Value().data(), cppValue.Value().postalCode.Value().size()) - .c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue.Value().postalCode.Value(), + value_postalCodeInsideOptional)); chip::JniReferences::GetInstance().CreateOptional(value_postalCodeInsideOptional, value_postalCode); } jobject value_lineupInfoType; @@ -17546,8 +17544,8 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR else { jobject value_nameInsideOptional; - value_nameInsideOptional = env->NewStringUTF( - std::string(cppValue.Value().name.Value().data(), cppValue.Value().name.Value().size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue.Value().name.Value(), + value_nameInsideOptional)); chip::JniReferences::GetInstance().CreateOptional(value_nameInsideOptional, value_name); } jobject value_callSign; @@ -17558,8 +17556,8 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR else { jobject value_callSignInsideOptional; - value_callSignInsideOptional = env->NewStringUTF( - std::string(cppValue.Value().callSign.Value().data(), cppValue.Value().callSign.Value().size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue.Value().callSign.Value(), + value_callSignInsideOptional)); chip::JniReferences::GetInstance().CreateOptional(value_callSignInsideOptional, value_callSign); } jobject value_affiliateCallSign; @@ -17570,10 +17568,8 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR else { jobject value_affiliateCallSignInsideOptional; - value_affiliateCallSignInsideOptional = - env->NewStringUTF(std::string(cppValue.Value().affiliateCallSign.Value().data(), - cppValue.Value().affiliateCallSign.Value().size()) - .c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue.Value().affiliateCallSign.Value(), + value_affiliateCallSignInsideOptional)); chip::JniReferences::GetInstance().CreateOptional(value_affiliateCallSignInsideOptional, value_affiliateCallSign); } @@ -17759,7 +17755,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR newElement_0_identifierCtorSignature.c_str(), entry_0.identifier, newElement_0_identifier); jobject newElement_0_name; - newElement_0_name = env->NewStringUTF(std::string(entry_0.name.data(), entry_0.name.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.name, newElement_0_name)); jclass targetInfoStructStructClass_1; err = chip::JniReferences::GetInstance().GetClassRef( @@ -18274,10 +18270,10 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR newElement_0_inputTypeClassName.c_str(), newElement_0_inputTypeCtorSignature.c_str(), static_cast(entry_0.inputType), newElement_0_inputType); jobject newElement_0_name; - newElement_0_name = env->NewStringUTF(std::string(entry_0.name.data(), entry_0.name.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.name, newElement_0_name)); jobject newElement_0_description; - newElement_0_description = - env->NewStringUTF(std::string(entry_0.description.data(), entry_0.description.size()).c_str()); + LogErrorOnFailure( + chip::JniReferences::GetInstance().CharToStringUTF(entry_0.description, newElement_0_description)); jclass inputInfoStructStructClass_1; err = chip::JniReferences::GetInstance().GetClassRef( @@ -18741,7 +18737,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR { auto & entry_0 = iter_value_0.GetValue(); jobject newElement_0; - newElement_0 = env->NewStringUTF(std::string(entry_0.data(), entry_0.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0, newElement_0)); chip::JniReferences::GetInstance().AddToList(value, newElement_0); } return value; @@ -18926,7 +18922,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR newElement_0_outputTypeClassName.c_str(), newElement_0_outputTypeCtorSignature.c_str(), static_cast(entry_0.outputType), newElement_0_outputType); jobject newElement_0_name; - newElement_0_name = env->NewStringUTF(std::string(entry_0.name.data(), entry_0.name.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.name, newElement_0_name)); jclass outputInfoStructStructClass_1; err = chip::JniReferences::GetInstance().GetClassRef( @@ -19148,9 +19144,8 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR value_application_catalogVendorIDClassName.c_str(), value_application_catalogVendorIDCtorSignature.c_str(), cppValue.Value().application.catalogVendorID, value_application_catalogVendorID); jobject value_application_applicationID; - value_application_applicationID = env->NewStringUTF(std::string(cppValue.Value().application.applicationID.data(), - cppValue.Value().application.applicationID.size()) - .c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue.Value().application.applicationID, + value_application_applicationID)); jclass applicationStructStructClass_2; err = chip::JniReferences::GetInstance().GetClassRef( @@ -19355,7 +19350,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::VendorID::Id: { @@ -19382,7 +19377,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::ProductID::Id: { @@ -19416,8 +19411,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR value_catalogVendorIDCtorSignature.c_str(), cppValue.catalogVendorID, value_catalogVendorID); jobject value_applicationID; - value_applicationID = - env->NewStringUTF(std::string(cppValue.applicationID.data(), cppValue.applicationID.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue.applicationID, value_applicationID)); jclass applicationStructStructClass_0; err = chip::JniReferences::GetInstance().GetClassRef( @@ -19463,7 +19457,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::AllowedVendorList::Id: { @@ -22569,7 +22563,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::LongCharString::Id: { @@ -22581,7 +22575,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - value = env->NewStringUTF(std::string(cppValue.data(), cppValue.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue, value)); return value; } case Attributes::EpochUs::Id: { @@ -22706,8 +22700,8 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } else { - newElement_0_nullableString = env->NewStringUTF( - std::string(entry_0.nullableString.Value().data(), entry_0.nullableString.Value().size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.nullableString.Value(), + newElement_0_nullableString)); } jobject newElement_0_optionalString; if (!entry_0.optionalString.HasValue()) @@ -22717,8 +22711,8 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR else { jobject newElement_0_optionalStringInsideOptional; - newElement_0_optionalStringInsideOptional = env->NewStringUTF( - std::string(entry_0.optionalString.Value().data(), entry_0.optionalString.Value().size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( + entry_0.optionalString.Value(), newElement_0_optionalStringInsideOptional)); chip::JniReferences::GetInstance().CreateOptional(newElement_0_optionalStringInsideOptional, newElement_0_optionalString); } @@ -22736,10 +22730,8 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } else { - newElement_0_nullableOptionalStringInsideOptional = - env->NewStringUTF(std::string(entry_0.nullableOptionalString.Value().Value().data(), - entry_0.nullableOptionalString.Value().Value().size()) - .c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( + entry_0.nullableOptionalString.Value().Value(), newElement_0_nullableOptionalStringInsideOptional)); } chip::JniReferences::GetInstance().CreateOptional(newElement_0_nullableOptionalStringInsideOptional, newElement_0_nullableOptionalString); @@ -22777,8 +22769,8 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR reinterpret_cast(entry_0.nullableStruct.Value().d.data())); newElement_0_nullableStruct_d = newElement_0_nullableStruct_dByteArray; jobject newElement_0_nullableStruct_e; - newElement_0_nullableStruct_e = env->NewStringUTF( - std::string(entry_0.nullableStruct.Value().e.data(), entry_0.nullableStruct.Value().e.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.nullableStruct.Value().e, + newElement_0_nullableStruct_e)); jobject newElement_0_nullableStruct_f; std::string newElement_0_nullableStruct_fClassName = "java/lang/Integer"; std::string newElement_0_nullableStruct_fCtorSignature = "(I)V"; @@ -22859,8 +22851,8 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR reinterpret_cast(entry_0.optionalStruct.Value().d.data())); newElement_0_optionalStructInsideOptional_d = newElement_0_optionalStructInsideOptional_dByteArray; jobject newElement_0_optionalStructInsideOptional_e; - newElement_0_optionalStructInsideOptional_e = env->NewStringUTF( - std::string(entry_0.optionalStruct.Value().e.data(), entry_0.optionalStruct.Value().e.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( + entry_0.optionalStruct.Value().e, newElement_0_optionalStructInsideOptional_e)); jobject newElement_0_optionalStructInsideOptional_f; std::string newElement_0_optionalStructInsideOptional_fClassName = "java/lang/Integer"; std::string newElement_0_optionalStructInsideOptional_fCtorSignature = "(I)V"; @@ -22956,10 +22948,8 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR newElement_0_nullableOptionalStructInsideOptional_d = newElement_0_nullableOptionalStructInsideOptional_dByteArray; jobject newElement_0_nullableOptionalStructInsideOptional_e; - newElement_0_nullableOptionalStructInsideOptional_e = - env->NewStringUTF(std::string(entry_0.nullableOptionalStruct.Value().Value().e.data(), - entry_0.nullableOptionalStruct.Value().Value().e.size()) - .c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( + entry_0.nullableOptionalStruct.Value().Value().e, newElement_0_nullableOptionalStructInsideOptional_e)); jobject newElement_0_nullableOptionalStructInsideOptional_f; std::string newElement_0_nullableOptionalStructInsideOptional_fClassName = "java/lang/Integer"; std::string newElement_0_nullableOptionalStructInsideOptional_fCtorSignature = "(I)V"; @@ -23172,7 +23162,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR reinterpret_cast(cppValue.d.data())); value_d = value_dByteArray; jobject value_e; - value_e = env->NewStringUTF(std::string(cppValue.e.data(), cppValue.e.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue.e, value_e)); jobject value_f; std::string value_fClassName = "java/lang/Integer"; std::string value_fCtorSignature = "(I)V"; @@ -23375,8 +23365,8 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR newElement_0_nullableOptionalFabricSensitiveInt8u); } jobject newElement_0_fabricSensitiveCharString; - newElement_0_fabricSensitiveCharString = env->NewStringUTF( - std::string(entry_0.fabricSensitiveCharString.data(), entry_0.fabricSensitiveCharString.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.fabricSensitiveCharString, + newElement_0_fabricSensitiveCharString)); jobject newElement_0_fabricSensitiveStruct; jobject newElement_0_fabricSensitiveStruct_a; std::string newElement_0_fabricSensitiveStruct_aClassName = "java/lang/Integer"; @@ -23407,8 +23397,8 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR reinterpret_cast(entry_0.fabricSensitiveStruct.d.data())); newElement_0_fabricSensitiveStruct_d = newElement_0_fabricSensitiveStruct_dByteArray; jobject newElement_0_fabricSensitiveStruct_e; - newElement_0_fabricSensitiveStruct_e = env->NewStringUTF( - std::string(entry_0.fabricSensitiveStruct.e.data(), entry_0.fabricSensitiveStruct.e.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.fabricSensitiveStruct.e, + newElement_0_fabricSensitiveStruct_e)); jobject newElement_0_fabricSensitiveStruct_f; std::string newElement_0_fabricSensitiveStruct_fClassName = "java/lang/Integer"; std::string newElement_0_fabricSensitiveStruct_fCtorSignature = "(I)V"; @@ -24150,7 +24140,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } else { - value = env->NewStringUTF(std::string(cppValue.Value().data(), cppValue.Value().size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue.Value(), value)); } return value; } @@ -24212,7 +24202,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR reinterpret_cast(cppValue.Value().d.data())); value_d = value_dByteArray; jobject value_e; - value_e = env->NewStringUTF(std::string(cppValue.Value().e.data(), cppValue.Value().e.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue.Value().e, value_e)); jobject value_f; std::string value_fClassName = "java/lang/Integer"; std::string value_fCtorSignature = "(I)V"; diff --git a/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp b/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp index ab27364d930ee3..066d36bdd1f4d2 100644 --- a/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp +++ b/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp @@ -1420,8 +1420,8 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & else { jobject value_nameInsideOptional; - value_nameInsideOptional = - env->NewStringUTF(std::string(cppValue.name.Value().data(), cppValue.name.Value().size()).c_str()); + LogErrorOnFailure( + chip::JniReferences::GetInstance().CharToStringUTF(cppValue.name.Value(), value_nameInsideOptional)); chip::JniReferences::GetInstance().CreateOptional(value_nameInsideOptional, value_name); } @@ -3498,7 +3498,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & reinterpret_cast(cppValue.arg4.d.data())); value_arg4_d = value_arg4_dByteArray; jobject value_arg4_e; - value_arg4_e = env->NewStringUTF(std::string(cppValue.arg4.e.data(), cppValue.arg4.e.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue.arg4.e, value_arg4_e)); jobject value_arg4_f; std::string value_arg4_fClassName = "java/lang/Integer"; std::string value_arg4_fCtorSignature = "(I)V"; @@ -3566,7 +3566,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & reinterpret_cast(entry_0.d.data())); newElement_0_d = newElement_0_dByteArray; jobject newElement_0_e; - newElement_0_e = env->NewStringUTF(std::string(entry_0.e.data(), entry_0.e.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.e, newElement_0_e)); jobject newElement_0_f; std::string newElement_0_fClassName = "java/lang/Integer"; std::string newElement_0_fCtorSignature = "(I)V"; diff --git a/src/controller/java/zap-generated/CHIPInvokeCallbacks.cpp b/src/controller/java/zap-generated/CHIPInvokeCallbacks.cpp index f2527732efb160..2fb5e13227f298 100644 --- a/src/controller/java/zap-generated/CHIPInvokeCallbacks.cpp +++ b/src/controller/java/zap-generated/CHIPInvokeCallbacks.cpp @@ -157,7 +157,7 @@ void CHIPGroupsClusterViewGroupResponseCallback::CallbackFn( chip::JniReferences::GetInstance().CreateBoxedObject(GroupIDClassName.c_str(), GroupIDCtorSignature.c_str(), dataResponse.groupID, GroupID); jobject GroupName; - GroupName = env->NewStringUTF(std::string(dataResponse.groupName.data(), dataResponse.groupName.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.groupName, GroupName)); env->CallVoidMethod(javaCallbackRef, javaMethod, Status, GroupID, GroupName); } @@ -470,8 +470,8 @@ void CHIPScenesClusterViewSceneResponseCallback::CallbackFn( else { jobject SceneNameInsideOptional; - SceneNameInsideOptional = - env->NewStringUTF(std::string(dataResponse.sceneName.Value().data(), dataResponse.sceneName.Value().size()).c_str()); + LogErrorOnFailure( + chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.sceneName.Value(), SceneNameInsideOptional)); chip::JniReferences::GetInstance().CreateOptional(SceneNameInsideOptional, SceneName); } jobject ExtensionFieldSets; @@ -1052,8 +1052,8 @@ void CHIPScenesClusterEnhancedViewSceneResponseCallback::CallbackFn( else { jobject SceneNameInsideOptional; - SceneNameInsideOptional = - env->NewStringUTF(std::string(dataResponse.sceneName.Value().data(), dataResponse.sceneName.Value().size()).c_str()); + LogErrorOnFailure( + chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.sceneName.Value(), SceneNameInsideOptional)); chip::JniReferences::GetInstance().CreateOptional(SceneNameInsideOptional, SceneName); } jobject ExtensionFieldSets; @@ -1321,8 +1321,8 @@ void CHIPOtaSoftwareUpdateProviderClusterQueryImageResponseCallback::CallbackFn( else { jobject ImageURIInsideOptional; - ImageURIInsideOptional = - env->NewStringUTF(std::string(dataResponse.imageURI.Value().data(), dataResponse.imageURI.Value().size()).c_str()); + LogErrorOnFailure( + chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.imageURI.Value(), ImageURIInsideOptional)); chip::JniReferences::GetInstance().CreateOptional(ImageURIInsideOptional, ImageURI); } jobject SoftwareVersion; @@ -1348,9 +1348,8 @@ void CHIPOtaSoftwareUpdateProviderClusterQueryImageResponseCallback::CallbackFn( else { jobject SoftwareVersionStringInsideOptional; - SoftwareVersionStringInsideOptional = env->NewStringUTF( - std::string(dataResponse.softwareVersionString.Value().data(), dataResponse.softwareVersionString.Value().size()) - .c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.softwareVersionString.Value(), + SoftwareVersionStringInsideOptional)); chip::JniReferences::GetInstance().CreateOptional(SoftwareVersionStringInsideOptional, SoftwareVersionString); } jobject UpdateToken; @@ -1532,7 +1531,7 @@ void CHIPGeneralCommissioningClusterArmFailSafeResponseCallback::CallbackFn( chip::JniReferences::GetInstance().CreateBoxedObject(ErrorCodeClassName.c_str(), ErrorCodeCtorSignature.c_str(), static_cast(dataResponse.errorCode), ErrorCode); jobject DebugText; - DebugText = env->NewStringUTF(std::string(dataResponse.debugText.data(), dataResponse.debugText.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.debugText, DebugText)); env->CallVoidMethod(javaCallbackRef, javaMethod, ErrorCode, DebugText); } @@ -1598,7 +1597,7 @@ void CHIPGeneralCommissioningClusterSetRegulatoryConfigResponseCallback::Callbac chip::JniReferences::GetInstance().CreateBoxedObject(ErrorCodeClassName.c_str(), ErrorCodeCtorSignature.c_str(), static_cast(dataResponse.errorCode), ErrorCode); jobject DebugText; - DebugText = env->NewStringUTF(std::string(dataResponse.debugText.data(), dataResponse.debugText.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.debugText, DebugText)); env->CallVoidMethod(javaCallbackRef, javaMethod, ErrorCode, DebugText); } @@ -1664,7 +1663,7 @@ void CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallback::Callb chip::JniReferences::GetInstance().CreateBoxedObject(ErrorCodeClassName.c_str(), ErrorCodeCtorSignature.c_str(), static_cast(dataResponse.errorCode), ErrorCode); jobject DebugText; - DebugText = env->NewStringUTF(std::string(dataResponse.debugText.data(), dataResponse.debugText.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.debugText, DebugText)); env->CallVoidMethod(javaCallbackRef, javaMethod, ErrorCode, DebugText); } @@ -1737,8 +1736,8 @@ void CHIPNetworkCommissioningClusterScanNetworksResponseCallback::CallbackFn( else { jobject DebugTextInsideOptional; - DebugTextInsideOptional = - env->NewStringUTF(std::string(dataResponse.debugText.Value().data(), dataResponse.debugText.Value().size()).c_str()); + LogErrorOnFailure( + chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.debugText.Value(), DebugTextInsideOptional)); chip::JniReferences::GetInstance().CreateOptional(DebugTextInsideOptional, DebugText); } jobject WiFiScanResults; @@ -1842,8 +1841,7 @@ void CHIPNetworkCommissioningClusterScanNetworksResponseCallback::CallbackFn( newElement_1_extendedPanIdCtorSignature.c_str(), entry_1.extendedPanId, newElement_1_extendedPanId); jobject newElement_1_networkName; - newElement_1_networkName = - env->NewStringUTF(std::string(entry_1.networkName.data(), entry_1.networkName.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_1.networkName, newElement_1_networkName)); jobject newElement_1_channel; std::string newElement_1_channelClassName = "java/lang/Integer"; std::string newElement_1_channelCtorSignature = "(I)V"; @@ -1971,8 +1969,8 @@ void CHIPNetworkCommissioningClusterNetworkConfigResponseCallback::CallbackFn( else { jobject DebugTextInsideOptional; - DebugTextInsideOptional = - env->NewStringUTF(std::string(dataResponse.debugText.Value().data(), dataResponse.debugText.Value().size()).c_str()); + LogErrorOnFailure( + chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.debugText.Value(), DebugTextInsideOptional)); chip::JniReferences::GetInstance().CreateOptional(DebugTextInsideOptional, DebugText); } jobject NetworkIndex; @@ -2061,8 +2059,8 @@ void CHIPNetworkCommissioningClusterConnectNetworkResponseCallback::CallbackFn( else { jobject DebugTextInsideOptional; - DebugTextInsideOptional = - env->NewStringUTF(std::string(dataResponse.debugText.Value().data(), dataResponse.debugText.Value().size()).c_str()); + LogErrorOnFailure( + chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.debugText.Value(), DebugTextInsideOptional)); chip::JniReferences::GetInstance().CreateOptional(DebugTextInsideOptional, DebugText); } jobject ErrorValue; @@ -2451,8 +2449,8 @@ void CHIPOperationalCredentialsClusterNOCResponseCallback::CallbackFn( else { jobject DebugTextInsideOptional; - DebugTextInsideOptional = - env->NewStringUTF(std::string(dataResponse.debugText.Value().data(), dataResponse.debugText.Value().size()).c_str()); + LogErrorOnFailure( + chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.debugText.Value(), DebugTextInsideOptional)); chip::JniReferences::GetInstance().CreateOptional(DebugTextInsideOptional, DebugText); } @@ -3135,8 +3133,7 @@ void CHIPDoorLockClusterGetUserResponseCallback::CallbackFn( } else { - UserName = - env->NewStringUTF(std::string(dataResponse.userName.Value().data(), dataResponse.userName.Value().size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.userName.Value(), UserName)); } jobject UserUniqueID; if (dataResponse.userUniqueID.IsNull()) @@ -3683,8 +3680,7 @@ void CHIPChannelClusterChangeChannelResponseCallback::CallbackFn( else { jobject DataInsideOptional; - DataInsideOptional = - env->NewStringUTF(std::string(dataResponse.data.Value().data(), dataResponse.data.Value().size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.data.Value(), DataInsideOptional)); chip::JniReferences::GetInstance().CreateOptional(DataInsideOptional, Data); } @@ -3757,8 +3753,7 @@ void CHIPTargetNavigatorClusterNavigateTargetResponseCallback::CallbackFn( else { jobject DataInsideOptional; - DataInsideOptional = - env->NewStringUTF(std::string(dataResponse.data.Value().data(), dataResponse.data.Value().size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.data.Value(), DataInsideOptional)); chip::JniReferences::GetInstance().CreateOptional(DataInsideOptional, Data); } @@ -3829,8 +3824,7 @@ void CHIPMediaPlaybackClusterPlaybackResponseCallback::CallbackFn( else { jobject DataInsideOptional; - DataInsideOptional = - env->NewStringUTF(std::string(dataResponse.data.Value().data(), dataResponse.data.Value().size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.data.Value(), DataInsideOptional)); chip::JniReferences::GetInstance().CreateOptional(DataInsideOptional, Data); } @@ -3961,8 +3955,7 @@ void CHIPContentLauncherClusterLauncherResponseCallback::CallbackFn( else { jobject DataInsideOptional; - DataInsideOptional = - env->NewStringUTF(std::string(dataResponse.data.Value().data(), dataResponse.data.Value().size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.data.Value(), DataInsideOptional)); chip::JniReferences::GetInstance().CreateOptional(DataInsideOptional, Data); } @@ -4097,7 +4090,7 @@ void CHIPAccountLoginClusterGetSetupPINResponseCallback::CallbackFn( VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); jobject SetupPIN; - SetupPIN = env->NewStringUTF(std::string(dataResponse.setupPIN.data(), dataResponse.setupPIN.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.setupPIN, SetupPIN)); env->CallVoidMethod(javaCallbackRef, javaMethod, SetupPIN); } @@ -4574,7 +4567,7 @@ void CHIPUnitTestingClusterTestStructArrayArgumentResponseCallback::CallbackFn( reinterpret_cast(entry_0.c.d.data())); newElement_0_c_d = newElement_0_c_dByteArray; jobject newElement_0_c_e; - newElement_0_c_e = env->NewStringUTF(std::string(entry_0.c.e.data(), entry_0.c.e.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.c.e, newElement_0_c_e)); jobject newElement_0_c_f; std::string newElement_0_c_fClassName = "java/lang/Integer"; std::string newElement_0_c_fCtorSignature = "(I)V"; @@ -4642,7 +4635,7 @@ void CHIPUnitTestingClusterTestStructArrayArgumentResponseCallback::CallbackFn( reinterpret_cast(entry_2.d.data())); newElement_2_d = newElement_2_dByteArray; jobject newElement_2_e; - newElement_2_e = env->NewStringUTF(std::string(entry_2.e.data(), entry_2.e.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_2.e, newElement_2_e)); jobject newElement_2_f; std::string newElement_2_fClassName = "java/lang/Integer"; std::string newElement_2_fCtorSignature = "(I)V"; @@ -4776,7 +4769,7 @@ void CHIPUnitTestingClusterTestStructArrayArgumentResponseCallback::CallbackFn( reinterpret_cast(entry_0.d.data())); newElement_0_d = newElement_0_dByteArray; jobject newElement_0_e; - newElement_0_e = env->NewStringUTF(std::string(entry_0.e.data(), entry_0.e.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.e, newElement_0_e)); jobject newElement_0_f; std::string newElement_0_fClassName = "java/lang/Integer"; std::string newElement_0_fCtorSignature = "(I)V"; @@ -5262,8 +5255,8 @@ void CHIPUnitTestingClusterTestComplexNullableOptionalResponseCallback::Callback else { jobject NullableStringValueInsideOptional; - NullableStringValueInsideOptional = env->NewStringUTF( - std::string(dataResponse.nullableStringValue.Value().data(), dataResponse.nullableStringValue.Value().size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.nullableStringValue.Value(), + NullableStringValueInsideOptional)); chip::JniReferences::GetInstance().CreateOptional(NullableStringValueInsideOptional, NullableStringValue); } jobject OptionalStringWasPresent; @@ -5280,8 +5273,8 @@ void CHIPUnitTestingClusterTestComplexNullableOptionalResponseCallback::Callback else { jobject OptionalStringValueInsideOptional; - OptionalStringValueInsideOptional = env->NewStringUTF( - std::string(dataResponse.optionalStringValue.Value().data(), dataResponse.optionalStringValue.Value().size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.optionalStringValue.Value(), + OptionalStringValueInsideOptional)); chip::JniReferences::GetInstance().CreateOptional(OptionalStringValueInsideOptional, OptionalStringValue); } jobject NullableOptionalStringWasPresent; @@ -5315,10 +5308,8 @@ void CHIPUnitTestingClusterTestComplexNullableOptionalResponseCallback::Callback else { jobject NullableOptionalStringValueInsideOptional; - NullableOptionalStringValueInsideOptional = - env->NewStringUTF(std::string(dataResponse.nullableOptionalStringValue.Value().data(), - dataResponse.nullableOptionalStringValue.Value().size()) - .c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.nullableOptionalStringValue.Value(), + NullableOptionalStringValueInsideOptional)); chip::JniReferences::GetInstance().CreateOptional(NullableOptionalStringValueInsideOptional, NullableOptionalStringValue); } jobject NullableStructWasNull; @@ -5361,9 +5352,8 @@ void CHIPUnitTestingClusterTestComplexNullableOptionalResponseCallback::Callback reinterpret_cast(dataResponse.nullableStructValue.Value().d.data())); NullableStructValueInsideOptional_d = NullableStructValueInsideOptional_dByteArray; jobject NullableStructValueInsideOptional_e; - NullableStructValueInsideOptional_e = env->NewStringUTF( - std::string(dataResponse.nullableStructValue.Value().e.data(), dataResponse.nullableStructValue.Value().e.size()) - .c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.nullableStructValue.Value().e, + NullableStructValueInsideOptional_e)); jobject NullableStructValueInsideOptional_f; std::string NullableStructValueInsideOptional_fClassName = "java/lang/Integer"; std::string NullableStructValueInsideOptional_fCtorSignature = "(I)V"; @@ -5448,9 +5438,8 @@ void CHIPUnitTestingClusterTestComplexNullableOptionalResponseCallback::Callback reinterpret_cast(dataResponse.optionalStructValue.Value().d.data())); OptionalStructValueInsideOptional_d = OptionalStructValueInsideOptional_dByteArray; jobject OptionalStructValueInsideOptional_e; - OptionalStructValueInsideOptional_e = env->NewStringUTF( - std::string(dataResponse.optionalStructValue.Value().e.data(), dataResponse.optionalStructValue.Value().e.size()) - .c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.optionalStructValue.Value().e, + OptionalStructValueInsideOptional_e)); jobject OptionalStructValueInsideOptional_f; std::string OptionalStructValueInsideOptional_fClassName = "java/lang/Integer"; std::string OptionalStructValueInsideOptional_fCtorSignature = "(I)V"; @@ -5555,10 +5544,8 @@ void CHIPUnitTestingClusterTestComplexNullableOptionalResponseCallback::Callback reinterpret_cast(dataResponse.nullableOptionalStructValue.Value().d.data())); NullableOptionalStructValueInsideOptional_d = NullableOptionalStructValueInsideOptional_dByteArray; jobject NullableOptionalStructValueInsideOptional_e; - NullableOptionalStructValueInsideOptional_e = - env->NewStringUTF(std::string(dataResponse.nullableOptionalStructValue.Value().e.data(), - dataResponse.nullableOptionalStructValue.Value().e.size()) - .c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.nullableOptionalStructValue.Value().e, + NullableOptionalStructValueInsideOptional_e)); jobject NullableOptionalStructValueInsideOptional_f; std::string NullableOptionalStructValueInsideOptional_fClassName = "java/lang/Integer"; std::string NullableOptionalStructValueInsideOptional_fCtorSignature = "(I)V"; @@ -5854,7 +5841,7 @@ void CHIPUnitTestingClusterSimpleStructResponseCallback::CallbackFn( reinterpret_cast(dataResponse.arg1.d.data())); arg1_d = arg1_dByteArray; jobject arg1_e; - arg1_e = env->NewStringUTF(std::string(dataResponse.arg1.e.data(), dataResponse.arg1.e.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(dataResponse.arg1.e, arg1_e)); jobject arg1_f; std::string arg1_fClassName = "java/lang/Integer"; std::string arg1_fCtorSignature = "(I)V"; diff --git a/src/controller/java/zap-generated/CHIPReadCallbacks.cpp b/src/controller/java/zap-generated/CHIPReadCallbacks.cpp index 0367add107cdf2..caf86b14ed9214 100644 --- a/src/controller/java/zap-generated/CHIPReadCallbacks.cpp +++ b/src/controller/java/zap-generated/CHIPReadCallbacks.cpp @@ -4836,7 +4836,7 @@ void CHIPActionsActionListAttributeCallback::CallbackFn( newElement_0_actionIDCtorSignature.c_str(), entry_0.actionID, newElement_0_actionID); jobject newElement_0_name; - newElement_0_name = env->NewStringUTF(std::string(entry_0.name.data(), entry_0.name.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.name, newElement_0_name)); jobject newElement_0_type; std::string newElement_0_typeClassName = "java/lang/Integer"; std::string newElement_0_typeCtorSignature = "(I)V"; @@ -4955,7 +4955,7 @@ void CHIPActionsEndpointListsAttributeCallback::CallbackFn( newElement_0_endpointListIDCtorSignature.c_str(), entry_0.endpointListID, newElement_0_endpointListID); jobject newElement_0_name; - newElement_0_name = env->NewStringUTF(std::string(entry_0.name.data(), entry_0.name.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.name, newElement_0_name)); jobject newElement_0_type; std::string newElement_0_typeClassName = "java/lang/Integer"; std::string newElement_0_typeCtorSignature = "(I)V"; @@ -6375,7 +6375,7 @@ void CHIPLocalizationConfigurationSupportedLocalesAttributeCallback::CallbackFn( { auto & entry_0 = iter_arrayListObj_0.GetValue(); jobject newElement_0; - newElement_0 = env->NewStringUTF(std::string(entry_0.data(), entry_0.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0, newElement_0)); chip::JniReferences::GetInstance().AddToList(arrayListObj, newElement_0); } @@ -9905,7 +9905,7 @@ void CHIPGeneralDiagnosticsNetworkInterfacesAttributeCallback::CallbackFn( auto & entry_0 = iter_arrayListObj_0.GetValue(); jobject newElement_0; jobject newElement_0_name; - newElement_0_name = env->NewStringUTF(std::string(entry_0.name.data(), entry_0.name.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.name, newElement_0_name)); jobject newElement_0_isOperational; std::string newElement_0_isOperationalClassName = "java/lang/Boolean"; std::string newElement_0_isOperationalCtorSignature = "(Z)V"; @@ -10581,8 +10581,8 @@ void CHIPSoftwareDiagnosticsThreadMetricsAttributeCallback::CallbackFn( else { jobject newElement_0_nameInsideOptional; - newElement_0_nameInsideOptional = - env->NewStringUTF(std::string(entry_0.name.Value().data(), entry_0.name.Value().size()).c_str()); + LogErrorOnFailure( + chip::JniReferences::GetInstance().CharToStringUTF(entry_0.name.Value(), newElement_0_nameInsideOptional)); chip::JniReferences::GetInstance().CreateOptional(newElement_0_nameInsideOptional, newElement_0_name); } jobject newElement_0_stackFreeCurrent; @@ -11139,7 +11139,7 @@ void CHIPThreadNetworkDiagnosticsNetworkNameAttributeCallback::CallbackFn( } else { - javaValue = env->NewStringUTF(std::string(value.Value().data(), value.Value().size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(value.Value(), javaValue)); } env->CallVoidMethod(javaCallbackRef, javaMethod, javaValue); @@ -15468,7 +15468,7 @@ void CHIPOperationalCredentialsFabricsAttributeCallback::CallbackFn( chip::JniReferences::GetInstance().CreateBoxedObject( newElement_0_nodeIDClassName.c_str(), newElement_0_nodeIDCtorSignature.c_str(), entry_0.nodeID, newElement_0_nodeID); jobject newElement_0_label; - newElement_0_label = env->NewStringUTF(std::string(entry_0.label.data(), entry_0.label.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.label, newElement_0_label)); jobject newElement_0_fabricIndex; std::string newElement_0_fabricIndexClassName = "java/lang/Integer"; std::string newElement_0_fabricIndexCtorSignature = "(I)V"; @@ -16056,8 +16056,8 @@ void CHIPGroupKeyManagementGroupTableAttributeCallback::CallbackFn( else { jobject newElement_0_groupNameInsideOptional; - newElement_0_groupNameInsideOptional = - env->NewStringUTF(std::string(entry_0.groupName.Value().data(), entry_0.groupName.Value().size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.groupName.Value(), + newElement_0_groupNameInsideOptional)); chip::JniReferences::GetInstance().CreateOptional(newElement_0_groupNameInsideOptional, newElement_0_groupName); } jobject newElement_0_fabricIndex; @@ -16437,9 +16437,9 @@ void CHIPFixedLabelLabelListAttributeCallback::CallbackFn( auto & entry_0 = iter_arrayListObj_0.GetValue(); jobject newElement_0; jobject newElement_0_label; - newElement_0_label = env->NewStringUTF(std::string(entry_0.label.data(), entry_0.label.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.label, newElement_0_label)); jobject newElement_0_value; - newElement_0_value = env->NewStringUTF(std::string(entry_0.value.data(), entry_0.value.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.value, newElement_0_value)); jclass labelStructStructClass_1; err = chip::JniReferences::GetInstance().GetClassRef(env, "chip/devicecontroller/ChipStructs$FixedLabelClusterLabelStruct", @@ -16805,9 +16805,9 @@ void CHIPUserLabelLabelListAttributeCallback::CallbackFn( auto & entry_0 = iter_arrayListObj_0.GetValue(); jobject newElement_0; jobject newElement_0_label; - newElement_0_label = env->NewStringUTF(std::string(entry_0.label.data(), entry_0.label.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.label, newElement_0_label)); jobject newElement_0_value; - newElement_0_value = env->NewStringUTF(std::string(entry_0.value.data(), entry_0.value.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.value, newElement_0_value)); jclass labelStructStructClass_1; err = chip::JniReferences::GetInstance().GetClassRef(env, "chip/devicecontroller/ChipStructs$UserLabelClusterLabelStruct", @@ -17522,7 +17522,7 @@ void CHIPModeSelectSupportedModesAttributeCallback::CallbackFn( auto & entry_0 = iter_arrayListObj_0.GetValue(); jobject newElement_0; jobject newElement_0_label; - newElement_0_label = env->NewStringUTF(std::string(entry_0.label.data(), entry_0.label.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.label, newElement_0_label)); jobject newElement_0_mode; std::string newElement_0_modeClassName = "java/lang/Integer"; std::string newElement_0_modeCtorSignature = "(I)V"; @@ -27709,8 +27709,8 @@ void CHIPChannelChannelListAttributeCallback::CallbackFn( else { jobject newElement_0_nameInsideOptional; - newElement_0_nameInsideOptional = - env->NewStringUTF(std::string(entry_0.name.Value().data(), entry_0.name.Value().size()).c_str()); + LogErrorOnFailure( + chip::JniReferences::GetInstance().CharToStringUTF(entry_0.name.Value(), newElement_0_nameInsideOptional)); chip::JniReferences::GetInstance().CreateOptional(newElement_0_nameInsideOptional, newElement_0_name); } jobject newElement_0_callSign; @@ -27721,8 +27721,8 @@ void CHIPChannelChannelListAttributeCallback::CallbackFn( else { jobject newElement_0_callSignInsideOptional; - newElement_0_callSignInsideOptional = - env->NewStringUTF(std::string(entry_0.callSign.Value().data(), entry_0.callSign.Value().size()).c_str()); + LogErrorOnFailure( + chip::JniReferences::GetInstance().CharToStringUTF(entry_0.callSign.Value(), newElement_0_callSignInsideOptional)); chip::JniReferences::GetInstance().CreateOptional(newElement_0_callSignInsideOptional, newElement_0_callSign); } jobject newElement_0_affiliateCallSign; @@ -27733,8 +27733,8 @@ void CHIPChannelChannelListAttributeCallback::CallbackFn( else { jobject newElement_0_affiliateCallSignInsideOptional; - newElement_0_affiliateCallSignInsideOptional = env->NewStringUTF( - std::string(entry_0.affiliateCallSign.Value().data(), entry_0.affiliateCallSign.Value().size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.affiliateCallSign.Value(), + newElement_0_affiliateCallSignInsideOptional)); chip::JniReferences::GetInstance().CreateOptional(newElement_0_affiliateCallSignInsideOptional, newElement_0_affiliateCallSign); } @@ -28115,7 +28115,7 @@ void CHIPTargetNavigatorTargetListAttributeCallback::CallbackFn( newElement_0_identifierCtorSignature.c_str(), entry_0.identifier, newElement_0_identifier); jobject newElement_0_name; - newElement_0_name = env->NewStringUTF(std::string(entry_0.name.data(), entry_0.name.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.name, newElement_0_name)); jclass targetInfoStructStructClass_1; err = chip::JniReferences::GetInstance().GetClassRef( @@ -29039,9 +29039,9 @@ void CHIPMediaInputInputListAttributeCallback::CallbackFn( newElement_0_inputTypeClassName.c_str(), newElement_0_inputTypeCtorSignature.c_str(), static_cast(entry_0.inputType), newElement_0_inputType); jobject newElement_0_name; - newElement_0_name = env->NewStringUTF(std::string(entry_0.name.data(), entry_0.name.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.name, newElement_0_name)); jobject newElement_0_description; - newElement_0_description = env->NewStringUTF(std::string(entry_0.description.data(), entry_0.description.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.description, newElement_0_description)); jclass inputInfoStructStructClass_1; err = chip::JniReferences::GetInstance().GetClassRef( @@ -29969,7 +29969,7 @@ void CHIPContentLauncherAcceptHeaderAttributeCallback::CallbackFn(void * context { auto & entry_0 = iter_arrayListObj_0.GetValue(); jobject newElement_0; - newElement_0 = env->NewStringUTF(std::string(entry_0.data(), entry_0.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0, newElement_0)); chip::JniReferences::GetInstance().AddToList(arrayListObj, newElement_0); } @@ -30330,7 +30330,7 @@ void CHIPAudioOutputOutputListAttributeCallback::CallbackFn( newElement_0_outputTypeClassName.c_str(), newElement_0_outputTypeCtorSignature.c_str(), static_cast(entry_0.outputType), newElement_0_outputType); jobject newElement_0_name; - newElement_0_name = env->NewStringUTF(std::string(entry_0.name.data(), entry_0.name.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.name, newElement_0_name)); jclass outputInfoStructStructClass_1; err = chip::JniReferences::GetInstance().GetClassRef( @@ -32663,8 +32663,8 @@ void CHIPUnitTestingListNullablesAndOptionalsStructAttributeCallback::CallbackFn } else { - newElement_0_nullableString = env->NewStringUTF( - std::string(entry_0.nullableString.Value().data(), entry_0.nullableString.Value().size()).c_str()); + LogErrorOnFailure( + chip::JniReferences::GetInstance().CharToStringUTF(entry_0.nullableString.Value(), newElement_0_nullableString)); } jobject newElement_0_optionalString; if (!entry_0.optionalString.HasValue()) @@ -32674,8 +32674,8 @@ void CHIPUnitTestingListNullablesAndOptionalsStructAttributeCallback::CallbackFn else { jobject newElement_0_optionalStringInsideOptional; - newElement_0_optionalStringInsideOptional = env->NewStringUTF( - std::string(entry_0.optionalString.Value().data(), entry_0.optionalString.Value().size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.optionalString.Value(), + newElement_0_optionalStringInsideOptional)); chip::JniReferences::GetInstance().CreateOptional(newElement_0_optionalStringInsideOptional, newElement_0_optionalString); } @@ -32693,10 +32693,8 @@ void CHIPUnitTestingListNullablesAndOptionalsStructAttributeCallback::CallbackFn } else { - newElement_0_nullableOptionalStringInsideOptional = - env->NewStringUTF(std::string(entry_0.nullableOptionalString.Value().Value().data(), - entry_0.nullableOptionalString.Value().Value().size()) - .c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( + entry_0.nullableOptionalString.Value().Value(), newElement_0_nullableOptionalStringInsideOptional)); } chip::JniReferences::GetInstance().CreateOptional(newElement_0_nullableOptionalStringInsideOptional, newElement_0_nullableOptionalString); @@ -32734,8 +32732,8 @@ void CHIPUnitTestingListNullablesAndOptionalsStructAttributeCallback::CallbackFn reinterpret_cast(entry_0.nullableStruct.Value().d.data())); newElement_0_nullableStruct_d = newElement_0_nullableStruct_dByteArray; jobject newElement_0_nullableStruct_e; - newElement_0_nullableStruct_e = env->NewStringUTF( - std::string(entry_0.nullableStruct.Value().e.data(), entry_0.nullableStruct.Value().e.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.nullableStruct.Value().e, + newElement_0_nullableStruct_e)); jobject newElement_0_nullableStruct_f; std::string newElement_0_nullableStruct_fClassName = "java/lang/Integer"; std::string newElement_0_nullableStruct_fCtorSignature = "(I)V"; @@ -32815,8 +32813,8 @@ void CHIPUnitTestingListNullablesAndOptionalsStructAttributeCallback::CallbackFn reinterpret_cast(entry_0.optionalStruct.Value().d.data())); newElement_0_optionalStructInsideOptional_d = newElement_0_optionalStructInsideOptional_dByteArray; jobject newElement_0_optionalStructInsideOptional_e; - newElement_0_optionalStructInsideOptional_e = env->NewStringUTF( - std::string(entry_0.optionalStruct.Value().e.data(), entry_0.optionalStruct.Value().e.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.optionalStruct.Value().e, + newElement_0_optionalStructInsideOptional_e)); jobject newElement_0_optionalStructInsideOptional_f; std::string newElement_0_optionalStructInsideOptional_fClassName = "java/lang/Integer"; std::string newElement_0_optionalStructInsideOptional_fCtorSignature = "(I)V"; @@ -32910,10 +32908,8 @@ void CHIPUnitTestingListNullablesAndOptionalsStructAttributeCallback::CallbackFn reinterpret_cast(entry_0.nullableOptionalStruct.Value().Value().d.data())); newElement_0_nullableOptionalStructInsideOptional_d = newElement_0_nullableOptionalStructInsideOptional_dByteArray; jobject newElement_0_nullableOptionalStructInsideOptional_e; - newElement_0_nullableOptionalStructInsideOptional_e = - env->NewStringUTF(std::string(entry_0.nullableOptionalStruct.Value().Value().e.data(), - entry_0.nullableOptionalStruct.Value().Value().e.size()) - .c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF( + entry_0.nullableOptionalStruct.Value().Value().e, newElement_0_nullableOptionalStructInsideOptional_e)); jobject newElement_0_nullableOptionalStructInsideOptional_f; std::string newElement_0_nullableOptionalStructInsideOptional_fClassName = "java/lang/Integer"; std::string newElement_0_nullableOptionalStructInsideOptional_fCtorSignature = "(I)V"; @@ -33268,8 +33264,8 @@ void CHIPUnitTestingListFabricScopedAttributeCallback::CallbackFn( newElement_0_nullableOptionalFabricSensitiveInt8u); } jobject newElement_0_fabricSensitiveCharString; - newElement_0_fabricSensitiveCharString = env->NewStringUTF( - std::string(entry_0.fabricSensitiveCharString.data(), entry_0.fabricSensitiveCharString.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.fabricSensitiveCharString, + newElement_0_fabricSensitiveCharString)); jobject newElement_0_fabricSensitiveStruct; jobject newElement_0_fabricSensitiveStruct_a; std::string newElement_0_fabricSensitiveStruct_aClassName = "java/lang/Integer"; @@ -33297,8 +33293,8 @@ void CHIPUnitTestingListFabricScopedAttributeCallback::CallbackFn( reinterpret_cast(entry_0.fabricSensitiveStruct.d.data())); newElement_0_fabricSensitiveStruct_d = newElement_0_fabricSensitiveStruct_dByteArray; jobject newElement_0_fabricSensitiveStruct_e; - newElement_0_fabricSensitiveStruct_e = - env->NewStringUTF(std::string(entry_0.fabricSensitiveStruct.e.data(), entry_0.fabricSensitiveStruct.e.size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(entry_0.fabricSensitiveStruct.e, + newElement_0_fabricSensitiveStruct_e)); jobject newElement_0_fabricSensitiveStruct_f; std::string newElement_0_fabricSensitiveStruct_fClassName = "java/lang/Integer"; std::string newElement_0_fabricSensitiveStruct_fCtorSignature = "(I)V"; @@ -35184,7 +35180,7 @@ void CHIPUnitTestingNullableCharStringAttributeCallback::CallbackFn(void * conte } else { - javaValue = env->NewStringUTF(std::string(value.Value().data(), value.Value().size()).c_str()); + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(value.Value(), javaValue)); } env->CallVoidMethod(javaCallbackRef, javaMethod, javaValue); diff --git a/src/credentials/tests/TestGroupDataProvider.cpp b/src/credentials/tests/TestGroupDataProvider.cpp index 56a6424557b8a4..17b71ff7a5c788 100644 --- a/src/credentials/tests/TestGroupDataProvider.cpp +++ b/src/credentials/tests/TestGroupDataProvider.cpp @@ -78,9 +78,9 @@ constexpr ByteSpan kCompressedFabricId1(kCompressedFabricIdBuffer1); static const uint8_t kCompressedFabricIdBuffer2[] = { 0x3f, 0xaa, 0xe2, 0x90, 0x93, 0xd5, 0xaf, 0x45 }; constexpr ByteSpan kCompressedFabricId2(kCompressedFabricIdBuffer2); -constexpr chip::GroupId kGroup1 = kMinFabricGroupId; +constexpr chip::GroupId kGroup1 = kMinApplicationGroupId; constexpr chip::GroupId kGroup2 = 0x2222; -constexpr chip::GroupId kGroup3 = kMaxFabricGroupId; +constexpr chip::GroupId kGroup3 = kMaxApplicationGroupId; constexpr chip::GroupId kGroup4 = 0x4444; constexpr chip::GroupId kGroup5 = 0x5555; diff --git a/src/darwin/Framework/CHIP/MTRBaseDevice.h b/src/darwin/Framework/CHIP/MTRBaseDevice.h index 4bf87183a7b1d9..a0ff37f5d682c8 100644 --- a/src/darwin/Framework/CHIP/MTRBaseDevice.h +++ b/src/darwin/Framework/CHIP/MTRBaseDevice.h @@ -337,6 +337,22 @@ typedef NS_ENUM(uint8_t, MTRTransportType) { completion:(MTRDeviceOpenCommissioningWindowHandler)completion API_AVAILABLE(ios(16.2), macos(13.1), watchos(9.2), tvos(16.2)); +/** + * Open a commissioning window on the device, using a random setup passcode. + * + * On success, completion will be called on queue with the MTRSetupPayload that + * can be used to commission the device. + * + * @param discriminator The discriminator to use for the commissionable + * advertisement. + * @param duration Duration, in seconds, during which the commissioning + * window will be open. + */ +- (void)openCommissioningWindowWithDiscriminator:(NSNumber *)discriminator + duration:(NSNumber *)duration + queue:(dispatch_queue_t)queue + completion:(MTRDeviceOpenCommissioningWindowHandler)completion MTR_NEWLY_AVAILABLE; + /** * Reads events from the device. * diff --git a/src/darwin/Framework/CHIP/MTRBaseDevice.mm b/src/darwin/Framework/CHIP/MTRBaseDevice.mm index ea47734e3facf6..09f5ea582cc9e2 100644 --- a/src/darwin/Framework/CHIP/MTRBaseDevice.mm +++ b/src/darwin/Framework/CHIP/MTRBaseDevice.mm @@ -1280,7 +1280,7 @@ - (void)deregisterReportHandlersWithQueue:(dispatch_queue_t)queue completion:(di public: static CHIP_ERROR OpenCommissioningWindow(Controller::DeviceController * controller, NodeId nodeID, - System::Clock::Seconds16 timeout, uint16_t discriminator, uint32_t setupPIN, ResultCallback callback); + System::Clock::Seconds16 timeout, uint16_t discriminator, const Optional & setupPIN, ResultCallback callback); private: OpenCommissioningWindowHelper(Controller::DeviceController * controller, ResultCallback callback); @@ -1300,7 +1300,7 @@ static CHIP_ERROR OpenCommissioningWindow(Controller::DeviceController * control } CHIP_ERROR OpenCommissioningWindowHelper::OpenCommissioningWindow(Controller::DeviceController * controller, NodeId nodeID, - System::Clock::Seconds16 timeout, uint16_t discriminator, uint32_t setupPIN, ResultCallback callback) + System::Clock::Seconds16 timeout, uint16_t discriminator, const Optional & setupPIN, ResultCallback callback) { auto * self = new (std::nothrow) OpenCommissioningWindowHelper(controller, callback); if (self == nullptr) { @@ -1309,7 +1309,7 @@ static CHIP_ERROR OpenCommissioningWindow(Controller::DeviceController * control SetupPayload unused; CHIP_ERROR err = self->mOpener.OpenCommissioningWindow(nodeID, timeout, Crypto::kSpake2p_Min_PBKDF_Iterations, discriminator, - MakeOptional(setupPIN), NullOptional, &self->mOnOpenCommissioningWindowCallback, unused); + setupPIN, NullOptional, &self->mOnOpenCommissioningWindowCallback, unused); if (err != CHIP_NO_ERROR) { delete self; } @@ -1327,11 +1327,11 @@ static CHIP_ERROR OpenCommissioningWindow(Controller::DeviceController * control } // anonymous namespace -- (void)openCommissioningWindowWithSetupPasscode:(NSNumber *)setupPasscode - discriminator:(NSNumber *)discriminator - duration:(NSNumber *)duration - queue:(dispatch_queue_t)queue - completion:(MTRDeviceOpenCommissioningWindowHandler)completion +- (void)_openCommissioningWindowWithSetupPasscode:(nullable NSNumber *)setupPasscode + discriminator:(NSNumber *)discriminator + duration:(NSNumber *)duration + queue:(dispatch_queue_t)queue + completion:(MTRDeviceOpenCommissioningWindowHandler)completion { if (self.isPASEDevice) { MTR_LOG_ERROR("Can't open a commissioning window over PASE"); @@ -1360,13 +1360,17 @@ - (void)openCommissioningWindowWithSetupPasscode:(NSNumber *)setupPasscode return; } - unsigned long long passcodeVal = [setupPasscode unsignedLongLongValue]; - if (!CanCastTo(passcodeVal) || !SetupPayload::IsValidSetupPIN(static_cast(passcodeVal))) { - MTR_LOG_ERROR("Error: Setup passcode %llu is not valid", passcodeVal); - dispatch_async(queue, ^{ - completion(nil, [MTRError errorForCHIPErrorCode:CHIP_ERROR_INVALID_INTEGER_VALUE]); - }); - return; + Optional passcode; + if (setupPasscode != nil) { + unsigned long long passcodeVal = [setupPasscode unsignedLongLongValue]; + if (!CanCastTo(passcodeVal) || !SetupPayload::IsValidSetupPIN(static_cast(passcodeVal))) { + MTR_LOG_ERROR("Error: Setup passcode %llu is not valid", passcodeVal); + dispatch_async(queue, ^{ + completion(nil, [MTRError errorForCHIPErrorCode:CHIP_ERROR_INVALID_INTEGER_VALUE]); + }); + return; + } + passcode.Emplace(static_cast(passcodeVal)); } [self.deviceController @@ -1394,7 +1398,7 @@ - (void)openCommissioningWindowWithSetupPasscode:(NSNumber *)setupPasscode SetupPayload setupPayload; auto errorCode = OpenCommissioningWindowHelper::OpenCommissioningWindow(commissioner, self.nodeID, chip::System::Clock::Seconds16(static_cast(durationVal)), static_cast(discriminatorVal), - static_cast(passcodeVal), resultCallback); + passcode, resultCallback); if (errorCode != CHIP_NO_ERROR) { dispatch_async(queue, ^{ @@ -1412,6 +1416,31 @@ - (void)openCommissioningWindowWithSetupPasscode:(NSNumber *)setupPasscode }]; } +- (void)openCommissioningWindowWithSetupPasscode:(NSNumber *)setupPasscode + discriminator:(NSNumber *)discriminator + duration:(NSNumber *)duration + queue:(dispatch_queue_t)queue + completion:(MTRDeviceOpenCommissioningWindowHandler)completion +{ + [self _openCommissioningWindowWithSetupPasscode:setupPasscode + discriminator:discriminator + duration:duration + queue:queue + completion:completion]; +} + +- (void)openCommissioningWindowWithDiscriminator:(NSNumber *)discriminator + duration:(NSNumber *)duration + queue:(dispatch_queue_t)queue + completion:(MTRDeviceOpenCommissioningWindowHandler)completion +{ + [self _openCommissioningWindowWithSetupPasscode:nil + discriminator:discriminator + duration:duration + queue:queue + completion:completion]; +} + #ifdef DEBUG // This method is for unit testing only - (void)failSubscribers:(dispatch_queue_t)queue completion:(void (^)(void))completion diff --git a/src/darwin/Framework/CHIP/MTRCSRInfo.h b/src/darwin/Framework/CHIP/MTRCSRInfo.h index b20c34d469a944..c4a218557fc207 100644 --- a/src/darwin/Framework/CHIP/MTRCSRInfo.h +++ b/src/darwin/Framework/CHIP/MTRCSRInfo.h @@ -17,6 +17,7 @@ #import +#import #import NS_ASSUME_NONNULL_BEGIN @@ -34,8 +35,7 @@ API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) @property (nonatomic, copy, readonly) MTRCSRDERBytes csr; /** - * The nonce provided in the original CSRRequest command that led to this CSR - * being created. + * The nonce associated with this CSR. */ @property (nonatomic, copy, readonly) NSData * csrNonce; @@ -54,11 +54,44 @@ API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) */ @property (nonatomic, copy, readonly) NSData * attestationSignature; +/** + * Initialize an MTROperationalCSRInfo by providing all the fields. It's the + * caller's responsibility to ensure that csr and csrNonce match the csrElementsTLV. + */ - (instancetype)initWithCSR:(MTRCSRDERBytes)csr csrNonce:(NSData *)csrNonce csrElementsTLV:(MTRTLVBytes)csrElementsTLV - attestationSignature:(NSData *)attestationSignature; + attestationSignature:(NSData *)attestationSignature + MTR_NEWLY_DEPRECATED("Please use one of the initializers that validates the input"); + +/** + * Initialize an MTROperationalCSRInfo by providing the csrNonce (for example, + * the nonce the client initially supplied), and the csrElementsTLV and + * attestationSignature that the server returned. This will ensure that + * csrNonce matches the data in csrElementsTLV, returning nil if it does not, + * and extract the csr from csrElementsTLV. + */ +- (nullable instancetype)initWithCSRNonce:(NSData *)csrNonce + csrElementsTLV:(MTRTLVBytes)csrElementsTLV + attestationSignature:(NSData *)attestationSignature MTR_NEWLY_AVAILABLE; +/** + * Initialize an MTROperationalCSRInfo by providing just the csrElementsTLV and + * attestationSignature (which can come from an + * MTROperationalCredentialsClusterCSRResponseParams). This will extract the + * csr and csrNonce from the csrElementsTLV, if possible, and return nil if that + * fails. + */ +- (nullable instancetype)initWithCSRElementsTLV:(MTRTLVBytes)csrElementsTLV + attestationSignature:(NSData *)attestationSignature MTR_NEWLY_AVAILABLE; + +/** + * Initialize an MTROperationalCSRInfo by providing an + * MTROperationalCredentialsClusterCSRResponseParams. This will extract the + * relevant fields from the response data. + */ +- (nullable instancetype)initWithCSRResponseParams:(MTROperationalCredentialsClusterCSRResponseParams *)responseParams + MTR_NEWLY_AVAILABLE; @end MTR_DEPRECATED("Please use MTROperationalCSRInfo", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)) diff --git a/src/darwin/Framework/CHIP/MTRCSRInfo.mm b/src/darwin/Framework/CHIP/MTRCSRInfo.mm index d8a77fba5e941a..1682a8bdf6c362 100644 --- a/src/darwin/Framework/CHIP/MTRCSRInfo.mm +++ b/src/darwin/Framework/CHIP/MTRCSRInfo.mm @@ -16,15 +16,41 @@ */ #import "MTRCSRInfo.h" +#import "MTRFramework.h" +#import "MTRLogging_Internal.h" +#import "NSDataSpanConversion.h" + +#include +#include +#include +#include + +static CHIP_ERROR ExtractCSRAndNonce(MTRTLVBytes csrElementsTLV, chip::ByteSpan & csr, chip::ByteSpan & nonce) +{ + // We don't care about vendor_reserved*. + chip::ByteSpan vendor_reserved1, vendor_reserved2, vendor_reserved3; + CHIP_ERROR err = chip::Credentials::DeconstructNOCSRElements( + AsByteSpan(csrElementsTLV), csr, nonce, vendor_reserved1, vendor_reserved2, vendor_reserved3); + if (err != CHIP_NO_ERROR) { + MTR_LOG_ERROR("Failed to parse csrElementsTLV %@: %" CHIP_ERROR_FORMAT, csrElementsTLV, err.Format()); + } + return err; +} NS_ASSUME_NONNULL_BEGIN @implementation MTROperationalCSRInfo : NSObject -- (instancetype)initWithCSR:(MTRCSRDERBytes)csr - csrNonce:(NSData *)csrNonce - csrElementsTLV:(MTRTLVBytes)csrElementsTLV - attestationSignature:(NSData *)attestationSignature; ++ (void)initialize +{ + // Needed for some of our init* methods. + MTRFrameworkInit(); +} + +- (instancetype)_initWithValidatedCSR:(MTRCSRDERBytes)csr + csrNonce:(NSData *)csrNonce + csrElementsTLV:(MTRTLVBytes)csrElementsTLV + attestationSignature:(NSData *)attestationSignature; { if (self = [super init]) { _csr = csr; @@ -34,6 +60,51 @@ - (instancetype)initWithCSR:(MTRCSRDERBytes)csr } return self; } + +- (instancetype)initWithCSR:(MTRCSRDERBytes)csr + csrNonce:(NSData *)csrNonce + csrElementsTLV:(MTRTLVBytes)csrElementsTLV + attestationSignature:(NSData *)attestationSignature; +{ + return [self _initWithValidatedCSR:csr + csrNonce:csrNonce + csrElementsTLV:csrElementsTLV + attestationSignature:attestationSignature]; +} + +- (nullable instancetype)initWithCSRNonce:(NSData *)csrNonce + csrElementsTLV:(MTRTLVBytes)csrElementsTLV + attestationSignature:(NSData *)attestationSignature +{ + chip::ByteSpan csr, extractedNonce; + VerifyOrReturnValue(ExtractCSRAndNonce(csrElementsTLV, csr, extractedNonce) == CHIP_NO_ERROR, nil); + + if (!extractedNonce.data_equal(AsByteSpan(csrNonce))) { + MTR_LOG_ERROR("Provided CSR nonce does not match provided csrElementsTLV"); + return nil; + } + + return [self _initWithValidatedCSR:AsData(csr) + csrNonce:csrNonce + csrElementsTLV:csrElementsTLV + attestationSignature:attestationSignature]; +} + +- (nullable instancetype)initWithCSRElementsTLV:(MTRTLVBytes)csrElementsTLV attestationSignature:(NSData *)attestationSignature +{ + chip::ByteSpan csr, csrNonce; + VerifyOrReturnValue(ExtractCSRAndNonce(csrElementsTLV, csr, csrNonce) == CHIP_NO_ERROR, nil); + + return [self _initWithValidatedCSR:AsData(csr) + csrNonce:AsData(csrNonce) + csrElementsTLV:csrElementsTLV + attestationSignature:attestationSignature]; +} + +- (nullable instancetype)initWithCSRResponseParams:(MTROperationalCredentialsClusterCSRResponseParams *)responseParams +{ + return [self initWithCSRElementsTLV:responseParams.nocsrElements attestationSignature:responseParams.attestationSignature]; +} @end @implementation CSRInfo : NSObject diff --git a/src/darwin/Framework/CHIP/MTRCertificates.h b/src/darwin/Framework/CHIP/MTRCertificates.h index 499991009fa468..268ee3e223ac30 100644 --- a/src/darwin/Framework/CHIP/MTRCertificates.h +++ b/src/darwin/Framework/CHIP/MTRCertificates.h @@ -91,9 +91,9 @@ NS_ASSUME_NONNULL_BEGIN * fabricID must be a valid Matter fabric id. * * caseAuthenticatedTags may be nil to indicate no CASE Authenticated Tags - * should be used. If caseAuthenticatedTags is not nil, it must have length at - * most 3 and the values in the array are expected to be 32-bit unsigned Case - * Authenticated Tag values. + * should be used. If caseAuthenticatedTags is not nil, it must contain at most + * 3 numbers, which are expected to be 32-bit unsigned Case Authenticated Tag + * values. * * On failure returns nil and if "error" is not null sets *error to the relevant * error. diff --git a/src/darwin/Framework/CHIP/MTRDevice.h b/src/darwin/Framework/CHIP/MTRDevice.h index 6baac86c76990a..6f8bda9703e0bc 100644 --- a/src/darwin/Framework/CHIP/MTRDevice.h +++ b/src/darwin/Framework/CHIP/MTRDevice.h @@ -184,6 +184,22 @@ typedef NS_ENUM(NSUInteger, MTRDeviceState) { completion:(MTRDeviceOpenCommissioningWindowHandler)completion API_AVAILABLE(ios(16.2), macos(13.1), watchos(9.2), tvos(16.2)); +/** + * Open a commissioning window on the device, using a random setup passcode. + * + * On success, completion will be called on queue with the MTRSetupPayload that + * can be used to commission the device. + * + * @param discriminator The discriminator to use for the commissionable + * advertisement. + * @param duration Duration, in seconds, during which the commissioning + * window will be open. + */ +- (void)openCommissioningWindowWithDiscriminator:(NSNumber *)discriminator + duration:(NSNumber *)duration + queue:(dispatch_queue_t)queue + completion:(MTRDeviceOpenCommissioningWindowHandler)completion MTR_NEWLY_AVAILABLE; + @end extern NSString * const MTREventNumberKey API_AVAILABLE(ios(16.5), macos(13.4), watchos(9.5), tvos(16.5)); diff --git a/src/darwin/Framework/CHIP/MTRDevice.mm b/src/darwin/Framework/CHIP/MTRDevice.mm index 30a184f8d37ef9..9d09201390b6b6 100644 --- a/src/darwin/Framework/CHIP/MTRDevice.mm +++ b/src/darwin/Framework/CHIP/MTRDevice.mm @@ -806,6 +806,15 @@ - (void)openCommissioningWindowWithSetupPasscode:(NSNumber *)setupPasscode completion:completion]; } +- (void)openCommissioningWindowWithDiscriminator:(NSNumber *)discriminator + duration:(NSNumber *)duration + queue:(dispatch_queue_t)queue + completion:(MTRDeviceOpenCommissioningWindowHandler)completion +{ + auto * baseDevice = [self newBaseDevice]; + [baseDevice openCommissioningWindowWithDiscriminator:discriminator duration:duration queue:queue completion:completion]; +} + #pragma mark - Cache management // assume lock is held diff --git a/src/darwin/Framework/CHIP/MTRDeviceController.mm b/src/darwin/Framework/CHIP/MTRDeviceController.mm index d51e3a50d7004d..9026251bae5fd3 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceController.mm +++ b/src/darwin/Framework/CHIP/MTRDeviceController.mm @@ -302,10 +302,34 @@ - (BOOL)startup:(MTRDeviceControllerStartupParamsInternal *)startupParams } else { chip::MutableByteSpan noc(nocBuffer); + chip::CATValues cats = chip::kUndefinedCATs; + if (startupParams.caseAuthenticatedTags != nil) { + unsigned long long tagCount = startupParams.caseAuthenticatedTags.count; + if (tagCount > chip::kMaxSubjectCATAttributeCount) { + MTR_LOG_ERROR("%llu CASE Authenticated Tags cannot be represented in a certificate.", tagCount); + return; + } + + size_t tagIndex = 0; + for (NSNumber * boxedTag in startupParams.caseAuthenticatedTags) { + if (!chip::CanCastTo(boxedTag.unsignedLongLongValue)) { + MTR_LOG_ERROR("0x%llx is not a valid CASE Authenticated Tag value.", boxedTag.unsignedLongLongValue); + return; + } + + auto tag = static_cast(boxedTag.unsignedLongLongValue); + if (!chip::IsValidCASEAuthTag(tag)) { + MTR_LOG_ERROR("0x%" PRIx32 " is not a valid CASE Authenticated Tag value.", tag); + return; + } + + cats.values[tagIndex++] = tag; + } + } + if (commissionerParams.operationalKeypair != nullptr) { errorCode = _operationalCredentialsDelegate->GenerateNOC(startupParams.nodeID.unsignedLongLongValue, - startupParams.fabricID.unsignedLongLongValue, chip::kUndefinedCATs, - commissionerParams.operationalKeypair->Pubkey(), noc); + startupParams.fabricID.unsignedLongLongValue, cats, commissionerParams.operationalKeypair->Pubkey(), noc); if ([self checkForStartError:errorCode logMsg:kErrorGenerateNOC]) { return; @@ -325,8 +349,8 @@ - (BOOL)startup:(MTRDeviceControllerStartupParamsInternal *)startupParams return; } - errorCode = _operationalCredentialsDelegate->GenerateNOC(startupParams.nodeID.unsignedLongLongValue, - startupParams.fabricID.unsignedLongLongValue, chip::kUndefinedCATs, pubKey, noc); + errorCode = _operationalCredentialsDelegate->GenerateNOC( + startupParams.nodeID.unsignedLongLongValue, startupParams.fabricID.unsignedLongLongValue, cats, pubKey, noc); if ([self checkForStartError:errorCode logMsg:kErrorGenerateNOC]) { return; @@ -335,6 +359,12 @@ - (BOOL)startup:(MTRDeviceControllerStartupParamsInternal *)startupParams commissionerParams.controllerNOC = noc; } commissionerParams.controllerVendorId = static_cast([startupParams.vendorID unsignedShortValue]); + commissionerParams.enableServerInteractions = startupParams.advertiseOperational; + // We don't want to remove things from the fabric table on controller + // shutdown, since our controller setup depends on being able to fetch + // fabric information for the relevant fabric indices on controller + // bring-up. + commissionerParams.removeFromFabricTableOnShutdown = false; commissionerParams.deviceAttestationVerifier = _factory.deviceAttestationVerifier; auto & factory = chip::Controller::DeviceControllerFactory::GetInstance(); diff --git a/src/darwin/Framework/CHIP/MTRDeviceControllerFactory.mm b/src/darwin/Framework/CHIP/MTRDeviceControllerFactory.mm index d71acaab034c11..ada02b3817529b 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceControllerFactory.mm +++ b/src/darwin/Framework/CHIP/MTRDeviceControllerFactory.mm @@ -85,6 +85,7 @@ @interface MTRDeviceControllerFactory () @property (readonly) Credentials::PersistentStorageOpCertStore * opCertStore; @property (readonly) MTROperationalBrowser * operationalBrowser; @property () chip::Credentials::DeviceAttestationVerifier * deviceAttestationVerifier; +@property (readonly) BOOL advertiseOperational; - (BOOL)findMatchingFabric:(FabricTable &)fabricTable params:(MTRDeviceControllerStartupParams *)params @@ -435,9 +436,7 @@ - (BOOL)startControllerFactory:(MTRDeviceControllerFactoryParams *)startupParams if (startupParams.port != nil) { params.listenPort = [startupParams.port unsignedShortValue]; } - if (startupParams.shouldStartServer == YES) { - params.enableServerInteractions = true; - } + params.enableServerInteractions = startupParams.shouldStartServer; params.groupDataProvider = _groupDataProvider; params.sessionKeystore = _sessionKeystore; @@ -470,6 +469,7 @@ - (BOOL)startControllerFactory:(MTRDeviceControllerFactoryParams *)startupParams _controllerFactory->RetainSystemState(); _controllerFactory->ReleaseSystemState(); + self->_advertiseOperational = startupParams.shouldStartServer; self->_running = YES; }); @@ -566,6 +566,7 @@ - (MTRDeviceController * _Nullable)createControllerOnExistingFabric:(MTRDeviceCo params = [[MTRDeviceControllerStartupParamsInternal alloc] initForExistingFabric:fabricTable fabricIndex:fabric->GetFabricIndex() keystore:_keystore + advertiseOperational:self.advertiseOperational params:startupParams]; if (params == nil) { fabricError = CHIP_ERROR_NO_MEMORY; @@ -649,6 +650,7 @@ - (MTRDeviceController * _Nullable)createControllerOnNewFabric:(MTRDeviceControl params = [[MTRDeviceControllerStartupParamsInternal alloc] initForNewFabric:fabricTable keystore:_keystore + advertiseOperational:self.advertiseOperational params:startupParams]; if (params == nil) { fabricError = CHIP_ERROR_NO_MEMORY; diff --git a/src/darwin/Framework/CHIP/MTRDeviceControllerStartupParams.h b/src/darwin/Framework/CHIP/MTRDeviceControllerStartupParams.h index 13053af8643c41..49970304ad517e 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceControllerStartupParams.h +++ b/src/darwin/Framework/CHIP/MTRDeviceControllerStartupParams.h @@ -127,16 +127,28 @@ NS_ASSUME_NONNULL_BEGIN * * ** nodeID is allowed to be nil to indicate that the existing operational node * id should be used. The existing operational keys will also be used, - * unless operationalKeypair is provided. + * unless operationalKeypair is provided. The existing caseAuthenticatedTags + * will be used. * * ** If nodeID is not nil, a new operational certificate will be generated for * the provided node id (even if that matches the existing node id), using * either the operationalKeypair if that is provided or a new randomly - * generated operational key. - * + * generated operational key, and using the provided caseAuthenticatedTags. */ @property (nonatomic, copy, nullable) NSNumber * nodeID API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); +/** + * CASE authenticated tags to use for this controller's operational certificate. + * + * Only allowed to be not nil if nodeID is not nil. In particular, if + * operationalCertificate is not nil, must be nil. The provided operational + * certificate will be used as-is. + * + * If not nil, must contain at most 3 numbers, which are expected to be 32-bit + * unsigned Case Authenticated Tag values. + */ +@property (nonatomic, copy, nullable) NSSet * caseAuthenticatedTags MTR_NEWLY_AVAILABLE; + /** * Root certificate, in X.509 DER form, to use. * @@ -219,8 +231,8 @@ NS_ASSUME_NONNULL_BEGIN * * If not nil, and if operationalCertificate is nil, a new operational * certificate will be generated for the given operationalKeypair. The node id - * will for that certificated will be determined as described in the - * documentation for nodeID. + * for that certificate will be determined as described in the documentation for + * nodeID. */ @property (nonatomic, strong, nullable) id operationalKeypair; diff --git a/src/darwin/Framework/CHIP/MTRDeviceControllerStartupParams.mm b/src/darwin/Framework/CHIP/MTRDeviceControllerStartupParams.mm index ba247576e916fa..771995bf01bc66 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceControllerStartupParams.mm +++ b/src/darwin/Framework/CHIP/MTRDeviceControllerStartupParams.mm @@ -98,6 +98,7 @@ - (instancetype)initWithParams:(MTRDeviceControllerStartupParams *)params _ipk = params.ipk; _vendorID = params.vendorID; _nodeID = params.nodeID; + _caseAuthenticatedTags = params.caseAuthenticatedTags; _rootCertificate = params.rootCertificate; _intermediateCertificate = params.intermediateCertificate; _operationalCertificate = params.operationalCertificate; @@ -190,6 +191,11 @@ - (instancetype)initWithParams:(MTRDeviceControllerStartupParams *)params return nil; } + if (self.caseAuthenticatedTags != nil && self.nodeID == nil) { + MTR_LOG_ERROR("caseAuthenticatedTags must be nil if nodeID is nil"); + return nil; + } + if (self.operationalCertificate != nil) { if (self.operationalKeypair == nil) { MTR_LOG_ERROR("Must have an operational keypair if an operational certificate is provided"); @@ -207,6 +213,7 @@ - (instancetype)initWithParams:(MTRDeviceControllerStartupParams *)params - (instancetype)initForNewFabric:(chip::FabricTable *)fabricTable keystore:(chip::Crypto::OperationalKeystore *)keystore + advertiseOperational:(BOOL)advertiseOperational params:(MTRDeviceControllerStartupParams *)params { if (!(self = [self initWithParams:params])) { @@ -240,6 +247,7 @@ - (instancetype)initForNewFabric:(chip::FabricTable *)fabricTable _fabricTable = fabricTable; _keystore = keystore; + _advertiseOperational = advertiseOperational; return self; } @@ -247,6 +255,7 @@ - (instancetype)initForNewFabric:(chip::FabricTable *)fabricTable - (instancetype)initForExistingFabric:(FabricTable *)fabricTable fabricIndex:(FabricIndex)fabricIndex keystore:(chip::Crypto::OperationalKeystore *)keystore + advertiseOperational:(BOOL)advertiseOperational params:(MTRDeviceControllerStartupParams *)params { if (!(self = [self initWithParams:params])) { @@ -263,14 +272,16 @@ - (instancetype)initForExistingFabric:(FabricTable *)fabricTable if (self.operationalCertificate == nil && self.nodeID == nil) { self.nodeID = @(fabric->GetNodeId()); + // Make sure to preserve caseAuthenticatedTags from the existing certificate. + uint8_t nocBuf[Credentials::kMaxCHIPCertLength]; + MutableByteSpan noc(nocBuf); + CHIP_ERROR err = fabricTable->FetchNOCCert(fabric->GetFabricIndex(), noc); + if (err != CHIP_NO_ERROR) { + MTR_LOG_ERROR("Failed to get existing NOC: %s", ErrorStr(err)); + return nil; + } + if (self.operationalKeypair == nil) { - uint8_t nocBuf[Credentials::kMaxCHIPCertLength]; - MutableByteSpan noc(nocBuf); - CHIP_ERROR err = fabricTable->FetchNOCCert(fabric->GetFabricIndex(), noc); - if (err != CHIP_NO_ERROR) { - MTR_LOG_ERROR("Failed to get existing NOC: %s", ErrorStr(err)); - return nil; - } self.operationalCertificate = MatterCertToX509Data(noc); if (self.operationalCertificate == nil) { MTR_LOG_ERROR("Failed to convert TLV NOC to DER X.509: %s", ErrorStr(err)); @@ -282,6 +293,26 @@ - (instancetype)initForExistingFabric:(FabricTable *)fabricTable } } + CATValues cats; + err = Credentials::ExtractCATsFromOpCert(noc, cats); + if (err != CHIP_NO_ERROR) { + MTR_LOG_ERROR("Failed to extract existing CATs: %s", ErrorStr(err)); + return nil; + } + + auto tagCount = cats.GetNumTagsPresent(); + if (tagCount > 0) { + auto * catSet = [[NSMutableSet alloc] initWithCapacity:tagCount]; + for (auto & value : cats.values) { + if (value != kUndefinedCAT) { + [catSet addObject:@(value)]; + } + } + self.caseAuthenticatedTags = [NSSet setWithSet:catSet]; + } else { + self.caseAuthenticatedTags = nil; + } + usingExistingNOC = YES; } @@ -352,6 +383,7 @@ - (instancetype)initForExistingFabric:(FabricTable *)fabricTable _fabricTable = fabricTable; _fabricIndex.Emplace(fabricIndex); _keystore = keystore; + _advertiseOperational = advertiseOperational; return self; } diff --git a/src/darwin/Framework/CHIP/MTRDeviceControllerStartupParams_Internal.h b/src/darwin/Framework/CHIP/MTRDeviceControllerStartupParams_Internal.h index 79751cc95362e8..146a4bad978985 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceControllerStartupParams_Internal.h +++ b/src/darwin/Framework/CHIP/MTRDeviceControllerStartupParams_Internal.h @@ -54,6 +54,8 @@ NS_ASSUME_NONNULL_BEGIN // Key store we're using with our fabric table, for sanity checks. @property (nonatomic, assign, readonly) chip::Crypto::OperationalKeystore * keystore; +@property (nonatomic, assign, readonly) BOOL advertiseOperational; + /** * Helper method that checks that our keypairs match our certificates. * Specifically: @@ -73,6 +75,7 @@ NS_ASSUME_NONNULL_BEGIN */ - (instancetype)initForNewFabric:(chip::FabricTable *)fabricTable keystore:(chip::Crypto::OperationalKeystore *)keystore + advertiseOperational:(BOOL)advertiseOperational params:(MTRDeviceControllerStartupParams *)params; /** @@ -81,6 +84,7 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)initForExistingFabric:(chip::FabricTable *)fabricTable fabricIndex:(chip::FabricIndex)fabricIndex keystore:(chip::Crypto::OperationalKeystore *)keystore + advertiseOperational:(BOOL)advertiseOperational params:(MTRDeviceControllerStartupParams *)params; /** diff --git a/src/darwin/Framework/CHIP/MTRDeviceOverXPC.mm b/src/darwin/Framework/CHIP/MTRDeviceOverXPC.mm index cea5e0308e595a..17cd039278d294 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceOverXPC.mm +++ b/src/darwin/Framework/CHIP/MTRDeviceOverXPC.mm @@ -327,6 +327,17 @@ - (void)openCommissioningWindowWithSetupPasscode:(NSNumber *)setupPasscode }); } +- (void)openCommissioningWindowWithDiscriminator:(NSNumber *)discriminator + duration:(NSNumber *)duration + queue:(dispatch_queue_t)queue + completion:(MTRDeviceOpenCommissioningWindowHandler)completion +{ + MTR_LOG_ERROR("MTRDevice doesn't support openCommissioningWindowWithDiscriminator over XPC"); + dispatch_async(queue, ^{ + completion(nil, [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeInvalidState userInfo:nil]); + }); +} + - (void)fetchProxyHandleWithQueue:(dispatch_queue_t)queue completion:(MTRFetchProxyHandleCompletion)completion { if (self.controllerID != nil) { diff --git a/src/darwin/Framework/CHIP/MTRError.mm b/src/darwin/Framework/CHIP/MTRError.mm index 4f907145ce5dcf..48c290c53dcfd6 100644 --- a/src/darwin/Framework/CHIP/MTRError.mm +++ b/src/darwin/Framework/CHIP/MTRError.mm @@ -238,6 +238,7 @@ + (CHIP_ERROR)errorToCHIPErrorCode:(NSError * _Nullable)error } if (error.domain != MTRErrorDomain) { + ChipLogError(Controller, "Trying to convert non-Matter error %@ to a Matter error code", error); return CHIP_ERROR_INTERNAL; } diff --git a/src/darwin/Framework/CHIP/MTROperationalCertificateIssuer.h b/src/darwin/Framework/CHIP/MTROperationalCertificateIssuer.h index e97d02ed3e1976..6dbdc869389488 100644 --- a/src/darwin/Framework/CHIP/MTROperationalCertificateIssuer.h +++ b/src/darwin/Framework/CHIP/MTROperationalCertificateIssuer.h @@ -74,6 +74,10 @@ API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) * * This will be called on the dispatch queue passed as * operationalCertificateIssuerQueue in the MTRDeviceControllerFactoryParams. + * + * The csrNonce in the provided MTROperationalCSRInfo will be the nonce that was + * sent in the CSRRequest command, which will be guaranteed, at this point, to + * match the nonce in the CSRResponse command. */ - (void)issueOperationalCertificateForRequest:(MTROperationalCSRInfo *)csrInfo attestationInfo:(MTRDeviceAttestationInfo *)attestationInfo diff --git a/src/darwin/Framework/CHIP/MTROperationalCredentialsDelegate.mm b/src/darwin/Framework/CHIP/MTROperationalCredentialsDelegate.mm index 16ae9da59103ab..b14ac062784105 100644 --- a/src/darwin/Framework/CHIP/MTROperationalCredentialsDelegate.mm +++ b/src/darwin/Framework/CHIP/MTROperationalCredentialsDelegate.mm @@ -145,28 +145,9 @@ mOnNOCCompletionCallback = onCompletion; - TLVReader reader; - reader.Init(csrElements); - - if (reader.GetType() == kTLVType_NotSpecified) { - ReturnErrorOnFailure(reader.Next()); - } - - VerifyOrReturnError(reader.GetType() == kTLVType_Structure, CHIP_ERROR_WRONG_TLV_TYPE); - VerifyOrReturnError(reader.GetTag() == AnonymousTag(), CHIP_ERROR_UNEXPECTED_TLV_ELEMENT); - - TLVType containerType; - ReturnErrorOnFailure(reader.EnterContainer(containerType)); - ReturnErrorOnFailure(reader.Next(kTLVType_ByteString, TLV::ContextTag(1))); - - chip::ByteSpan csr; - reader.Get(csr); - reader.ExitContainer(containerType); - - auto * csrInfo = [[MTROperationalCSRInfo alloc] initWithCSR:AsData(csr) - csrNonce:AsData(csrNonce) - csrElementsTLV:AsData(csrElements) - attestationSignature:AsData(csrElementsSignature)]; + auto * csrInfo = [[MTROperationalCSRInfo alloc] initWithCSRNonce:AsData(csrNonce) + csrElementsTLV:AsData(csrElements) + attestationSignature:AsData(csrElementsSignature)]; chip::ByteSpan certificationDeclarationSpan; chip::ByteSpan attestationNonceSpan; diff --git a/src/darwin/Framework/CHIPTests/MTRControllerTests.m b/src/darwin/Framework/CHIPTests/MTRControllerTests.m index 06dfb7a2beb3b7..63a5baf32b64d5 100644 --- a/src/darwin/Framework/CHIPTests/MTRControllerTests.m +++ b/src/darwin/Framework/CHIPTests/MTRControllerTests.m @@ -29,6 +29,22 @@ static uint16_t kTestVendorId = 0xFFF1u; +static void CheckStoredOpcertCats(id storage, uint8_t fabricIndex, NSSet * cats) +{ + __auto_type * certData = [storage storageDataForKey:[NSString stringWithFormat:@"f/%x/n", fabricIndex]]; + XCTAssertNotNil(certData); + + __auto_type * info = [[MTRCertificateInfo alloc] initWithTLVBytes:certData]; + XCTAssertNotNil(info); + + __auto_type * storedCATs = info.subject.caseAuthenticatedTags; + if (cats == nil) { + XCTAssertTrue(storedCATs.count == 0); + } else { + XCTAssertEqualObjects(storedCATs, cats); + } +} + @interface MTRControllerTests : XCTestCase @end @@ -391,8 +407,29 @@ - (void)testControllerStartControllersOnTwoFabricIds XCTAssertNotNil(controller2); XCTAssertTrue([controller2 isRunning]); + // Verify that we can't start on an existing fabric while we have a + // controller on that fabric already. XCTAssertNil([factory createControllerOnExistingFabric:params2 error:nil]); + // Now test restarting the controller on the first fabric while the + // controller on the second fabric is still running. + [controller1 shutdown]; + XCTAssertFalse([controller1 isRunning]); + + controller1 = [factory createControllerOnExistingFabric:params1 error:nil]; + XCTAssertNotNil(controller1); + XCTAssertTrue([controller1 isRunning]); + + // Now test restarting the controller on the second fabric while the + // controller on the first fabric is still running. + [controller2 shutdown]; + XCTAssertFalse([controller2 isRunning]); + + controller2 = [factory createControllerOnExistingFabric:params2 error:nil]; + XCTAssertNotNil(controller2); + XCTAssertTrue([controller2 isRunning]); + + // Shut down everything. [controller1 shutdown]; XCTAssertFalse([controller1 isRunning]); @@ -1338,4 +1375,177 @@ - (void)testControllerExternallyProvidedOperationalKey XCTAssertFalse([factory isRunning]); } +- (void)testControllerCATs +{ + __auto_type * factory = [MTRDeviceControllerFactory sharedInstance]; + XCTAssertNotNil(factory); + + __auto_type * storage = [[MTRTestStorage alloc] init]; + __auto_type * factoryParams = [[MTRDeviceControllerFactoryParams alloc] initWithStorage:storage]; + XCTAssertTrue([factory startControllerFactory:factoryParams error:nil]); + XCTAssertTrue([factory isRunning]); + + __auto_type * rootKeys = [[MTRTestKeys alloc] init]; + XCTAssertNotNil(rootKeys); + + __auto_type * params = [[MTRDeviceControllerStartupParams alloc] initWithIPK:rootKeys.ipk fabricID:@(1) nocSigner:rootKeys]; + XCTAssertNotNil(params); + + params.vendorID = @(kTestVendorId); + + // + // Trying to bring up a controller with too-long CATs should fail. + // + __auto_type * tooLongCATs = [NSSet setWithObjects:@(0x10001), @(0x20001), @(0x30001), @(0x40001), nil]; + params.caseAuthenticatedTags = tooLongCATs; + MTRDeviceController * controller = [factory createControllerOnExistingFabric:params error:nil]; + XCTAssertNil(controller); + + // + // Trying to bring up a controller that has an invalid CAT value should + // fail. + // + __auto_type * invalidCATs = [NSSet setWithObjects:@(0x10001), @(0x20001), @(0x0), nil]; + params.caseAuthenticatedTags = invalidCATs; + controller = [factory createControllerOnExistingFabric:params error:nil]; + XCTAssertNil(controller); + + // + // Bring up a controller with valid CATs + // + __auto_type * validCATs = [NSSet setWithObjects:@(0x10001), @(0x20007), @(0x30005), nil]; + params.nodeID = @(17); + params.caseAuthenticatedTags = validCATs; + controller = [factory createControllerOnNewFabric:params error:nil]; + XCTAssertNotNil(controller); + XCTAssertTrue([controller isRunning]); + + // Check that the resulting certificate has the right CATs and node ID + CheckStoredOpcertCats(storage, 1, validCATs); + XCTAssertEqualObjects([controller controllerNodeID], @(17)); + + [controller shutdown]; + XCTAssertFalse([controller isRunning]); + + // + // Trying to bring up the same fabric without specifying any node id + // should not allow trying to specify the same CATs. + // + params.nodeID = nil; + params.caseAuthenticatedTags = validCATs; + controller = [factory createControllerOnExistingFabric:params error:nil]; + XCTAssertNil(controller); + + // + // Trying to bring up the same fabric without specifying any node id + // should not allow trying to specify different CATs. + // + __auto_type * newCATs = [NSSet setWithObjects:@(0x20005), @(0x70009), @(0x80004), nil]; + XCTAssertNotEqualObjects(validCATs, newCATs); + params.nodeID = nil; + params.caseAuthenticatedTags = newCATs; + controller = [factory createControllerOnExistingFabric:params error:nil]; + XCTAssertNil(controller); + + // + // Trying to bring up the same fabric without specifying any node id + // should end up using the existing CATs. + // + params.nodeID = nil; + params.caseAuthenticatedTags = nil; + controller = [factory createControllerOnExistingFabric:params error:nil]; + XCTAssertNotNil(controller); + XCTAssertTrue([controller isRunning]); + + // Check that the resulting certificate has the right CATs and node ID + CheckStoredOpcertCats(storage, 1, validCATs); + XCTAssertEqualObjects([controller controllerNodeID], @(17)); + + [controller shutdown]; + XCTAssertFalse([controller isRunning]); + + // + // Trying to bring up the same fabric without specifying any node id + // should end up using the existing CATs, even if a new + // operational key is specified. + // + __auto_type * operationalKeys = [[MTRTestKeys alloc] init]; + XCTAssertNotNil(operationalKeys); + params.nodeID = nil; + params.operationalKeypair = operationalKeys; + params.caseAuthenticatedTags = nil; + + controller = [factory createControllerOnExistingFabric:params error:nil]; + XCTAssertNotNil(controller); + XCTAssertTrue([controller isRunning]); + + // Check that the resulting certificate has the right CATs and node ID + CheckStoredOpcertCats(storage, 1, validCATs); + XCTAssertEqualObjects([controller controllerNodeID], @(17)); + + [controller shutdown]; + XCTAssertFalse([controller isRunning]); + + // + // Trying to bring up the same fabric while specifying the node ID, even if + // it's the same one, should pick up the new CATs. + // + params.nodeID = @(17); + params.operationalKeypair = operationalKeys; + params.caseAuthenticatedTags = newCATs; + + controller = [factory createControllerOnExistingFabric:params error:nil]; + XCTAssertNotNil(controller); + XCTAssertTrue([controller isRunning]); + + // Check that the resulting certificate has the right CATs and node ID + CheckStoredOpcertCats(storage, 1, newCATs); + XCTAssertEqualObjects([controller controllerNodeID], @(17)); + + [controller shutdown]; + XCTAssertFalse([controller isRunning]); + + // + // Trying to bring up the same fabric while specifying the node ID should + // let us remove CATs altogether. + // + params.nodeID = @(17); + params.operationalKeypair = operationalKeys; + params.caseAuthenticatedTags = nil; + + controller = [factory createControllerOnExistingFabric:params error:nil]; + XCTAssertNotNil(controller); + XCTAssertTrue([controller isRunning]); + + // Check that the resulting certificate has the right CATs and node ID + CheckStoredOpcertCats(storage, 1, nil); + XCTAssertEqualObjects([controller controllerNodeID], @(17)); + + [controller shutdown]; + XCTAssertFalse([controller isRunning]); + + // + // Trying to bring up the same fabric with too-long CATs should fail, if we + // are taking the provided CATs into account. + // + params.nodeID = @(17); + params.operationalKeypair = operationalKeys; + params.caseAuthenticatedTags = tooLongCATs; + controller = [factory createControllerOnExistingFabric:params error:nil]; + XCTAssertNil(controller); + + // + // Trying to bring up the same fabric with invalid CATs should fail, if we + // are taking the provided CATs into account. + // + params.nodeID = @(17); + params.operationalKeypair = operationalKeys; + params.caseAuthenticatedTags = invalidCATs; + controller = [factory createControllerOnExistingFabric:params error:nil]; + XCTAssertNil(controller); + + [factory stopControllerFactory]; + XCTAssertFalse([factory isRunning]); +} + @end diff --git a/src/darwin/Framework/CHIPTests/MTROperationalCertificateIssuerTests.m b/src/darwin/Framework/CHIPTests/MTROperationalCertificateIssuerTests.m index bb9c1597900709..8efc8989abb689 100644 --- a/src/darwin/Framework/CHIPTests/MTROperationalCertificateIssuerTests.m +++ b/src/darwin/Framework/CHIPTests/MTROperationalCertificateIssuerTests.m @@ -98,6 +98,13 @@ - (void)issueOperationalCertificateForRequest:(MTROperationalCSRInfo *)csrInfo XCTAssertNotNil(attestationInfo); XCTAssertEqual(controller, sController); + __auto_type * csrInfoCopy = [[MTROperationalCSRInfo alloc] initWithCSRElementsTLV:csrInfo.csrElementsTLV + attestationSignature:csrInfo.attestationSignature]; + XCTAssertEqualObjects(csrInfoCopy.csr, csrInfo.csr); + XCTAssertEqualObjects(csrInfoCopy.csrNonce, csrInfo.csrNonce); + XCTAssertEqualObjects(csrInfoCopy.csrElementsTLV, csrInfo.csrElementsTLV); + XCTAssertEqualObjects(csrInfoCopy.attestationSignature, csrInfo.attestationSignature); + completion(nil, [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeIntegrityCheckFailed userInfo:nil]); } diff --git a/src/darwin/Framework/CHIPTests/MTRTestStorage.h b/src/darwin/Framework/CHIPTests/MTRTestStorage.h index ba5e386be23b8c..8e0a5d6859180a 100644 --- a/src/darwin/Framework/CHIPTests/MTRTestStorage.h +++ b/src/darwin/Framework/CHIPTests/MTRTestStorage.h @@ -23,6 +23,7 @@ NS_ASSUME_NONNULL_BEGIN - (nullable NSData *)storageDataForKey:(NSString *)key; - (BOOL)setStorageData:(NSData *)value forKey:(NSString *)key; - (BOOL)removeStorageDataForKey:(NSString *)key; +- (NSString *)dumpStorageToString; @end NS_ASSUME_NONNULL_END diff --git a/src/darwin/Framework/CHIPTests/MTRTestStorage.m b/src/darwin/Framework/CHIPTests/MTRTestStorage.m index b03b3509891d39..8d80bd59d8b381 100644 --- a/src/darwin/Framework/CHIPTests/MTRTestStorage.m +++ b/src/darwin/Framework/CHIPTests/MTRTestStorage.m @@ -52,4 +52,9 @@ - (instancetype)init return self; } +- (NSString *)dumpStorageToString +{ + return [NSString stringWithFormat:@"%@", _values]; +} + @end diff --git a/src/lib/core/CHIPError.cpp b/src/lib/core/CHIPError.cpp index d28242d8176723..e6985efc890146 100644 --- a/src/lib/core/CHIPError.cpp +++ b/src/lib/core/CHIPError.cpp @@ -344,6 +344,9 @@ bool FormatCHIPError(char * buf, uint16_t bufSize, CHIP_ERROR err) case CHIP_ERROR_IM_FABRIC_DELETED.AsInteger(): desc = "The fabric is deleted, and the corresponding IM resources are released"; break; + case CHIP_ERROR_IN_PROGRESS.AsInteger(): + desc = "The operation is still in progress"; + break; case CHIP_ERROR_ACCESS_DENIED.AsInteger(): desc = "The CHIP message is not granted access"; break; diff --git a/src/lib/core/CHIPError.h b/src/lib/core/CHIPError.h index 4faf0da397c063..fbc6ba4e88d8c1 100644 --- a/src/lib/core/CHIPError.h +++ b/src/lib/core/CHIPError.h @@ -1362,7 +1362,14 @@ using CHIP_ERROR = ::chip::ChipError; // AVAILABLE: 0xa2 // AVAILABLE: 0xa3 -// AVAILABLE: 0xa4 + +/** + * @def CHIP_ERROR_IN_PROGRESS + * + * @brief + * The operation is still in progress + */ +#define CHIP_ERROR_IN_PROGRESS CHIP_CORE_ERROR(0xa4) /** * @def CHIP_ERROR_ACCESS_DENIED diff --git a/src/lib/core/GroupId.h b/src/lib/core/GroupId.h index effe85b74ddb06..c1168b1cd71f3a 100644 --- a/src/lib/core/GroupId.h +++ b/src/lib/core/GroupId.h @@ -25,17 +25,17 @@ using GroupId = uint16_t; constexpr GroupId kUndefinedGroupId = 0; -constexpr GroupId kMinUniversalGroupId = 0x8000; +constexpr GroupId kMinUniversalGroupId = 0xFF00; constexpr GroupId kMaxUniversalGroupId = 0xFFFF; -constexpr GroupId kMinFabricGroupId = 0x0001; -constexpr GroupId kMaxFabricGroupId = 0x7FFF; +constexpr GroupId kMinApplicationGroupId = 0x0001; +constexpr GroupId kMaxApplicationGroupId = 0xFEFF; constexpr GroupId kAllNodes = 0xFFFF; constexpr GroupId kAllNonSleepy = 0xFFFE; constexpr GroupId kAllProxies = 0xFFFD; -constexpr GroupId kMinUniversalGroupIdReserved = 0x8000; +constexpr GroupId kMinUniversalGroupIdReserved = 0xFF00; constexpr GroupId kMaxUniversalGroupIdReserved = 0xFFFC; constexpr bool IsOperationalGroupId(GroupId aGroupId) @@ -44,9 +44,9 @@ constexpr bool IsOperationalGroupId(GroupId aGroupId) ((aGroupId < kMinUniversalGroupIdReserved) || (aGroupId > kMaxUniversalGroupIdReserved)); } -constexpr bool IsFabricGroupId(GroupId aGroupId) +constexpr bool IsApplicationGroupId(GroupId aGroupId) { - return (aGroupId >= kMinFabricGroupId) && (aGroupId <= kMaxFabricGroupId); + return (aGroupId >= kMinApplicationGroupId) && (aGroupId <= kMaxApplicationGroupId); } constexpr bool IsUniversalGroupId(GroupId aGroupId) diff --git a/src/lib/core/tests/TestCHIPErrorStr.cpp b/src/lib/core/tests/TestCHIPErrorStr.cpp index fcadcd6b543f16..b5fabd64afe145 100644 --- a/src/lib/core/tests/TestCHIPErrorStr.cpp +++ b/src/lib/core/tests/TestCHIPErrorStr.cpp @@ -170,6 +170,7 @@ static const CHIP_ERROR kTestElements[] = CHIP_ERROR_INVALID_FILE_IDENTIFIER, CHIP_ERROR_BUSY, CHIP_ERROR_HANDLER_NOT_SET, + CHIP_ERROR_IN_PROGRESS, }; // clang-format on diff --git a/src/lib/dnssd/Resolver.h b/src/lib/dnssd/Resolver.h index 5f48378bd01d4e..eecf21db306fa2 100644 --- a/src/lib/dnssd/Resolver.h +++ b/src/lib/dnssd/Resolver.h @@ -38,8 +38,7 @@ namespace Dnssd { /// Node resolution data common to both operational and commissionable discovery struct CommonResolutionData { - // TODO: is this count OK? Sufficient space for IPv6 LL, GUA, ULA (and maybe IPv4 if enabled) - static constexpr unsigned kMaxIPAddresses = 5; + static constexpr unsigned kMaxIPAddresses = CHIP_DEVICE_CONFIG_MAX_DISCOVERED_IP_ADDRESSES; Inet::InterfaceId interfaceId; diff --git a/src/lib/shell/BUILD.gn b/src/lib/shell/BUILD.gn index 43b0766a871328..7f3d1d46cb62b1 100644 --- a/src/lib/shell/BUILD.gn +++ b/src/lib/shell/BUILD.gn @@ -50,15 +50,11 @@ static_library("shell") { "MainLoopESP32.cpp", "streamer_esp32.cpp", ] - } else if (chip_device_platform == "efr32") { + } else if (chip_device_platform == "efr32" || + chip_device_platform == "SiWx917") { sources += [ - "MainLoopEFR32.cpp", - "streamer_efr32.cpp", - ] - } else if (chip_device_platform == "SiWx917") { - sources += [ - "MainLoopEFR32.cpp", - "streamer_efr32.cpp", + "MainLoopSilabs.cpp", + "streamer_silabs.cpp", ] } else if (chip_device_platform == "k32w0") { sources += [ diff --git a/src/lib/shell/MainLoopEFR32.cpp b/src/lib/shell/MainLoopSilabs.cpp similarity index 93% rename from src/lib/shell/MainLoopEFR32.cpp rename to src/lib/shell/MainLoopSilabs.cpp index b43673ba526dd6..2b755119fd8cd5 100644 --- a/src/lib/shell/MainLoopEFR32.cpp +++ b/src/lib/shell/MainLoopSilabs.cpp @@ -49,11 +49,22 @@ void ReadLine(char * buffer, size_t max) break; } +#ifdef BRD4325A + // for 917 SoC board, we need to create a rx event before we wait for the shell activity + // NotifyShellProcessFromISR() is called once the buffer is filled + if (streamer_read(streamer_get(), buffer + line_sz, 1) != 1) + { + continue; + } +#endif chip::WaitForShellActivity(); +#ifndef BRD4325A + // for EFR32 boards if (streamer_read(streamer_get(), buffer + line_sz, 1) != 1) { continue; } +#endif // Process character we just read. switch (buffer[line_sz]) diff --git a/src/lib/shell/streamer_efr32.cpp b/src/lib/shell/streamer_silabs.cpp similarity index 100% rename from src/lib/shell/streamer_efr32.cpp rename to src/lib/shell/streamer_silabs.cpp diff --git a/src/lib/support/BUILD.gn b/src/lib/support/BUILD.gn index d006b42bf1b38e..724e029cbbc379 100644 --- a/src/lib/support/BUILD.gn +++ b/src/lib/support/BUILD.gn @@ -216,7 +216,7 @@ static_library("support") { } if (chip_pw_tokenizer_logging) { - public_deps += [ "${dir_pw_tokenizer}:global_handler_with_payload" ] + public_deps += [ "${dir_pw_tokenizer}" ] } if (chip_config_memory_debug_dmalloc) { diff --git a/src/lib/support/JniReferences.cpp b/src/lib/support/JniReferences.cpp index c7834348e06a1a..1a4fae9e22ff32 100644 --- a/src/lib/support/JniReferences.cpp +++ b/src/lib/support/JniReferences.cpp @@ -388,4 +388,34 @@ CHIP_ERROR JniReferences::GetObjectField(jobject objectToRead, const char * name return err; } +CHIP_ERROR JniReferences::CharToStringUTF(const chip::CharSpan & charSpan, jobject & outStr) +{ + JNIEnv * env = GetEnvForCurrentThread(); + jobject jbyteBuffer = env->NewDirectByteBuffer((void *) charSpan.data(), static_cast(charSpan.size())); + + jclass charSetClass = env->FindClass("java/nio/charset/Charset"); + jmethodID charsetForNameMethod = + env->GetStaticMethodID(charSetClass, "forName", "(Ljava/lang/String;)Ljava/nio/charset/Charset;"); + jobject charsetObject = env->CallStaticObjectMethod(charSetClass, charsetForNameMethod, env->NewStringUTF("UTF-8")); + + jclass charSetDocoderClass = env->FindClass("java/nio/charset/CharsetDecoder"); + jmethodID newDocoderMethod = env->GetMethodID(charSetClass, "newDecoder", "()Ljava/nio/charset/CharsetDecoder;"); + jobject decoderObject = env->CallObjectMethod(charsetObject, newDocoderMethod); + + jmethodID charSetDecodeMethod = env->GetMethodID(charSetDocoderClass, "decode", "(Ljava/nio/ByteBuffer;)Ljava/nio/CharBuffer;"); + jobject decodeObject = env->CallObjectMethod(decoderObject, charSetDecodeMethod, jbyteBuffer); + env->DeleteLocalRef(jbyteBuffer); + + // If decode exception occur, outStr will be set null. + outStr = nullptr; + + VerifyOrReturnError(!env->ExceptionCheck(), CHIP_JNI_ERROR_EXCEPTION_THROWN); + + jclass charBufferClass = env->FindClass("java/nio/CharBuffer"); + jmethodID charBufferToString = env->GetMethodID(charBufferClass, "toString", "()Ljava/lang/String;"); + outStr = static_cast(env->CallObjectMethod(decodeObject, charBufferToString)); + + return CHIP_NO_ERROR; +} + } // namespace chip diff --git a/src/lib/support/JniReferences.h b/src/lib/support/JniReferences.h index f2e357de2db46a..5e323d93f46394 100644 --- a/src/lib/support/JniReferences.h +++ b/src/lib/support/JniReferences.h @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -160,6 +161,15 @@ class JniReferences return CreateBoxedObject(boxedTypeClsName, constructorSignature, chip::to_underlying(value), outObj); } + /** + * Use instead of 'NewStringUTF' function + * If the value is not decoded with "UTF-8", the error will be returned. + * (The NewStringUTF function crashes when the value can not decoded as "UTF-8".) + * + * Creates a java string type based on char array. + */ + CHIP_ERROR CharToStringUTF(const chip::CharSpan & charSpan, jobject & outString); + private: JniReferences() {} diff --git a/src/lib/support/logging/CHIPLogging.cpp b/src/lib/support/logging/CHIPLogging.cpp index ca04f60388d6b8..27b93e802f7991 100644 --- a/src/lib/support/logging/CHIPLogging.cpp +++ b/src/lib/support/logging/CHIPLogging.cpp @@ -38,33 +38,45 @@ #include +#if CHIP_PW_TOKENIZER_LOGGING +#include "pw_tokenizer/encode_args.h" +#endif + +namespace chip { +namespace Logging { + +#if _CHIP_USE_LOGGING + #if CHIP_PW_TOKENIZER_LOGGING -extern "C" void pw_tokenizer_HandleEncodedMessageWithPayload(uintptr_t levels, const uint8_t encoded_message[], size_t size_bytes) +void HandleTokenizedLog(uint32_t levels, pw_tokenizer_Token token, pw_tokenizer_ArgTypes types, ...) { + uint8_t encoded_message[PW_TOKENIZER_CFG_ENCODING_BUFFER_SIZE_BYTES]; + + va_list args; + va_start(args, types); + // Use the C argument encoding API, since the C++ API requires C++17. + const size_t encoded_size = pw_tokenizer_EncodeArgs(types, args, encoded_message, sizeof(encoded_message)); + va_end(args); + uint8_t log_category = levels >> 8 & 0xFF; uint8_t log_module = levels & 0xFF; - char * buffer = (char *) chip::Platform::MemoryAlloc(2 * size_bytes + 1); + char * buffer = (char *) chip::Platform::MemoryAlloc(2 * encoded_size + 1); if (buffer) { - for (int i = 0; i < size_bytes; i++) + for (int i = 0; i < encoded_size; i++) { sprintf(buffer + 2 * i, "%02x", encoded_message[i]); } - buffer[2 * size_bytes] = '\0'; - chip::Logging::Log(log_module, log_category, "%s", buffer); + buffer[2 * encoded_size] = '\0'; + Log(log_module, log_category, "%s", buffer); chip::Platform::MemoryFree(buffer); } } #endif -namespace chip { -namespace Logging { - -#if _CHIP_USE_LOGGING - namespace { std::atomic sLogRedirectCallback{ nullptr }; diff --git a/src/lib/support/logging/CHIPLogging.h b/src/lib/support/logging/CHIPLogging.h index 5bb01ff1ed5c6b..3d0dd96d2f5f60 100644 --- a/src/lib/support/logging/CHIPLogging.h +++ b/src/lib/support/logging/CHIPLogging.h @@ -50,7 +50,7 @@ #endif #if CHIP_PW_TOKENIZER_LOGGING -#include "pw_tokenizer/tokenize_to_global_handler_with_payload.h" +#include "pw_tokenizer/tokenize.h" #endif /** @@ -423,13 +423,17 @@ void LogV(uint8_t module, uint8_t category, const char * msg, va_list args) ENFO #endif // CHIP_SYSTEM_CONFIG_PLATFORM_LOG #if CHIP_PW_TOKENIZER_LOGGING + +void HandleTokenizedLog(uint32_t levels, pw_tokenizer_Token token, pw_tokenizer_ArgTypes, ...); + #define ChipInternalLogImpl(MOD, CAT, MSG, ...) \ do \ { \ if (chip::Logging::IsCategoryEnabled(CAT)) \ { \ - PW_TOKENIZE_TO_GLOBAL_HANDLER_WITH_PAYLOAD((pw_tokenizer_Payload)((CAT << 8) | chip::Logging::kLogModule_##MOD), MSG, \ - __VA_ARGS__); \ + PW_TOKENIZE_FORMAT_STRING(PW_TOKENIZER_DEFAULT_DOMAIN, UINT32_MAX, MSG, __VA_ARGS__); \ + ::chip::Logging::HandleTokenizedLog((uint32_t)((CAT << 8) | chip::Logging::kLogModule_##MOD), _pw_tokenizer_token, \ + PW_TOKENIZER_ARG_TYPES(__VA_ARGS__) PW_COMMA_ARGS(__VA_ARGS__)); \ } \ } while (0) #else // CHIP_PW_TOKENIZER_LOGGING diff --git a/src/platform/Ameba/AmebaUtils.cpp b/src/platform/Ameba/AmebaUtils.cpp index 72d0e7fda0c4cc..578ffab2cd5816 100644 --- a/src/platform/Ameba/AmebaUtils.cpp +++ b/src/platform/Ameba/AmebaUtils.cpp @@ -136,7 +136,7 @@ CHIP_ERROR AmebaUtils::WiFiDisconnect(void) return err; } -CHIP_ERROR AmebaUtils::WiFiConnect(void) +CHIP_ERROR AmebaUtils::WiFiConnectProvisionedNetwork(void) { CHIP_ERROR err = CHIP_NO_ERROR; rtw_wifi_config_t * config = (rtw_wifi_config_t *) pvPortMalloc(sizeof(rtw_wifi_config_t)); @@ -144,9 +144,56 @@ CHIP_ERROR AmebaUtils::WiFiConnect(void) GetWiFiConfig(config); ChipLogProgress(DeviceLayer, "Connecting to AP : [%s]", (char *) config->ssid); int ameba_err = matter_wifi_connect((char *) config->ssid, RTW_SECURITY_WPA_WPA2_MIXED, (char *) config->password, - strlen((const char *) config->ssid), strlen((const char *) config->password), 0, NULL); + strlen((const char *) config->ssid), strlen((const char *) config->password), 0, nullptr); vPortFree(config); err = (ameba_err == RTW_SUCCESS) ? CHIP_NO_ERROR : CHIP_ERROR_INTERNAL; return err; } + +CHIP_ERROR AmebaUtils::WiFiConnect(const char * ssid, const char * password) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + ChipLogProgress(DeviceLayer, "Connecting to AP : [%s]", (char *) ssid); + int ameba_err = matter_wifi_connect((char *) ssid, RTW_SECURITY_WPA_WPA2_MIXED, (char *) password, strlen(ssid), + strlen(password), 0, nullptr); + err = (ameba_err == RTW_SUCCESS) ? CHIP_NO_ERROR : CHIP_ERROR_INTERNAL; + return err; +} + +CHIP_ERROR AmebaUtils::SetCurrentProvisionedNetwork() +{ + CHIP_ERROR err = CHIP_NO_ERROR; + rtw_wifi_setting_t pSetting; + int ret = matter_get_sta_wifi_info(&pSetting); + if (ret < 0) + { + ChipLogProgress(DeviceLayer, "STA No Wi-Fi Info"); + goto exit; + } + else + { + rtw_wifi_config_t config = { 0 }; + GetWiFiConfig(&config); + if (!memcmp(config.ssid, pSetting.ssid, strlen((const char *) pSetting.ssid) + 1)) + { + ChipLogProgress(DeviceLayer, "STA Wi-Fi Info exist, do nothing"); + goto exit; + } + else + { + ChipLogProgress(DeviceLayer, "STA Wi-Fi Info "); + + memcpy(config.ssid, pSetting.ssid, strlen((const char *) pSetting.ssid) + 1); + memcpy(config.password, pSetting.password, strlen((const char *) pSetting.password) + 1); + err = SetWiFiConfig(&config); + if (err != CHIP_NO_ERROR) + { + ChipLogError(DeviceLayer, "SetWiFiConfig() failed"); + goto exit; + } + } + } +exit: + return err; +} diff --git a/src/platform/Ameba/AmebaUtils.h b/src/platform/Ameba/AmebaUtils.h index b2f68f38dad1ef..5fcc5c9c2ef487 100644 --- a/src/platform/Ameba/AmebaUtils.h +++ b/src/platform/Ameba/AmebaUtils.h @@ -36,7 +36,9 @@ class AmebaUtils static CHIP_ERROR GetWiFiConfig(rtw_wifi_config_t * config); static CHIP_ERROR ClearWiFiConfig(void); static CHIP_ERROR WiFiDisconnect(void); - static CHIP_ERROR WiFiConnect(void); + static CHIP_ERROR WiFiConnectProvisionedNetwork(void); + static CHIP_ERROR WiFiConnect(const char * ssid, const char * password); + static CHIP_ERROR SetCurrentProvisionedNetwork(void); }; } // namespace Internal diff --git a/src/platform/Ameba/ConnectivityManagerImpl.cpp b/src/platform/Ameba/ConnectivityManagerImpl.cpp index 670c060e95b94f..ba289b115c0bab 100644 --- a/src/platform/Ameba/ConnectivityManagerImpl.cpp +++ b/src/platform/Ameba/ConnectivityManagerImpl.cpp @@ -83,7 +83,7 @@ CHIP_ERROR ConnectivityManagerImpl::_Init() chip_connmgr_set_callback_func((chip_connmgr_callback)(conn_callback_dispatcher), this); // Register WiFi event handlers - wifi_reg_event_handler(WIFI_EVENT_CONNECT, ConnectivityManagerImpl::RtkWiFiStationConnectedHandler, NULL); + wifi_reg_event_handler(WIFI_EVENT_FOURWAY_HANDSHAKE_DONE, ConnectivityManagerImpl::RtkWiFiStationConnectedHandler, NULL); wifi_reg_event_handler(WIFI_EVENT_DISCONNECT, ConnectivityManagerImpl::RtkWiFiStationDisconnectedHandler, NULL); err = Internal::AmebaUtils::StartWiFi(); @@ -148,13 +148,16 @@ void ConnectivityManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) if (event->Type == DeviceEventType::kRtkWiFiStationConnectedEvent) { ChipLogProgress(DeviceLayer, "WiFiStationConnected"); + // Only do DHCP when connecting to wifi via matter provisioning + // External wifi provisioning will do DHCP on their own if (mWiFiStationState == kWiFiStationState_Connecting) { - ChangeWiFiStationState(kWiFiStationState_Connecting_Succeeded); + DHCPProcess(); } - if (rtw_join_status & JOIN_HANDSHAKE_DONE) + // Allow external wifi provisioning methods by allowing NotConnected states to advance to Connecting_succeed + if ((mWiFiStationState == kWiFiStationState_Connecting) || (mWiFiStationState == kWiFiStationState_NotConnected)) { - DHCPProcess(); + ChangeWiFiStationState(kWiFiStationState_Connecting_Succeeded); } DriveStationState(); } @@ -166,6 +169,10 @@ void ConnectivityManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) { ChangeWiFiStationState(kWiFiStationState_Connecting_Failed); } + if (mWiFiStationState == kWiFiStationState_Connected) + { + ChangeWiFiStationState(kWiFiStationState_Disconnecting); + } DriveStationState(); } if (event->Type == DeviceEventType::kRtkWiFiScanCompletedEvent) @@ -204,7 +211,8 @@ CHIP_ERROR ConnectivityManagerImpl::_SetWiFiStationMode(WiFiStationMode val) if (mWiFiStationMode != val) { - ChipLogProgress(DeviceLayer, "WiFi station mode change: %d -> %d", (mWiFiStationMode), (val)); + ChipLogProgress(DeviceLayer, "WiFi station mode change: %s -> %s", WiFiStationModeToStr(mWiFiStationMode), + WiFiStationModeToStr(val)); } mWiFiStationMode = val; @@ -221,9 +229,7 @@ bool ConnectivityManagerImpl::_IsWiFiStationProvisioned(void) void ConnectivityManagerImpl::_ClearWiFiStationProvision(void) { // Clear Ameba WiFi station config - rtw_wifi_config_t wifiConfig; - memset(&wifiConfig, 0, sizeof(wifiConfig)); - Internal::AmebaUtils::SetWiFiConfig(&wifiConfig); + Internal::AmebaUtils::ClearWiFiConfig(); } CHIP_ERROR ConnectivityManagerImpl::_SetWiFiAPMode(WiFiAPMode val) @@ -496,9 +502,9 @@ void ConnectivityManagerImpl::DriveStationState() // If the station interface is currently connected ... if (stationConnected) { - // Advance the station state to Connected if it was previously NotConnected or + // Advance the station state to Connected if // a previously initiated connect attempt succeeded. - if (mWiFiStationState == kWiFiStationState_NotConnected || mWiFiStationState == kWiFiStationState_Connecting_Succeeded) + if (mWiFiStationState == kWiFiStationState_Connecting_Succeeded) { ChangeWiFiStationState(kWiFiStationState_Connected); ChipLogProgress(DeviceLayer, "WiFi station interface connected"); @@ -512,23 +518,23 @@ void ConnectivityManagerImpl::DriveStationState() { System::Clock::Timestamp now = System::SystemClock().GetMonotonicTimestamp(); - // Advance the station state to NotConnected if it was previously Connected or Disconnecting, + // Advance the station state to NotConnected if it was previously Disconnecting, // or if a previous initiated connect attempt failed. - if (mWiFiStationState == kWiFiStationState_Connected || mWiFiStationState == kWiFiStationState_Disconnecting || - mWiFiStationState == kWiFiStationState_Connecting_Failed) + if (mWiFiStationState == kWiFiStationState_Disconnecting || mWiFiStationState == kWiFiStationState_Connecting_Failed) { WiFiStationState prevState = mWiFiStationState; ChangeWiFiStationState(kWiFiStationState_NotConnected); if (prevState != kWiFiStationState_Connecting_Failed) { - ChipLogProgress(DeviceLayer, "WiFi station interface disconnected"); - mLastStationConnectFailTime = System::Clock::kZero; - OnStationDisconnected(); + ChipLogProgress(DeviceLayer, "WiFi station failed to connect"); + // TODO: check retry count if exceeded, then clearwificonfig } else { - mLastStationConnectFailTime = now; + ChipLogProgress(DeviceLayer, "WiFi station disconnected"); } + mLastStationConnectFailTime = now; + OnStationDisconnected(); } // If the WiFi station interface is now enabled and provisioned (and by implication, // not presently under application control), AND the system is not in the process of @@ -541,14 +547,13 @@ void ConnectivityManagerImpl::DriveStationState() now >= mLastStationConnectFailTime + mWiFiStationReconnectInterval) { ChipLogProgress(DeviceLayer, "Attempting to connect WiFi station interface"); - err = Internal::AmebaUtils::WiFiConnect(); + ChangeWiFiStationState(kWiFiStationState_Connecting); + err = Internal::AmebaUtils::WiFiConnectProvisionedNetwork(); if (err != CHIP_NO_ERROR) { - ChipLogError(DeviceLayer, "WiFiConnect() failed: %s", chip::ErrorStr(err)); + ChipLogError(DeviceLayer, "WiFiConnectProvisionedNetwork() failed: %s", chip::ErrorStr(err)); } SuccessOrExit(err); - - ChangeWiFiStationState(kWiFiStationState_Connecting); } // Otherwise arrange another connection attempt at a suitable point in the future. @@ -644,7 +649,8 @@ void ConnectivityManagerImpl::ChangeWiFiStationState(WiFiStationState newState) { if (mWiFiStationState != newState) { - ChipLogProgress(DeviceLayer, "WiFi station state change: %d -> %d", (mWiFiStationState), (newState)); + ChipLogProgress(DeviceLayer, "WiFi station state change: %s -> %s", WiFiStationStateToStr(mWiFiStationState), + WiFiStationStateToStr(newState)); mWiFiStationState = newState; SystemLayer().ScheduleLambda([]() { NetworkCommissioning::AmebaWiFiDriver::GetInstance().OnNetworkStatusChange(); }); } diff --git a/src/platform/Ameba/ConnectivityManagerImpl.h b/src/platform/Ameba/ConnectivityManagerImpl.h index 9863c47dec88d8..c4c04c5346e482 100644 --- a/src/platform/Ameba/ConnectivityManagerImpl.h +++ b/src/platform/Ameba/ConnectivityManagerImpl.h @@ -84,6 +84,9 @@ class ConnectivityManagerImpl final : public ConnectivityManager, // the implementation methods provided by this class. friend class ConnectivityManager; +public: + void ChangeWiFiStationState(WiFiStationState newState); + private: CHIP_ERROR _Init(void); void _OnPlatformEvent(const ChipDeviceEvent * event); @@ -130,7 +133,6 @@ class ConnectivityManagerImpl final : public ConnectivityManager, void DriveStationState(void); void OnStationConnected(void); void OnStationDisconnected(void); - void ChangeWiFiStationState(WiFiStationState newState); static void DriveStationState(::chip::System::Layer * aLayer, void * aAppState); void DriveAPState(void); diff --git a/src/platform/Ameba/NetworkCommissioningWiFiDriver.cpp b/src/platform/Ameba/NetworkCommissioningWiFiDriver.cpp index 2edc96aa20a77a..38be3f2080f0b5 100644 --- a/src/platform/Ameba/NetworkCommissioningWiFiDriver.cpp +++ b/src/platform/Ameba/NetworkCommissioningWiFiDriver.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -145,25 +146,10 @@ CHIP_ERROR AmebaWiFiDriver::ConnectWiFiNetwork(const char * ssid, uint8_t ssidLe } } - ReturnErrorOnFailure(ConnectivityMgr().SetWiFiStationMode(ConnectivityManager::kWiFiStationMode_Disabled)); + ConnectivityMgrImpl().ChangeWiFiStationState(ConnectivityManager::kWiFiStationState_Connecting); - rtw_wifi_config_t wifiConfig; - - // Set the wifi configuration - memset(&wifiConfig, 0, sizeof(wifiConfig)); - memcpy(wifiConfig.ssid, ssid, ssidLen + 1); - memcpy(wifiConfig.password, key, keyLen + 1); - - // Configure the WiFi interface. - err = chip::DeviceLayer::Internal::AmebaUtils::SetWiFiConfig(&wifiConfig); - if (err != CHIP_NO_ERROR) - { - ChipLogError(DeviceLayer, "SetWiFiConfig() failed"); - return err; - } - - ReturnErrorOnFailure(ConnectivityMgr().SetWiFiStationMode(ConnectivityManager::kWiFiStationMode_Disabled)); - return ConnectivityMgr().SetWiFiStationMode(ConnectivityManager::kWiFiStationMode_Enabled); + err = chip::DeviceLayer::Internal::AmebaUtils::WiFiConnect(ssid, key); + return err; } void AmebaWiFiDriver::OnConnectWiFiNetwork() @@ -228,8 +214,7 @@ void AmebaWiFiDriver::OnScanWiFiNetworkDone() return; } - rtw_scan_result_t * ScanResult = (rtw_scan_result *) pvPortMalloc(NumAP * sizeof(rtw_scan_result)); - matter_get_scan_results(ScanResult, NumAP); + rtw_scan_result_t * ScanResult = matter_get_scan_results(); if (ScanResult) { @@ -258,7 +243,6 @@ void AmebaWiFiDriver::OnScanWiFiNetworkDone() mpScanCallback = nullptr; } } - vPortFree(ScanResult); } CHIP_ERROR GetConfiguredNetwork(Network & network) @@ -320,7 +304,7 @@ void AmebaWiFiDriver::ScanNetworks(ByteSpan ssid, WiFiDriver::ScanCallback * cal CHIP_ERROR AmebaWiFiDriver::SetLastDisconnectReason(const ChipDeviceEvent * event) { VerifyOrReturnError(event->Type == DeviceEventType::kRtkWiFiStationDisconnectedEvent, CHIP_ERROR_INVALID_ARGUMENT); - mLastDisconnectedReason = wifi_get_last_error(); + mLastDisconnectedReason = wifi_get_last_error(); // TODO: change this to wrapper return CHIP_NO_ERROR; } diff --git a/src/platform/BUILD.gn b/src/platform/BUILD.gn index ac478a14d0ce52..678cbb8778fc79 100644 --- a/src/platform/BUILD.gn +++ b/src/platform/BUILD.gn @@ -65,6 +65,9 @@ if (chip_device_platform != "none" && chip_device_platform != "external") { # The string of device software version was built. chip_device_config_device_software_version_string = "" + + # Define the default number of ip addresses to discover + chip_max_discovered_ip_addresses = 5 } if (chip_stack_lock_tracking == "auto") { @@ -291,6 +294,8 @@ if (chip_device_platform != "none" && chip_device_platform != "external") { if (chip_device_config_device_software_version_string != "") { defines += [ "CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING=\"${chip_device_config_device_software_version_string}\"" ] } + + defines += [ "CHIP_DEVICE_CONFIG_MAX_DISCOVERED_IP_ADDRESSES=${chip_max_discovered_ip_addresses}" ] } } else if (chip_device_platform == "none") { buildconfig_header("platform_buildconfig") { diff --git a/src/platform/ESP32/BUILD.gn b/src/platform/ESP32/BUILD.gn index fce0f93971ee29..9718bebbc70edb 100644 --- a/src/platform/ESP32/BUILD.gn +++ b/src/platform/ESP32/BUILD.gn @@ -27,6 +27,7 @@ declare_args() { chip_enable_chipoble = true chip_bt_nimble_enabled = false chip_bt_bluedroid_enabled = false + chip_use_secure_cert_dac_provider = false } defines = [ @@ -64,7 +65,10 @@ static_library("ESP32") { "${chip_root}/src/setup_payload", ] - public = [ "${chip_root}/src/credentials/DeviceAttestationCredsProvider.h" ] + public = [ + "${chip_root}/src/credentials/CHIPCert.h", + "${chip_root}/src/credentials/DeviceAttestationCredsProvider.h", + ] public_deps = [ "${chip_root}/src/crypto", @@ -149,5 +153,12 @@ static_library("ESP32") { ] } + if (chip_use_secure_cert_dac_provider) { + sources += [ + "ESP32SecureCertDACProvider.cpp", + "ESP32SecureCertDACProvider.h", + ] + } + cflags = [ "-Wconversion" ] } diff --git a/src/platform/ESP32/CHIPDevicePlatformConfig.h b/src/platform/ESP32/CHIPDevicePlatformConfig.h index 13360bf91cda89..757af45869a7dd 100644 --- a/src/platform/ESP32/CHIPDevicePlatformConfig.h +++ b/src/platform/ESP32/CHIPDevicePlatformConfig.h @@ -47,7 +47,7 @@ #endif /* CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID */ -#define CHIP_DEVICE_CONFIG_ENABLE_THREAD CONFIG_OPENTHREAD_ENABLED +#define CHIP_DEVICE_CONFIG_ENABLE_THREAD CONFIG_ENABLE_MATTER_OVER_THREAD #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT CONFIG_OPENTHREAD_SRP_CLIENT #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT CONFIG_OPENTHREAD_DNS_CLIENT diff --git a/src/platform/ESP32/ESP32SecureCertDACProvider.cpp b/src/platform/ESP32/ESP32SecureCertDACProvider.cpp new file mode 100644 index 00000000000000..7c45caf5202d33 --- /dev/null +++ b/src/platform/ESP32/ESP32SecureCertDACProvider.cpp @@ -0,0 +1,147 @@ +/* + * + * 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. + * 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 +#include +#include +#include +#include +#include +#include + +#define TAG "dac_provider" + +#if CONFIG_SEC_CERT_DAC_PROVIDER + +namespace chip { +namespace DeviceLayer { + +using namespace chip::Credentials; +using namespace chip::DeviceLayer::Internal; + +namespace { +static constexpr uint32_t kDACPrivateKeySize = 32; +static constexpr uint32_t kDACPublicKeySize = 65; +static constexpr uint8_t kPrivKeyOffset = 7; +static constexpr uint8_t kPubKeyOffset = 56; + +CHIP_ERROR LoadKeypairFromRaw(ByteSpan privateKey, ByteSpan publicKey, Crypto::P256Keypair & keypair) +{ + Crypto::P256SerializedKeypair serializedKeypair; + ReturnErrorOnFailure(serializedKeypair.SetLength(privateKey.size() + publicKey.size())); + memcpy(serializedKeypair.Bytes(), publicKey.data(), publicKey.size()); + memcpy(serializedKeypair.Bytes() + publicKey.size(), privateKey.data(), privateKey.size()); + return keypair.Deserialize(serializedKeypair); +} +} // namespace + +CHIP_ERROR ESP32SecureCertDACProvider ::GetCertificationDeclaration(MutableByteSpan & outBuffer) +{ + size_t certSize; + ReturnErrorOnFailure( + ESP32Config::ReadConfigValueBin(ESP32Config::kConfigKey_CertDeclaration, outBuffer.data(), outBuffer.size(), certSize)); + outBuffer.reduce_size(certSize); + return CHIP_NO_ERROR; +} + +CHIP_ERROR ESP32SecureCertDACProvider ::GetFirmwareInformation(MutableByteSpan & out_firmware_info_buffer) +{ + // We do not provide any FirmwareInformation. + out_firmware_info_buffer.reduce_size(0); + return CHIP_NO_ERROR; +} + +CHIP_ERROR ESP32SecureCertDACProvider ::GetDeviceAttestationCert(MutableByteSpan & outBuffer) +{ + char * dac_cert = NULL; + uint32_t dac_len = 0; + + esp_err_t err = esp_secure_cert_get_device_cert(&dac_cert, &dac_len); + if (err == ESP_OK && dac_cert != NULL && dac_len != 0) + { + ESP_FAULT_ASSERT(err == ESP_OK && dac_cert != NULL && dac_len != 0); + VerifyOrReturnError(dac_len <= kMaxDERCertLength, CHIP_ERROR_UNSUPPORTED_CERT_FORMAT, + esp_secure_cert_free_ca_cert(dac_cert)); + VerifyOrReturnError(dac_len <= outBuffer.size(), CHIP_ERROR_BUFFER_TOO_SMALL, esp_secure_cert_free_ca_cert(dac_cert)); + memcpy(outBuffer.data(), dac_cert, outBuffer.size()); + outBuffer.reduce_size(dac_len); + esp_secure_cert_free_device_cert(dac_cert); + return CHIP_NO_ERROR; + } + + ESP_LOGE(TAG, "esp_secure_cert_get_device_cert failed err:%d", err); + return CHIP_ERROR_INCORRECT_STATE; +} + +CHIP_ERROR ESP32SecureCertDACProvider ::GetProductAttestationIntermediateCert(MutableByteSpan & outBuffer) +{ + char * pai_cert = NULL; + uint32_t pai_len = 0; + esp_err_t err = esp_secure_cert_get_ca_cert(&pai_cert, &pai_len); + if (err == ESP_OK && pai_cert != NULL && pai_len != 0) + { + ESP_FAULT_ASSERT(err == ESP_OK && pai_cert != NULL && pai_len != 0); + VerifyOrReturnError(pai_len <= kMaxDERCertLength, CHIP_ERROR_UNSUPPORTED_CERT_FORMAT, + esp_secure_cert_free_ca_cert(pai_cert)); + VerifyOrReturnError(pai_len <= outBuffer.size(), CHIP_ERROR_BUFFER_TOO_SMALL, esp_secure_cert_free_ca_cert(pai_cert)); + memcpy(outBuffer.data(), pai_cert, outBuffer.size()); + outBuffer.reduce_size(pai_len); + esp_secure_cert_free_ca_cert(pai_cert); + return CHIP_NO_ERROR; + } + + ESP_LOGE(TAG, "esp_secure_cert_get_ca_cert failed err:%d", err); + return CHIP_ERROR_INCORRECT_STATE; +} + +CHIP_ERROR ESP32SecureCertDACProvider ::SignWithDeviceAttestationKey(const ByteSpan & messageToSign, + MutableByteSpan & outSignBuffer) +{ + Crypto::P256ECDSASignature signature; + Crypto::P256Keypair keypair; + char * sc_keypair = NULL; + uint32_t sc_keypair_len = 0; + + VerifyOrReturnError(IsSpanUsable(outSignBuffer), CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrReturnError(IsSpanUsable(messageToSign), CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrReturnError(outSignBuffer.size() >= signature.Capacity(), CHIP_ERROR_BUFFER_TOO_SMALL); + + esp_err_t err = esp_secure_cert_get_priv_key(&sc_keypair, &sc_keypair_len); + if (err == ESP_OK && sc_keypair != NULL && sc_keypair_len != 0) + { + ESP_FAULT_ASSERT(err == ESP_OK && sc_keypair != NULL && sc_keypair_len != 0); + CHIP_ERROR chipError = + LoadKeypairFromRaw(ByteSpan(reinterpret_cast(sc_keypair + kPrivKeyOffset), kDACPrivateKeySize), + ByteSpan(reinterpret_cast(sc_keypair + kPubKeyOffset), kDACPublicKeySize), keypair); + VerifyOrReturnError(chipError == CHIP_NO_ERROR, chipError, esp_secure_cert_free_priv_key(sc_keypair)); + + chipError = keypair.ECDSA_sign_msg(messageToSign.data(), messageToSign.size(), signature); + VerifyOrReturnError(chipError == CHIP_NO_ERROR, chipError, esp_secure_cert_free_priv_key(sc_keypair)); + + esp_secure_cert_free_priv_key(sc_keypair); + chipError = CopySpanToMutableSpan(ByteSpan{ signature.ConstBytes(), signature.Length() }, outSignBuffer); + return chipError; + } + + ESP_LOGE(TAG, "esp_secure_cert_get_priv_key failed err:%d", err); + return CHIP_ERROR_INCORRECT_STATE; +} + +} // namespace DeviceLayer +} // namespace chip + +#endif // CONFIG_SEC_CERT_DAC_PROVIDER diff --git a/src/platform/ESP32/ESP32SecureCertDACProvider.h b/src/platform/ESP32/ESP32SecureCertDACProvider.h new file mode 100644 index 00000000000000..997695aec0ec74 --- /dev/null +++ b/src/platform/ESP32/ESP32SecureCertDACProvider.h @@ -0,0 +1,36 @@ +/* + * + * 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. + * 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 + +namespace chip { +namespace DeviceLayer { + +class ESP32SecureCertDACProvider : public Credentials::DeviceAttestationCredentialsProvider +{ +public: + ESP32SecureCertDACProvider() : Credentials::DeviceAttestationCredentialsProvider() {} + ~ESP32SecureCertDACProvider() {} + CHIP_ERROR GetCertificationDeclaration(MutableByteSpan & outBuffer) override; + CHIP_ERROR GetFirmwareInformation(MutableByteSpan & out_firmware_info_buffer) override; + CHIP_ERROR GetDeviceAttestationCert(MutableByteSpan & outBuffer) override; + CHIP_ERROR GetProductAttestationIntermediateCert(MutableByteSpan & outBuffer) override; + CHIP_ERROR SignWithDeviceAttestationKey(const ByteSpan & messageToSign, MutableByteSpan & outSignBuffer) override; +}; +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/Infineon/PSOC6/ConnectivityManagerImpl.cpp b/src/platform/Infineon/PSOC6/ConnectivityManagerImpl.cpp index a005d88f01fe5a..ef1d25072f5e39 100644 --- a/src/platform/Infineon/PSOC6/ConnectivityManagerImpl.cpp +++ b/src/platform/Infineon/PSOC6/ConnectivityManagerImpl.cpp @@ -176,12 +176,13 @@ CHIP_ERROR ConnectivityManagerImpl::_GetAndLogWiFiStatsCounters(void) { cy_wcm_associated_ap_info_t ap_info; cy_rslt_t result = CY_RSLT_SUCCESS; + CHIP_ERROR err = CHIP_NO_ERROR; result = cy_wcm_get_associated_ap_info(&ap_info); if (result != CY_RSLT_SUCCESS) { ChipLogError(DeviceLayer, "cy_wcm_get_associated_ap_info failed: %d", (int) result); - SuccessOrExit(CHIP_ERROR_INTERNAL); + SuccessOrExit(err = CHIP_ERROR_INTERNAL); } ChipLogProgress(DeviceLayer, @@ -193,7 +194,7 @@ CHIP_ERROR ConnectivityManagerImpl::_GetAndLogWiFiStatsCounters(void) ap_info.BSSID[0], ap_info.BSSID[1], ap_info.BSSID[2], ap_info.BSSID[3], ap_info.BSSID[4], ap_info.BSSID[5], ap_info.signal_strength, ap_info.channel, ap_info.channel_width); exit: - return CHIP_NO_ERROR; + return err; } // ==================== ConnectivityManager Platform Internal Methods ==================== diff --git a/src/platform/Infineon/PSOC6/DiagnosticDataProviderImpl.cpp b/src/platform/Infineon/PSOC6/DiagnosticDataProviderImpl.cpp index 076238a2f52899..b5635b6ead0353 100644 --- a/src/platform/Infineon/PSOC6/DiagnosticDataProviderImpl.cpp +++ b/src/platform/Infineon/PSOC6/DiagnosticDataProviderImpl.cpp @@ -193,7 +193,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiBssId(ByteSpan & value) if (result != CY_RSLT_SUCCESS) { ChipLogError(DeviceLayer, "cy_wcm_get_associated_ap_info failed: %d", (int) result); - SuccessOrExit(CHIP_ERROR_INTERNAL); + SuccessOrExit(err = CHIP_ERROR_INTERNAL); } memcpy(mWiFiMacAddress, ap_info.BSSID, CY_WCM_MAC_ADDR_LEN); value = ByteSpan(mWiFiMacAddress, CY_WCM_MAC_ADDR_LEN); @@ -214,7 +214,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiSecurityType(app::Clusters::WiFiNe if (result != CY_RSLT_SUCCESS) { ChipLogError(DeviceLayer, "cy_wcm_get_associated_ap_info failed: %d", (int) result); - SuccessOrExit(CHIP_ERROR_INTERNAL); + SuccessOrExit(err = CHIP_ERROR_INTERNAL); } if (ap_info.security == CY_WCM_SECURITY_OPEN) { @@ -289,7 +289,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiChannelNumber(uint16_t & channelNu if (result != CY_RSLT_SUCCESS) { ChipLogError(DeviceLayer, "cy_wcm_get_associated_ap_info failed: %d", (int) result); - SuccessOrExit(CHIP_ERROR_INTERNAL); + SuccessOrExit(err = CHIP_ERROR_INTERNAL); } channelNumber = ap_info.channel; @@ -307,7 +307,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiRssi(int8_t & rssi) if (result != CY_RSLT_SUCCESS) { ChipLogError(DeviceLayer, "cy_wcm_get_associated_ap_info failed: %d", (int) result); - SuccessOrExit(CHIP_ERROR_INTERNAL); + SuccessOrExit(err = CHIP_ERROR_INTERNAL); } rssi = ap_info.signal_strength; @@ -350,7 +350,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiCurrentMaxRate(uint64_t & currentM if (result != CY_RSLT_SUCCESS) { ChipLogError(DeviceLayer, "cy_wcm_get_wlan_statistics failed: %d", (int) result); - SuccessOrExit(CHIP_ERROR_INTERNAL); + SuccessOrExit(err = CHIP_ERROR_INTERNAL); } count = stats.tx_bitrate * PHYRATE_KPBS_BYTES_PER_SEC; currentMaxRate = static_cast(count); @@ -394,7 +394,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiPacketUnicastRxCount(uint32_t & pa if (result != CY_RSLT_SUCCESS) { ChipLogError(DeviceLayer, "cy_wcm_get_wlan_statistics failed: %d", (int) result); - SuccessOrExit(CHIP_ERROR_INTERNAL); + SuccessOrExit(err = CHIP_ERROR_INTERNAL); } count = stats.rx_packets; count -= mPacketUnicastRxCount; @@ -417,7 +417,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiPacketUnicastTxCount(uint32_t & pa if (result != CY_RSLT_SUCCESS) { ChipLogError(DeviceLayer, "cy_wcm_get_wlan_statistics failed: %d", (int) result); - SuccessOrExit(CHIP_ERROR_INTERNAL); + SuccessOrExit(err = CHIP_ERROR_INTERNAL); } count = stats.tx_packets; diff --git a/src/platform/android/java/chip/platform/NsdServiceFinderAndResolver.java b/src/platform/android/java/chip/platform/NsdServiceFinderAndResolver.java index 743c1b97e19602..7ee8f979e5ac33 100644 --- a/src/platform/android/java/chip/platform/NsdServiceFinderAndResolver.java +++ b/src/platform/android/java/chip/platform/NsdServiceFinderAndResolver.java @@ -132,7 +132,12 @@ public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode) { "Failed to resolve service '" + serviceInfo.getServiceName() + "': " + errorCode); chipMdnsCallback.handleServiceResolve( serviceInfo.getServiceName(), - serviceInfo.getServiceType(), + // Use the target service info since the resolved service info sometimes appends a + // "." at the front likely because it is trying to strip the service name out of it + // and something is missed. + // The target service info service type should be effectively the same as the + // resolved service info. + NsdServiceFinderAndResolver.this.targetServiceInfo.getServiceType(), null, null, 0, @@ -157,11 +162,18 @@ public void onServiceResolved(NsdServiceInfo serviceInfo) { "Resolved service '" + serviceInfo.getServiceName() + "' to " - + serviceInfo.getHost()); + + serviceInfo.getHost() + + ", type : " + + serviceInfo.getServiceType()); // TODO: Find out if DNS-SD results for Android should contain interface ID chipMdnsCallback.handleServiceResolve( serviceInfo.getServiceName(), - serviceInfo.getServiceType(), + // Use the target service info since the resolved service info sometimes appends a + // "." at the front likely because it is trying to strip the service name out of it + // and something is missed. + // The target service info service type should be effectively the same as the + // resolved service info. + NsdServiceFinderAndResolver.this.targetServiceInfo.getServiceType(), serviceInfo.getHost().getHostName(), serviceInfo.getHost().getHostAddress(), serviceInfo.getPort(), diff --git a/src/platform/bouffalolab/BL602/BUILD.gn b/src/platform/bouffalolab/BL602/BUILD.gn index be0dd88d664852..64846e02898547 100644 --- a/src/platform/bouffalolab/BL602/BUILD.gn +++ b/src/platform/bouffalolab/BL602/BUILD.gn @@ -60,4 +60,11 @@ static_library("BL602") { "KeyValueStoreManagerImpl.cpp", "KeyValueStoreManagerImpl.h", ] + + sources += [ + "${chip_root}/src/credentials/CHIPCert.h", + "${chip_root}/src/credentials/DeviceAttestationCredsProvider.h", + "../common/FactoryDataProvider.cpp", + "../common/FactoryDataProvider.h", + ] } diff --git a/src/platform/bouffalolab/common/FactoryDataProvider.cpp b/src/platform/bouffalolab/common/FactoryDataProvider.cpp new file mode 100644 index 00000000000000..d659afc6257d1e --- /dev/null +++ b/src/platform/bouffalolab/common/FactoryDataProvider.cpp @@ -0,0 +1,711 @@ +/* + * + * 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. + */ + +#include "FactoryDataProvider.h" +#include "CHIPDevicePlatformConfig.h" +#include +#include + +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE +#include +#else +#include +extern "C" { +#include +} +#endif +#include +extern "C" { +#include +} +#include + +namespace chip { +namespace DeviceLayer { + +CHIP_ERROR LoadKeypairFromRaw(ByteSpan privateKey, ByteSpan publicKey, Crypto::P256Keypair & keypair) +{ + Crypto::P256SerializedKeypair serializedKeypair; + ReturnErrorOnFailure(serializedKeypair.SetLength(privateKey.size() + publicKey.size())); + memcpy(serializedKeypair.Bytes(), publicKey.data(), publicKey.size()); + memcpy(serializedKeypair.Bytes() + publicKey.size(), privateKey.data(), privateKey.size()); + return keypair.Deserialize(serializedKeypair); +} + +CHIP_ERROR FactoryDataProvider::Init() +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + if (false == mfd_init()) + { + return CHIP_ERROR_PERSISTED_STORAGE_FAILED; + } +#endif + return CHIP_NO_ERROR; +} + +CHIP_ERROR FactoryDataProvider::GetCertificationDeclaration(MutableByteSpan & outBuffer) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getCd(outBuffer.data(), outBuffer.size()); + if (len > 0) + { + outBuffer.reduce_size(len); + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + + static const unsigned char Chip_Test_CD_130D_f001_der[539] = { + 0x30, 0x81, 0xe9, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x02, 0xa0, 0x81, 0xdb, 0x30, 0x81, 0xd8, + 0x02, 0x01, 0x03, 0x31, 0x0d, 0x30, 0x0b, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x30, 0x45, + 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x01, 0xa0, 0x38, 0x04, 0x36, 0x15, 0x24, 0x00, 0x01, 0x25, + 0x01, 0x0d, 0x13, 0x36, 0x02, 0x05, 0x01, 0xf0, 0x18, 0x25, 0x03, 0x34, 0x12, 0x2c, 0x04, 0x13, 0x5a, 0x49, 0x47, 0x32, + 0x30, 0x31, 0x34, 0x31, 0x5a, 0x42, 0x33, 0x33, 0x30, 0x30, 0x30, 0x31, 0x2d, 0x32, 0x34, 0x24, 0x05, 0x00, 0x24, 0x06, + 0x00, 0x25, 0x07, 0x76, 0x98, 0x24, 0x08, 0x00, 0x18, 0x31, 0x7d, 0x30, 0x7b, 0x02, 0x01, 0x03, 0x80, 0x14, 0x62, 0xfa, + 0x82, 0x33, 0x59, 0xac, 0xfa, 0xa9, 0x96, 0x3e, 0x1c, 0xfa, 0x14, 0x0a, 0xdd, 0xf5, 0x04, 0xf3, 0x71, 0x60, 0x30, 0x0b, + 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, + 0x04, 0x03, 0x02, 0x04, 0x47, 0x30, 0x45, 0x02, 0x21, 0x00, 0xd9, 0x91, 0xc9, 0xce, 0xaf, 0x8e, 0x81, 0x56, 0x10, 0x63, + 0x1d, 0x1d, 0x69, 0x3d, 0x0c, 0xbb, 0xb6, 0x17, 0x6e, 0x0b, 0x91, 0xba, 0x7b, 0x23, 0x57, 0xdc, 0x50, 0x80, 0x23, 0xc9, + 0x8e, 0xd0, 0x02, 0x20, 0x34, 0x5d, 0xeb, 0xd7, 0x38, 0xca, 0x8f, 0xfb, 0xa8, 0x4e, 0x8b, 0xe9, 0x5b, 0x66, 0x8b, 0x15, + 0xb9, 0x0a, 0x9a, 0xf2, 0x11, 0x82, 0x0a, 0x7a, 0xf2, 0x9f, 0x3b, 0xdd, 0xd8, 0x15, 0x51, 0x07 + }; + + ReturnErrorOnFailure(CopySpanToMutableSpan(ByteSpan(Chip_Test_CD_130D_f001_der), outBuffer)); + + return CHIP_NO_ERROR; +#endif +} + +CHIP_ERROR FactoryDataProvider::GetFirmwareInformation(MutableByteSpan & out_firmware_info_buffer) +{ + out_firmware_info_buffer.reduce_size(0); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR FactoryDataProvider::GetDeviceAttestationCert(MutableByteSpan & outBuffer) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getDacCert(outBuffer.data(), outBuffer.size()); + if (len > 0) + { + outBuffer.reduce_size(len); + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + static const uint8_t Dac_Cert_Array[] = { + 0x30, 0x82, 0x01, 0xd0, 0x30, 0x82, 0x01, 0x76, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x08, 0x68, 0xa3, 0xb6, 0x6e, 0x27, + 0x6b, 0x5b, 0x29, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x30, 0x30, 0x31, 0x18, 0x30, + 0x16, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0f, 0x4d, 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, + 0x50, 0x41, 0x49, 0x31, 0x14, 0x30, 0x12, 0x06, 0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0xa2, 0x7c, 0x02, 0x01, 0x0c, + 0x04, 0x31, 0x33, 0x30, 0x44, 0x30, 0x20, 0x17, 0x0d, 0x32, 0x31, 0x30, 0x36, 0x32, 0x38, 0x31, 0x34, 0x32, 0x33, 0x34, + 0x33, 0x5a, 0x18, 0x0f, 0x39, 0x39, 0x39, 0x39, 0x31, 0x32, 0x33, 0x31, 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5a, 0x30, + 0x48, 0x31, 0x1a, 0x30, 0x18, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x11, 0x4d, 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, + 0x65, 0x73, 0x74, 0x20, 0x44, 0x41, 0x43, 0x20, 0x30, 0x31, 0x14, 0x30, 0x12, 0x06, 0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, + 0x82, 0xa2, 0x7c, 0x02, 0x01, 0x0c, 0x04, 0x31, 0x33, 0x30, 0x44, 0x31, 0x14, 0x30, 0x12, 0x06, 0x0a, 0x2b, 0x06, 0x01, + 0x04, 0x01, 0x82, 0xa2, 0x7c, 0x02, 0x02, 0x0c, 0x04, 0x46, 0x30, 0x30, 0x31, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, + 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, + 0xd8, 0x19, 0x93, 0xac, 0xf1, 0xc8, 0x63, 0xbb, 0x04, 0x2b, 0x8c, 0x2e, 0x4d, 0xe4, 0x08, 0x39, 0x4f, 0xf9, 0x3e, 0xa3, + 0x89, 0x19, 0x96, 0x8c, 0x22, 0xa1, 0x0f, 0xeb, 0x4c, 0x20, 0x2a, 0x8a, 0x12, 0xff, 0xe4, 0xe6, 0x09, 0x4f, 0x13, 0x4b, + 0xa8, 0x35, 0x53, 0x2f, 0xa4, 0x9d, 0x8e, 0x79, 0x8c, 0x07, 0x01, 0x5c, 0x73, 0xff, 0x0d, 0x1c, 0x34, 0xfe, 0x14, 0x7f, + 0xbe, 0xc6, 0x70, 0xf8, 0xa3, 0x60, 0x30, 0x5e, 0x30, 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x02, + 0x30, 0x00, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x01, 0x01, 0xff, 0x04, 0x04, 0x03, 0x02, 0x07, 0x80, 0x30, 0x1d, + 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x63, 0x9f, 0xbd, 0x91, 0x8c, 0x90, 0xed, 0x7a, 0xbf, 0x64, 0xcd, + 0xe8, 0x2e, 0x13, 0x10, 0x8e, 0xee, 0x5d, 0x6f, 0x8e, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, + 0x80, 0x14, 0x3a, 0xb2, 0xfa, 0x06, 0x27, 0xcc, 0x4a, 0xdc, 0x84, 0xac, 0x9c, 0x95, 0x1e, 0x8c, 0x8f, 0xdc, 0x4c, 0x0d, + 0xec, 0x01, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x03, 0x48, 0x00, 0x30, 0x45, 0x02, + 0x21, 0x00, 0xd6, 0xc3, 0xab, 0x6d, 0xbd, 0xd0, 0xa2, 0x45, 0xbc, 0xcf, 0xb7, 0x2d, 0x6f, 0x5e, 0xd1, 0xbe, 0xd7, 0xd4, + 0xea, 0xca, 0x9e, 0xf2, 0xa1, 0x09, 0x77, 0xc3, 0x43, 0xa2, 0x29, 0x67, 0x63, 0x3d, 0x02, 0x20, 0x2b, 0xb8, 0x39, 0xf8, + 0x31, 0xeb, 0x83, 0x31, 0xe2, 0x31, 0xeb, 0xd2, 0x5c, 0x82, 0xe4, 0xb7, 0x14, 0xfd, 0x62, 0x97, 0x1f, 0x64, 0xff, 0x51, + 0x43, 0x83, 0xb4, 0xa9, 0x19, 0x6f, 0x96, 0xcf + }; + + ReturnErrorOnFailure(CopySpanToMutableSpan(ByteSpan(Dac_Cert_Array), outBuffer)); + + return CHIP_NO_ERROR; +#endif +} + +CHIP_ERROR FactoryDataProvider::GetProductAttestationIntermediateCert(MutableByteSpan & outBuffer) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getPaiCert(outBuffer.data(), outBuffer.size()); + if (len > 0) + { + outBuffer.reduce_size(len); + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + static const uint8_t Pai_Cert_Array[] = { + 0x30, 0x82, 0x01, 0xa7, 0x30, 0x82, 0x01, 0x4e, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x08, 0x01, 0x0f, 0x96, 0xa1, 0x42, + 0x5c, 0xe7, 0x0c, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x30, 0x1a, 0x31, 0x18, 0x30, + 0x16, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0f, 0x4d, 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, + 0x50, 0x41, 0x41, 0x30, 0x20, 0x17, 0x0d, 0x32, 0x31, 0x30, 0x36, 0x32, 0x38, 0x31, 0x34, 0x32, 0x33, 0x34, 0x33, 0x5a, + 0x18, 0x0f, 0x39, 0x39, 0x39, 0x39, 0x31, 0x32, 0x33, 0x31, 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5a, 0x30, 0x30, 0x31, + 0x18, 0x30, 0x16, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0f, 0x4d, 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, 0x73, + 0x74, 0x20, 0x50, 0x41, 0x49, 0x31, 0x14, 0x30, 0x12, 0x06, 0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0xa2, 0x7c, 0x02, + 0x01, 0x0c, 0x04, 0x31, 0x33, 0x30, 0x44, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, + 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0xdb, 0xbe, 0xac, 0xd5, 0xf3, 0xd6, + 0x32, 0x36, 0x04, 0x00, 0xe0, 0xa1, 0x16, 0x8d, 0xbf, 0x0c, 0x74, 0x8f, 0xdb, 0xd7, 0x03, 0x7f, 0x8c, 0x4e, 0x65, 0x58, + 0x27, 0x2f, 0xfa, 0x2d, 0x64, 0x61, 0x4e, 0xe5, 0x72, 0xb8, 0xa5, 0x87, 0x8c, 0x15, 0xc7, 0x25, 0x55, 0x47, 0xc4, 0xc9, + 0x62, 0xda, 0xd7, 0x02, 0x64, 0xd2, 0x84, 0x2d, 0xe8, 0x2d, 0xf1, 0x69, 0xcb, 0x56, 0x42, 0x86, 0xf8, 0x55, 0xa3, 0x66, + 0x30, 0x64, 0x30, 0x12, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, 0xff, 0x02, + 0x01, 0x00, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x01, 0x01, 0xff, 0x04, 0x04, 0x03, 0x02, 0x01, 0x06, 0x30, 0x1d, + 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x3a, 0xb2, 0xfa, 0x06, 0x27, 0xcc, 0x4a, 0xdc, 0x84, 0xac, 0x9c, + 0x95, 0x1e, 0x8c, 0x8f, 0xdc, 0x4c, 0x0d, 0xec, 0x01, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, + 0x80, 0x14, 0x78, 0x5c, 0xe7, 0x05, 0xb8, 0x6b, 0x8f, 0x4e, 0x6f, 0xc7, 0x93, 0xaa, 0x60, 0xcb, 0x43, 0xea, 0x69, 0x68, + 0x82, 0xd5, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x03, 0x47, 0x00, 0x30, 0x44, 0x02, + 0x20, 0x0f, 0x12, 0x2f, 0x8c, 0x83, 0xab, 0xdd, 0x35, 0x53, 0xbc, 0xcd, 0xe5, 0xec, 0x2d, 0x84, 0x99, 0x24, 0xb5, 0xe0, + 0x1a, 0x54, 0x45, 0x37, 0x78, 0xba, 0x88, 0xa8, 0x51, 0x18, 0xf8, 0x0e, 0x05, 0x02, 0x20, 0x59, 0x84, 0x16, 0xe1, 0xd1, + 0xee, 0x5e, 0xc6, 0x50, 0xcd, 0x5d, 0x58, 0x47, 0xb8, 0x10, 0x82, 0xa9, 0xa2, 0x2f, 0x4f, 0x31, 0x7e, 0xc7, 0x5d, 0xb6, + 0x6c, 0xc9, 0xc5, 0x70, 0xb8, 0x1e, 0xd8 + }; + + ReturnErrorOnFailure(CopySpanToMutableSpan(ByteSpan(Pai_Cert_Array), outBuffer)); + + return CHIP_NO_ERROR; +#endif +} + +CHIP_ERROR FactoryDataProvider::SignWithDeviceAttestationKey(const ByteSpan & messageToSign, MutableByteSpan & outSignBuffer) +{ + Crypto::P256ECDSASignature signature; + Crypto::P256Keypair keypair; + chip::Crypto::P256PublicKey dacPublicKey; + + if (outSignBuffer.size() < signature.Capacity()) + { + return CHIP_ERROR_BUFFER_TOO_SMALL; + } + +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + + uint32_t dacCertSize = 0, dacPrivateKeySize = 0; + uint8_t * pDacCertPtr = mfd_getDacCertPtr(&dacCertSize); + uint8_t * pDacPrivateKeyPtr = mfd_getDacPrivateKeyPtr(&dacPrivateKeySize); + + if (NULL == pDacCertPtr || 0 == dacCertSize || NULL == pDacPrivateKeyPtr || 0 == dacPrivateKeySize) + { + outSignBuffer.reduce_size(0); + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + ByteSpan dacCert(pDacCertPtr, dacCertSize); + ByteSpan dacPrivateKey(pDacPrivateKeyPtr, dacPrivateKeySize); + +#else + static const uint8_t Dac_PrivateKey_Array[] = { 0x65, 0x11, 0x78, 0x2e, 0xf7, 0xcd, 0x30, 0x59, 0xbd, 0x3a, 0xdd, + 0x44, 0x6f, 0xc5, 0xdd, 0x92, 0xe5, 0xd8, 0x3c, 0x56, 0x9d, 0x67, + 0x7a, 0x29, 0xc7, 0xe9, 0xa7, 0x8f, 0x67, 0xc5, 0x5f, 0xf2 }; + + uint8_t dac_cert_array[Credentials::kMaxDERCertLength]; + uint8_t dac_cert_private_key_array[sizeof(Dac_PrivateKey_Array)]; + MutableByteSpan dacCert(dac_cert_array, Credentials::kMaxDERCertLength), + dacPrivateKey(dac_cert_private_key_array, sizeof(dac_cert_private_key_array)); + + ReturnErrorOnFailure(CopySpanToMutableSpan(ByteSpan(Dac_PrivateKey_Array), dacPrivateKey)); + ReturnErrorOnFailure(GetDeviceAttestationCert(dacCert)); + +#endif + + ReturnErrorOnFailure(chip::Crypto::ExtractPubkeyFromX509Cert(dacCert, dacPublicKey)); + + ReturnErrorOnFailure(LoadKeypairFromRaw(dacPrivateKey, ByteSpan(dacPublicKey.Bytes(), dacPublicKey.Length()), keypair)); + ReturnErrorOnFailure(keypair.ECDSA_sign_msg(messageToSign.data(), messageToSign.size(), signature)); + + ReturnErrorOnFailure(CopySpanToMutableSpan(ByteSpan(signature.Bytes(), signature.Length()), outSignBuffer)); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR FactoryDataProvider::GetSetupDiscriminator(uint16_t & setupDiscriminator) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getDiscriminator((uint8_t *) &setupDiscriminator, sizeof(setupDiscriminator)); + if (len > 0) + { + setupDiscriminator = 0xfff & setupDiscriminator; + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + setupDiscriminator = 3840; + + return CHIP_NO_ERROR; +#endif +} + +CHIP_ERROR FactoryDataProvider::SetSetupDiscriminator(uint16_t setupDiscriminator) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR FactoryDataProvider::GetSpake2pIterationCount(uint32_t & iterationCount) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getSapke2It((uint8_t *) &iterationCount, sizeof(iterationCount)); + if (len > 0) + { + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + iterationCount = 1000; + + return CHIP_NO_ERROR; +#endif +} + +CHIP_ERROR FactoryDataProvider::GetSpake2pSalt(MutableByteSpan & saltBuf) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getSapke2Salt(saltBuf.data(), saltBuf.size()); + if (len > 0) + { + saltBuf.reduce_size(len); + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + static const char spake2pSalt[] = "U1BBS0UyUCBLZXkgU2FsdA=="; + uint32_t aSpake2pSaltLen; + + if (!utils_base64decode((const uint8_t *) spake2pSalt, sizeof(spake2pSalt) - 1, saltBuf.size(), saltBuf.data(), + &aSpake2pSaltLen)) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + saltBuf = MutableByteSpan(saltBuf.data(), aSpake2pSaltLen); + + return CHIP_NO_ERROR; +#endif +} + +CHIP_ERROR FactoryDataProvider::GetSpake2pVerifier(MutableByteSpan & verifierBuf, size_t & verifierLen) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getSapke2Verifier(verifierBuf.data(), verifierBuf.size()); + if (len > 0) + { + verifierLen = len; + verifierBuf.reduce_size(len); + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + static const char spake2pVerifier[] = "jdf0KbjmAwujViR8WckvvklJzE0UL+uIOiIjTtb3a5kE/" + "WdbVWhmDFSSjLqFhiiCILxXQ4NVO3YBWTdkERnTlXbFmx+T/32FMRpZLPz8yqFXyALytJW7ZJfArBz0/CP9hA=="; + uint32_t aSpake2pVerifierLen; + + if (!utils_base64decode((const uint8_t *) spake2pVerifier, sizeof(spake2pVerifier) - 1, verifierBuf.size(), verifierBuf.data(), + &aSpake2pVerifierLen)) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + verifierBuf = MutableByteSpan(verifierBuf.data(), aSpake2pVerifierLen); + verifierLen = aSpake2pVerifierLen; + + return CHIP_NO_ERROR; +#endif +} + +CHIP_ERROR FactoryDataProvider::GetSetupPasscode(uint32_t & setupPasscode) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getPasscode((uint8_t *) &setupPasscode, sizeof(setupPasscode)); + if (len > 0) + { + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + setupPasscode = 49808401; + return CHIP_NO_ERROR; +#endif +} + +CHIP_ERROR FactoryDataProvider::SetSetupPasscode(uint32_t setupPasscode) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR FactoryDataProvider::GetVendorName(char * buf, size_t bufSize) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getVendorName(buf, bufSize); + if (len > 0) + { + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + static const char vendorName[] = "Bouffalo Lab"; + strncpy(buf, vendorName, bufSize); + + return CHIP_NO_ERROR; +#endif +} + +CHIP_ERROR FactoryDataProvider::GetVendorId(uint16_t & vendorId) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getVendorId((uint8_t *) &vendorId, sizeof(vendorId)); + if (len > 0) + { + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + vendorId = 0x130D; + return CHIP_NO_ERROR; +#endif +} + +CHIP_ERROR FactoryDataProvider::GetProductName(char * buf, size_t bufSize) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getProductName(buf, bufSize); + if (len > 0) + { + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + strncpy(buf, CHIP_BLE_DEVICE_NAME, bufSize); + + return CHIP_NO_ERROR; +#endif +} + +CHIP_ERROR FactoryDataProvider::GetProductId(uint16_t & productId) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getProductId((uint8_t *) &productId, sizeof(productId)); + if (len > 0) + { + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + productId = 0xf001; + + return CHIP_NO_ERROR; +#endif +} + +CHIP_ERROR FactoryDataProvider::GetPartNumber(char * buf, size_t bufSize) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getPartNumber(buf, bufSize); + if (len > 0) + { + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; +#endif +} + +CHIP_ERROR FactoryDataProvider::GetProductURL(char * buf, size_t bufSize) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getProductUrl(buf, bufSize); + if (len > 0) + { + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; +#endif +} + +CHIP_ERROR FactoryDataProvider::GetProductLabel(char * buf, size_t bufSize) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getProductLabel(buf, bufSize); + if (len > 0) + { + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; +#endif +} + +CHIP_ERROR FactoryDataProvider::GetSerialNumber(char * buf, size_t bufSize) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getSerialNumber(buf, bufSize); + if (len > 0) + { + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + strncpy(buf, CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER, bufSize); + + return CHIP_NO_ERROR; +#endif +} + +CHIP_ERROR FactoryDataProvider::GetManufacturingDate(uint16_t & year, uint8_t & month, uint8_t & day) +{ +#define OS_YEAR \ + ((((int) (__DATE__[7] - '0') * 10 + (int) (__DATE__[8] - '0')) * 10 + (int) (__DATE__[9] - '0')) * 10 + \ + (int) (__DATE__[10] - '0')) + +#define OS_MONTH \ + (__DATE__[2] == 'n' ? (__DATE__[1] == 'a' ? 1 : 6) \ + : __DATE__[2] == 'b' ? 2 \ + : __DATE__[2] == 'r' ? (__DATE__[0] == 'M' ? 3 : 4) \ + : __DATE__[2] == 'y' ? 5 \ + : __DATE__[2] == 'l' \ + ? 7 \ + : __DATE__[2] == 'g' ? 8 \ + : __DATE__[2] == 'p' ? 9 : __DATE__[2] == 't' ? 10 : __DATE__[2] == 'v' ? 11 : 12) + +#define OS_DAY ((__DATE__[4] == ' ' ? 0 : __DATE__[4] - '0') * 10 + (__DATE__[5] - '0')) + +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + if (mfd_getManufacturingDate(&year, &month, &day)) + { + return CHIP_NO_ERROR; + } +#endif + + year = (uint16_t) OS_YEAR; + month = (uint8_t) OS_MONTH; + day = (uint8_t) OS_DAY; + + return CHIP_NO_ERROR; +} + +CHIP_ERROR FactoryDataProvider::GetHardwareVersion(uint16_t & hardwareVersion) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getHardwareVersion((uint8_t *) &hardwareVersion, sizeof(hardwareVersion)); + if (len > 0) + { + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + hardwareVersion = CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION; + + return CHIP_NO_ERROR; +#endif +} + +CHIP_ERROR FactoryDataProvider::GetHardwareVersionString(char * buf, size_t bufSize) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getHardwareVersionString(buf, bufSize); + if (len > 0) + { + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + strncpy(buf, CHIP_DEVICE_CONFIG_DEFAULT_DEVICE_HARDWARE_VERSION_STRING, bufSize); + + return CHIP_NO_ERROR; +#endif +} + +CHIP_ERROR FactoryDataProvider::GetRotatingDeviceIdUniqueId(MutableByteSpan & uniqueIdSpan) +{ +#if CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + int len = 0; + + len = mfd_getRotatingDeviceIdUniqueId(uniqueIdSpan.data(), uniqueIdSpan.size()); + if (len > 0) + { + return CHIP_NO_ERROR; + } + else if (0 == len) + { + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + return CHIP_ERROR_BUFFER_TOO_SMALL; +#else + constexpr uint8_t uniqueId[] = CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID; + + uniqueIdSpan = MutableByteSpan((uint8_t *) uniqueId, sizeof(uniqueId)); + + return CHIP_NO_ERROR; +#endif +} + +extern "C" bool spake2pUtils_test(uint32_t aIt, uint8_t * aSalt, uint32_t aSaltLen, uint8_t * aSaltVerifier, + uint32_t * pSaltVerifierLen, uint32_t pincode) +{ + chip::Crypto::Spake2pVerifier verifier; + ByteSpan salt(aSalt, aSaltLen); + chip::MutableByteSpan serializedVerifierSpan(aSaltVerifier, *pSaltVerifierLen); + + VerifyOrReturnValue(aIt >= chip::Crypto::kSpake2p_Min_PBKDF_Iterations && aIt <= chip::Crypto::kSpake2p_Max_PBKDF_Iterations, + false); + VerifyOrReturnValue(aSalt && aSaltLen >= chip::Crypto::kSpake2p_Min_PBKDF_Salt_Length && + aSaltLen <= chip::Crypto::kSpake2p_Max_PBKDF_Salt_Length, + false); + VerifyOrReturnValue(aSaltVerifier && *pSaltVerifierLen >= chip::Crypto::kSpake2p_VerifierSerialized_Length, false); + + VerifyOrReturnValue(CHIP_NO_ERROR == verifier.Generate(aIt, salt, pincode), false); + + VerifyOrReturnValue(CHIP_NO_ERROR == verifier.Serialize(serializedVerifierSpan), false); + + *pSaltVerifierLen = serializedVerifierSpan.size(); + + return true; +} + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/bouffalolab/common/FactoryDataProvider.h b/src/platform/bouffalolab/common/FactoryDataProvider.h new file mode 100644 index 00000000000000..58ea373cd935ed --- /dev/null +++ b/src/platform/bouffalolab/common/FactoryDataProvider.h @@ -0,0 +1,76 @@ +/* + * + * 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. + */ + +#pragma once + +#include +#include +#include + +#include + +namespace chip { +namespace DeviceLayer { + +class FactoryDataProvider : public chip::Credentials::DeviceAttestationCredentialsProvider, + public CommissionableDataProvider, + public DeviceInstanceInfoProvider +{ +public: + CHIP_ERROR Init(); + + // ===== Members functions that implement the DeviceAttestationCredentialsProvider + CHIP_ERROR GetCertificationDeclaration(MutableByteSpan & outBuffer) override; + CHIP_ERROR GetFirmwareInformation(MutableByteSpan & out_firmware_info_buffer) override; + CHIP_ERROR GetDeviceAttestationCert(MutableByteSpan & outBuffer) override; + CHIP_ERROR GetProductAttestationIntermediateCert(MutableByteSpan & outBuffer) override; + CHIP_ERROR SignWithDeviceAttestationKey(const ByteSpan & messageToSign, MutableByteSpan & outSignBuffer) override; + + // ===== Members functions that implement the CommissionableDataProvider + CHIP_ERROR GetSetupDiscriminator(uint16_t & setupDiscriminator) override; + CHIP_ERROR SetSetupDiscriminator(uint16_t setupDiscriminator) override; + CHIP_ERROR GetSpake2pIterationCount(uint32_t & iterationCount) override; + CHIP_ERROR GetSpake2pSalt(MutableByteSpan & saltBuf) override; + CHIP_ERROR GetSpake2pVerifier(MutableByteSpan & verifierBuf, size_t & verifierLen) override; + CHIP_ERROR GetSetupPasscode(uint32_t & setupPasscode) override; + CHIP_ERROR SetSetupPasscode(uint32_t setupPasscode) override; + + // ===== Members functions that implement the DeviceInstanceInfoProvider + CHIP_ERROR GetVendorName(char * buf, size_t bufSize) override; + CHIP_ERROR GetVendorId(uint16_t & vendorId) override; + CHIP_ERROR GetProductName(char * buf, size_t bufSize) override; + CHIP_ERROR GetProductId(uint16_t & productId) override; + CHIP_ERROR GetPartNumber(char * buf, size_t bufSize) override; + CHIP_ERROR GetProductURL(char * buf, size_t bufSize) override; + CHIP_ERROR GetProductLabel(char * buf, size_t bufSize) override; + CHIP_ERROR GetSerialNumber(char * buf, size_t bufSize) override; + CHIP_ERROR GetManufacturingDate(uint16_t & year, uint8_t & month, uint8_t & day) override; + CHIP_ERROR GetHardwareVersion(uint16_t & hardwareVersion) override; + CHIP_ERROR GetHardwareVersionString(char * buf, size_t bufSize) override; + CHIP_ERROR GetRotatingDeviceIdUniqueId(MutableByteSpan & uniqueIdSpan) override; + +private: +#if !CONFIG_BOUFFALOLAB_FACTORY_DATA_ENABLE + uint8_t mSpake2pSalt[32]; + uint32_t mSpake2pSaltLen; + uint8_t mSpake2pVerifier[100]; + uint32_t mSpake2pVerifierLen; +#endif +}; + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/qpg/qpgConfig.cpp b/src/platform/qpg/qpgConfig.cpp index cb104485bedfca..562ed7d837d3bb 100644 --- a/src/platform/qpg/qpgConfig.cpp +++ b/src/platform/qpg/qpgConfig.cpp @@ -40,18 +40,8 @@ namespace Internal { CHIP_ERROR QPGConfig::Init() { - const qvStatus_t status = qvCHIP_KvsInit(); - - if (QV_STATUS_NO_ERROR == status) - { - return CHIP_NO_ERROR; - } - else if (QV_STATUS_BUFFER_TOO_SMALL == status) - { - return CHIP_ERROR_BUFFER_TOO_SMALL; - } - - return CHIP_ERROR_INTERNAL; + // KVS will already be initialized in qvCHIP_Init before this is called from CHIP stack + return CHIP_NO_ERROR; } CHIP_ERROR QPGConfig::ReadConfigValue(Key key, bool & val) diff --git a/src/platform/silabs/efr32/BUILD.gn b/src/platform/silabs/efr32/BUILD.gn index 5d5bde61f33f4b..1f43416c8013bb 100644 --- a/src/platform/silabs/efr32/BUILD.gn +++ b/src/platform/silabs/efr32/BUILD.gn @@ -131,7 +131,7 @@ static_library("efr32") { "wifi/wifi_config.h", ] - if (use_wf200 || use_rs9116) { + if (use_wf200 || use_rs9116 || use_SiWx917) { sources += [ "wifi/dhcp_client.cpp", "wifi/dhcp_client.h", diff --git a/src/platform/tests/TestDnssd.cpp b/src/platform/tests/TestDnssd.cpp index fe7312fff8d7c9..4a0437ce35bfb6 100644 --- a/src/platform/tests/TestDnssd.cpp +++ b/src/platform/tests/TestDnssd.cpp @@ -164,8 +164,8 @@ int TestDnssd() // This will stop the event loop above, and wait till it has actually stopped // (i.e exited RunEventLoop()). // - chip::Dnssd::ChipDnssdShutdown(); chip::DeviceLayer::PlatformMgr().StopEventLoopTask(); + chip::Dnssd::ChipDnssdShutdown(); chip::DeviceLayer::PlatformMgr().Shutdown(); shutdown = true; @@ -181,8 +181,8 @@ int TestDnssd() if (!shutdown) { - chip::Dnssd::ChipDnssdShutdown(); chip::DeviceLayer::PlatformMgr().StopEventLoopTask(); + chip::Dnssd::ChipDnssdShutdown(); chip::DeviceLayer::PlatformMgr().Shutdown(); } chip::Platform::MemoryShutdown(); diff --git a/src/protocols/secure_channel/RendezvousParameters.h b/src/protocols/secure_channel/RendezvousParameters.h index ad0721e232d864..e563166f8acff0 100644 --- a/src/protocols/secure_channel/RendezvousParameters.h +++ b/src/protocols/secure_channel/RendezvousParameters.h @@ -40,8 +40,6 @@ class RendezvousParameters public: RendezvousParameters() = default; - bool IsController() const { return HasDiscriminator() || HasConnectionObject(); } - bool HasSetupPINCode() const { return mSetupPINCode != 0; } uint32_t GetSetupPINCode() const { return mSetupPINCode; } RendezvousParameters & SetSetupPINCode(uint32_t setupPINCode) diff --git a/src/python_testing/TC_CGEN_2_4.py b/src/python_testing/TC_CGEN_2_4.py index c522cb07aacbc6..7ef128a787dfe3 100644 --- a/src/python_testing/TC_CGEN_2_4.py +++ b/src/python_testing/TC_CGEN_2_4.py @@ -32,7 +32,7 @@ class TC_CGEN_2_4(MatterBaseTest): def OpenCommissioningWindow(self) -> int: try: pin, code = self.th1.OpenCommissioningWindow( - nodeid=self.dut_node_id, timeout=600, iteration=10000, discriminator=self.matter_test_config.discriminator, option=1) + nodeid=self.dut_node_id, timeout=600, iteration=10000, discriminator=self.matter_test_config.discriminator[0], option=1) time.sleep(5) return pin, code @@ -51,7 +51,7 @@ async def CommissionToStageSendCompleteAndCleanup( self.th2.SetTestCommissionerPrematureCompleteAfter(stage) success, errcode = self.th2.CommissionOnNetwork( nodeId=self.dut_node_id, setupPinCode=pin, - filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=self.matter_test_config.discriminator) + filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=self.matter_test_config.discriminator[0]) logging.info('Commissioning complete done. Successful? {}, errorcode = {}'.format(success, errcode)) asserts.assert_false(success, 'Commissioning complete did not error as expected') asserts.assert_true(errcode.sdk_part == expectedErrorPart, 'Unexpected error type returned from CommissioningComplete') @@ -91,7 +91,7 @@ async def test_TC_CGEN_2_4(self): self.th2.ResetTestCommissioner() success, errcode = self.th2.CommissionOnNetwork( nodeId=self.dut_node_id, setupPinCode=pin, - filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=self.matter_test_config.discriminator) + filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=self.matter_test_config.discriminator[0]) logging.info('Commissioning complete done. Successful? {}, errorcode = {}'.format(success, errcode)) logging.info('Step 17 - TH1 sends an arm failsafe') diff --git a/third_party/bouffalolab/bl602/bl_iot_sdk.gni b/third_party/bouffalolab/bl602/bl_iot_sdk.gni index 85cf926562b4fa..ea44002bccf38d 100644 --- a/third_party/bouffalolab/bl602/bl_iot_sdk.gni +++ b/third_party/bouffalolab/bl602/bl_iot_sdk.gni @@ -475,6 +475,7 @@ template("bl_iot_sdk") { "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/aes.c", "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/asn1parse.c", "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/asn1write.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/base64.c", "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/bignum.c", "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/ccm.c", "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/cipher.c", @@ -491,6 +492,7 @@ template("bl_iot_sdk") { "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/hmac_drbg.c", "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/md.c", "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/oid.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/pem.c", "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/pk.c", "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/pk_wrap.c", "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/pkcs5.c", @@ -499,7 +501,9 @@ template("bl_iot_sdk") { "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/platform_util.c", "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/sha256.c", "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/sha512.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/x509.c", "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/x509_create.c", + "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/x509_crt.c", "${bl_iot_sdk_root}/components/security/mbedtls_lts/mbedtls/library/x509write_csr.c", ] @@ -607,6 +611,7 @@ template("bl_iot_sdk") { ] public_configs = [ ":${sdk_target_name}_config", + ":${sdk_target_name}_config_hosal", ":${sdk_target_name}_ble_config", ] @@ -932,12 +937,24 @@ template("bl_iot_sdk") { ] } + config("${sdk_target_name}_config_factory_data") { + include_dirs = [ "${bl_iot_sdk_root}/components/network/matter/matter_factory_data/include" ] + } + + source_set("${sdk_target_name}_factory_data") { + libs = [ "${bl_iot_sdk_root}/components/network/matter/matter_factory_data/lib/libmatter_factory_data.a" ] + + configs += [ ":${sdk_target_name}_config" ] + public_configs = [ ":${sdk_target_name}_config_factory_data" ] + } + group(sdk_target_name) { public_deps = [ ":${sdk_target_name}_BSP_Driver", ":${sdk_target_name}_bl602_freertos", ":${sdk_target_name}_blcrypto_suite", ":${sdk_target_name}_ble", + ":${sdk_target_name}_factory_data", ":${sdk_target_name}_fs", ":${sdk_target_name}_hosal", ":${sdk_target_name}_libc", diff --git a/third_party/bouffalolab/bl702/bl_iot_sdk.gni b/third_party/bouffalolab/bl702/bl_iot_sdk.gni index 9c7d8ea64ea339..9783d77e6a732b 100644 --- a/third_party/bouffalolab/bl702/bl_iot_sdk.gni +++ b/third_party/bouffalolab/bl702/bl_iot_sdk.gni @@ -643,6 +643,7 @@ template("bl_iot_sdk") { configs += [ ":${sdk_target_name}_config_BSP_Driver", + ":${sdk_target_name}_config_hosal", ":${sdk_target_name}_config_freertos", ":${sdk_target_name}_config_utils", ] diff --git a/third_party/bouffalolab/repo b/third_party/bouffalolab/repo index 890577da8b6b1d..7ca85fd77663ab 160000 --- a/third_party/bouffalolab/repo +++ b/third_party/bouffalolab/repo @@ -1 +1 @@ -Subproject commit 890577da8b6b1d7f1078382e4e320a1e60cc5f60 +Subproject commit 7ca85fd77663ab6e13ce8481593474ea38ad4bb2 diff --git a/third_party/pigweed/repo b/third_party/pigweed/repo index 71ba37c8a6cc65..73cac22f49069a 160000 --- a/third_party/pigweed/repo +++ b/third_party/pigweed/repo @@ -1 +1 @@ -Subproject commit 71ba37c8a6cc65c8084078fb000e8f470cff8597 +Subproject commit 73cac22f49069a18fbec3bb60cb5f762b32ce20b diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index 6926ae35e79f10..55ff1066d214ff 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -273,7 +273,7 @@ template("efr32_sdk") { ] } - if (use_wf200 || use_rs9116) { + if (use_wf200 || use_rs9116 || use_SiWx917) { import("${chip_root}/src/platform/silabs/efr32/wifi_args.gni") defines += [ "LWIP_NETIF_API=1" ]