diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index e80dfa78bded48..ce44f93caadcea 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -17,7 +17,7 @@ "build": { "dockerfile": "Dockerfile", "args": { - "BUILD_VERSION": "0.5.79" + "BUILD_VERSION": "0.5.84" } }, "remoteUser": "vscode", diff --git a/.github/labeler.yml b/.github/labeler.yml index ae076f92e36001..6e52598d8782b7 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -126,6 +126,11 @@ setup payload: ############################################################ platform: - src/platform/* + - config/tizen/chip-gn/platform/* + - examples/platform/* + - scripts/tools/memory/platform/* + - src/include/platform/* + - src/lib/dnssd/platform/* darwin: - src/platform/Darwin/* diff --git a/.github/workflows/bloat_check.yaml b/.github/workflows/bloat_check.yaml index f7a59c578317e5..3e6e6856a8c0ce 100644 --- a/.github/workflows/bloat_check.yaml +++ b/.github/workflows/bloat_check.yaml @@ -30,7 +30,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.5.79 + image: connectedhomeip/chip-build:0.5.84 steps: - uses: Wandalen/wretry.action@v1.0.15 diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 6fffb7fb6196a0..5f9e3b8e8da158 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -32,7 +32,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.5.79 + image: connectedhomeip/chip-build:0.5.84 volumes: - "/tmp/log_output:/tmp/test_logs" options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 @@ -67,7 +67,7 @@ jobs: run: scripts/build/gn_bootstrap.sh - name: Uploading bootstrap logs uses: actions/upload-artifact@v2 - if: ${{ always() }} && ${{ !env.ACT }} + if: ${{ always() && !env.ACT }} with: name: bootstrap-logs path: | @@ -106,7 +106,7 @@ jobs: run: scripts/run_in_build_env.sh "ninja -C ./out" - name: Uploading core files uses: actions/upload-artifact@v2 - if: ${{ failure() }} && ${{ !env.ACT }} + if: ${{ failure() && !env.ACT }} with: name: crash-core-linux-gcc-debug path: /tmp/cores/ @@ -114,7 +114,7 @@ jobs: retention-days: 5 - name: Uploading objdir for debugging uses: actions/upload-artifact@v2 - if: ${{ failure() }} && ${{ !env.ACT }} + if: ${{ failure() && !env.ACT }} with: name: crash-objdir-linux-gcc-debug path: out/ @@ -128,7 +128,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.5.79 + image: connectedhomeip/chip-build:0.5.84 volumes: - "/tmp/log_output:/tmp/test_logs" options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 @@ -168,7 +168,7 @@ jobs: run: scripts/build/gn_bootstrap.sh - name: Uploading bootstrap logs uses: actions/upload-artifact@v2 - if: ${{ always() }} && ${{ !env.ACT }} + if: ${{ always() && !env.ACT }} with: name: bootstrap-logs path: | @@ -239,7 +239,7 @@ jobs: "./scripts/build/build_examples.py --no-log-timestamps --target linux-fake-tests build" - name: Uploading core files uses: actions/upload-artifact@v2 - if: ${{ failure() }} && ${{ !env.ACT }} + if: ${{ failure() && !env.ACT }} with: name: crash-core-linux path: /tmp/cores/ @@ -247,7 +247,7 @@ jobs: retention-days: 5 - name: Uploading objdir for debugging uses: actions/upload-artifact@v2 - if: ${{ failure() }} && ${{ !env.ACT }} + if: ${{ failure() && !env.ACT }} with: name: crash-objdir-linux path: out/ @@ -279,7 +279,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.5.79 + image: connectedhomeip/chip-build:0.5.84 volumes: - "/tmp/log_output:/tmp/test_logs" options: --sysctl "net.ipv6.conf.all.disable_ipv6=0 @@ -359,7 +359,7 @@ jobs: run: scripts/build/gn_bootstrap.sh - name: Uploading bootstrap logs uses: actions/upload-artifact@v2 - if: ${{ always() }} && ${{ !env.ACT }} + if: ${{ always() && !env.ACT }} with: name: bootstrap-logs path: | @@ -407,7 +407,7 @@ jobs: " - name: Uploading diagnostic logs uses: actions/upload-artifact@v2 - if: ${{ failure() }} && ${{ !env.ACT }} + if: ${{ failure() && !env.ACT }} with: name: crash-log-darwin path: ~/Library/Logs/DiagnosticReports/ diff --git a/.github/workflows/chef.yaml b/.github/workflows/chef.yaml index a11e2786477b52..7a3e9f86bd7946 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.5.79 + image: connectedhomeip/chip-build:0.5.84 options: --user root steps: @@ -42,6 +42,11 @@ jobs: token: ${{ github.token }} attempt_limit: 3 attempt_delay: 2000 + - name: Checkout submodules + run: scripts/checkout_submodules.py --shallow --platform linux + - name: Bootstrap + timeout-minutes: 10 + run: scripts/build/gn_bootstrap.sh - name: CI Examples Linux shell: bash run: | @@ -53,7 +58,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32:0.5.79 + image: connectedhomeip/chip-build-esp32:0.5.84 options: --user root steps: @@ -65,6 +70,11 @@ jobs: token: ${{ github.token }} attempt_limit: 3 attempt_delay: 2000 + - name: Checkout submodules + run: scripts/checkout_submodules.py --shallow --platform esp32 + - name: Bootstrap + timeout-minutes: 10 + run: scripts/build/gn_bootstrap.sh - name: CI Examples ESP32 shell: bash run: | @@ -76,7 +86,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-nrf-platform:0.5.79 + image: connectedhomeip/chip-build-nrf-platform:0.5.84 options: --user root steps: @@ -88,6 +98,11 @@ jobs: token: ${{ github.token }} attempt_limit: 3 attempt_delay: 2000 + - name: Checkout submodules + run: scripts/checkout_submodules.py --shallow --platform nrfconnect + - name: Bootstrap + timeout-minutes: 10 + run: scripts/build/gn_bootstrap.sh - name: CI Examples NRFConnect shell: bash run: | diff --git a/.github/workflows/cherry-picks.yaml b/.github/workflows/cherry-picks.yaml new file mode 100644 index 00000000000000..ac113172aa4748 --- /dev/null +++ b/.github/workflows/cherry-picks.yaml @@ -0,0 +1,42 @@ +name: Cherry-Pick Merges + +on: + pull_request_target: + branches: + - master + types: ["closed"] + +jobs: + cherry_pick_release_v1_0: + runs-on: ubuntu-latest + name: Cherry-Pick into SVE + if: | + (github.event.pull_request.merged == true) + && ( + (contains(github.event.pull_request.labels.*.name, 'sve')) + || (contains(github.event.pull_request.labels.*.name, 'cert blocker')) + || (contains(github.event.pull_request.labels.*.name, 'spec')) + || (contains(github.event.pull_request.labels.*.name, 'platform')) + || (contains(github.event.pull_request.labels.*.name, 'darwin')) + || (contains(github.event.pull_request.labels.*.name, 'android')) + || (contains(github.event.pull_request.labels.*.name, 'examples')) + || (contains(github.event.pull_request.labels.*.name, 'scripts')) + || (contains(github.event.pull_request.labels.*.name, 'workflows')) + || (contains(github.event.pull_request.labels.*.name, 'github')) + || (contains(github.event.pull_request.labels.*.name, 'sve cherry-pick')) + ) + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Cherry-Pick into sve branch + uses: carloscastrojumo/github-cherry-pick-action@v1.0.1 + with: + token: ${{ secrets.MATTER_PAT }} + branch: sve + reviewers: | + woody-apple + andy31415 +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/cirque.yaml b/.github/workflows/cirque.yaml index cc8f6528d6520c..e867790820231a 100644 --- a/.github/workflows/cirque.yaml +++ b/.github/workflows/cirque.yaml @@ -38,7 +38,7 @@ jobs: # need to run with privilege, which isn't supported by job.XXX.contaner # https://github.com/actions/container-action/issues/2 # container: - # image: connectedhomeip/chip-build-cirque:0.5.79 + # image: connectedhomeip/chip-build-cirque:0.5.84 # volumes: # - "/tmp:/tmp" # - "/dev/pts:/dev/pts" @@ -127,7 +127,7 @@ jobs: -- scripts/tests/cirque_tests.sh run_all_tests - name: Uploading Binaries uses: actions/upload-artifact@v2 - if: ${{ always() }} && ${{ !env.ACT }} + if: ${{ always() && !env.ACT }} with: name: cirque_log-${{steps.outsuffix.outputs.value}}-logs path: /tmp/cirque_test_output/ diff --git a/.github/workflows/darwin-tests.yaml b/.github/workflows/darwin-tests.yaml index b4c8efdd639e60..026071e76a9e48 100644 --- a/.github/workflows/darwin-tests.yaml +++ b/.github/workflows/darwin-tests.yaml @@ -20,8 +20,7 @@ on: workflow_dispatch: concurrency: - group: - ${{ github.ref }}-${{ github.workflow }}-${{ (github.event_name == + group: ${{ github.ref }}-${{ github.workflow }}-${{ (github.event_name == 'pull_request' && github.event.number) || (github.event_name == 'workflow_dispatch' && github.run_number) || github.sha }} cancel-in-progress: true @@ -74,65 +73,84 @@ jobs: run: scripts/build/gn_bootstrap.sh - name: Uploading bootstrap logs uses: actions/upload-artifact@v2 - if: ${{ always() }} && ${{ !env.ACT }} + if: ${{ always() && !env.ACT }} with: - name: - bootstrap-logs-darwin-${{ matrix.build_variant }}${{ matrix.chip_tool }} + name: bootstrap-logs-darwin-${{ matrix.build_variant }}${{ matrix.chip_tool }} path: | .environment/gn_out/.ninja_log .environment/pigweed-venv/*.log - - name: Build Apps - timeout-minutes: 60 + - name: Delete Defaults + run: defaults delete com.apple.dt.xctest.tool + continue-on-error: true + - name: Run macOS Build + timeout-minutes: 40 + # Enable -Werror by hand here, because the Xcode config can't + # enable it for various reasons. Keep whatever Xcode settings + # for OTHER_CFLAGS exist by using ${inherited}. + # + # Disable -Wmacro-redefined because CHIP_DEVICE_CONFIG_ENABLE_MDNS + # seems to be unconditionally defined in CHIPDeviceBuildConfig.h, + # which is apparently being included after CHIPDeviceConfig.h. + run: xcodebuild -target "Matter" -sdk macosx OTHER_CFLAGS='${inherited} -Werror -Wno-macro-redefined' + working-directory: src/darwin/Framework + - name: Copying Framework to Temporary Path + continue-on-error: true run: | - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py \ - --target darwin-x64-darwin-framework-tool-${BUILD_VARIANT} \ - --target darwin-x64-all-clusters-${BUILD_VARIANT} \ - --target darwin-x64-lock-${BUILD_VARIANT} \ - --target darwin-x64-ota-provider-${BUILD_VARIANT} \ - --target darwin-x64-ota-requestor-${BUILD_VARIANT} \ - --target darwin-x64-tv-app-${BUILD_VARIANT} \ - build \ - --copy-artifacts-to objdir-clone \ - " - - name: Run Tests - timeout-minutes: 60 - run: | - ./scripts/run_in_build_env.sh \ - "./scripts/tests/run_test_suite.py \ - --chip-tool ./out/darwin-x64-darwin-framework-tool-${BUILD_VARIANT}/darwin-framework-tool \ - --target-skip-glob '{TestGroupMessaging}' \ - run \ - --iterations 1 \ - --test-timeout-seconds 120 \ - --all-clusters-app ./out/darwin-x64-all-clusters-${BUILD_VARIANT}/chip-all-clusters-app \ - --lock-app ./out/darwin-x64-lock-${BUILD_VARIANT}/chip-lock-app \ - --ota-provider-app ./out/darwin-x64-ota-provider-${BUILD_VARIANT}/chip-ota-provider-app \ - --ota-requestor-app ./out/darwin-x64-ota-requestor-${BUILD_VARIANT}/chip-ota-requestor-app \ - --tv-app ./out/darwin-x64-tv-app-${BUILD_VARIANT}/chip-tv-app \ - " + mkdir -p /tmp/macos_framework_output + ls -la /Users/runner/work/connectedhomeip/connectedhomeip/src/darwin/Framework/build/Release/ + mv /Users/runner/work/connectedhomeip/connectedhomeip/src/darwin/Framework/build/Release/Matter.framework /tmp/macos_framework_output + ls -la /tmp/macos_framework_output + # Disabling for now + # + # - name: Build Apps + # timeout-minutes: 60 + # run: | + # ./scripts/run_in_build_env.sh \ + # "./scripts/build/build_examples.py \ + # --target darwin-x64-darwin-framework-tool-${BUILD_VARIANT} \ + # --target darwin-x64-all-clusters-${BUILD_VARIANT} \ + # --target darwin-x64-lock-${BUILD_VARIANT} \ + # --target darwin-x64-ota-provider-${BUILD_VARIANT} \ + # --target darwin-x64-ota-requestor-${BUILD_VARIANT} \ + # --target darwin-x64-tv-app-${BUILD_VARIANT} \ + # build \ + # --copy-artifacts-to objdir-clone \ + # " + # - name: Run Tests + # timeout-minutes: 60 + # run: | + # ./scripts/run_in_build_env.sh \ + # "./scripts/tests/run_test_suite.py \ + # --chip-tool ./out/darwin-x64-darwin-framework-tool-${BUILD_VARIANT}/darwin-framework-tool \ + # --target-skip-glob '{TestGroupMessaging}' \ + # run \ + # --iterations 1 \ + # --test-timeout-seconds 120 \ + # --all-clusters-app ./out/darwin-x64-all-clusters-${BUILD_VARIANT}/chip-all-clusters-app \ + # --lock-app ./out/darwin-x64-lock-${BUILD_VARIANT}/chip-lock-app \ + # --ota-provider-app ./out/darwin-x64-ota-provider-${BUILD_VARIANT}/chip-ota-provider-app \ + # --ota-requestor-app ./out/darwin-x64-ota-requestor-${BUILD_VARIANT}/chip-ota-requestor-app \ + # --tv-app ./out/darwin-x64-tv-app-${BUILD_VARIANT}/chip-tv-app \ + # " - name: Uploading core files uses: actions/upload-artifact@v2 - if: ${{ failure() }} && ${{ !env.ACT }} + if: ${{ failure() && !env.ACT }} with: - name: - crash-core-darwin-${{ matrix.build_variant }}${{ matrix.chip_tool }} + name: crash-core-darwin-${{ matrix.build_variant }}${{ matrix.chip_tool }} path: /cores/ # Cores are big; don't hold on to them too long. retention-days: 5 - name: Uploading diagnostic logs uses: actions/upload-artifact@v2 - if: ${{ failure() }} && ${{ !env.ACT }} + if: ${{ failure() && !env.ACT }} with: - name: - crash-log-darwin-${{ matrix.build_variant }}${{ matrix.chip_tool }} + name: crash-log-darwin-${{ matrix.build_variant }}${{ matrix.chip_tool }} path: ~/Library/Logs/DiagnosticReports/ - name: Uploading objdir for debugging uses: actions/upload-artifact@v2 - if: ${{ failure() }} && ${{ !env.ACT }} + if: ${{ failure() && !env.ACT }} with: - name: - crash-objdir-darwin-${{ matrix.build_variant }}${{ matrix.chip_tool }} + name: crash-objdir-darwin-${{ matrix.build_variant }}${{ matrix.chip_tool }} path: objdir-clone/ # objdirs are big; don't hold on to them too long. retention-days: 5 diff --git a/.github/workflows/darwin.yaml b/.github/workflows/darwin.yaml index 258d2d66336833..f1c87eb9314547 100644 --- a/.github/workflows/darwin.yaml +++ b/.github/workflows/darwin.yaml @@ -57,7 +57,7 @@ jobs: run: scripts/build/gn_bootstrap.sh - name: Uploading bootstrap logs uses: actions/upload-artifact@v2 - if: ${{ always() }} && ${{ !env.ACT }} + if: ${{ always() && !env.ACT }} with: name: bootstrap-logs path: | @@ -66,11 +66,11 @@ jobs: - name: Run iOS Build Debug timeout-minutes: 30 working-directory: src/darwin/Framework - run: xcodebuild -target "CHIP" -sdk iphoneos + run: xcodebuild -target "Matter" -sdk iphoneos - name: Run iOS Build Release timeout-minutes: 30 working-directory: src/darwin/Framework - run: xcodebuild -target "CHIP" -sdk iphoneos -configuration Release + run: xcodebuild -target "Matter" -sdk iphoneos -configuration Release - name: Clean Build run: xcodebuild clean working-directory: src/darwin/Framework @@ -78,7 +78,7 @@ jobs: run: defaults delete com.apple.dt.xctest.tool continue-on-error: true - name: Run macOS Build - timeout-minutes: 30 + timeout-minutes: 40 # Enable -Werror by hand here, because the Xcode config can't # enable it for various reasons. Keep whatever Xcode settings # for OTHER_CFLAGS exist by using ${inherited}. @@ -86,15 +86,23 @@ jobs: # Disable -Wmacro-redefined because CHIP_DEVICE_CONFIG_ENABLE_MDNS # seems to be unconditionally defined in CHIPDeviceBuildConfig.h, # which is apparently being included after CHIPDeviceConfig.h. - run: xcodebuild -target "CHIP" -sdk macosx OTHER_CFLAGS='${inherited} -Werror -Wno-macro-redefined' + run: xcodebuild -target "Matter" -sdk macosx OTHER_CFLAGS='${inherited} -Werror -Wno-macro-redefined' working-directory: src/darwin/Framework + - name: Copying Framework to Temporary Path + continue-on-error: true + run: | + mkdir -p /tmp/macos_framework_output + ls -la /Users/runner/work/connectedhomeip/connectedhomeip/src/darwin/Framework/build/Release/ + mv /Users/runner/work/connectedhomeip/connectedhomeip/src/darwin/Framework/build/Release/Matter.framework /tmp/macos_framework_output + ls -la /tmp/macos_framework_output - name: Clean Build run: xcodebuild clean working-directory: src/darwin/Framework - - name: Build example darwin-framework-tool - timeout-minutes: 15 - run: | - scripts/examples/gn_build_example.sh examples/darwin-framework-tool out/debug chip_config_network_layer_ble=false is_asan=true + # Disabling for now + # - name: Build example darwin-framework-tool + # timeout-minutes: 15 + # run: | + # scripts/examples/gn_build_example.sh examples/darwin-framework-tool out/debug chip_config_network_layer_ble=false is_asan=true - name: Build example All Clusters Server timeout-minutes: 15 run: | @@ -115,11 +123,11 @@ jobs: run: | mkdir -p /tmp/darwin/framework-tests ../../../out/debug/chip-all-clusters-app --interface-id -1 > >(tee /tmp/darwin/framework-tests/all-cluster-app.log) 2> >(tee /tmp/darwin/framework-tests/all-cluster-app-err.log >&2) & - xcodebuild test -target "CHIP" -scheme "CHIP Framework Tests" -sdk macosx OTHER_CFLAGS='${inherited} -Werror -Wno-incomplete-umbrella' > >(tee /tmp/darwin/framework-tests/darwin-tests.log) 2> >(tee /tmp/darwin/framework-tests/darwin-tests-err.log >&2) + xcodebuild test -target "Matter" -scheme "Matter Framework Tests" -sdk macosx OTHER_CFLAGS='${inherited} -Werror -Wno-incomplete-umbrella' > >(tee /tmp/darwin/framework-tests/darwin-tests.log) 2> >(tee /tmp/darwin/framework-tests/darwin-tests-err.log >&2) working-directory: src/darwin/Framework - name: Uploading log files uses: actions/upload-artifact@v2 - if: ${{ failure() }} && ${{ !env.ACT }} + if: ${{ failure() && !env.ACT }} with: name: darwin-framework-test-logs path: /tmp/darwin/framework-tests diff --git a/.github/workflows/doxygen.yaml b/.github/workflows/doxygen.yaml index a9b503ac0f4835..ec6cb8671a44af 100644 --- a/.github/workflows/doxygen.yaml +++ b/.github/workflows/doxygen.yaml @@ -82,7 +82,7 @@ jobs: runs-on: ubuntu-20.04 container: - image: connectedhomeip/chip-build-doxygen:0.5.79 + image: connectedhomeip/chip-build-doxygen:0.5.84 if: github.actor != 'restyled-io[bot]' diff --git a/.github/workflows/examples-ameba.yaml b/.github/workflows/examples-ameba.yaml index b52f0c998157e3..08e8a0a46bac75 100644 --- a/.github/workflows/examples-ameba.yaml +++ b/.github/workflows/examples-ameba.yaml @@ -32,7 +32,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-ameba:0.5.79 + image: connectedhomeip/chip-build-ameba:0.5.84 options: --user root steps: diff --git a/.github/workflows/examples-cc13x2x7_26x2x7.yaml b/.github/workflows/examples-cc13x2x7_26x2x7.yaml index 885133547c3d54..3e9612c5823a0a 100644 --- a/.github/workflows/examples-cc13x2x7_26x2x7.yaml +++ b/.github/workflows/examples-cc13x2x7_26x2x7.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-ti:0.5.79 + image: connectedhomeip/chip-build-ti:0.5.84 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: @@ -58,7 +58,7 @@ jobs: run: scripts/build/gn_bootstrap.sh - name: Uploading bootstrap logs uses: actions/upload-artifact@v2 - if: ${{ always() }} && ${{ !env.ACT }} + if: ${{ always() && !env.ACT }} with: name: bootstrap-logs path: | diff --git a/.github/workflows/examples-cyw30739.yaml b/.github/workflows/examples-cyw30739.yaml index 458833b33bdfec..a3126dbba0442c 100644 --- a/.github/workflows/examples-cyw30739.yaml +++ b/.github/workflows/examples-cyw30739.yaml @@ -57,7 +57,7 @@ jobs: run: scripts/build/gn_bootstrap.sh - name: Uploading bootstrap logs uses: actions/upload-artifact@v2 - if: ${{ always() }} && ${{ !env.ACT }} + if: ${{ always() && !env.ACT }} with: name: bootstrap-logs path: | diff --git a/.github/workflows/examples-efr32.yaml b/.github/workflows/examples-efr32.yaml index 262d9b771795bc..2fa6e21cc2273d 100644 --- a/.github/workflows/examples-efr32.yaml +++ b/.github/workflows/examples-efr32.yaml @@ -35,7 +35,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-efr32:0.5.79 + image: connectedhomeip/chip-build-efr32:0.5.84 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: @@ -61,7 +61,7 @@ jobs: run: scripts/build/gn_bootstrap.sh - name: Uploading bootstrap logs uses: actions/upload-artifact@v2 - if: ${{ always() }} && ${{ !env.ACT }} + if: ${{ always() && !env.ACT }} with: name: bootstrap-logs path: | diff --git a/.github/workflows/examples-esp32.yaml b/.github/workflows/examples-esp32.yaml index 61190b3a763a04..469ec1e9088df9 100644 --- a/.github/workflows/examples-esp32.yaml +++ b/.github/workflows/examples-esp32.yaml @@ -32,7 +32,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32:0.5.79 + image: connectedhomeip/chip-build-esp32:0.5.84 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" @@ -59,7 +59,7 @@ jobs: run: scripts/build/gn_bootstrap.sh - name: Uploading bootstrap logs uses: actions/upload-artifact@v2 - if: ${{ always() }} && ${{ !env.ACT }} + if: ${{ always() && !env.ACT }} with: name: bootstrap-logs path: | @@ -118,7 +118,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32:0.5.79 + image: connectedhomeip/chip-build-esp32:0.5.84 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" @@ -140,7 +140,7 @@ jobs: - name: Uploading bootstrap logs uses: actions/upload-artifact@v2 - if: ${{ always() }} && ${{ !env.ACT }} + if: ${{ always() && !env.ACT }} with: name: bootstrap-logs path: | diff --git a/.github/workflows/examples-infineon.yaml b/.github/workflows/examples-infineon.yaml index 5f381cc180cd5e..bb2aea6a47e8b5 100644 --- a/.github/workflows/examples-infineon.yaml +++ b/.github/workflows/examples-infineon.yaml @@ -32,7 +32,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-infineon:0.5.79 + image: connectedhomeip/chip-build-infineon:0.5.84 steps: - uses: Wandalen/wretry.action@v1.0.15 @@ -57,7 +57,7 @@ jobs: run: scripts/build/gn_bootstrap.sh - name: Uploading bootstrap logs uses: actions/upload-artifact@v2 - if: ${{ always() }} && ${{ !env.ACT }} + if: ${{ always() && !env.ACT }} with: name: bootstrap-logs path: | diff --git a/.github/workflows/examples-k32w.yaml b/.github/workflows/examples-k32w.yaml index e43db4cef5c77b..9885e1e43788b6 100644 --- a/.github/workflows/examples-k32w.yaml +++ b/.github/workflows/examples-k32w.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-k32w:0.5.79 + image: connectedhomeip/chip-build-k32w:0.5.84 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: @@ -60,7 +60,7 @@ jobs: run: scripts/build/gn_bootstrap.sh - name: Uploading bootstrap logs uses: actions/upload-artifact@v2 - if: ${{ always() }} && ${{ !env.ACT }} + if: ${{ always() && !env.ACT }} with: name: bootstrap-logs path: | diff --git a/.github/workflows/examples-linux-arm.yaml b/.github/workflows/examples-linux-arm.yaml index 369500947303e5..d8509480619562 100644 --- a/.github/workflows/examples-linux-arm.yaml +++ b/.github/workflows/examples-linux-arm.yaml @@ -31,7 +31,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-crosscompile:0.5.79 + image: connectedhomeip/chip-build-crosscompile:0.5.84 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" @@ -58,7 +58,7 @@ jobs: run: scripts/build/gn_bootstrap.sh - name: Uploading bootstrap logs uses: actions/upload-artifact@v2 - if: ${{ always() }} && ${{ !env.ACT }} + if: ${{ always() && !env.ACT }} with: name: bootstrap-logs path: | diff --git a/.github/workflows/examples-linux-imx.yaml b/.github/workflows/examples-linux-imx.yaml index 2236761bc264ea..e1fb25379daf7a 100644 --- a/.github/workflows/examples-linux-imx.yaml +++ b/.github/workflows/examples-linux-imx.yaml @@ -31,6 +31,11 @@ jobs: if: github.actor != 'restyled-io[bot]' container: + # TODO: this image SHOULD use a newer version. + # + # NOTE: After https://github.com/project-chip/connectedhomeip/pull/19941 + # the image became large enough that github CI runs out of space. + # The image has increased from aroud 2.5GB to 10+GB image: connectedhomeip/chip-build-imx:0.5.79 steps: diff --git a/.github/workflows/examples-linux-standalone.yaml b/.github/workflows/examples-linux-standalone.yaml index 2e6e0edb3f40e4..6aefd6d6e4a4ff 100644 --- a/.github/workflows/examples-linux-standalone.yaml +++ b/.github/workflows/examples-linux-standalone.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.5.79 + image: connectedhomeip/chip-build:0.5.84 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" @@ -61,7 +61,7 @@ jobs: run: scripts/build/gn_bootstrap.sh - name: Uploading bootstrap logs uses: actions/upload-artifact@v2 - if: ${{ always() }} && ${{ !env.ACT }} + if: ${{ always() && !env.ACT }} with: name: bootstrap-logs path: | diff --git a/.github/workflows/examples-mbed.yaml b/.github/workflows/examples-mbed.yaml index 65bf46ebfcdf71..5facc4ae1d6bba 100644 --- a/.github/workflows/examples-mbed.yaml +++ b/.github/workflows/examples-mbed.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-mbed-os:0.5.79 + image: connectedhomeip/chip-build-mbed-os:0.5.84 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" @@ -75,7 +75,7 @@ jobs: - name: Uploading bootstrap logs uses: actions/upload-artifact@v2 - if: ${{ always() }} && ${{ !env.ACT }} + if: ${{ always() && !env.ACT }} with: name: bootstrap-logs path: | diff --git a/.github/workflows/examples-nrfconnect.yaml b/.github/workflows/examples-nrfconnect.yaml index b15ad7d4aa1da0..0e2c7f4c4f0090 100644 --- a/.github/workflows/examples-nrfconnect.yaml +++ b/.github/workflows/examples-nrfconnect.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-nrf-platform:0.5.79 + image: connectedhomeip/chip-build-nrf-platform:0.5.84 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" @@ -74,7 +74,7 @@ jobs: run: scripts/build/gn_bootstrap.sh - name: Uploading bootstrap logs uses: actions/upload-artifact@v2 - if: ${{ always() }} && ${{ !env.ACT }} + if: ${{ always() && !env.ACT }} with: name: bootstrap-logs path: | @@ -196,7 +196,7 @@ jobs: scripts/run_in_build_env.sh "./scripts/build/build_examples.py --target nrf-native-posix-64-tests build" - name: Uploading Failed Test Logs uses: actions/upload-artifact@v2 - if: ${{ failure() }} && ${{ !env.ACT }} + if: ${{ failure() && !env.ACT }} with: name: test-log path: | diff --git a/.github/workflows/examples-qpg.yaml b/.github/workflows/examples-qpg.yaml index e1e4b40b1f6d3c..b903c0d1d1ba66 100644 --- a/.github/workflows/examples-qpg.yaml +++ b/.github/workflows/examples-qpg.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.5.79 + image: connectedhomeip/chip-build:0.5.84 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: @@ -60,7 +60,7 @@ jobs: run: scripts/build/gn_bootstrap.sh - name: Uploading bootstrap logs uses: actions/upload-artifact@v2 - if: ${{ always() }} && ${{ !env.ACT }} + if: ${{ always() && !env.ACT }} with: name: bootstrap-logs path: | diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 1089f0a31af578..c74de0749c66ed 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -32,7 +32,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-telink:0.5.79 + image: connectedhomeip/chip-build-telink:0.5.84 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-tizen.yaml b/.github/workflows/examples-tizen.yaml index 68186bfefd1d69..c238ebb2cf5be0 100644 --- a/.github/workflows/examples-tizen.yaml +++ b/.github/workflows/examples-tizen.yaml @@ -32,7 +32,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-tizen:0.5.81 + image: connectedhomeip/chip-build-tizen:0.5.84 options: --user root volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/full-android.yaml b/.github/workflows/full-android.yaml index 09960d78aaba1e..64f948db3973b1 100644 --- a/.github/workflows/full-android.yaml +++ b/.github/workflows/full-android.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-android:0.5.79 + image: connectedhomeip/chip-build-android:0.5.84 volumes: - "/tmp/log_output:/tmp/test_logs" @@ -53,7 +53,7 @@ jobs: run: scripts/build/gn_bootstrap.sh - name: Uploading bootstrap logs uses: actions/upload-artifact@v2 - if: ${{ always() }} && ${{ !env.ACT }} + if: ${{ always() && !env.ACT }} with: name: bootstrap-logs path: | diff --git a/.github/workflows/fuzzing-build.yaml b/.github/workflows/fuzzing-build.yaml index dedc1b67b109c4..70f3a88f8fcc5a 100644 --- a/.github/workflows/fuzzing-build.yaml +++ b/.github/workflows/fuzzing-build.yaml @@ -31,7 +31,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.5.79 + image: connectedhomeip/chip-build:0.5.84 volumes: - "/tmp/log_output:/tmp/test_logs" @@ -55,7 +55,7 @@ jobs: run: scripts/build/gn_bootstrap.sh - name: Uploading bootstrap logs uses: actions/upload-artifact@v2 - if: ${{ always() }} && ${{ !env.ACT }} + if: ${{ always() && !env.ACT }} with: name: bootstrap-logs path: | @@ -113,7 +113,7 @@ jobs: run: scripts/build/gn_bootstrap.sh - name: Uploading bootstrap logs uses: actions/upload-artifact@v2 - if: ${{ always() }} && ${{ !env.ACT }} + if: ${{ always() && !env.ACT }} with: name: bootstrap-logs path: | diff --git a/.github/workflows/qemu.yaml b/.github/workflows/qemu.yaml index 60f620195025d4..30e70d95ec452d 100644 --- a/.github/workflows/qemu.yaml +++ b/.github/workflows/qemu.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32-qemu:0.5.79 + image: connectedhomeip/chip-build-esp32-qemu:0.5.84 volumes: - "/tmp/log_output:/tmp/test_logs" @@ -54,7 +54,7 @@ jobs: run: scripts/build/gn_bootstrap.sh - name: Uploading bootstrap logs uses: actions/upload-artifact@v2 - if: ${{ always() }} && ${{ !env.ACT }} + if: ${{ always() && !env.ACT }} with: name: bootstrap-logs path: | diff --git a/.github/workflows/release_artifacts.yaml b/.github/workflows/release_artifacts.yaml index de38d645157cd8..60c4cc1454c128 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.5.79 + image: connectedhomeip/chip-build-esp32:0.5.84 steps: - uses: Wandalen/wretry.action@v1.0.15 @@ -47,7 +47,7 @@ jobs: run: scripts/build/gn_bootstrap.sh - name: Uploading bootstrap logs uses: actions/upload-artifact@v2 - if: ${{ always() }} && ${{ !env.ACT }} + if: ${{ always() && !env.ACT }} with: name: bootstrap-logs path: | @@ -75,7 +75,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build-efr32:0.5.79 + image: connectedhomeip/chip-build-efr32:0.5.84 steps: - uses: Wandalen/wretry.action@v1.0.15 name: Checkout @@ -92,7 +92,7 @@ jobs: run: scripts/build/gn_bootstrap.sh - name: Uploading bootstrap logs uses: actions/upload-artifact@v2 - if: ${{ always() }} && ${{ !env.ACT }} + if: ${{ always() && !env.ACT }} with: name: bootstrap-logs path: | diff --git a/.github/workflows/smoketest-android.yaml b/.github/workflows/smoketest-android.yaml index dc800768554bd3..aae77701773fd1 100644 --- a/.github/workflows/smoketest-android.yaml +++ b/.github/workflows/smoketest-android.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-android:0.5.79 + image: connectedhomeip/chip-build-android:0.5.84 volumes: - "/tmp/log_output:/tmp/test_logs" @@ -54,7 +54,7 @@ jobs: run: scripts/build/gn_bootstrap.sh - name: Uploading bootstrap logs uses: actions/upload-artifact@v2 - if: ${{ always() }} && ${{ !env.ACT }} + if: ${{ always() && !env.ACT }} with: name: bootstrap-logs path: | diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 72fc925d80c3dc..08a23cb1c4b73c 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -43,7 +43,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.5.79 + image: connectedhomeip/chip-build:0.5.84 options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1" @@ -69,7 +69,7 @@ jobs: run: scripts/build/gn_bootstrap.sh - name: Uploading bootstrap logs uses: actions/upload-artifact@v2 - if: ${{ always() }} && ${{ !env.ACT }} + if: ${{ always() && !env.ACT }} with: name: bootstrap-logs-linux-${{ matrix.build_variant }}${{ matrix.chip_tool }} path: | @@ -106,7 +106,7 @@ jobs: " - name: Uploading core files uses: actions/upload-artifact@v2 - if: ${{ failure() }} && ${{ !env.ACT }} + if: ${{ failure() && !env.ACT }} with: name: crash-core-linux-${{ matrix.build_variant }}${{ matrix.chip_tool }} path: /tmp/cores/ @@ -114,7 +114,7 @@ jobs: retention-days: 5 - name: Uploading objdir for debugging uses: actions/upload-artifact@v2 - if: ${{ failure() }} && ${{ !env.ACT }} + if: ${{ failure() && !env.ACT }} with: name: crash-objdir-linux-${{ matrix.build_variant }}${{ matrix.chip_tool }} path: objdir-clone/ @@ -170,14 +170,14 @@ jobs: run: scripts/build/gn_bootstrap.sh - name: Uploading bootstrap logs uses: actions/upload-artifact@v2 - if: ${{ always() }} && ${{ !env.ACT }} + if: ${{ always() && !env.ACT }} with: name: bootstrap-logs-darwin-${{ matrix.build_variant }}${{ matrix.chip_tool }} path: | .environment/gn_out/.ninja_log .environment/pigweed-venv/*.log - name: Build Apps - timeout-minutes: 40 + timeout-minutes: 60 run: | ./scripts/run_in_build_env.sh \ "./scripts/build/build_examples.py \ @@ -208,7 +208,7 @@ jobs: " - name: Uploading core files uses: actions/upload-artifact@v2 - if: ${{ failure() }} && ${{ !env.ACT }} + if: ${{ failure() && !env.ACT }} with: name: crash-core-darwin-${{ matrix.build_variant }}${{ matrix.chip_tool }} path: /cores/ @@ -216,13 +216,13 @@ jobs: retention-days: 5 - name: Uploading diagnostic logs uses: actions/upload-artifact@v2 - if: ${{ failure() }} && ${{ !env.ACT }} + if: ${{ failure() && !env.ACT }} with: name: crash-log-darwin-${{ matrix.build_variant }}${{ matrix.chip_tool }} path: ~/Library/Logs/DiagnosticReports/ - name: Uploading objdir for debugging uses: actions/upload-artifact@v2 - if: ${{ failure() }} && ${{ !env.ACT }} + if: ${{ failure() && !env.ACT }} with: name: crash-objdir-darwin-${{ matrix.build_variant }}${{ matrix.chip_tool }} path: objdir-clone/ @@ -239,9 +239,8 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.5.79 - options: - --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 + image: connectedhomeip/chip-build:0.5.84 + options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1" steps: @@ -249,8 +248,7 @@ jobs: uses: actions/checkout@v2 - name: Checkout submodules run: scripts/checkout_submodules.py --shallow --platform linux - - name: - Try to ensure the directories for core dumping exist and we + - name: Try to ensure the directories for core dumping exist and we can write them. run: | mkdir /tmp/cores || true @@ -261,43 +259,40 @@ jobs: run: scripts/build/gn_bootstrap.sh - name: Uploading bootstrap logs uses: actions/upload-artifact@v2 - if: ${{ always() }} && ${{ !env.ACT }} + if: ${{ always() && !env.ACT }} with: - name: - bootstrap-logs-linux-${{ matrix.build_variant }}${{ matrix.chip_tool }} + name: bootstrap-logs-linux-${{ matrix.build_variant }}${{ matrix.chip_tool }} path: | .environment/gn_out/.ninja_log .environment/pigweed-venv/*.log - name: Build Python REPL and example apps timeout-minutes: 50 run: | - scripts/run_in_build_env.sh './scripts/build_python.sh --install_wheel build-env' - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py \ - --target linux-x64-all-clusters-no-ble-no-wifi-tsan-clang-test \ - --target linux-x64-python-bindings \ - build \ - --copy-artifacts-to objdir-clone \ - " + scripts/run_in_build_env.sh './scripts/build_python.sh --install_wheel build-env' + ./scripts/run_in_build_env.sh \ + "./scripts/build/build_examples.py \ + --target linux-x64-all-clusters-no-ble-no-wifi-tsan-clang-test \ + --target linux-x64-python-bindings \ + build \ + --copy-artifacts-to objdir-clone \ + " - name: Run Tests timeout-minutes: 40 run: | - scripts/run_in_build_env.sh './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --script-args "--log-level INFO -t 3600 --disable-test ClusterObjectTests.TestTimedRequestTimeout"' + scripts/run_in_build_env.sh './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --script-args "--log-level INFO -t 3600 --disable-test ClusterObjectTests.TestTimedRequestTimeout"' - name: Uploading core files uses: actions/upload-artifact@v2 - if: ${{ failure() }} && ${{ !env.ACT }} + if: ${{ failure() && !env.ACT }} with: - name: - crash-core-linux-python-repl + name: crash-core-linux-python-repl path: /tmp/cores/ # Cores are big; don't hold on to them too long. retention-days: 5 - name: Uploading objdir for debugging uses: actions/upload-artifact@v2 - if: ${{ failure() }} && ${{ !env.ACT }} + if: ${{ failure() && !env.ACT }} with: - name: - crash-objdir-linux-python-repl + name: crash-objdir-linux-python-repl path: objdir-clone/ # objdirs are big; don't hold on to them too long. retention-days: 5 @@ -344,49 +339,45 @@ jobs: run: scripts/build/gn_bootstrap.sh - name: Uploading bootstrap logs uses: actions/upload-artifact@v2 - if: ${{ always() }} && ${{ !env.ACT }} + if: ${{ always() && !env.ACT }} with: - name: - bootstrap-logs-darwin-${{ matrix.build_variant }}${{ matrix.chip_tool }} + name: bootstrap-logs-darwin-${{ matrix.build_variant }}${{ matrix.chip_tool }} path: | .environment/gn_out/.ninja_log .environment/pigweed-venv/*.log - name: Build Python REPL and example apps timeout-minutes: 50 run: | - scripts/run_in_build_env.sh './scripts/build_python.sh --install_wheel build-env' - ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py \ - --target darwin-x64-all-clusters-${BUILD_VARIANT}-test \ - build \ - --copy-artifacts-to objdir-clone \ - " + scripts/run_in_build_env.sh './scripts/build_python.sh --install_wheel build-env' + ./scripts/run_in_build_env.sh \ + "./scripts/build/build_examples.py \ + --target darwin-x64-all-clusters-${BUILD_VARIANT}-test \ + build \ + --copy-artifacts-to objdir-clone \ + " - name: Run Tests timeout-minutes: 30 run: | - scripts/run_in_build_env.sh './scripts/tests/run_python_test.py --app out/darwin-x64-all-clusters-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 3840 --interface-id -1" --script-args "-t 3600 --disable-test ClusterObjectTests.TestTimedRequestTimeout"' + scripts/run_in_build_env.sh './scripts/tests/run_python_test.py --app out/darwin-x64-all-clusters-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 3840 --interface-id -1" --script-args "-t 3600 --disable-test ClusterObjectTests.TestTimedRequestTimeout"' - name: Uploading core files uses: actions/upload-artifact@v2 - if: ${{ failure() }} && ${{ !env.ACT }} + if: ${{ failure() && !env.ACT }} with: - name: - crash-core-darwin-python-repl + name: crash-core-darwin-python-repl path: /cores/ # Cores are big; don't hold on to them too long. retention-days: 5 - name: Uploading diagnostic logs uses: actions/upload-artifact@v2 - if: ${{ failure() }} && ${{ !env.ACT }} + if: ${{ failure() && !env.ACT }} with: - name: - crash-log-darwin-python-repl + name: crash-log-darwin-python-repl path: ~/Library/Logs/DiagnosticReports/ - name: Uploading objdir for debugging uses: actions/upload-artifact@v2 - if: ${{ failure() }} && ${{ !env.ACT }} + if: ${{ failure() && !env.ACT }} with: - name: - crash-objdir-darwin-python-repl + name: crash-objdir-darwin-python-repl path: objdir-clone/ # objdirs are big; don't hold on to them too long. retention-days: 5 diff --git a/.github/workflows/unit_integration_test.yaml b/.github/workflows/unit_integration_test.yaml index d13919cd245a64..c3f8d9224aedc0 100644 --- a/.github/workflows/unit_integration_test.yaml +++ b/.github/workflows/unit_integration_test.yaml @@ -37,7 +37,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.5.79 + image: connectedhomeip/chip-build:0.5.84 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" @@ -60,7 +60,7 @@ jobs: scripts/build/gn_bootstrap.sh ; - name: Uploading bootstrap logs uses: actions/upload-artifact@v2 - if: ${{ always() }} && ${{ !env.ACT }} + if: ${{ always() && !env.ACT }} with: name: bootstrap-logs path: | diff --git a/.github/workflows/zap_regeneration.yaml b/.github/workflows/zap_regeneration.yaml index ebd49b363048a6..0f8a3bf232dc19 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-zap:0.5.79 + image: connectedhomeip/chip-build-zap:0.5.84 defaults: run: shell: sh diff --git a/.github/workflows/zap_templates.yaml b/.github/workflows/zap_templates.yaml index 56355d7e351324..6d1b2f2e59682a 100644 --- a/.github/workflows/zap_templates.yaml +++ b/.github/workflows/zap_templates.yaml @@ -29,7 +29,7 @@ jobs: runs-on: ubuntu-20.04 container: - image: connectedhomeip/chip-build-zap:0.5.79 + image: connectedhomeip/chip-build-zap:0.5.84 defaults: run: shell: sh diff --git a/.gitmodules b/.gitmodules index ed490c7ed0dd40..2a733a8e6a026e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -266,3 +266,6 @@ url = https://github.com/SiliconLabs/wiseconnect-wifi-bt-sdk.git branch = master platforms = efr32 +[submodule "editline"] + path = third_party/editline/repo + url = https://github.com/troglobit/editline.git diff --git a/.restyled.yaml b/.restyled.yaml index 937a8b4afa2a53..c45fe98588b7ec 100644 --- a/.restyled.yaml +++ b/.restyled.yaml @@ -72,6 +72,7 @@ exclude: - "scripts/idl/tests/outputs/**/*" # Matches generated output 1:1 - "examples/chef/sample_app_util/test_files/*.yaml" - "examples/chef/zzz_generated/**/*" + - "src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm" # https://github.com/project-chip/connectedhomeip/issues/20236 changed_paths: diff --git a/BUILD.gn b/BUILD.gn index 7e3cc729bb96ea..b54672a8124a27 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -27,9 +27,12 @@ import("$dir_pw_build/python.gni") # This build file should not be used in superproject builds. assert(chip_root == "//") +import("${chip_root}/build/chip/fuzz_test.gni") import("${chip_root}/build/chip/tests.gni") import("${chip_root}/build/chip/tools.gni") +import("${build_root}/config/compiler/compiler.gni") + import("//src/crypto/crypto.gni") if (current_toolchain != "${dir_pw_toolchain}/default:default") { @@ -40,6 +43,16 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") { enable_pylib = false } + if (enable_fuzz_test_targets) { + group("fuzz_tests") { + deps = [ + "${chip_root}/src/credentials/tests:fuzz-chip-cert", + "${chip_root}/src/lib/core/tests:fuzz-tlv-reader", + "${chip_root}/src/lib/dnssd/minimal_mdns/tests:fuzz-minmdns-packet-parsing", + ] + } + } + # Python packages for supporting specific targets. pw_python_group("python_packages") { python_deps = [ @@ -88,6 +101,10 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") { "${nlunit_test_root}:nlunit-test", ] + if (enable_fuzz_test_targets) { + deps += [ "//:fuzz_tests" ] + } + if (chip_device_platform != "none") { deps += [ "${chip_root}/src/app/server" ] } @@ -210,7 +227,9 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") { declare_args() { # Enable building chip with clang. - enable_host_clang_build = enable_default_builds && host_os != "win" + # Disabled on Mac arm64 but note that the "gcc" build uses Apple clang. + enable_host_clang_build = enable_default_builds && host_os != "win" && + (host_os != "mac" || host_cpu != "arm64") # Enable building chip with gcc. enable_host_gcc_build = enable_default_builds && host_os != "win" @@ -226,9 +245,9 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") { enable_standalone_chip_tool_build = enable_default_builds && host_os != "win" - # Build the darwin-framework-tool example. - enable_standalone_chip_tool_darwin_build = - enable_default_builds && host_os == "mac" + # Build the darwin-framework-tool example. By default this is off, because + # it requires a preceding XCode build of the framework. + enable_standalone_chip_tool_darwin_build = false # Build the shell example. enable_standalone_shell_build = enable_default_builds && host_os != "win" diff --git a/build/chip/fuzz_test.gni b/build/chip/fuzz_test.gni new file mode 100644 index 00000000000000..3d101c21e03762 --- /dev/null +++ b/build/chip/fuzz_test.gni @@ -0,0 +1,64 @@ +# Copyright (c) 2020 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/build.gni") +import("//build_overrides/chip.gni") +import("${build_root}/config/compiler/compiler.gni") + +declare_args() { + enable_fuzz_test_targets = + is_clang && (current_os == "linux" || current_os == "mac") +} + +# Define a fuzz target for chip. +# +# Fuzz generally only apply on the following environments: +# - linux and mac host builds when using clang +# +# Sample usage +# +# chip_fuzz_target("fuzz-target-name") { +# sources = [ +# "FuzzTarget.cpp", # Fuzz target +# ] +# +# public_deps = [ +# "${chip_root}/src/lib/foo", # add dependencies here +# "${nlunit_test_root}:nlunit-test", +# ] +# } +# +# +template("chip_fuzz_target") { + if (enable_fuzz_test_targets) { + executable(target_name) { + forward_variables_from(invoker, "*") + + if (defined(public_configs)) { + public_configs += [ + "//build/config/compiler:libfuzzer_fuzzing", + "//build/config/compiler:sanitize_address", + ] + } else { + public_configs = [ + "//build/config/compiler:libfuzzer_fuzzing", + "//build/config/compiler:sanitize_address", + ] + } + 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 35c51811418096..c5f6392613b749 100644 --- a/build/config/compiler/BUILD.gn +++ b/build/config/compiler/BUILD.gn @@ -453,7 +453,7 @@ config("coverage_default") { declare_args() { # Enable Runtime Type Information (RTTI) - enable_rtti = false + enable_rtti = current_os == "mac" || current_os == "ios" } config("no_rtti") { diff --git a/build_overrides/editline.gni b/build_overrides/editline.gni new file mode 100644 index 00000000000000..cd3133fdc3397b --- /dev/null +++ b/build_overrides/editline.gni @@ -0,0 +1,18 @@ +# 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. + +declare_args() { + # Root directory for editline. + editline_root = "//third_party/editline" +} diff --git a/config/bouffalolab/bl602/lib/pw_rpc/BUILD.gn b/config/bouffalolab/bl602/lib/pw_rpc/BUILD.gn index 66ab51fc23adf0..8f11811b370736 100644 --- a/config/bouffalolab/bl602/lib/pw_rpc/BUILD.gn +++ b/config/bouffalolab/bl602/lib/pw_rpc/BUILD.gn @@ -24,7 +24,7 @@ static_library("pw_rpc") { public_deps = [ "$dir_pw_rpc:server", "$dir_pw_rpc/nanopb:echo_service", - "${chip_root}/examples/platform/bl602/pw_sys_io:pw_sys_io_bl602", + "${chip_root}/examples/platform/bouffalolab/bl602/pw_sys_io:pw_sys_io_bl602", "${dir_pigweed}/pw_hdlc:pw_rpc", dir_pw_assert, dir_pw_checksum, diff --git a/config/bouffalolab/bl602/lib/pw_rpc/pw_rpc.gni b/config/bouffalolab/bl602/lib/pw_rpc/pw_rpc.gni index 172d2f366d3212..87e772e7c7ba96 100644 --- a/config/bouffalolab/bl602/lib/pw_rpc/pw_rpc.gni +++ b/config/bouffalolab/bl602/lib/pw_rpc/pw_rpc.gni @@ -16,9 +16,9 @@ import("//build_overrides/chip.gni") import("//build_overrides/pigweed.gni") pw_log_BACKEND = "$dir_pw_log_basic" -pw_assert_BACKEND = "$dir_pw_assert_log:check_backend" +pw_assert_BACKEND = "$dir_pw_assert_log" pw_sys_io_BACKEND = - "${chip_root}/examples/platform/bl602/pw_sys_io:pw_sys_io_bl602" + "${chip_root}/examples/platform/bouffalolab/bl602/pw_sys_io:pw_sys_io_bl602" pw_span_ENABLE_STD_SPAN_POLYFILL = false pw_build_LINK_DEPS = [ diff --git a/config/nrfconnect/chip-module/Kconfig b/config/nrfconnect/chip-module/Kconfig index 9bf628cdb1a63e..2fe7f24571eaff 100644 --- a/config/nrfconnect/chip-module/Kconfig +++ b/config/nrfconnect/chip-module/Kconfig @@ -78,6 +78,7 @@ config CHIP_DEBUG_SYMBOLS config CHIP_FACTORY_DATA bool "Enable Factory Data support" select ZCBOR + select FPROTECT help Enables support for reading factory data from flash memory partition. It requires factory_data partition to exist in the partition manager diff --git a/docs/guides/nrfconnect_factory_data_configuration.md b/docs/guides/nrfconnect_factory_data_configuration.md index 786042f7c785a7..9e587c85030fdb 100644 --- a/docs/guides/nrfconnect_factory_data_configuration.md +++ b/docs/guides/nrfconnect_factory_data_configuration.md @@ -22,6 +22,12 @@ For the nRF Connect platform, the factory data is stored by default in a separate partition of the internal flash memory. This helps to keep the factory data secure by applying hardware write protection. +> Note: Due to hardware limitations, in the nRF Connect platform, protection +> against writing can be applied only to the internal memory partition. The +> [Fprotect](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/libraries/others/fprotect.html) +> is the hardware flash protection driver, and we used it to ensure write +> protection of the factory data partition in internal flash memory. +

Nordic Semiconductor logo nRF52840 DK diff --git a/examples/all-clusters-app/ameba/main/DeviceCallbacks.cpp b/examples/all-clusters-app/ameba/main/DeviceCallbacks.cpp index 2db5f21cee2c85..259ff3d726f529 100644 --- a/examples/all-clusters-app/ameba/main/DeviceCallbacks.cpp +++ b/examples/all-clusters-app/ameba/main/DeviceCallbacks.cpp @@ -71,9 +71,6 @@ void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_ OnInternetConnectivityChange(event); break; - case DeviceEventType::kSessionEstablished: - OnSessionEstablished(event); - break; case DeviceEventType::kInterfaceIpAddressChanged: if ((event->InterfaceIpAddressChanged.Type == InterfaceIpChangeType::kIpV4_Assigned) || (event->InterfaceIpAddressChanged.Type == InterfaceIpChangeType::kIpV6_Assigned)) @@ -140,14 +137,6 @@ void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event } } -void DeviceCallbacks::OnSessionEstablished(const ChipDeviceEvent * event) -{ - if (event->SessionEstablished.IsCommissioner) - { - ChipLogProgress(DeviceLayer, "Commissioner detected!"); - } -} - void DeviceCallbacks::OnOnOffPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { VerifyOrExit(attributeId == ZCL_ON_OFF_ATTRIBUTE_ID, diff --git a/examples/all-clusters-app/ameba/main/include/DeviceCallbacks.h b/examples/all-clusters-app/ameba/main/include/DeviceCallbacks.h index 003b6e700db0eb..18ebb25ed75f36 100644 --- a/examples/all-clusters-app/ameba/main/include/DeviceCallbacks.h +++ b/examples/all-clusters-app/ameba/main/include/DeviceCallbacks.h @@ -39,7 +39,6 @@ class DeviceCallbacks : public chip::DeviceManager::CHIPDeviceManagerCallbacks private: void OnInternetConnectivityChange(const chip::DeviceLayer::ChipDeviceEvent * event); - void OnSessionEstablished(const chip::DeviceLayer::ChipDeviceEvent * event); void OnOnOffPostAttributeChangeCallback(chip::EndpointId endpointId, chip::AttributeId attributeId, uint8_t * value); void OnIdentifyPostAttributeChangeCallback(chip::EndpointId endpointId, chip::AttributeId attributeId, uint8_t * value); }; diff --git a/examples/all-clusters-app/cc13x2x7_26x2x7/args.gni b/examples/all-clusters-app/cc13x2x7_26x2x7/args.gni index bd6e49f7871b4f..8f67c7f5edd0c7 100644 --- a/examples/all-clusters-app/cc13x2x7_26x2x7/args.gni +++ b/examples/all-clusters-app/cc13x2x7_26x2x7/args.gni @@ -33,6 +33,8 @@ chip_openthread_ftd = false # Disable CHIP Logging chip_progress_logging = false + +# Dsiable verbose logs for all-clusters app to save Flash chip_detail_logging = false chip_automation_logging = false diff --git a/examples/all-clusters-app/cc13x2x7_26x2x7/main/AppTask.cpp b/examples/all-clusters-app/cc13x2x7_26x2x7/main/AppTask.cpp index f99dd873e2fd60..b00e11a766a6da 100644 --- a/examples/all-clusters-app/cc13x2x7_26x2x7/main/AppTask.cpp +++ b/examples/all-clusters-app/cc13x2x7_26x2x7/main/AppTask.cpp @@ -30,6 +30,13 @@ #include +#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR +#include +#include +#include +#include +#include +#endif #include #include @@ -62,6 +69,26 @@ AppTask AppTask::sAppTask; constexpr EndpointId kNetworkCommissioningEndpointSecondary = 0xFFFE; +#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR +static DefaultOTARequestor sRequestorCore; +static DefaultOTARequestorStorage sRequestorStorage; +static DefaultOTARequestorDriver sRequestorUser; +static BDXDownloader sDownloader; +static OTAImageProcessorImpl sImageProcessor; + +void InitializeOTARequestor(void) +{ + // Initialize and interconnect the Requestor and Image Processor objects + SetRequestorInstance(&sRequestorCore); + + sRequestorStorage.Init(Server::GetInstance().GetPersistentStorage()); + sRequestorCore.Init(Server::GetInstance(), sRequestorStorage, sRequestorUser, sDownloader); + sImageProcessor.SetOTADownloader(&sDownloader); + sDownloader.SetImageProcessorDelegate(&sImageProcessor); + sRequestorUser.Init(&sRequestorCore, &sImageProcessor); +} +#endif + #ifdef AUTO_PRINT_METRICS static void printMetrics(void) { @@ -93,14 +120,6 @@ void DeviceEventCallback(const ChipDeviceEvent * event, intptr_t arg) { switch (event->Type) { - case DeviceEventType::kSessionEstablished: { - if (event->SessionEstablished.IsCommissioner) - { - PLAT_LOG("Commissioning session established"); - } - } - break; - case DeviceEventType::kCHIPoBLEConnectionEstablished: PLAT_LOG("CHIPoBLE connection established"); break; @@ -238,6 +257,9 @@ int AppTask::Init() // this function will happen on the CHIP event loop thread, not the app_main thread. PlatformMgr().AddEventHandler(DeviceEventCallback, reinterpret_cast(nullptr)); +#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR + InitializeOTARequestor(); +#endif // QR code will be used with CHIP Tool PrintOnboardingCodes(RendezvousInformationFlags(RendezvousInformationFlag::kBLE)); diff --git a/examples/all-clusters-app/linux/main-common.cpp b/examples/all-clusters-app/linux/main-common.cpp index 3095a00458d8da..ea2b7e5094c95e 100644 --- a/examples/all-clusters-app/linux/main-common.cpp +++ b/examples/all-clusters-app/linux/main-common.cpp @@ -31,12 +31,23 @@ #include #include #include -#include #include +#include #include #include #include +#if CHIP_DEVICE_LAYER_TARGET_DARWIN +#include +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI +#include +#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI +#endif // CHIP_DEVICE_LAYER_TARGET_DARWIN + +#if CHIP_DEVICE_LAYER_TARGET_LINUX +#include +#endif // CHIP_DEVICE_LAYER_TARGET_LINUX + #include using namespace chip; @@ -388,22 +399,33 @@ constexpr EndpointId kNetworkCommissioningEndpointSecondary = 0xFFFE; #if CHIP_DEVICE_LAYER_TARGET_LINUX #if CHIP_DEVICE_CONFIG_ENABLE_THREAD -NetworkCommissioning::LinuxThreadDriver sLinuxThreadDriver; -Clusters::NetworkCommissioning::Instance sThreadNetworkCommissioningInstance(kNetworkCommissioningEndpointMain, - &sLinuxThreadDriver); -#endif -#if CHIP_DEVICE_CONFIG_ENABLE_WPA -NetworkCommissioning::LinuxWiFiDriver sLinuxWiFiDriver; -Clusters::NetworkCommissioning::Instance sWiFiNetworkCommissioningInstance(kNetworkCommissioningEndpointSecondary, - &sLinuxWiFiDriver); -#endif -NetworkCommissioning::LinuxEthernetDriver sLinuxEthernetDriver; -Clusters::NetworkCommissioning::Instance sEthernetNetworkCommissioningInstance(kNetworkCommissioningEndpointMain, - &sLinuxEthernetDriver); -#else // CHIP_DEVICE_LAYER_TARGET_LINUX -Clusters::NetworkCommissioning::NullNetworkDriver sNullNetworkDriver; -Clusters::NetworkCommissioning::Instance sNullNetworkCommissioningInstance(kNetworkCommissioningEndpointMain, &sNullNetworkDriver); +NetworkCommissioning::LinuxThreadDriver sThreadDriver; +#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD + +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI +NetworkCommissioning::LinuxWiFiDriver sWiFiDriver; +#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI + +NetworkCommissioning::LinuxEthernetDriver sEthernetDriver; #endif // CHIP_DEVICE_LAYER_TARGET_LINUX + +#if CHIP_DEVICE_LAYER_TARGET_DARWIN +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI +NetworkCommissioning::DarwinWiFiDriver sWiFiDriver; +#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI + +NetworkCommissioning::DarwinEthernetDriver sEthernetDriver; +#endif // CHIP_DEVICE_LAYER_TARGET_DARWIN + +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD +Clusters::NetworkCommissioning::Instance sThreadNetworkCommissioningInstance(kNetworkCommissioningEndpointMain, &sThreadDriver); +#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD + +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI +Clusters::NetworkCommissioning::Instance sWiFiNetworkCommissioningInstance(kNetworkCommissioningEndpointSecondary, &sWiFiDriver); +#endif + +Clusters::NetworkCommissioning::Instance sEthernetNetworkCommissioningInstance(kNetworkCommissioningEndpointMain, &sEthernetDriver); } // namespace void ApplicationInit() @@ -416,7 +438,6 @@ void ApplicationInit() // Enable secondary endpoint only when we need it, this should be applied to all platforms. emberAfEndpointEnableDisable(kNetworkCommissioningEndpointSecondary, false); -#if CHIP_DEVICE_LAYER_TARGET_LINUX const bool kThreadEnabled = { #if CHIP_DEVICE_CONFIG_ENABLE_THREAD LinuxDeviceOptions::GetInstance().mThread @@ -426,7 +447,7 @@ void ApplicationInit() }; const bool kWiFiEnabled = { -#if CHIP_DEVICE_CONFIG_ENABLE_WPA +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI LinuxDeviceOptions::GetInstance().mWiFi #else false @@ -438,7 +459,7 @@ void ApplicationInit() #if CHIP_DEVICE_CONFIG_ENABLE_THREAD sThreadNetworkCommissioningInstance.Init(); #endif -#if CHIP_DEVICE_CONFIG_ENABLE_WPA +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI sWiFiNetworkCommissioningInstance.Init(); #endif // Only enable secondary endpoint for network commissioning cluster when both WiFi and Thread are enabled. @@ -452,23 +473,17 @@ void ApplicationInit() } else if (kWiFiEnabled) { -#if CHIP_DEVICE_CONFIG_ENABLE_WPA +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI // If we only enable WiFi on this device, "move" WiFi instance to main NetworkCommissioning cluster endpoint. sWiFiNetworkCommissioningInstance.~Instance(); new (&sWiFiNetworkCommissioningInstance) - Clusters::NetworkCommissioning::Instance(kNetworkCommissioningEndpointMain, &sLinuxWiFiDriver); + Clusters::NetworkCommissioning::Instance(kNetworkCommissioningEndpointMain, &sWiFiDriver); sWiFiNetworkCommissioningInstance.Init(); #endif } else -#endif // CHIP_DEVICE_LAYER_TARGET_LINUX { -#if CHIP_DEVICE_LAYER_TARGET_LINUX sEthernetNetworkCommissioningInstance.Init(); -#else - // Use NullNetworkCommissioningInstance to disable the network commissioning functions. - sNullNetworkCommissioningInstance.Init(); -#endif } } diff --git a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter index 70297d01d4ac6d..0943510a9b81d6 100644 --- a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter +++ b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter @@ -2086,6 +2086,9 @@ server cluster WindowCovering = 258 { readonly attribute OperationalStatus operationalStatus = 10; readonly attribute EndProductType endProductType = 13; attribute access(write: manage) Mode mode = 23; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute attrib_id attributeList[] = 65531; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -3590,6 +3593,9 @@ endpoint 1 { ram attribute operationalStatus; ram attribute endProductType; persist attribute mode; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; ram attribute featureMap default = 1; ram attribute clusterRevision default = 5; } diff --git a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.zap b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.zap index 4828e3e7b31699..8a0a01ca25588f 100644 --- a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.zap +++ b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.zap @@ -13880,6 +13880,54 @@ "maxInterval": 65344, "reportableChange": 0 }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "FeatureMap", "code": 65532, diff --git a/examples/all-clusters-minimal-app/ameba/main/DeviceCallbacks.cpp b/examples/all-clusters-minimal-app/ameba/main/DeviceCallbacks.cpp index 8f18f730999cde..502057c88ae215 100644 --- a/examples/all-clusters-minimal-app/ameba/main/DeviceCallbacks.cpp +++ b/examples/all-clusters-minimal-app/ameba/main/DeviceCallbacks.cpp @@ -60,9 +60,6 @@ void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_ OnInternetConnectivityChange(event); break; - case DeviceEventType::kSessionEstablished: - OnSessionEstablished(event); - break; case DeviceEventType::kInterfaceIpAddressChanged: if ((event->InterfaceIpAddressChanged.Type == InterfaceIpChangeType::kIpV4_Assigned) || (event->InterfaceIpAddressChanged.Type == InterfaceIpChangeType::kIpV6_Assigned)) @@ -117,14 +114,6 @@ void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event } } -void DeviceCallbacks::OnSessionEstablished(const ChipDeviceEvent * event) -{ - if (event->SessionEstablished.IsCommissioner) - { - ChipLogProgress(DeviceLayer, "Commissioner detected!"); - } -} - void DeviceCallbacks::OnOnOffPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { VerifyOrExit(attributeId == ZCL_ON_OFF_ATTRIBUTE_ID, diff --git a/examples/all-clusters-minimal-app/ameba/main/include/DeviceCallbacks.h b/examples/all-clusters-minimal-app/ameba/main/include/DeviceCallbacks.h index 003b6e700db0eb..18ebb25ed75f36 100644 --- a/examples/all-clusters-minimal-app/ameba/main/include/DeviceCallbacks.h +++ b/examples/all-clusters-minimal-app/ameba/main/include/DeviceCallbacks.h @@ -39,7 +39,6 @@ class DeviceCallbacks : public chip::DeviceManager::CHIPDeviceManagerCallbacks private: void OnInternetConnectivityChange(const chip::DeviceLayer::ChipDeviceEvent * event); - void OnSessionEstablished(const chip::DeviceLayer::ChipDeviceEvent * event); void OnOnOffPostAttributeChangeCallback(chip::EndpointId endpointId, chip::AttributeId attributeId, uint8_t * value); void OnIdentifyPostAttributeChangeCallback(chip::EndpointId endpointId, chip::AttributeId attributeId, uint8_t * value); }; diff --git a/examples/all-clusters-minimal-app/cc13x2x7_26x2x7/args.gni b/examples/all-clusters-minimal-app/cc13x2x7_26x2x7/args.gni index e7438af247a9c2..8f67c7f5edd0c7 100644 --- a/examples/all-clusters-minimal-app/cc13x2x7_26x2x7/args.gni +++ b/examples/all-clusters-minimal-app/cc13x2x7_26x2x7/args.gni @@ -32,7 +32,9 @@ chip_enable_ota_requestor = false chip_openthread_ftd = false # Disable CHIP Logging -#chip_progress_logging = false +chip_progress_logging = false + +# Dsiable verbose logs for all-clusters app to save Flash chip_detail_logging = false chip_automation_logging = false diff --git a/examples/all-clusters-minimal-app/cc13x2x7_26x2x7/main/AppTask.cpp b/examples/all-clusters-minimal-app/cc13x2x7_26x2x7/main/AppTask.cpp index f99dd873e2fd60..b00e11a766a6da 100644 --- a/examples/all-clusters-minimal-app/cc13x2x7_26x2x7/main/AppTask.cpp +++ b/examples/all-clusters-minimal-app/cc13x2x7_26x2x7/main/AppTask.cpp @@ -30,6 +30,13 @@ #include +#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR +#include +#include +#include +#include +#include +#endif #include #include @@ -62,6 +69,26 @@ AppTask AppTask::sAppTask; constexpr EndpointId kNetworkCommissioningEndpointSecondary = 0xFFFE; +#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR +static DefaultOTARequestor sRequestorCore; +static DefaultOTARequestorStorage sRequestorStorage; +static DefaultOTARequestorDriver sRequestorUser; +static BDXDownloader sDownloader; +static OTAImageProcessorImpl sImageProcessor; + +void InitializeOTARequestor(void) +{ + // Initialize and interconnect the Requestor and Image Processor objects + SetRequestorInstance(&sRequestorCore); + + sRequestorStorage.Init(Server::GetInstance().GetPersistentStorage()); + sRequestorCore.Init(Server::GetInstance(), sRequestorStorage, sRequestorUser, sDownloader); + sImageProcessor.SetOTADownloader(&sDownloader); + sDownloader.SetImageProcessorDelegate(&sImageProcessor); + sRequestorUser.Init(&sRequestorCore, &sImageProcessor); +} +#endif + #ifdef AUTO_PRINT_METRICS static void printMetrics(void) { @@ -93,14 +120,6 @@ void DeviceEventCallback(const ChipDeviceEvent * event, intptr_t arg) { switch (event->Type) { - case DeviceEventType::kSessionEstablished: { - if (event->SessionEstablished.IsCommissioner) - { - PLAT_LOG("Commissioning session established"); - } - } - break; - case DeviceEventType::kCHIPoBLEConnectionEstablished: PLAT_LOG("CHIPoBLE connection established"); break; @@ -238,6 +257,9 @@ int AppTask::Init() // this function will happen on the CHIP event loop thread, not the app_main thread. PlatformMgr().AddEventHandler(DeviceEventCallback, reinterpret_cast(nullptr)); +#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR + InitializeOTARequestor(); +#endif // QR code will be used with CHIP Tool PrintOnboardingCodes(RendezvousInformationFlags(RendezvousInformationFlag::kBLE)); diff --git a/examples/build_overrides/editline.gni b/examples/build_overrides/editline.gni new file mode 100644 index 00000000000000..7f20e53733eeb7 --- /dev/null +++ b/examples/build_overrides/editline.gni @@ -0,0 +1,18 @@ +# 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. + +declare_args() { + # Root directory for editline. + editline_root = "//third_party/connectedhomeip/third_party/editline" +} diff --git a/examples/chef/README.md b/examples/chef/README.md index cacd895b2c0342..07579f3791947a 100644 --- a/examples/chef/README.md +++ b/examples/chef/README.md @@ -1,25 +1,23 @@ # MATTER CHEF APP -The purpose of the chef app is to to increase the coverage of device types in -Matter. +The purpose of the chef app is to to: -It uses the shell app a starting point, adding the processing of ZAP files and -the support of a few targets under a unified build script: `chef.py`. +1. Increase the coverage of device types in Matter +2. Provide a sample application that may have its data model easily configured. + +Chef uses the shell app a starting point, but processes the data model defined +on ZAP files during build time. This procedure is handled by its unified build +script: `chef.py`. As it incorporates the processing of ZAP files as part of the build process, it does not use `zzz_generated`, but rather places the auto-generated zap artifacts -under its `zap-generated` temporary folder. - -All device types available (DM/IM .zap files) are found inside the `devices` -folder. +under its `out` temporary folder. -## Building a Sample Application - -Run `chef.py -h` to see the available commands +All device types available (.zap files) are found inside the `devices` folder. ## Building your first sample -1. Make sure you have the toolchain installed for your desired target +1. Make sure you have the toolchain installed for your desired target. 2. Run `chef.py` the first time to create a `config.yaml` configuration file. If you already have SDK environment variables such as IDF_PATH (esp32) and ZEPHYR_BASE (nrfconnect) it will use those values as default. @@ -44,11 +42,12 @@ Run `chef.py -h` to see the available commands TTY: /dev/ttyUSB0 ``` -4. Run `$ chef.py -u` to update zap and the toolchain (on selected platforms) +4. Run `$ chef.py -u` to update zap and the toolchain (on selected platforms). 5. Run `$ chef.py -gzbf -t -d lighting`. This command will run the ZAP GUI opening the `devices/lighting.zap` file and will allow editing. It will then generate the zap artifacts, place them on the `zap-generated` - folder, run a build and flash the binary in your target + folder, run a build and flash the binary in your target. +6. Run `chef.py -h` to see all available commands. ## Creating a new device type in your device library @@ -59,6 +58,27 @@ Run `chef.py -h` to see the available commands into the `devices` folder. This device is now available for the script. See `chef.py -h` for a list of devices available. +## Folder Structure and Guidelines + +- ``: build system and `main.cpp` file for every supported platform. + When porting a new platform, please minimize the source code in this folder, + favoring the `common` folder for code that is not platform related. +- `common`: contains code shared between different platforms. It may contain + source code that enables specific features such as `LightingManager` class + or `LockManager`, as long as the application dynamically identify the + presence of the relevant cluster configurations and it doesn't break the use + cases where chef is built without these clusters. +- `devices`: contains the data models that may be used with chef. As of Matter + 1.0 the data models are defined using .zap files. +- `out`: temporary folder used for placing ZAP generated artifacts. +- `sample_app_util`: guidelines and scripts for generating file names for new + device types committed to the `devices` folder. +- `config.yaml`: contains general configuration for the `chef.py` script. As + of Matter 1.0 this is used exclusively for toolchain and TTY interface + paths. +- `chef.py`: main script for generating samples. More info on its help + `chef.py -h`. + ## CI All CI jobs for chef can be found in `.github/workflows/chef.yaml`. diff --git a/examples/chef/chef.py b/examples/chef/chef.py index f570a95100b3cb..723861bbc35dbf 100755 --- a/examples/chef/chef.py +++ b/examples/chef/chef.py @@ -323,6 +323,11 @@ def main(argv: Sequence[str]) -> None: dest="keep_going", action="store_true") parser.add_option( "", "--ci", help="Builds Chef examples defined in cicd_config. Uses --use_zzz. Uses specified target from -t. Chef exits after completion.", dest="ci", action="store_true") + parser.add_option( + "", "--ipv6only", help="Compile build which only supports ipv6. Linux only.", + action="store_true") + parser.add_option( + "", "--cpu_type", help="CPU type to compile for. Linux only.", choices=["arm64", "x64"]) options, _ = parser.parse_args(argv) @@ -355,7 +360,10 @@ def main(argv: Sequence[str]) -> None: # if options.ci: - for device_name in [d for d in _DEVICE_LIST if d in cicd_config["ci_allow_list"]]: + for device_name in cicd_config["ci_allow_list"]: + if device_name not in _DEVICE_LIST: + flush_print(f"{device_name} in CICD config but not {_DEVICE_FOLDER}!") + exit(1) if options.build_target == "nrfconnect": shell.run_cmd("export GNUARMEMB_TOOLCHAIN_PATH=\"$PW_ARM_CIPD_INSTALL_DIR\"") shell.run_cmd(f"cd {_CHEF_SCRIPT_PATH}") @@ -505,6 +513,7 @@ def main(argv: Sequence[str]) -> None: if options.do_build: sw_ver_string = "" + if options.do_automated_test_stamp: branch = "" for branch_text in shell.run_cmd("git branch", return_cmd_output=True).split("\n"): @@ -596,17 +605,48 @@ def main(argv: Sequence[str]) -> None: elif options.build_target == "linux": shell.run_cmd(f"cd {_CHEF_SCRIPT_PATH}/linux") + + linux_args = [] + if options.do_rpc: + linux_args.append('import("//with_pw_rpc.gni")') + linux_args.extend([ + 'import("//build_overrides/chip.gni")', + 'import("${chip_root}/config/standalone/args.gni")', + 'chip_shell_cmd_server = false', + 'chip_build_libshell = true', + 'chip_config_network_layer_ble = false', + f'target_defines = ["CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID={options.vid}", "CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID={options.pid}", "CONFIG_ENABLE_PW_RPC={int(options.do_rpc)}"]', + ]) + if options.cpu_type == "arm64": + uname_resp = shell.run_cmd("uname -m", return_cmd_output=True) + if "aarch" not in uname_resp and "arm" not in uname_resp: + if ( + "aarch" not in uname_resp and + "arm" not in uname_resp and + "SYSROOT_AARCH64" not in shell.env): + flush_print( + "SYSROOT_AARCH64 env variable not set. " + "AARCH64 toolchain needed for cross-compiling for arm64.") + exit(1) + shell.env["PKG_CONFIG_PATH"] = ( + f'{shell.env["SYSROOT_AARCH64"]}/lib/aarch64-linux-gnu/pkgconfig') + linux_args.append('target_cpu="arm64"') + linux_args.append('is_clang=true') + linux_args.append('chip_crypto="mbedtls"') + linux_args.append(f'sysroot="{shell.env["SYSROOT_AARCH64"]}"') + elif options.cpu_type == "x64": + uname_resp = shell.run_cmd("uname -m", return_cmd_output=True) + if "x64" not in uname_resp and "x86_64" not in uname_resp: + flush_print(f"Unable to cross compile for x64 on {uname_resp}") + exit(1) + if options.ipv6only: + linux_args.append("chip_inet_config_enable_ipv4=false") + + if sw_ver_string: + linux_args.append( + f'chip_device_config_device_software_version_string = "{sw_ver_string}"') with open(f"{_CHEF_SCRIPT_PATH}/linux/args.gni", "w") as f: - sw_ver_string_config_text = f"chip_device_config_device_software_version_string = \"{sw_ver_string}\"" if sw_ver_string else "" - f.write(textwrap.dedent(f"""\ - import("//build_overrides/chip.gni") - import("${{chip_root}}/config/standalone/args.gni") - chip_shell_cmd_server = false - chip_build_libshell = true - chip_config_network_layer_ble = false - target_defines = ["CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID={options.vid}", "CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID={options.pid}", "CONFIG_ENABLE_PW_RPC={'1' if options.do_rpc else '0'}"] - {sw_ver_string_config_text} - """)) + f.write("\n".join(linux_args)) with open(f"{_CHEF_SCRIPT_PATH}/linux/sample.gni", "w") as f: f.write(textwrap.dedent(f"""\ sample_zap_file = "{options.sample_device_type_name}.zap" @@ -614,11 +654,7 @@ def main(argv: Sequence[str]) -> None: """)) if options.do_clean: shell.run_cmd(f"rm -rf out") - if options.do_rpc: - shell.run_cmd( - "gn gen out --args='import(\"//with_pw_rpc.gni\")'") - else: - shell.run_cmd("gn gen out --args=''") + shell.run_cmd("gn gen out") shell.run_cmd("ninja -C out") # diff --git a/examples/chef/cicd_config.json b/examples/chef/cicd_config.json index a8b7ca99bad84f..ab283ae2a4b10f 100644 --- a/examples/chef/cicd_config.json +++ b/examples/chef/cicd_config.json @@ -1,5 +1,5 @@ { - "ci_allow_list": ["rootnode_dimmablelight_gY80DaqEUL"], + "ci_allow_list": ["rootnode_dimmablelight_bCwGYSDpoe"], "cd_platforms": { "linux": "linux_x86", "esp32": "m5stack", diff --git a/examples/chef/efr32/BUILD.gn b/examples/chef/efr32/BUILD.gn index 4161916a993f49..8016d069fb4b34 100644 --- a/examples/chef/efr32/BUILD.gn +++ b/examples/chef/efr32/BUILD.gn @@ -336,6 +336,11 @@ efr32_executable("chef_app") { ] } + # Attestation Credentials + if (chip_build_platform_attestation_credentials_provider) { + deps += [ "${examples_plat_dir}:efr32-attestation-credentials" ] + } + output_dir = root_out_dir } diff --git a/examples/chef/efr32/src/AppTask.cpp b/examples/chef/efr32/src/AppTask.cpp index 15ff91d64a5fa6..b6450ba696d126 100644 --- a/examples/chef/efr32/src/AppTask.cpp +++ b/examples/chef/efr32/src/AppTask.cpp @@ -43,9 +43,6 @@ #include -#include -#include - #include #include @@ -167,7 +164,6 @@ Identify gIdentify = { } // namespace using namespace chip::TLV; -using namespace ::chip::Credentials; using namespace ::chip::DeviceLayer; AppTask AppTask::sAppTask; @@ -205,11 +201,6 @@ CHIP_ERROR AppTask::Init() sWiFiNetworkCommissioningInstance.Init(); #endif - chip::DeviceLayer::PlatformMgr().LockChipStack(); - // Initialize device attestation config - SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); - chip::DeviceLayer::PlatformMgr().UnlockChipStack(); - // Create FreeRTOS sw timer for Function Selection. sFunctionTimer = xTimerCreate("FnTmr", // Just a text name, not used by the RTOS kernel 1, // == default timer period (mS) diff --git a/examples/chef/efr32/src/main.cpp b/examples/chef/efr32/src/main.cpp index 920f51b8e5805d..1e658f4369c92d 100644 --- a/examples/chef/efr32/src/main.cpp +++ b/examples/chef/efr32/src/main.cpp @@ -25,12 +25,19 @@ #include "sl_system_kernel.h" #include #include +#include #include +#ifdef EFR32_ATTESTATION_CREDENTIALS +#include +#else +#include +#endif #define BLE_DEV_NAME "SiLabs-Chef-App" using namespace ::chip; using namespace ::chip::Inet; using namespace ::chip::DeviceLayer; +using namespace ::chip::Credentials; #define UNUSED_PARAMETER(a) (a = a) @@ -49,6 +56,15 @@ int main(void) gExampleDeviceInfoProvider.SetStorageDelegate(&Server::GetInstance().GetPersistentStorage()); chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); + chip::DeviceLayer::PlatformMgr().LockChipStack(); + // Initialize device attestation config +#ifdef EFR32_ATTESTATION_CREDENTIALS + SetDeviceAttestationCredentialsProvider(EFR32::GetEFR32DacProvider()); +#else + SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); +#endif + chip::DeviceLayer::PlatformMgr().UnlockChipStack(); + EFR32_LOG("Starting App Task"); if (GetAppTask().StartAppTask() != CHIP_NO_ERROR) appError(CHIP_ERROR_INTERNAL); diff --git a/examples/chef/esp32/main/main.cpp b/examples/chef/esp32/main/main.cpp index f09a8a7ed3ca37..a3e8737289f4ef 100644 --- a/examples/chef/esp32/main/main.cpp +++ b/examples/chef/esp32/main/main.cpp @@ -98,13 +98,6 @@ void DeviceEventCallback(const ChipDeviceEvent * event, intptr_t arg) break; - case DeviceEventType::kSessionEstablished: - if (event->SessionEstablished.IsCommissioner) - { - ChipLogProgress(Shell, "Commissioner detected!"); - } - break; - case DeviceEventType::kCHIPoBLEConnectionEstablished: ChipLogProgress(Shell, "CHIPoBLE connection established"); break; diff --git a/examples/chip-tool/BUILD.gn b/examples/chip-tool/BUILD.gn index 1e47fb4f2ed1bb..2c5880cea2d9a0 100644 --- a/examples/chip-tool/BUILD.gn +++ b/examples/chip-tool/BUILD.gn @@ -19,6 +19,10 @@ import("${chip_root}/build/chip/tools.gni") import("${chip_root}/examples/chip-tool/chip-tool.gni") import("${chip_root}/src/lib/core/core.gni") +if (config_use_interactive_mode) { + import("//build_overrides/editline.gni") +} + assert(chip_build_tools) config("config") { @@ -37,10 +41,6 @@ config("config") { ] cflags = [ "-Wconversion" ] - - if (config_use_interactive_mode) { - libs = [ "readline" ] - } } static_library("chip-tool-utils") { @@ -77,8 +77,11 @@ static_library("chip-tool-utils") { "config/PersistentStorage.cpp", ] + deps = [] + if (config_use_interactive_mode) { sources += [ "commands/interactive/InteractiveCommands.cpp" ] + deps += [ "${editline_root}:editline" ] } if (config_enable_yaml_tests) { diff --git a/examples/chip-tool/commands/clusters/ModelCommand.cpp b/examples/chip-tool/commands/clusters/ModelCommand.cpp index 9c06ed70b0edd1..fd255abfe204b0 100644 --- a/examples/chip-tool/commands/clusters/ModelCommand.cpp +++ b/examples/chip-tool/commands/clusters/ModelCommand.cpp @@ -66,7 +66,8 @@ void ModelCommand::OnDeviceConnectionFailureFn(void * context, PeerId peerId, CH void ModelCommand::Shutdown() { - ResetArguments(); mOnDeviceConnectedCallback.Cancel(); mOnDeviceConnectionFailureCallback.Cancel(); + + CHIPCommand::Shutdown(); } diff --git a/examples/chip-tool/commands/clusters/ReportCommand.h b/examples/chip-tool/commands/clusters/ReportCommand.h index 5a6bb4bf20c3b3..98f8f6de772051 100644 --- a/examples/chip-tool/commands/clusters/ReportCommand.h +++ b/examples/chip-tool/commands/clusters/ReportCommand.h @@ -411,3 +411,29 @@ class SubscribeEvent : public SubscribeCommand chip::Optional mKeepSubscriptions; chip::Optional> mIsUrgents; }; + +class ReadAll : public ReadCommand +{ +public: + ReadAll(CredentialIssuerCommands * credsIssuerConfig) : ReadCommand("read-all", credsIssuerConfig) + { + AddArgument("fabric-filtered", 0, 1, &mFabricFiltered); + ReadCommand::AddArguments(); + } + + ~ReadAll() {} + + void OnDone(chip::app::ReadClient * aReadClient) override + { + InteractionModelReports::CleanupReadClient(aReadClient); + SetCommandExitStatus(mError); + } + + CHIP_ERROR SendCommand(chip::DeviceProxy * device, std::vector endpointIds) override + { + return ReadCommand::ReadAll(device, endpointIds, mFabricFiltered); + } + +private: + chip::Optional mFabricFiltered; +}; diff --git a/examples/chip-tool/commands/common/CHIPCommand.h b/examples/chip-tool/commands/common/CHIPCommand.h index e4cebf6095cc35..7688a34873bfbe 100644 --- a/examples/chip-tool/commands/common/CHIPCommand.h +++ b/examples/chip-tool/commands/common/CHIPCommand.h @@ -101,7 +101,7 @@ class CHIPCommand : public Command // Shut down the command. After a Shutdown call the command object is ready // to be used for another command invocation. - virtual void Shutdown() {} + virtual void Shutdown() { ResetArguments(); } // Clean up any resources allocated by the command. Some commands may hold // on to resources after Shutdown(), but Cleanup() will guarantee those are diff --git a/examples/chip-tool/commands/common/Command.cpp b/examples/chip-tool/commands/common/Command.cpp index 1931d88e39752f..59812076cfde75 100644 --- a/examples/chip-tool/commands/common/Command.cpp +++ b/examples/chip-tool/commands/common/Command.cpp @@ -355,7 +355,7 @@ bool Command::InitArgument(size_t argIndex, char * argValue) isValidArgument = HandleNullableOptional(arg, argValue, [&](auto * value) { // We support two ways to pass an octet string argument. If it happens // to be all-ASCII, you can just pass it in. Otherwise you can pass in - // 0x followed by the hex-encoded bytes. + // "hex:" followed by the hex-encoded bytes. size_t argLen = strlen(argValue); static constexpr char hexPrefix[] = "hex:"; constexpr size_t prefixLen = ArraySize(hexPrefix) - 1; // Don't count the null @@ -854,44 +854,154 @@ size_t Command::AddArgumentToList(Argument && argument) return 0; } +namespace { +template +void ResetOptionalArg(const Argument & arg) +{ + VerifyOrDie(arg.isOptional()); + + if (arg.isNullable()) + { + reinterpret_cast> *>(arg.value)->ClearValue(); + } + else + { + reinterpret_cast *>(arg.value)->ClearValue(); + } +} +} // anonymous namespace + void Command::ResetArguments() { for (size_t i = 0; i < mArgs.size(); i++) { const Argument arg = mArgs[i]; const ArgumentType type = arg.type; - const uint8_t flags = arg.flags; - if (type == ArgumentType::VectorBool && flags == Argument::kOptional) + if (arg.isOptional()) { - auto vectorArgument = static_cast *>(arg.value); - vectorArgument->clear(); - } - else if (type == ArgumentType::Vector16 && flags != Argument::kOptional) - { - auto vectorArgument = static_cast *>(arg.value); - vectorArgument->clear(); - } - else if (type == ArgumentType::Vector32 && flags != Argument::kOptional) - { - auto vectorArgument = static_cast *>(arg.value); - vectorArgument->clear(); - } - else if (type == ArgumentType::Vector32 && flags == Argument::kOptional) - { - auto optionalArgument = static_cast> *>(arg.value); - if (optionalArgument->HasValue()) + // Must always clean these up so they don't carry over to the next + // command invocation in interactive mode. + switch (type) { - optionalArgument->Value().clear(); + case ArgumentType::Complex: { + // No optional complex arguments so far. + VerifyOrDie(false); + break; + } + case ArgumentType::Custom: { + // No optional custom arguments so far. + VerifyOrDie(false); + break; + } + case ArgumentType::VectorBool: { + auto vectorArgument = static_cast *>(arg.value); + vectorArgument->clear(); + break; + } + case ArgumentType::Vector16: { + // No optional Vector16 arguments so far. + VerifyOrDie(false); + break; + } + case ArgumentType::Vector32: { + ResetOptionalArg>(arg); + break; + } + case ArgumentType::VectorCustom: { + // No optional VectorCustom arguments so far. + VerifyOrDie(false); + break; + } + case ArgumentType::Attribute: { + // No optional Attribute arguments so far. + VerifyOrDie(false); + break; + } + case ArgumentType::String: { + ResetOptionalArg(arg); + break; + } + case ArgumentType::CharString: { + ResetOptionalArg(arg); + break; + } + case ArgumentType::OctetString: { + ResetOptionalArg(arg); + break; + } + case ArgumentType::Bool: { + ResetOptionalArg(arg); + break; + } + case ArgumentType::Number_uint8: { + ResetOptionalArg(arg); + break; + } + case ArgumentType::Number_uint16: { + ResetOptionalArg(arg); + break; + } + case ArgumentType::Number_uint32: { + ResetOptionalArg(arg); + break; + } + case ArgumentType::Number_uint64: { + ResetOptionalArg(arg); + break; + } + case ArgumentType::Number_int8: { + ResetOptionalArg(arg); + break; + } + case ArgumentType::Number_int16: { + ResetOptionalArg(arg); + break; + } + case ArgumentType::Number_int32: { + ResetOptionalArg(arg); + break; + } + case ArgumentType::Number_int64: { + ResetOptionalArg(arg); + break; + } + case ArgumentType::Float: { + ResetOptionalArg(arg); + break; + } + case ArgumentType::Double: { + ResetOptionalArg(arg); + break; + } + case ArgumentType::Address: { + ResetOptionalArg(arg); + break; + } } } - else if (type == ArgumentType::VectorCustom && flags != Argument::kOptional) + else { - auto vectorArgument = static_cast *>(arg.value); - for (auto & customArgument : *vectorArgument) + // Some non-optional arguments have state that needs to be cleaned + // up too. + if (type == ArgumentType::Vector16) { - delete customArgument; + auto vectorArgument = static_cast *>(arg.value); + vectorArgument->clear(); + } + else if (type == ArgumentType::Vector32) + { + auto vectorArgument = static_cast *>(arg.value); + vectorArgument->clear(); + } + else if (type == ArgumentType::VectorCustom) + { + auto vectorArgument = static_cast *>(arg.value); + for (auto & customArgument : *vectorArgument) + { + delete customArgument; + } + vectorArgument->clear(); } - vectorArgument->clear(); } } } diff --git a/examples/chip-tool/commands/discover/DiscoverCommissionersCommand.cpp b/examples/chip-tool/commands/discover/DiscoverCommissionersCommand.cpp index 3cb3cf6153f129..b2fe353931328a 100644 --- a/examples/chip-tool/commands/discover/DiscoverCommissionersCommand.cpp +++ b/examples/chip-tool/commands/discover/DiscoverCommissionersCommand.cpp @@ -42,4 +42,6 @@ void DiscoverCommissionersCommand::Shutdown() ChipLogProgress(chipTool, "Total of %d commissioner(s) discovered in %u sec", commissionerCount, std::chrono::duration_cast(GetWaitDuration()).count()); + + CHIPCommand::Shutdown(); } diff --git a/examples/chip-tool/commands/interactive/InteractiveCommands.cpp b/examples/chip-tool/commands/interactive/InteractiveCommands.cpp index dbb3a6fbc1c5f0..8a0235f7bb0fb3 100644 --- a/examples/chip-tool/commands/interactive/InteractiveCommands.cpp +++ b/examples/chip-tool/commands/interactive/InteractiveCommands.cpp @@ -18,9 +18,8 @@ #include "InteractiveCommands.h" +#include #include -#include -#include #include char kInteractiveModeName[] = ""; diff --git a/examples/chip-tool/commands/payload/SetupPayloadGenerateCommand.cpp b/examples/chip-tool/commands/payload/SetupPayloadGenerateCommand.cpp index a9f18be49cd1e6..74abe2a0d58d16 100644 --- a/examples/chip-tool/commands/payload/SetupPayloadGenerateCommand.cpp +++ b/examples/chip-tool/commands/payload/SetupPayloadGenerateCommand.cpp @@ -17,6 +17,7 @@ */ #include "SetupPayloadGenerateCommand.h" +#include #include #include #include @@ -62,9 +63,14 @@ CHIP_ERROR SetupPayloadGenerateQRCodeCommand::Run() { SetupPayload payload; - if (mPayload.HasValue()) + if (mExistingPayload.HasValue()) { - QRCodeSetupPayloadParser(mPayload.Value()).populatePayload(payload); + CHIP_ERROR err = QRCodeSetupPayloadParser(mExistingPayload.Value()).populatePayload(payload); + if (err != CHIP_NO_ERROR) + { + ChipLogError(chipTool, "Invalid existing payload: %" CHIP_ERROR_FORMAT, err.Format()); + return err; + } } ConfigurePayload(payload); @@ -74,23 +80,135 @@ CHIP_ERROR SetupPayloadGenerateQRCodeCommand::Run() payload.rendezvousInformation.SetRaw(mRendezvous.Value()); } + if (mTLVBytes.HasValue()) + { + CHIP_ERROR err = PopulatePayloadTLVFromBytes(payload, mTLVBytes.Value()); + if (err != CHIP_NO_ERROR) + { + ChipLogError(chipTool, "Unable to populate payload TLV: %" CHIP_ERROR_FORMAT, err.Format()); + return err; + } + } + QRCodeSetupPayloadGenerator generator(payload); generator.SetAllowInvalidPayload(mAllowInvalidPayload.ValueOr(false)); std::string code; - ReturnErrorOnFailure(generator.payloadBase38Representation(code)); + ReturnErrorOnFailure(generator.payloadBase38RepresentationWithAutoTLVBuffer(code)); ChipLogProgress(chipTool, "QR Code: %s", code.c_str()); return CHIP_NO_ERROR; } +CHIP_ERROR SetupPayloadGenerateQRCodeCommand::PopulatePayloadTLVFromBytes(SetupPayload & payload, const ByteSpan & tlvBytes) +{ + // First clear out all the existing TVL bits from the payload. Ignore + // errors here, because we don't care if those bits are not present. + payload.removeSerialNumber(); + + auto existingVendorData = payload.getAllOptionalVendorData(); + for (auto & data : existingVendorData) + { + payload.removeOptionalVendorData(data.tag); + } + + if (tlvBytes.empty()) + { + // Used to just clear out the existing TLV. + return CHIP_NO_ERROR; + } + + TLV::TLVReader reader; + reader.Init(tlvBytes); + + // Data is a TLV structure. + ReturnErrorOnFailure(reader.Next(TLV::kTLVType_Structure, TLV::AnonymousTag())); + + TLV::TLVType outerType; + ReturnErrorOnFailure(reader.EnterContainer(outerType)); + + CHIP_ERROR err; + while ((err = reader.Next()) == CHIP_NO_ERROR) + { + TLV::Tag tag = reader.GetTag(); + if (!TLV::IsContextTag(tag)) + { + ChipLogError(chipTool, "Unexpected non-context TLV tag."); + return CHIP_ERROR_INVALID_TLV_TAG; + } + + uint8_t tagNum = static_cast(TLV::TagNumFromTag(tag)); + if (tagNum < 0x80) + { + // Matter-common tag. + if (tagNum != kSerialNumberTag) + { + ChipLogError(chipTool, "No support yet for Matter-common tags other than serial number"); + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; + } + + // Serial number can be a string or an unsigned integer. + if (reader.GetType() == TLV::kTLVType_UTF8String) + { + CharSpan data; + ReturnErrorOnFailure(reader.Get(data)); + ReturnErrorOnFailure(payload.addSerialNumber(std::string(data.data(), data.size()))); + continue; + } + + if (reader.GetType() == TLV::kTLVType_UnsignedInteger) + { + uint32_t value; + ReturnErrorOnFailure(reader.Get(value)); + ReturnErrorOnFailure(payload.addSerialNumber(value)); + continue; + } + + ChipLogError(chipTool, "Unexpected type for serial number: %d", to_underlying(reader.GetType())); + return CHIP_ERROR_WRONG_TLV_TYPE; + } + + // Vendor tag. We support strings and signed integers. + if (reader.GetType() == TLV::kTLVType_UTF8String) + { + CharSpan data; + ReturnErrorOnFailure(reader.Get(data)); + ReturnErrorOnFailure(payload.addOptionalVendorData(tagNum, std::string(data.data(), data.size()))); + continue; + } + + if (reader.GetType() == TLV::kTLVType_SignedInteger) + { + int32_t value; + ReturnErrorOnFailure(reader.Get(value)); + ReturnErrorOnFailure(payload.addOptionalVendorData(tagNum, value)); + continue; + } + + ChipLogError(chipTool, "Unexpected type for vendor data: %d", to_underlying(reader.GetType())); + return CHIP_ERROR_WRONG_TLV_TYPE; + } + + VerifyOrReturnError(err == CHIP_END_OF_TLV, err); + + ReturnErrorOnFailure(reader.ExitContainer(outerType)); + ReturnErrorOnFailure(reader.VerifyEndOfContainer()); + + return CHIP_NO_ERROR; +} + CHIP_ERROR SetupPayloadGenerateManualCodeCommand::Run() { SetupPayload payload; - if (mPayload.HasValue()) + if (mExistingPayload.HasValue()) { - ManualSetupPayloadParser(mPayload.Value()).populatePayload(payload); + CHIP_ERROR err = ManualSetupPayloadParser(mExistingPayload.Value()).populatePayload(payload); + if (err != CHIP_NO_ERROR) + { + ChipLogError(chipTool, "Invalid existing payload: %" CHIP_ERROR_FORMAT, err.Format()); + return err; + } } ConfigurePayload(payload); diff --git a/examples/chip-tool/commands/payload/SetupPayloadGenerateCommand.h b/examples/chip-tool/commands/payload/SetupPayloadGenerateCommand.h index 9e0d13c7cef3b2..31a16e1d9940a5 100644 --- a/examples/chip-tool/commands/payload/SetupPayloadGenerateCommand.h +++ b/examples/chip-tool/commands/payload/SetupPayloadGenerateCommand.h @@ -26,7 +26,7 @@ class SetupPayloadGenerateCommand : public Command public: SetupPayloadGenerateCommand(const char * name) : Command(name) { - AddArgument("payload", &mPayload); + AddArgument("existing-payload", &mExistingPayload, "An existing setup payload to modify based on the other arguments."); AddArgument("discriminator", 0, UINT16_MAX, &mDiscriminator); AddArgument("setup-pin-code", 0, UINT32_MAX, &mSetUpPINCode); AddArgument("version", 0, UINT8_MAX, &mVersion); @@ -44,7 +44,7 @@ class SetupPayloadGenerateCommand : public Command chip::Optional mVersion; chip::Optional mVendorId; chip::Optional mProductId; - chip::Optional mPayload; + chip::Optional mExistingPayload; chip::Optional mCommissioningMode; chip::Optional mAllowInvalidPayload; }; @@ -55,11 +55,18 @@ class SetupPayloadGenerateQRCodeCommand : public SetupPayloadGenerateCommand SetupPayloadGenerateQRCodeCommand() : SetupPayloadGenerateCommand("generate-qrcode") { AddArgument("rendezvous", 0, UINT8_MAX, &mRendezvous); + AddArgument( + "tlvBytes", &mTLVBytes, + "Pre-encoded TLV for the optional part of the payload. A nonempty value should be passed as \"hex:\" followed by the " + "bytes in hex encoding. Passing an empty string to override the TLV in an existing payload is allowed."); } CHIP_ERROR Run() override; private: + static CHIP_ERROR PopulatePayloadTLVFromBytes(chip::SetupPayload & payload, const chip::ByteSpan & tlvBytes); + chip::Optional mRendezvous; + chip::Optional mTLVBytes; }; class SetupPayloadGenerateManualCodeCommand : public SetupPayloadGenerateCommand diff --git a/examples/chip-tool/config/PersistentStorage.cpp b/examples/chip-tool/config/PersistentStorage.cpp index 8ec4eb35c256f0..f8ceb248095709 100644 --- a/examples/chip-tool/config/PersistentStorage.cpp +++ b/examples/chip-tool/config/PersistentStorage.cpp @@ -18,8 +18,7 @@ #include "PersistentStorage.h" #include -#include -#include +#include #include #include @@ -30,6 +29,7 @@ using Sections = std::map; using namespace ::chip; using namespace ::chip::Controller; +using namespace ::chip::IniEscaping; using namespace ::chip::Logging; constexpr const char kDefaultSectionName[] = "Default"; @@ -48,37 +48,6 @@ std::string GetFilename(const char * name) return "/tmp/chip_tool_config." + std::string(name) + ".ini"; } -namespace { - -std::string StringToBase64(const std::string & value) -{ - std::unique_ptr buffer(new char[BASE64_ENCODED_LEN(value.length())]); - - uint32_t len = - chip::Base64Encode32(reinterpret_cast(value.data()), static_cast(value.length()), buffer.get()); - if (len == UINT32_MAX) - { - return ""; - } - - return std::string(buffer.get(), len); -} - -std::string Base64ToString(const std::string & b64Value) -{ - std::unique_ptr buffer(new uint8_t[BASE64_MAX_DECODED_LEN(b64Value.length())]); - - uint32_t len = chip::Base64Decode32(b64Value.data(), static_cast(b64Value.length()), buffer.get()); - if (len == UINT32_MAX) - { - return ""; - } - - return std::string(reinterpret_cast(buffer.get()), len); -} - -} // namespace - CHIP_ERROR PersistentStorage::Init(const char * name) { CHIP_ERROR err = CHIP_NO_ERROR; @@ -95,6 +64,12 @@ CHIP_ERROR PersistentStorage::Init(const char * name) mName = name; mConfig.parse(ifs); ifs.close(); + + // To audit the contents at init, uncomment the following: +#if 0 + DumpKeys(); +#endif + exit: return err; } @@ -106,10 +81,11 @@ CHIP_ERROR PersistentStorage::SyncGetKeyValue(const char * key, void * value, ui ReturnErrorCodeIf(((value == nullptr) && (size != 0)), CHIP_ERROR_INVALID_ARGUMENT); auto section = mConfig.sections[kDefaultSectionName]; - auto it = section.find(key); - ReturnErrorCodeIf(it == section.end(), CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); - ReturnErrorCodeIf(!inipp::extract(section[key], iniValue), CHIP_ERROR_INVALID_ARGUMENT); + ReturnErrorCodeIf(!SyncDoesKeyExist(key), CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); + + std::string escapedKey = EscapeKey(key); + ReturnErrorCodeIf(!inipp::extract(section[escapedKey], iniValue), CHIP_ERROR_INVALID_ARGUMENT); iniValue = Base64ToString(iniValue); @@ -126,8 +102,19 @@ CHIP_ERROR PersistentStorage::SyncGetKeyValue(const char * key, void * value, ui CHIP_ERROR PersistentStorage::SyncSetKeyValue(const char * key, const void * value, uint16_t size) { + ReturnErrorCodeIf((value == nullptr) && (size != 0), CHIP_ERROR_INVALID_ARGUMENT); + auto section = mConfig.sections[kDefaultSectionName]; - section[key] = StringToBase64(std::string(static_cast(value), size)); + + std::string escapedKey = EscapeKey(key); + if (value == nullptr) + { + section[escapedKey] = ""; + } + else + { + section[escapedKey] = StringToBase64(std::string(static_cast(value), size)); + } mConfig.sections[kDefaultSectionName] = section; return CommitConfig(mName); @@ -136,15 +123,42 @@ CHIP_ERROR PersistentStorage::SyncSetKeyValue(const char * key, const void * val CHIP_ERROR PersistentStorage::SyncDeleteKeyValue(const char * key) { auto section = mConfig.sections[kDefaultSectionName]; - auto it = section.find(key); - ReturnErrorCodeIf(it == section.end(), CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); - section.erase(key); + ReturnErrorCodeIf(!SyncDoesKeyExist(key), CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); + + std::string escapedKey = EscapeKey(key); + section.erase(escapedKey); mConfig.sections[kDefaultSectionName] = section; return CommitConfig(mName); } +bool PersistentStorage::SyncDoesKeyExist(const char * key) +{ + std::string escapedKey = EscapeKey(key); + auto section = mConfig.sections[kDefaultSectionName]; + auto it = section.find(escapedKey); + return (it != section.end()); +} + +void PersistentStorage::DumpKeys() const +{ +#if CHIP_PROGRESS_LOGGING + for (const auto & section : mConfig.sections) + { + const std::string & sectionName = section.first; + const auto & sectionContent = section.second; + + ChipLogProgress(chipTool, "[%s]", sectionName.c_str()); + for (const auto & entry : sectionContent) + { + const std::string & keyName = entry.first; + ChipLogProgress(chipTool, " => %s", UnescapeKey(keyName).c_str()); + } + } +#endif // CHIP_PROGRESS_LOGGING +} + CHIP_ERROR PersistentStorage::SyncClearAll() { ChipLogProgress(chipTool, "Clearing %s storage", kDefaultSectionName); diff --git a/examples/chip-tool/config/PersistentStorage.h b/examples/chip-tool/config/PersistentStorage.h index d26582ea9b9dfa..f2afde99355bf7 100644 --- a/examples/chip-tool/config/PersistentStorage.h +++ b/examples/chip-tool/config/PersistentStorage.h @@ -32,6 +32,9 @@ class PersistentStorage : public chip::PersistentStorageDelegate CHIP_ERROR SyncGetKeyValue(const char * key, void * buffer, uint16_t & size) override; CHIP_ERROR SyncSetKeyValue(const char * key, const void * value, uint16_t size) override; CHIP_ERROR SyncDeleteKeyValue(const char * key) override; + bool SyncDoesKeyExist(const char * key) override; + + void DumpKeys() const; uint16_t GetListenPort(); chip::Logging::LogCategory GetLoggingLevel(); diff --git a/examples/chip-tool/templates/commands.zapt b/examples/chip-tool/templates/commands.zapt index 25c8a54859f471..2600ce10eeaa1f 100644 --- a/examples/chip-tool/templates/commands.zapt +++ b/examples/chip-tool/templates/commands.zapt @@ -137,6 +137,7 @@ void registerClusterAny(Commands & commands, CredentialIssuerCommands * credsIss make_unique(credsIssuerConfig), // make_unique(credsIssuerConfig), // make_unique(credsIssuerConfig), // + make_unique(credsIssuerConfig), // }; commands.Register(clusterName, clusterCommands); diff --git a/examples/common/pigweed/bouffalolab/bl602/PigweedLoggerMutex.cpp b/examples/common/pigweed/bouffalolab/bl602/PigweedLoggerMutex.cpp new file mode 100644 index 00000000000000..5061d53e768a6d --- /dev/null +++ b/examples/common/pigweed/bouffalolab/bl602/PigweedLoggerMutex.cpp @@ -0,0 +1,27 @@ +/* + * + * 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 "PigweedLoggerMutex.h" + +namespace chip { +namespace rpc { + +PigweedLoggerMutex logger_mutex; + +} // namespace rpc +} // namespace chip diff --git a/examples/common/pigweed/bouffalolab/bl602/PigweedLoggerMutex.h b/examples/common/pigweed/bouffalolab/bl602/PigweedLoggerMutex.h new file mode 100644 index 00000000000000..4df8b616895e39 --- /dev/null +++ b/examples/common/pigweed/bouffalolab/bl602/PigweedLoggerMutex.h @@ -0,0 +1,54 @@ +/* + * + * 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 "PigweedLogger.h" +#include "pigweed/RpcService.h" +#include "semphr.h" +#include + +namespace chip { +namespace rpc { +class PigweedLoggerMutex : public ::chip::rpc::Mutex +{ + +public: + PigweedLoggerMutex() {} + void Lock() override + { + SemaphoreHandle_t * sem = PigweedLogger::GetSemaphore(); + if (sem) + { + xSemaphoreTake(*sem, portMAX_DELAY); + } + } + void Unlock() override + { + SemaphoreHandle_t * sem = PigweedLogger::GetSemaphore(); + if (sem) + { + xSemaphoreGive(*sem); + } + } +}; + +extern PigweedLoggerMutex logger_mutex; + +} // namespace rpc +} // namespace chip diff --git a/examples/common/pigweed/rpc_services/Device.h b/examples/common/pigweed/rpc_services/Device.h index 67de5e3c3b3749..d3d5afd165810d 100644 --- a/examples/common/pigweed/rpc_services/Device.h +++ b/examples/common/pigweed/rpc_services/Device.h @@ -223,6 +223,7 @@ class Device : public pw_rpc::nanopb::Device::Service virtual pw::Status TriggerOta(const pw_protobuf_Empty & request, pw_protobuf_Empty & response) { +#if CONFIG_CHIP_OTA_REQUESTOR chip::DeviceLayer::PlatformMgr().ScheduleWork( [](intptr_t) { chip::OTARequestorInterface * requestor = chip::GetRequestorInstance(); @@ -237,6 +238,10 @@ class Device : public pw_rpc::nanopb::Device::Service }, reinterpret_cast(nullptr)); return pw::OkStatus(); +#else + ChipLogError(AppServer, "Trigger OTA requested, but OTA requestor not compiled in."); + return pw::Status::Unimplemented(); +#endif } virtual pw::Status SetPairingState(const chip_rpc_PairingState & request, pw_protobuf_Empty & response) diff --git a/examples/darwin-framework-tool/BUILD.gn b/examples/darwin-framework-tool/BUILD.gn index 58d4dd3dd18196..5469315293126e 100644 --- a/examples/darwin-framework-tool/BUILD.gn +++ b/examples/darwin-framework-tool/BUILD.gn @@ -18,16 +18,26 @@ import("//build_overrides/chip.gni") import("${chip_root}/build/chip/tools.gni") import("${chip_root}/examples//chip-tool/chip-tool.gni") +if (config_use_interactive_mode) { + import("//build_overrides/editline.gni") +} + assert(chip_build_tools) config("config") { include_dirs = [ ".", + "${chip_root}/src/darwin/Framework/CHIP/zap-generated", + "${chip_root}/src/darwin/Framework/CHIP", + "${chip_root}/examples/darwin-framework-tool/commands/common", "${chip_root}/zzz_generated/darwin-framework-tool", "${chip_root}/zzz_generated/controller-clusters", "${chip_root}/examples/chip-tool/commands/clusters/ComplexArgument.h", + "/tmp/macos_framework_output", ] + framework_dirs = [ "/tmp/macos_framework_output" ] + defines = [ "CONFIG_ENABLE_YAML_TESTS=${config_enable_yaml_tests}", "CONFIG_USE_INTERACTIVE_MODE=${config_use_interactive_mode}", @@ -37,10 +47,6 @@ config("config") { "-Wconversion", "-fobjc-arc", ] - - if (config_use_interactive_mode) { - libs = [ "readline" ] - } } executable("darwin-framework-tool") { @@ -51,6 +57,7 @@ executable("darwin-framework-tool") { # privilege-storage.cpp. "${chip_root}/src/app/util/privilege-storage.cpp", "${chip_root}/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp", + "${chip_root}/zzz_generated/controller-clusters/zap-generated/CHIPClusters.h", "commands/clusters/ClusterCommandBridge.h", "commands/clusters/ModelCommandBridge.mm", "commands/clusters/ReportCommandBridge.h", @@ -58,11 +65,15 @@ executable("darwin-framework-tool") { "commands/common/CHIPCommandBridge.mm", "commands/common/CHIPCommandStorageDelegate.mm", "commands/common/CHIPToolKeypair.mm", + "commands/common/MTRError.mm", + "commands/common/MTRError_Utils.h", + "commands/common/MTRLogging.h", "commands/pairing/Commands.h", "commands/pairing/OpenCommissioningWindowCommand.h", "commands/pairing/OpenCommissioningWindowCommand.mm", "commands/pairing/PairingCommandBridge.mm", "commands/pairing/PairingDelegateBridge.mm", + "commands/payload/SetupPayloadParseCommand.mm", "commands/storage/Commands.h", "commands/storage/StorageManagementCommand.mm", "main.mm", @@ -70,22 +81,28 @@ executable("darwin-framework-tool") { if (config_use_interactive_mode) { sources += [ "commands/interactive/InteractiveCommands.mm" ] + deps += [ "${editline_root}:editline" ] } if (config_enable_yaml_tests) { - sources += [ "${chip_root}/zzz_generated/darwin-framework-tool/zap-generated/cluster/CHIPTestClustersObjc.mm" ] + sources += [ "${chip_root}/zzz_generated/darwin-framework-tool/zap-generated/cluster/MTRTestClustersObjc.mm" ] } deps = [ "${chip_root}/examples/chip-tool:chip-tool-utils", "${chip_root}/src/app/server", - "${chip_root}/src/darwin/Framework/CHIP", + "${chip_root}/src/darwin/Framework/CHIP:static-matter", "${chip_root}/src/lib", "${chip_root}/src/platform", "${chip_root}/third_party/inipp", "${chip_root}/third_party/jsoncpp", ] + frameworks = [ + "Matter.framework", + "Security.framework", + ] + public_configs = [ ":config" ] output_dir = root_out_dir diff --git a/examples/darwin-framework-tool/commands/clusters/ClusterCommandBridge.h b/examples/darwin-framework-tool/commands/clusters/ClusterCommandBridge.h index 4eac3990aba8c4..c7c71a324e2a0d 100644 --- a/examples/darwin-framework-tool/commands/clusters/ClusterCommandBridge.h +++ b/examples/darwin-framework-tool/commands/clusters/ClusterCommandBridge.h @@ -18,8 +18,9 @@ #pragma once -#import -#import // For NSObjectFromCHIPTLV +#import "MTRError_Utils.h" +#import + #include #include "ModelCommandBridge.h" @@ -46,7 +47,7 @@ class ClusterCommand : public ModelCommand { ~ClusterCommand() {} - CHIP_ERROR SendCommand(CHIPDevice * _Nonnull device, chip::EndpointId endpointId) override + CHIP_ERROR SendCommand(MTRDevice * _Nonnull device, chip::EndpointId endpointId) override { chip::TLV::TLVWriter writer; chip::TLV::TLVReader reader; @@ -67,7 +68,7 @@ class ClusterCommand : public ModelCommand { return ClusterCommand::SendCommand(device, endpointId, mClusterId, mCommandId, commandFields); } - CHIP_ERROR SendCommand(CHIPDevice * _Nonnull device, chip::EndpointId endpointId, chip::ClusterId clusterId, + CHIP_ERROR SendCommand(MTRDevice * _Nonnull device, chip::EndpointId endpointId, chip::ClusterId clusterId, chip::CommandId commandId, id _Nonnull commandFields) { uint16_t repeatCount = mRepeatCount.ValueOr(1); diff --git a/examples/darwin-framework-tool/commands/clusters/ModelCommandBridge.h b/examples/darwin-framework-tool/commands/clusters/ModelCommandBridge.h index adb1d21dece650..ad86fa79aa690e 100644 --- a/examples/darwin-framework-tool/commands/clusters/ModelCommandBridge.h +++ b/examples/darwin-framework-tool/commands/clusters/ModelCommandBridge.h @@ -42,7 +42,7 @@ class ModelCommand : public CHIPCommandBridge CHIP_ERROR RunCommand() override; chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(10); } - virtual CHIP_ERROR SendCommand(CHIPDevice * _Nonnull device, chip::EndpointId endPointId) = 0; + virtual CHIP_ERROR SendCommand(MTRDevice * _Nonnull device, chip::EndpointId endPointId) = 0; private: chip::NodeId mNodeId; diff --git a/examples/darwin-framework-tool/commands/clusters/ModelCommandBridge.mm b/examples/darwin-framework-tool/commands/clusters/ModelCommandBridge.mm index 8a27391324cdc5..e039391b8e6289 100644 --- a/examples/darwin-framework-tool/commands/clusters/ModelCommandBridge.mm +++ b/examples/darwin-framework-tool/commands/clusters/ModelCommandBridge.mm @@ -19,34 +19,37 @@ #include "ModelCommandBridge.h" #include +#import + using namespace ::chip; CHIP_ERROR ModelCommand::RunCommand() { dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip-tool.command", DISPATCH_QUEUE_SERIAL); + MTRDeviceController * commissioner = CurrentCommissioner(); ChipLogProgress(chipTool, "Sending command to node 0x" ChipLogFormatX64, ChipLogValueX64(mNodeId)); - [CurrentCommissioner() getConnectedDevice:mNodeId - queue:callbackQueue - completionHandler:^(CHIPDevice * _Nullable device, NSError * _Nullable error) { - if (error != nil) { - SetCommandExitStatus(error, "Error getting connected device"); - return; - } - - CHIP_ERROR err; - if (device == nil) { - err = CHIP_ERROR_INTERNAL; - } else { - err = SendCommand(device, mEndPointId); - } - - if (err != CHIP_NO_ERROR) { - ChipLogError(chipTool, "Error: %s", chip::ErrorStr(err)); - SetCommandExitStatus(err); - return; - } - }]; + [commissioner getDevice:mNodeId + queue:callbackQueue + completionHandler:^(MTRDevice * _Nullable device, NSError * _Nullable error) { + if (error != nil) { + SetCommandExitStatus(error, "Error getting connected device"); + return; + } + + CHIP_ERROR err; + if (device == nil) { + err = CHIP_ERROR_INTERNAL; + } else { + err = SendCommand(device, mEndPointId); + } + + if (err != CHIP_NO_ERROR) { + ChipLogError(chipTool, "Error: %s", chip::ErrorStr(err)); + SetCommandExitStatus(err); + return; + } + }]; return CHIP_NO_ERROR; } diff --git a/examples/darwin-framework-tool/commands/clusters/ReportCommandBridge.h b/examples/darwin-framework-tool/commands/clusters/ReportCommandBridge.h index 17baa322ddc581..3357b12a8eada6 100644 --- a/examples/darwin-framework-tool/commands/clusters/ReportCommandBridge.h +++ b/examples/darwin-framework-tool/commands/clusters/ReportCommandBridge.h @@ -50,10 +50,10 @@ class ReadAttribute : public ModelCommand { ~ReadAttribute() {} - CHIP_ERROR SendCommand(CHIPDevice * _Nonnull device, chip::EndpointId endpointId) override + CHIP_ERROR SendCommand(MTRDevice * _Nonnull device, chip::EndpointId endpointId) override { dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); - CHIPReadParams * params = [[CHIPReadParams alloc] init]; + MTRReadParams * params = [[MTRReadParams alloc] init]; params.fabricFiltered = mFabricFiltered.HasValue() ? [NSNumber numberWithBool:mFabricFiltered.Value()] : nil; [device readAttributeWithEndpointId:[NSNumber numberWithUnsignedShort:endpointId] @@ -125,10 +125,10 @@ class SubscribeAttribute : public ModelCommand { ~SubscribeAttribute() {} - CHIP_ERROR SendCommand(CHIPDevice * _Nonnull device, chip::EndpointId endpointId) override + CHIP_ERROR SendCommand(MTRDevice * _Nonnull device, chip::EndpointId endpointId) override { dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); - CHIPSubscribeParams * params = [[CHIPSubscribeParams alloc] init]; + MTRSubscribeParams * params = [[MTRSubscribeParams alloc] init]; params.keepPreviousSubscriptions = mKeepSubscriptions.HasValue() ? [NSNumber numberWithBool:mKeepSubscriptions.Value()] : nil; [device subscribeAttributeWithEndpointId:[NSNumber numberWithUnsignedShort:endpointId] @@ -195,11 +195,11 @@ class SubscribeEvent : public ModelCommand { ~SubscribeEvent() {} - CHIP_ERROR SendCommand(CHIPDevice * _Nonnull device, chip::EndpointId endpointId) override + CHIP_ERROR SendCommand(MTRDevice * _Nonnull device, chip::EndpointId endpointId) override { dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); - CHIPSubscribeParams * params = [[CHIPSubscribeParams alloc] init]; + MTRSubscribeParams * params = [[MTRSubscribeParams alloc] init]; params.keepPreviousSubscriptions = mKeepSubscriptions.HasValue() ? [NSNumber numberWithBool:mKeepSubscriptions.Value()] : nil; [device subscribeWithQueue:callbackQueue diff --git a/examples/darwin-framework-tool/commands/clusters/WriteAttributeCommandBridge.h b/examples/darwin-framework-tool/commands/clusters/WriteAttributeCommandBridge.h index 69c52aa21797ac..37df173a8c417b 100644 --- a/examples/darwin-framework-tool/commands/clusters/WriteAttributeCommandBridge.h +++ b/examples/darwin-framework-tool/commands/clusters/WriteAttributeCommandBridge.h @@ -22,6 +22,9 @@ #include "ModelCommandBridge.h" +#import "MTRError_Utils.h" +#import + class WriteAttribute : public ModelCommand { public: WriteAttribute() @@ -44,7 +47,7 @@ class WriteAttribute : public ModelCommand { ~WriteAttribute() {} - CHIP_ERROR SendCommand(CHIPDevice * _Nonnull device, chip::EndpointId endpointId) override + CHIP_ERROR SendCommand(MTRDevice * _Nonnull device, chip::EndpointId endpointId) override { chip::TLV::TLVWriter writer; chip::TLV::TLVReader reader; @@ -66,7 +69,7 @@ class WriteAttribute : public ModelCommand { return WriteAttribute::SendCommand(device, endpointId, mClusterId, mAttributeId, value); } - CHIP_ERROR SendCommand(CHIPDevice * _Nonnull device, chip::EndpointId endpointId, chip::ClusterId clusterId, + CHIP_ERROR SendCommand(MTRDevice * _Nonnull device, chip::EndpointId endpointId, chip::ClusterId clusterId, chip::AttributeId attributeId, id _Nonnull value) { dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); diff --git a/examples/darwin-framework-tool/commands/common/CHIPCommandBridge.h b/examples/darwin-framework-tool/commands/common/CHIPCommandBridge.h index 2891a8f7e05e50..5892d21ec8f079 100644 --- a/examples/darwin-framework-tool/commands/common/CHIPCommandBridge.h +++ b/examples/darwin-framework-tool/commands/common/CHIPCommandBridge.h @@ -17,7 +17,7 @@ */ #pragma once -#import +#import #include #include #include @@ -67,9 +67,9 @@ class CHIPCommandBridge : public Command void SetIdentity(const char * identity); // This method returns the commissioner instance to be used for running the command. - CHIPDeviceController * CurrentCommissioner(); + MTRDeviceController * CurrentCommissioner(); - CHIPDeviceController * GetCommissioner(const char * identity); + MTRDeviceController * GetCommissioner(const char * identity); // Will log the given string and given error (as progress if success, error // if failure). @@ -106,10 +106,10 @@ class CHIPCommandBridge : public Command void MaybeTearDownStack(); // Our three controllers: alpha, beta, gamma. - static std::map mControllers; + static std::map mControllers; // The current controller; the one the current command should be using. - CHIPDeviceController * mCurrentController; + MTRDeviceController * mCurrentController; std::condition_variable cvWaitingForResponse; std::mutex cvWaitingForResponseMutex; diff --git a/examples/darwin-framework-tool/commands/common/CHIPCommandBridge.mm b/examples/darwin-framework-tool/commands/common/CHIPCommandBridge.mm index 995c9f7d686fe1..caebb41c20de2a 100644 --- a/examples/darwin-framework-tool/commands/common/CHIPCommandBridge.mm +++ b/examples/darwin-framework-tool/commands/common/CHIPCommandBridge.mm @@ -19,16 +19,17 @@ #include "CHIPCommandBridge.h" #import "CHIPToolKeypair.h" -#import -#import +#import #include #include +#include "MTRError_Utils.h" + const uint16_t kListenPort = 5541; static CHIPToolPersistentStorageDelegate * storage = nil; std::set CHIPCommandBridge::sDeferredCleanups; -std::map CHIPCommandBridge::mControllers; +std::map CHIPCommandBridge::mControllers; CHIP_ERROR CHIPCommandBridge::Run() { @@ -61,13 +62,13 @@ CHIPToolKeypair * nocSigner = [[CHIPToolKeypair alloc] init]; storage = [[CHIPToolPersistentStorageDelegate alloc] init]; - auto factory = [MatterControllerFactory sharedInstance]; + auto factory = [MTRControllerFactory sharedInstance]; if (factory == nil) { ChipLogError(chipTool, "Controller factory is nil"); return CHIP_ERROR_INTERNAL; } - auto params = [[MatterControllerFactoryParams alloc] initWithStorage:storage]; + auto params = [[MTRControllerFactoryParams alloc] initWithStorage:storage]; params.port = @(kListenPort); params.startServer = YES; @@ -82,9 +83,9 @@ constexpr const char * identities[] = { kIdentityAlpha, kIdentityBeta, kIdentityGamma }; for (size_t i = 0; i < ArraySize(identities); ++i) { - auto controllerParams = [[CHIPDeviceControllerStartupParams alloc] initWithSigningKeypair:nocSigner - fabricId:(i + 1) - ipk:ipk]; + auto controllerParams = [[MTRDeviceControllerStartupParams alloc] initWithSigningKeypair:nocSigner + fabricId:(i + 1) + ipk:ipk]; // We're not sure whether we're creating a new fabric or using an // existing one, so just try both. @@ -124,9 +125,9 @@ mCurrentController = mControllers[name]; } -CHIPDeviceController * CHIPCommandBridge::CurrentCommissioner() { return mCurrentController; } +MTRDeviceController * CHIPCommandBridge::CurrentCommissioner() { return mCurrentController; } -CHIPDeviceController * CHIPCommandBridge::GetCommissioner(const char * identity) { return mControllers[identity]; } +MTRDeviceController * CHIPCommandBridge::GetCommissioner(const char * identity) { return mControllers[identity]; } void CHIPCommandBridge::ShutdownCommissioner() { @@ -137,7 +138,7 @@ mControllers.clear(); mCurrentController = nil; - [[MatterControllerFactory sharedInstance] shutdown]; + [[MTRControllerFactory sharedInstance] shutdown]; } CHIP_ERROR CHIPCommandBridge::StartWaiting(chip::System::Clock::Timeout duration) @@ -167,13 +168,13 @@ if (logString != nullptr) { LogNSError(logString, error); } - CHIP_ERROR err = [CHIPError errorToCHIPErrorCode:error]; + CHIP_ERROR err = MTRErrorToCHIPErrorCode(error); SetCommandExitStatus(err); } void CHIPCommandBridge::LogNSError(const char * logString, NSError * error) { - CHIP_ERROR err = [CHIPError errorToCHIPErrorCode:error]; + CHIP_ERROR err = MTRErrorToCHIPErrorCode(error); if (err == CHIP_NO_ERROR) { ChipLogProgress(chipTool, "%s: %s", logString, chip::ErrorStr(err)); } else { diff --git a/examples/darwin-framework-tool/commands/common/CHIPCommandStorageDelegate.h b/examples/darwin-framework-tool/commands/common/CHIPCommandStorageDelegate.h index e4e5e14a2011bd..c2f7ba220e9e50 100644 --- a/examples/darwin-framework-tool/commands/common/CHIPCommandStorageDelegate.h +++ b/examples/darwin-framework-tool/commands/common/CHIPCommandStorageDelegate.h @@ -1,9 +1,9 @@ -#import #import +#import NS_ASSUME_NONNULL_BEGIN -@interface CHIPToolPersistentStorageDelegate : NSObject +@interface CHIPToolPersistentStorageDelegate : NSObject - (nullable NSData *)storageDataForKey:(NSString *)key; - (BOOL)setStorageData:(NSData *)value forKey:(NSString *)key; - (BOOL)removeStorageDataForKey:(NSString *)key; diff --git a/examples/darwin-framework-tool/commands/common/CHIPCommandStorageDelegate.mm b/examples/darwin-framework-tool/commands/common/CHIPCommandStorageDelegate.mm index 5d217ed56b4245..7712eab13cd29f 100644 --- a/examples/darwin-framework-tool/commands/common/CHIPCommandStorageDelegate.mm +++ b/examples/darwin-framework-tool/commands/common/CHIPCommandStorageDelegate.mm @@ -1,8 +1,10 @@ #include "CHIPCommandStorageDelegate.h" +#import + NSString * const kCHIPToolDefaultsDomain = @"com.apple.chiptool"; -id CHIPGetDomainValueForKey(NSString * domain, NSString * key) +id MTRGetDomainValueForKey(NSString * domain, NSString * key) { id value = (id) CFBridgingRelease(CFPreferencesCopyAppValue((CFStringRef) key, (CFStringRef) domain)); if (value) { @@ -11,13 +13,13 @@ id CHIPGetDomainValueForKey(NSString * domain, NSString * key) return nil; } -BOOL CHIPSetDomainValueForKey(NSString * domain, NSString * key, id value) +BOOL MTRSetDomainValueForKey(NSString * domain, NSString * key, id value) { CFPreferencesSetAppValue((CFStringRef) key, (__bridge CFPropertyListRef _Nullable)(value), (CFStringRef) domain); return CFPreferencesAppSynchronize((CFStringRef) domain) == true; } -BOOL CHIPRemoveDomainValueForKey(NSString * domain, NSString * key) +BOOL MTRRemoveDomainValueForKey(NSString * domain, NSString * key) { CFPreferencesSetAppValue((CFStringRef) key, nullptr, (CFStringRef) domain); return CFPreferencesAppSynchronize((CFStringRef) domain) == true; @@ -40,7 +42,7 @@ BOOL CHIPClearAllDomain(NSString * domain) NSLog(@"Removing keys: %@ %@", allKeys, domain); for (id key in allKeys) { NSLog(@"Removing key: %@", key); - if (!CHIPRemoveDomainValueForKey(domain, (NSString *) key)) { + if (!MTRRemoveDomainValueForKey(domain, (NSString *) key)) { return NO; } } @@ -58,7 +60,7 @@ - (BOOL)deleteAllStorage - (nullable NSData *)storageDataForKey:(NSString *)key { - NSData * value = CHIPGetDomainValueForKey(kCHIPToolDefaultsDomain, key); + NSData * value = MTRGetDomainValueForKey(kCHIPToolDefaultsDomain, key); NSLog(@"CHIPPersistentStorageDelegate Get Value for Key: %@, value %@", key, value); return value; } @@ -70,10 +72,10 @@ - (BOOL)setStorageData:(NSData *)value forKey:(NSString *)key - (BOOL)removeStorageDataForKey:(NSString *)key { - if (CHIPGetDomainValueForKey(kCHIPToolDefaultsDomain, key) == nil) { + if (MTRGetDomainValueForKey(kCHIPToolDefaultsDomain, key) == nil) { return NO; } - return CHIPRemoveDomainValueForKey(kCHIPToolDefaultsDomain, key); + return MTRRemoveDomainValueForKey(kCHIPToolDefaultsDomain, key); } @end diff --git a/examples/darwin-framework-tool/commands/common/CHIPToolKeypair.h b/examples/darwin-framework-tool/commands/common/CHIPToolKeypair.h index b1721a612dedfb..bd92c406c789c3 100644 --- a/examples/darwin-framework-tool/commands/common/CHIPToolKeypair.h +++ b/examples/darwin-framework-tool/commands/common/CHIPToolKeypair.h @@ -1,11 +1,11 @@ #include "CHIPCommandStorageDelegate.h" -#import +#import #include -@interface CHIPToolKeypair : NSObject +@interface CHIPToolKeypair : NSObject - (BOOL)initialize; - (NSData *)ECDSA_sign_message_raw:(NSData *)message; -- (SecKeyRef)pubkey; +- (SecKeyRef)publicKey; - (CHIP_ERROR)Serialize:(chip::Crypto::P256SerializedKeypair &)output; - (CHIP_ERROR)Deserialize:(chip::Crypto::P256SerializedKeypair &)input; - (CHIP_ERROR)createOrLoadKeys:(CHIPToolPersistentStorageDelegate *)storage; diff --git a/examples/darwin-framework-tool/commands/common/CHIPToolKeypair.mm b/examples/darwin-framework-tool/commands/common/CHIPToolKeypair.mm index 6525a9d319dc2b..56be3fa36b15a3 100644 --- a/examples/darwin-framework-tool/commands/common/CHIPToolKeypair.mm +++ b/examples/darwin-framework-tool/commands/common/CHIPToolKeypair.mm @@ -1,5 +1,5 @@ #import "CHIPToolKeypair.h" -#include +#import #include #include #include @@ -44,7 +44,7 @@ - (NSData *)ECDSA_sign_message_raw:(NSData *)message return out_signature; } -- (SecKeyRef)pubkey +- (SecKeyRef)publicKey { chip::Crypto::P256PublicKey publicKey = _mKeyPair.Pubkey(); NSData * publicKeyNSData = [NSData dataWithBytes:publicKey.Bytes() length:publicKey.Length()]; diff --git a/src/darwin/Framework/CHIP/CHIPCluster_internal.h b/examples/darwin-framework-tool/commands/common/MTRCluster_Externs.h similarity index 78% rename from src/darwin/Framework/CHIP/CHIPCluster_internal.h rename to examples/darwin-framework-tool/commands/common/MTRCluster_Externs.h index b196306f0a3ee4..a71c5301deba2c 100644 --- a/src/darwin/Framework/CHIP/CHIPCluster_internal.h +++ b/examples/darwin-framework-tool/commands/common/MTRCluster_Externs.h @@ -15,18 +15,18 @@ * limitations under the License. */ -#import +#ifndef MTR_CLUSTER_EXTERNS_H +#define MTR_CLUSTER_EXTERNS_H -#import "CHIPCluster.h" -#import "CHIPDevice.h" -#import "CHIPDevice_Internal.h" +#import -#import "zap-generated/CHIPClusters.h" -#import "zap-generated/CHIPClustersObjc.h" +#import -@interface CHIPCluster () +@interface MTRCluster (PrivateExtensions) @property (readonly, nonatomic) dispatch_queue_t callbackQueue; -- (chip::Controller::ClusterBase *)getCluster; + - (chip::ByteSpan)asByteSpan:(NSData *)value; - (chip::CharSpan)asCharSpan:(NSString *)value; @end + +#endif diff --git a/examples/darwin-framework-tool/commands/common/MTRDevice_Externs.h b/examples/darwin-framework-tool/commands/common/MTRDevice_Externs.h new file mode 100644 index 00000000000000..33e8b613e29065 --- /dev/null +++ b/examples/darwin-framework-tool/commands/common/MTRDevice_Externs.h @@ -0,0 +1,40 @@ +/** + * + * Copyright (c) 2020 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef MTR_DEVICE_EXTERNS_H +#define MTR_DEVICE_EXTERNS_H + +#import +#import + +#include +#include +#include + +NS_ASSUME_NONNULL_BEGIN + +@interface MTRDevice (InternalIntrospection) + +// TODO: remove me +// Used to access the internal chip::DeviceProxy from TestCommandBridge +- (chip::DeviceProxy *)internalDevice; + +@end + +NS_ASSUME_NONNULL_END + +#endif /* MTR_DEVICE_EXTERNS_H */ diff --git a/examples/darwin-framework-tool/commands/common/MTRError.mm b/examples/darwin-framework-tool/commands/common/MTRError.mm new file mode 100644 index 00000000000000..5d0abd4b0137e8 --- /dev/null +++ b/examples/darwin-framework-tool/commands/common/MTRError.mm @@ -0,0 +1,222 @@ +/** + * + * Copyright (c) 2020 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import "MTRError_Utils.h" +#import "MTRLogging.h" +#import + +#import +#import +#import +#import +#import + +// Stolen for now from the framework, need to export this properly. +@interface MTRErrorHolder : NSObject +@property (nonatomic, readonly) CHIP_ERROR error; +@end + +CHIP_ERROR MTRErrorToCHIPErrorCode(NSError * error) +{ + if (error == nil) { + return CHIP_NO_ERROR; + } + + if (error.domain == MTRInteractionErrorDomain) { + chip::app::StatusIB status(static_cast(error.code)); + if (error.userInfo != nil && error.userInfo[@"clusterStatus"] != nil) { + status.mClusterStatus.Emplace([error.userInfo[@"clusterStatus"] unsignedCharValue]); + } + return status.ToChipError(); + } + + if (error.domain != MTRErrorDomain) { + return CHIP_ERROR_INTERNAL; + } + + if (error.userInfo != nil) { + id underlyingError = error.userInfo[@"underlyingError"]; + if (underlyingError != nil && [underlyingError isKindOfClass:[MTRErrorHolder class]]) { + return ((MTRErrorHolder *) underlyingError).error; + } + } + + chip::ChipError::StorageType code; + switch (error.code) { + case MTRErrorCodeInvalidStringLength: + code = CHIP_ERROR_INVALID_STRING_LENGTH.AsInteger(); + break; + case MTRErrorCodeInvalidIntegerValue: + code = CHIP_ERROR_INVALID_INTEGER_VALUE.AsInteger(); + break; + case MTRErrorCodeInvalidArgument: + code = CHIP_ERROR_INVALID_ARGUMENT.AsInteger(); + break; + case MTRErrorCodeInvalidMessageLength: + code = CHIP_ERROR_INVALID_MESSAGE_LENGTH.AsInteger(); + break; + case MTRErrorCodeInvalidState: + code = CHIP_ERROR_INCORRECT_STATE.AsInteger(); + break; + case MTRErrorCodeIntegrityCheckFailed: + code = CHIP_ERROR_INTEGRITY_CHECK_FAILED.AsInteger(); + break; + case MTRErrorCodeTimeout: + code = CHIP_ERROR_TIMEOUT.AsInteger(); + break; + case MTRErrorCodeGeneralError: { + if (error.userInfo != nil && error.userInfo[@"errorCode"] != nil) { + code = static_cast([error.userInfo[@"errorCode"] unsignedLongValue]); + break; + } + // Weird error we did not create. Fall through. + default: + code = CHIP_ERROR_INTERNAL.AsInteger(); + break; + } + } + + return chip::ChipError(code); +} + +// Convert TLV data into NSObject +id NSObjectFromCHIPTLV(chip::TLV::TLVReader * data) +{ + chip::TLV::TLVType dataTLVType = data->GetType(); + switch (dataTLVType) { + case chip::TLV::kTLVType_SignedInteger: { + int64_t val; + CHIP_ERROR err = data->Get(val); + if (err != CHIP_NO_ERROR) { + MTR_LOG_ERROR("Error(%s): TLV signed integer decoding failed", chip::ErrorStr(err)); + return nil; + } + return [NSDictionary dictionaryWithObjectsAndKeys:MTRSignedIntegerValueType, MTRTypeKey, [NSNumber numberWithLongLong:val], + MTRValueKey, nil]; + } + case chip::TLV::kTLVType_UnsignedInteger: { + uint64_t val; + CHIP_ERROR err = data->Get(val); + if (err != CHIP_NO_ERROR) { + MTR_LOG_ERROR("Error(%s): TLV unsigned integer decoding failed", chip::ErrorStr(err)); + return nil; + } + return [NSDictionary dictionaryWithObjectsAndKeys:MTRUnsignedIntegerValueType, MTRTypeKey, + [NSNumber numberWithUnsignedLongLong:val], MTRValueKey, nil]; + } + case chip::TLV::kTLVType_Boolean: { + bool val; + CHIP_ERROR err = data->Get(val); + if (err != CHIP_NO_ERROR) { + MTR_LOG_ERROR("Error(%s): TLV boolean decoding failed", chip::ErrorStr(err)); + return nil; + } + return [NSDictionary + dictionaryWithObjectsAndKeys:MTRBooleanValueType, MTRTypeKey, [NSNumber numberWithBool:val], MTRValueKey, nil]; + } + case chip::TLV::kTLVType_FloatingPointNumber: { + // Try float first + float floatValue; + CHIP_ERROR err = data->Get(floatValue); + if (err == CHIP_NO_ERROR) { + return @ { MTRTypeKey : MTRFloatValueType, MTRValueKey : [NSNumber numberWithFloat:floatValue] }; + } + double val; + err = data->Get(val); + if (err != CHIP_NO_ERROR) { + MTR_LOG_ERROR("Error(%s): TLV floating point decoding failed", chip::ErrorStr(err)); + return nil; + } + return [NSDictionary + dictionaryWithObjectsAndKeys:MTRDoubleValueType, MTRTypeKey, [NSNumber numberWithDouble:val], MTRValueKey, nil]; + } + case chip::TLV::kTLVType_UTF8String: { + uint32_t len = data->GetLength(); + const uint8_t * ptr; + CHIP_ERROR err = data->GetDataPtr(ptr); + if (err != CHIP_NO_ERROR) { + MTR_LOG_ERROR("Error(%s): TLV UTF8String decoding failed", chip::ErrorStr(err)); + return nil; + } + return [NSDictionary dictionaryWithObjectsAndKeys:MTRUTF8StringValueType, MTRTypeKey, + [[NSString alloc] initWithBytes:ptr length:len encoding:NSUTF8StringEncoding], MTRValueKey, nil]; + } + case chip::TLV::kTLVType_ByteString: { + uint32_t len = data->GetLength(); + const uint8_t * ptr; + CHIP_ERROR err = data->GetDataPtr(ptr); + if (err != CHIP_NO_ERROR) { + MTR_LOG_ERROR("Error(%s): TLV ByteString decoding failed", chip::ErrorStr(err)); + return nil; + } + return [NSDictionary dictionaryWithObjectsAndKeys:MTROctetStringValueType, MTRTypeKey, + [NSData dataWithBytes:ptr length:len], MTRValueKey, nil]; + } + case chip::TLV::kTLVType_Null: { + return [NSDictionary dictionaryWithObjectsAndKeys:MTRNullValueType, MTRTypeKey, nil]; + } + case chip::TLV::kTLVType_Structure: + case chip::TLV::kTLVType_Array: { + NSString * typeName; + switch (dataTLVType) { + case chip::TLV::kTLVType_Structure: + typeName = MTRStructureValueType; + break; + case chip::TLV::kTLVType_Array: + typeName = MTRArrayValueType; + break; + default: + typeName = @"Unsupported"; + break; + } + chip::TLV::TLVType tlvType; + CHIP_ERROR err = data->EnterContainer(tlvType); + if (err != CHIP_NO_ERROR) { + MTR_LOG_ERROR("Error(%s): TLV container entering failed", chip::ErrorStr(err)); + return nil; + } + NSMutableArray * array = [[NSMutableArray alloc] init]; + while ((err = data->Next()) == CHIP_NO_ERROR) { + chip::TLV::Tag tag = data->GetTag(); + id value = NSObjectFromCHIPTLV(data); + if (value == nullptr) { + MTR_LOG_ERROR("Error when decoding TLV container"); + return nil; + } + NSMutableDictionary * arrayElement = [NSMutableDictionary dictionary]; + [arrayElement setObject:value forKey:MTRDataKey]; + if (dataTLVType == chip::TLV::kTLVType_Structure) { + [arrayElement setObject:[NSNumber numberWithUnsignedLong:TagNumFromTag(tag)] forKey:MTRContextTagKey]; + } + [array addObject:arrayElement]; + } + if (err != CHIP_END_OF_TLV) { + MTR_LOG_ERROR("Error(%s): TLV container decoding failed", chip::ErrorStr(err)); + return nil; + } + err = data->ExitContainer(tlvType); + if (err != CHIP_NO_ERROR) { + MTR_LOG_ERROR("Error(%s): TLV container exiting failed", chip::ErrorStr(err)); + return nil; + } + return [NSDictionary dictionaryWithObjectsAndKeys:typeName, MTRTypeKey, array, MTRValueKey, nil]; + } + default: + MTR_LOG_ERROR("Error: Unsupported TLV type for conversion: %u", (unsigned) data->GetType()); + return nil; + } +} diff --git a/examples/darwin-framework-tool/commands/common/MTRError_Utils.h b/examples/darwin-framework-tool/commands/common/MTRError_Utils.h new file mode 100644 index 00000000000000..470a4ad9e88c4b --- /dev/null +++ b/examples/darwin-framework-tool/commands/common/MTRError_Utils.h @@ -0,0 +1,26 @@ +/** + * + * Copyright (c) 2021 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 + +#include +#include + +#include + +CHIP_ERROR MTRErrorToCHIPErrorCode(NSError * error); +id NSObjectFromCHIPTLV(chip::TLV::TLVReader * data); diff --git a/src/darwin/Framework/CHIP/CHIPLogging.h b/examples/darwin-framework-tool/commands/common/MTRLogging.h similarity index 75% rename from src/darwin/Framework/CHIP/CHIPLogging.h rename to examples/darwin-framework-tool/commands/common/MTRLogging.h index 2d76a657e85745..4835e4f159d447 100644 --- a/src/darwin/Framework/CHIP/CHIPLogging.h +++ b/examples/darwin-framework-tool/commands/common/MTRLogging.h @@ -22,15 +22,15 @@ #import #if DEBUG -#define CHIP_LOG_DEBUG(format, ...) os_log(OS_LOG_DEFAULT, format, ##__VA_ARGS__) -#define CHIP_LOG_ERROR(format, ...) os_log(OS_LOG_DEFAULT, format, ##__VA_ARGS__) -#define CHIP_LOG_METHOD_ENTRY() \ +#define MTR_LOG_DEBUG(format, ...) os_log(OS_LOG_DEFAULT, format, ##__VA_ARGS__) +#define MTR_LOG_ERROR(format, ...) os_log(OS_LOG_DEFAULT, format, ##__VA_ARGS__) +#define MTR_LOG_METHOD_ENTRY() \ ({ os_log(OS_LOG_DEFAULT, "[<%@: %p> %@]", NSStringFromClass([self class]), self, NSStringFromSelector(_cmd)); }) #else -#define CHIP_LOG_DEBUG(...) -#define CHIP_LOG_ERROR(...) -#define CHIP_LOG_METHOD_ENTRY() ({}) +#define MTR_LOG_DEBUG(...) +#define MTR_LOG_ERROR(...) +#define MTR_LOG_METHOD_ENTRY() ({}) #endif diff --git a/examples/darwin-framework-tool/commands/interactive/Commands.h b/examples/darwin-framework-tool/commands/interactive/Commands.h index 59a06b6a60fe5b..722feb8ae2069a 100644 --- a/examples/darwin-framework-tool/commands/interactive/Commands.h +++ b/examples/darwin-framework-tool/commands/interactive/Commands.h @@ -18,6 +18,8 @@ #pragma once +#import + #include "../common/CHIPCommandBridge.h" #include diff --git a/examples/darwin-framework-tool/commands/interactive/InteractiveCommands.h b/examples/darwin-framework-tool/commands/interactive/InteractiveCommands.h index 98347747f64fc6..c6e8c5d85e45f1 100644 --- a/examples/darwin-framework-tool/commands/interactive/InteractiveCommands.h +++ b/examples/darwin-framework-tool/commands/interactive/InteractiveCommands.h @@ -18,6 +18,8 @@ #pragma once +#import + #include "../common/CHIPCommandBridge.h" #include "commands/common/Commands.h" diff --git a/examples/darwin-framework-tool/commands/interactive/InteractiveCommands.mm b/examples/darwin-framework-tool/commands/interactive/InteractiveCommands.mm index 3ffe41c7744f94..24121ff7660f02 100644 --- a/examples/darwin-framework-tool/commands/interactive/InteractiveCommands.mm +++ b/examples/darwin-framework-tool/commands/interactive/InteractiveCommands.mm @@ -17,6 +17,7 @@ */ #include "InteractiveCommands.h" +#import #include #include diff --git a/examples/darwin-framework-tool/commands/pairing/Commands.h b/examples/darwin-framework-tool/commands/pairing/Commands.h index 1fed642addae64..164c952ffc2f4f 100644 --- a/examples/darwin-framework-tool/commands/pairing/Commands.h +++ b/examples/darwin-framework-tool/commands/pairing/Commands.h @@ -18,6 +18,8 @@ #pragma once +#import + #include "OpenCommissioningWindowCommand.h" #include "PairingCommandBridge.h" diff --git a/examples/darwin-framework-tool/commands/pairing/OpenCommissioningWindowCommand.h b/examples/darwin-framework-tool/commands/pairing/OpenCommissioningWindowCommand.h index c5af318e841f35..e9fc4ce373b352 100644 --- a/examples/darwin-framework-tool/commands/pairing/OpenCommissioningWindowCommand.h +++ b/examples/darwin-framework-tool/commands/pairing/OpenCommissioningWindowCommand.h @@ -17,6 +17,8 @@ #pragma once +#import + #include "../common/CHIPCommandBridge.h" class OpenCommissioningWindowCommand : public CHIPCommandBridge diff --git a/examples/darwin-framework-tool/commands/pairing/OpenCommissioningWindowCommand.mm b/examples/darwin-framework-tool/commands/pairing/OpenCommissioningWindowCommand.mm index e7f97bca379b0d..63078d94fed4e0 100644 --- a/examples/darwin-framework-tool/commands/pairing/OpenCommissioningWindowCommand.mm +++ b/examples/darwin-framework-tool/commands/pairing/OpenCommissioningWindowCommand.mm @@ -15,7 +15,7 @@ * limitations under the License. */ -#import +#import #include "OpenCommissioningWindowCommand.h" diff --git a/examples/darwin-framework-tool/commands/pairing/PairingCommandBridge.h b/examples/darwin-framework-tool/commands/pairing/PairingCommandBridge.h index 92043c7b888088..cf736e0e193387 100644 --- a/examples/darwin-framework-tool/commands/pairing/PairingCommandBridge.h +++ b/examples/darwin-framework-tool/commands/pairing/PairingCommandBridge.h @@ -18,7 +18,7 @@ #pragma once #include "../common/CHIPCommandBridge.h" -#import +#import enum class PairingMode { diff --git a/examples/darwin-framework-tool/commands/pairing/PairingCommandBridge.mm b/examples/darwin-framework-tool/commands/pairing/PairingCommandBridge.mm index 9e24db3d844ffb..8a6935e9c6df34 100644 --- a/examples/darwin-framework-tool/commands/pairing/PairingCommandBridge.mm +++ b/examples/darwin-framework-tool/commands/pairing/PairingCommandBridge.mm @@ -16,14 +16,15 @@ * */ -#import -#import +#import #include "../common/CHIPCommandBridge.h" #include "PairingCommandBridge.h" #include "PairingDelegateBridge.h" #include +#import "MTRError_Utils.h" + using namespace ::chip; using namespace ::chip::Controller; @@ -31,7 +32,8 @@ { dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.pairing", DISPATCH_QUEUE_SERIAL); CHIPToolPairingDelegate * pairing = [[CHIPToolPairingDelegate alloc] init]; - CHIPCommissioningParameters * params = [[CHIPCommissioningParameters alloc] init]; + MTRCommissioningParameters * params = [[MTRCommissioningParameters alloc] init]; + MTRDeviceController * commissioner = CurrentCommissioner(); [pairing setDeviceID:mNodeId]; switch (mNetworkType) { @@ -49,9 +51,9 @@ [pairing setCommandBridge:this]; [pairing setParams:params]; - [pairing setCommissioner:CurrentCommissioner()]; + [pairing setCommissioner:commissioner]; - [CurrentCommissioner() setPairingDelegate:pairing queue:callbackQueue]; + [commissioner setPairingDelegate:pairing queue:callbackQueue]; } CHIP_ERROR PairingCommandBridge::RunCommand() @@ -81,7 +83,8 @@ void PairingCommandBridge::PairWithCode(NSError * __autoreleasing * error) { SetUpPairingDelegate(); - [CurrentCommissioner() pairDevice:mNodeId discriminator:mDiscriminator setupPINCode:mSetupPINCode error:error]; + MTRDeviceController * commissioner = CurrentCommissioner(); + [commissioner pairDevice:mNodeId discriminator:mDiscriminator setupPINCode:mSetupPINCode error:error]; } void PairingCommandBridge::PairWithPayload(NSError * __autoreleasing * error) @@ -89,63 +92,65 @@ NSString * payload = [NSString stringWithUTF8String:mOnboardingPayload]; SetUpPairingDelegate(); - [CurrentCommissioner() pairDevice:mNodeId onboardingPayload:payload error:error]; + MTRDeviceController * commissioner = CurrentCommissioner(); + [commissioner pairDevice:mNodeId onboardingPayload:payload error:error]; } void PairingCommandBridge::PairWithIPAddress(NSError * __autoreleasing * error) { SetUpPairingDelegate(); - [CurrentCommissioner() pairDevice:mNodeId - address:[NSString stringWithUTF8String:ipAddress] - port:mRemotePort - setupPINCode:mSetupPINCode - error:error]; + MTRDeviceController * commissioner = CurrentCommissioner(); + [commissioner pairDevice:mNodeId + address:[NSString stringWithUTF8String:ipAddress] + port:mRemotePort + setupPINCode:mSetupPINCode + error:error]; } void PairingCommandBridge::Unpair() { dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip-tool.command", DISPATCH_QUEUE_SERIAL); - [CurrentCommissioner() - getConnectedDevice:mNodeId - queue:callbackQueue - completionHandler:^(CHIPDevice * _Nullable device, NSError * _Nullable error) { - CHIP_ERROR err = CHIP_NO_ERROR; - if (error) { - err = [CHIPError errorToCHIPErrorCode:error]; - LogNSError("Error: ", error); - SetCommandExitStatus(err); - } else if (device == nil) { - ChipLogError(chipTool, "Error: %s", chip::ErrorStr(CHIP_ERROR_INTERNAL)); - SetCommandExitStatus(CHIP_ERROR_INTERNAL); - } else { - ChipLogProgress(chipTool, "Attempting to unpair device %llu", mNodeId); - CHIPOperationalCredentials * opCredsCluster = [[CHIPOperationalCredentials alloc] initWithDevice:device - endpoint:0 - queue:callbackQueue]; - [opCredsCluster readAttributeCurrentFabricIndexWithCompletionHandler:^( - NSNumber * _Nullable value, NSError * _Nullable readError) { - if (readError) { - CHIP_ERROR readErr = [CHIPError errorToCHIPErrorCode:readError]; - LogNSError("Failed to get current fabric: ", readError); - SetCommandExitStatus(readErr); - return; - } - CHIPOperationalCredentialsClusterRemoveFabricParams * params = - [[CHIPOperationalCredentialsClusterRemoveFabricParams alloc] init]; - params.fabricIndex = value; - [opCredsCluster removeFabricWithParams:params - completionHandler:^(CHIPOperationalCredentialsClusterNOCResponseParams * _Nullable data, - NSError * _Nullable removeError) { - CHIP_ERROR removeErr = CHIP_NO_ERROR; - if (removeError) { - removeErr = [CHIPError errorToCHIPErrorCode:removeError]; - LogNSError("Failed to remove current fabric: ", removeError); - } else { - ChipLogProgress(chipTool, "Successfully unpaired deviceId %llu", mNodeId); - } - SetCommandExitStatus(removeErr); - }]; - }]; - } - }]; + MTRDeviceController * commissioner = CurrentCommissioner(); + [commissioner getDevice:mNodeId + queue:callbackQueue + completionHandler:^(MTRDevice * _Nullable device, NSError * _Nullable error) { + CHIP_ERROR err = CHIP_NO_ERROR; + if (error) { + err = MTRErrorToCHIPErrorCode(error); + LogNSError("Error: ", error); + SetCommandExitStatus(err); + } else if (device == nil) { + ChipLogError(chipTool, "Error: %s", chip::ErrorStr(CHIP_ERROR_INTERNAL)); + SetCommandExitStatus(CHIP_ERROR_INTERNAL); + } else { + ChipLogProgress(chipTool, "Attempting to unpair device %llu", mNodeId); + MTROperationalCredentials * opCredsCluster = [[MTROperationalCredentials alloc] initWithDevice:device + endpoint:0 + queue:callbackQueue]; + [opCredsCluster readAttributeCurrentFabricIndexWithCompletionHandler:^( + NSNumber * _Nullable value, NSError * _Nullable readError) { + if (readError) { + CHIP_ERROR readErr = MTRErrorToCHIPErrorCode(readError); + LogNSError("Failed to get current fabric: ", readError); + SetCommandExitStatus(readErr); + return; + } + MTROperationalCredentialsClusterRemoveFabricParams * params = + [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init]; + params.fabricIndex = value; + [opCredsCluster removeFabricWithParams:params + completionHandler:^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable data, + NSError * _Nullable removeError) { + CHIP_ERROR removeErr = CHIP_NO_ERROR; + if (removeError) { + removeErr = MTRErrorToCHIPErrorCode(removeError); + LogNSError("Failed to remove current fabric: ", removeError); + } else { + ChipLogProgress(chipTool, "Successfully unpaired deviceId %llu", mNodeId); + } + SetCommandExitStatus(removeErr); + }]; + }]; + } + }]; } diff --git a/examples/darwin-framework-tool/commands/pairing/PairingDelegateBridge.h b/examples/darwin-framework-tool/commands/pairing/PairingDelegateBridge.h index 641ac77e79501a..e295e084725701 100644 --- a/examples/darwin-framework-tool/commands/pairing/PairingDelegateBridge.h +++ b/examples/darwin-framework-tool/commands/pairing/PairingDelegateBridge.h @@ -18,11 +18,13 @@ #pragma once #include "PairingCommandBridge.h" -@interface CHIPToolPairingDelegate : NSObject +#import + +@interface CHIPToolPairingDelegate : NSObject @property PairingCommandBridge * commandBridge; @property chip::NodeId deviceID; -@property CHIPDeviceController * commissioner; -@property CHIPCommissioningParameters * params; +@property MTRDeviceController * commissioner; +@property MTRCommissioningParameters * params; - (void)onPairingComplete:(NSError *)error; - (void)onPairingDeleted:(NSError *)error; diff --git a/examples/darwin-framework-tool/commands/pairing/PairingDelegateBridge.mm b/examples/darwin-framework-tool/commands/pairing/PairingDelegateBridge.mm index 64467e476d8f47..0bd24146b76aba 100644 --- a/examples/darwin-framework-tool/commands/pairing/PairingDelegateBridge.mm +++ b/examples/darwin-framework-tool/commands/pairing/PairingDelegateBridge.mm @@ -17,24 +17,24 @@ */ #include "PairingDelegateBridge.h" -#import +#import @interface CHIPToolPairingDelegate () @end @implementation CHIPToolPairingDelegate -- (void)onStatusUpdate:(CHIPPairingStatus)status +- (void)onStatusUpdate:(MTRPairingStatus)status { NSLog(@"Pairing Status Update: %lu", status); switch (status) { - case kSecurePairingSuccess: + case MTRPairingStatusSuccess: ChipLogProgress(chipTool, "Secure Pairing Success"); ChipLogProgress(chipTool, "CASE establishment successful"); break; - case kSecurePairingFailed: + case MTRPairingStatusFailed: ChipLogError(chipTool, "Secure Pairing Failed"); break; - case kUnknownStatus: + case MTRPairingStatusUnknown: ChipLogError(chipTool, "Uknown Pairing Status"); break; } diff --git a/examples/darwin-framework-tool/commands/payload/Commands.h b/examples/darwin-framework-tool/commands/payload/Commands.h new file mode 100644 index 00000000000000..67615bcd2c3a7d --- /dev/null +++ b/examples/darwin-framework-tool/commands/payload/Commands.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#pragma once + +#include "SetupPayloadParseCommand.h" + +void registerCommandsPayload(Commands & commands) +{ + const char * clusterName = "Payload"; + commands_list clusterCommands = { + make_unique(), // + }; + + commands.Register(clusterName, clusterCommands); +} diff --git a/examples/darwin-framework-tool/commands/payload/SetupPayloadParseCommand.h b/examples/darwin-framework-tool/commands/payload/SetupPayloadParseCommand.h new file mode 100644 index 00000000000000..babbaf2e06b5c4 --- /dev/null +++ b/examples/darwin-framework-tool/commands/payload/SetupPayloadParseCommand.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#pragma once + +#import +#include + +class SetupPayloadParseCommand : public Command { +public: + SetupPayloadParseCommand() + : Command("parse-setup-payload") + { + AddArgument("payload", &mCode); + } + CHIP_ERROR Run() override; + static bool IsQRCode(NSString * codeString); + +private: + char * mCode; + CHIP_ERROR Print(CHIPSetupPayload * payload); + + // Will log the given string and given error (as progress if success, error + // if failure). + void LogNSError(const char * logString, NSError * error); +}; diff --git a/examples/darwin-framework-tool/commands/payload/SetupPayloadParseCommand.mm b/examples/darwin-framework-tool/commands/payload/SetupPayloadParseCommand.mm new file mode 100644 index 00000000000000..04d28646cb42af --- /dev/null +++ b/examples/darwin-framework-tool/commands/payload/SetupPayloadParseCommand.mm @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "SetupPayloadParseCommand.h" +#import +#import + +using namespace ::chip; + +namespace { + +#if CHIP_PROGRESS_LOGGING + +NSString * CustomFlowString(CHIPCommissioningFlow flow) +{ + switch (flow) { + case kCommissioningFlowStandard: + return @"STANDARD"; + case kCommissioningFlowUserActionRequired: + return @"USER ACTION REQUIRED"; + case kCommissioningFlowCustom: + return @"CUSTOM"; + case kCommissioningFlowInvalid: + return @"INVALID"; + } + + return @"???"; +} + +#endif // CHIP_PROGRESS_LOGGING + +} // namespace + +void SetupPayloadParseCommand::LogNSError(const char * logString, NSError * error) +{ + CHIP_ERROR err = [CHIPError errorToCHIPErrorCode:error]; + if (err == CHIP_NO_ERROR) { + ChipLogProgress(chipTool, "%s: %s", logString, chip::ErrorStr(err)); + } else { + ChipLogError(chipTool, "%s: %s", logString, chip::ErrorStr(err)); + } +} + +CHIP_ERROR SetupPayloadParseCommand::Run() +{ + NSString * codeString = [NSString stringWithCString:mCode encoding:NSASCIIStringEncoding]; + NSError * error; + CHIPSetupPayload * payload; + CHIPOnboardingPayloadType codeType; + if (IsQRCode(codeString)) { + codeType = CHIPOnboardingPayloadTypeQRCode; + } else { + codeType = CHIPOnboardingPayloadTypeManualCode; + } + payload = [CHIPOnboardingPayloadParser setupPayloadForOnboardingPayload:codeString ofType:codeType error:&error]; + if (error) { + LogNSError("Error: ", error); + return CHIP_ERROR_INTERNAL; + } + ReturnErrorOnFailure(Print(payload)); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR SetupPayloadParseCommand::Print(CHIPSetupPayload * payload) +{ + NSLog(@"Version: %@", payload.version); + NSLog(@"VendorID: %@", payload.vendorID); + NSLog(@"ProductID: %@", payload.productID); + NSLog(@"Custom flow: %lu (%@)", payload.commissioningFlow, CustomFlowString(payload.commissioningFlow)); + { + NSMutableString * humanFlags = [[NSMutableString alloc] init]; + + if (payload.rendezvousInformation) { + if (payload.rendezvousInformation & kRendezvousInformationNone) { + [humanFlags appendString:@"NONE"]; + } else { + if (payload.rendezvousInformation & kRendezvousInformationSoftAP) { + [humanFlags appendString:@"SoftAP"]; + } + if (payload.rendezvousInformation & kRendezvousInformationBLE) { + if (!humanFlags) { + [humanFlags appendString:@", "]; + } + [humanFlags appendString:@"BLE"]; + } + if (payload.rendezvousInformation & kRendezvousInformationOnNetwork) { + if (!humanFlags) { + [humanFlags appendString:@", "]; + } + [humanFlags appendString:@"ON NETWORK"]; + } + } + } else { + [humanFlags appendString:@"NONE"]; + } + + NSLog(@"Capabilities: 0x%02lX (%@)", payload.rendezvousInformation, humanFlags); + } + NSLog(@"Discriminator: %@", payload.discriminator); + NSLog(@"Passcode: %@", payload.setUpPINCode); + + if (payload.serialNumber) { + NSLog(@"SerialNumber: %@", payload.serialNumber); + } + NSError * error; + NSArray * optionalVendorData = [payload getAllOptionalVendorData:&error]; + if (error) { + LogNSError("Error: ", error); + return CHIP_ERROR_INTERNAL; + } + for (const CHIPOptionalQRCodeInfo * info : optionalVendorData) { + bool isTypeString = [info.infoType isEqual:@(kOptionalQRCodeInfoTypeString)]; + bool isTypeInt32 = [info.infoType isEqual:@(kOptionalQRCodeInfoTypeInt32)]; + VerifyOrReturnError(isTypeString || isTypeInt32, CHIP_ERROR_INVALID_ARGUMENT); + + if (isTypeString) { + NSLog(@"OptionalQRCodeInfo: tag=%@,string value=%@", info.tag, info.stringValue); + } else { + NSLog(@"OptionalQRCodeInfo: tag=%@,int value=%@", info.tag, info.integerValue); + } + } + + return CHIP_NO_ERROR; +} + +bool SetupPayloadParseCommand::IsQRCode(NSString * codeString) { return [codeString hasPrefix:@"MT:"]; } diff --git a/examples/darwin-framework-tool/commands/storage/StorageManagementCommand.mm b/examples/darwin-framework-tool/commands/storage/StorageManagementCommand.mm index c9cc0b87dca854..e0c1b18ec890dc 100644 --- a/examples/darwin-framework-tool/commands/storage/StorageManagementCommand.mm +++ b/examples/darwin-framework-tool/commands/storage/StorageManagementCommand.mm @@ -20,6 +20,8 @@ #include "StorageManagementCommand.h" +#import + static CHIPToolPersistentStorageDelegate * storage = nil; CHIP_ERROR StorageClearAll::Run() diff --git a/examples/darwin-framework-tool/commands/tests/TestCommandBridge.h b/examples/darwin-framework-tool/commands/tests/TestCommandBridge.h index 06479a115a922f..985f1918eef178 100644 --- a/examples/darwin-framework-tool/commands/tests/TestCommandBridge.h +++ b/examples/darwin-framework-tool/commands/tests/TestCommandBridge.h @@ -28,21 +28,23 @@ #include #include #include -#include +#include -#import -#import +#import + +#import "MTRDevice_Externs.h" +#import "MTRError_Utils.h" class TestCommandBridge; NS_ASSUME_NONNULL_BEGIN -@interface TestPairingDelegate : NSObject +@interface TestPairingDelegate : NSObject @property TestCommandBridge * commandBridge; @property chip::NodeId deviceId; @property BOOL active; // Whether to pass on notifications to the commandBridge -- (void)onStatusUpdate:(CHIPPairingStatus)status; +- (void)onStatusUpdate:(MTRPairingStatus)status; - (void)onPairingComplete:(NSError * _Nullable)error; - (void)onPairingDeleted:(NSError * _Nullable)error; - (void)onCommissioningComplete:(NSError * _Nullable)error; @@ -112,7 +114,7 @@ class TestCommandBridge : public CHIPCommandBridge, CHIP_ERROR WaitForCommissionee(const char * _Nullable identity, const chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type & value) override { - CHIPDeviceController * controller = GetCommissioner(identity); + MTRDeviceController * controller = GetCommissioner(identity); VerifyOrReturnError(controller != nil, CHIP_ERROR_INCORRECT_STATE); SetIdentity(identity); @@ -125,17 +127,17 @@ class TestCommandBridge : public CHIPCommandBridge, mConnectedDevices[identity] = nil; } - [controller getConnectedDevice:value.nodeId - queue:mCallbackQueue - completionHandler:^(CHIPDevice * _Nullable device, NSError * _Nullable error) { - if (error != nil) { - SetCommandExitStatus(error); - return; - } - - mConnectedDevices[identity] = device; - NextTest(); - }]; + [controller getDevice:value.nodeId + queue:mCallbackQueue + completionHandler:^(MTRDevice * _Nullable device, NSError * _Nullable error) { + if (error != nil) { + SetCommandExitStatus(error); + return; + } + + mConnectedDevices[identity] = device; + NextTest(); + }]; return CHIP_NO_ERROR; } @@ -143,7 +145,7 @@ class TestCommandBridge : public CHIPCommandBridge, CHIP_ERROR PairWithCode( const char * _Nullable identity, const chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type & value) { - CHIPDeviceController * controller = GetCommissioner(identity); + MTRDeviceController * controller = GetCommissioner(identity); VerifyOrReturnError(controller != nil, CHIP_ERROR_INCORRECT_STATE); SetIdentity(identity); @@ -161,7 +163,7 @@ class TestCommandBridge : public CHIPCommandBridge, return CHIP_NO_ERROR; } - return [CHIPError errorToCHIPErrorCode:err]; + return MTRErrorToCHIPErrorCode(err); } /////////// SystemCommands Interface ///////// @@ -177,7 +179,7 @@ class TestCommandBridge : public CHIPCommandBridge, return CHIP_NO_ERROR; } - CHIPDevice * _Nullable GetDevice(const char * _Nullable identity) { return mConnectedDevices[identity]; } + MTRDevice * _Nullable GetDevice(const char * _Nullable identity) { return mConnectedDevices[identity]; } // PairingDeleted and PairingComplete need to be public so our pairing // delegate can call them. @@ -189,12 +191,12 @@ class TestCommandBridge : public CHIPCommandBridge, void PairingComplete(chip::NodeId nodeId) { - CHIPDeviceController * controller = CurrentCommissioner(); - VerifyOrReturn(controller != nil, Exit("No current commissioner")); + MTRDeviceController * commissioner = CurrentCommissioner(); + VerifyOrReturn(commissioner != nil, Exit("No current commissioner")); NSError * commissionError = nil; - [controller commissionDevice:nodeId commissioningParams:[[CHIPCommissioningParameters alloc] init] error:&commissionError]; - CHIP_ERROR err = [CHIPError errorToCHIPErrorCode:commissionError]; + [commissioner commissionDevice:nodeId commissioningParams:[[MTRCommissioningParameters alloc] init] error:&commissionError]; + CHIP_ERROR err = MTRErrorToCHIPErrorCode(commissionError); if (err != CHIP_NO_ERROR) { Exit("Failed to kick off commissioning", err); return; @@ -327,7 +329,7 @@ class TestCommandBridge : public CHIPCommandBridge, template bool CheckConstraintNotValue(const char * _Nonnull itemName, NSError * _Nullable current, T expected) { - NSNumber * currentValue = @([CHIPError errorToCHIPErrorCode:current].AsInteger()); + NSNumber * currentValue = @(MTRErrorToCHIPErrorCode(current).AsInteger()); return CheckConstraintNotValue(itemName, currentValue, @(expected)); } @@ -459,18 +461,18 @@ class TestCommandBridge : public CHIPCommandBridge, TestPairingDelegate * _Nonnull mPairingDelegate; // Set of our connected devices, keyed by identity. - std::map mConnectedDevices; + std::map mConnectedDevices; }; NS_ASSUME_NONNULL_BEGIN @implementation TestPairingDelegate -- (void)onStatusUpdate:(CHIPPairingStatus)status +- (void)onStatusUpdate:(MTRPairingStatus)status { if (_active) { - if (status == kSecurePairingSuccess) { + if (status == MTRPairingStatusSuccess) { NSLog(@"Secure pairing success"); - } else if (status == kSecurePairingFailed) { + } else if (status == MTRPairingStatusFailed) { _active = NO; NSLog(@"Secure pairing failed"); _commandBridge->OnStatusUpdate(chip::app::StatusIB(chip::Protocols::InteractionModel::Status::Failure)); @@ -484,7 +486,7 @@ NS_ASSUME_NONNULL_BEGIN if (error != nil) { _active = NO; NSLog(@"Pairing complete with error"); - CHIP_ERROR err = [CHIPError errorToCHIPErrorCode:error]; + CHIP_ERROR err = MTRErrorToCHIPErrorCode(error); _commandBridge->OnStatusUpdate([self convertToStatusIB:err]); } else { _commandBridge->PairingComplete(_deviceId); @@ -503,7 +505,7 @@ NS_ASSUME_NONNULL_BEGIN { if (_active) { _active = NO; - CHIP_ERROR err = [CHIPError errorToCHIPErrorCode:error]; + CHIP_ERROR err = MTRErrorToCHIPErrorCode(error); _commandBridge->OnStatusUpdate([self convertToStatusIB:err]); } } diff --git a/examples/darwin-framework-tool/main.mm b/examples/darwin-framework-tool/main.mm index 53d12e4b8d9032..8159f91df78ac0 100644 --- a/examples/darwin-framework-tool/main.mm +++ b/examples/darwin-framework-tool/main.mm @@ -16,9 +16,12 @@ * */ +#import + #include "commands/common/Commands.h" #include "commands/interactive/Commands.h" #include "commands/pairing/Commands.h" +#include "commands/payload/Commands.h" #include "commands/storage/Commands.h" #include @@ -29,6 +32,7 @@ int main(int argc, const char * argv[]) Commands commands; registerCommandsPairing(commands); registerCommandsInteractive(commands); + registerCommandsPayload(commands); registerCommandsStorage(commands); registerCommandsTests(commands); registerClusters(commands); diff --git a/examples/darwin-framework-tool/templates/commands.zapt b/examples/darwin-framework-tool/templates/commands.zapt index 55eaf9e419546f..21a06554127044 100644 --- a/examples/darwin-framework-tool/templates/commands.zapt +++ b/examples/darwin-framework-tool/templates/commands.zapt @@ -2,7 +2,7 @@ #pragma once -#import +#import #include #include @@ -41,13 +41,13 @@ public: ClusterCommand::AddArguments(); } - CHIP_ERROR SendCommand(CHIPDevice * device, chip::EndpointId endpointId) override + CHIP_ERROR SendCommand(MTRDevice * device, chip::EndpointId endpointId) override { ChipLogProgress(chipTool, "Sending cluster ({{asHex parent.code 8}}) command ({{asHex code 8}}) on endpoint %u", endpointId); dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); - CHIP{{asUpperCamelCase clusterName}} * cluster = [[CHIP{{asUpperCamelCase clusterName}} alloc] initWithDevice:device endpoint:endpointId queue:callbackQueue]; - __auto_type * params = [[CHIP{{asUpperCamelCase clusterName}}Cluster{{asUpperCamelCase name}}Params alloc] init]; + MTR{{asUpperCamelCase clusterName}} * cluster = [[MTR{{asUpperCamelCase clusterName}} alloc] initWithDevice:device endpoint:endpointId queue:callbackQueue]; + __auto_type * params = [[MTR{{asUpperCamelCase clusterName}}Cluster{{asUpperCamelCase name}}Params alloc] init]; params.timedInvokeTimeoutMs = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; {{#chip_cluster_command_arguments}} {{>decodable_value target=(concat "params." (asStructPropertyName label)) source=(concat "mRequest." (asLowerCamelCase label)) cluster=parent.clusterName type=type depth=0}} @@ -58,7 +58,7 @@ public: { [cluster {{asLowerCamelCase name}}WithParams:params completionHandler: {{#if hasSpecificResponse}} - ^(CHIP{{asUpperCamelCase clusterName}}Cluster{{asUpperCamelCase responseName}}Params * _Nullable values, NSError * _Nullable error) { + ^(MTR{{asUpperCamelCase clusterName}}Cluster{{asUpperCamelCase responseName}}Params * _Nullable values, NSError * _Nullable error) { NSLog(@"Values: %@", values); {{else}} ^(NSError * _Nullable error) { @@ -106,14 +106,14 @@ public: { } - CHIP_ERROR SendCommand(CHIPDevice * device, chip::EndpointId endpointId) override + CHIP_ERROR SendCommand(MTRDevice * device, chip::EndpointId endpointId) override { ChipLogProgress(chipTool, "Sending cluster ({{asHex parent.code 8}}) ReadAttribute ({{asHex code 8}}) on endpoint %u", endpointId); dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); - CHIP{{asUpperCamelCase parent.name}} * cluster = [[CHIP{{asUpperCamelCase parent.name}} alloc] initWithDevice:device endpoint:endpointId queue:callbackQueue]; + MTR{{asUpperCamelCase parent.name}} * cluster = [[MTR{{asUpperCamelCase parent.name}} alloc] initWithDevice:device endpoint:endpointId queue:callbackQueue]; {{#if_is_fabric_scoped_struct type}} - CHIPReadParams * params = [[CHIPReadParams alloc] init]; + MTRReadParams * params = [[MTRReadParams alloc] init]; params.fabricFiltered = mFabricFiltered.HasValue() ? [NSNumber numberWithBool:mFabricFiltered.Value()] : nil; {{/if_is_fabric_scoped_struct}} [cluster readAttribute{{asUpperCamelCase name}}With @@ -157,12 +157,12 @@ public: { } - CHIP_ERROR SendCommand(CHIPDevice * device, chip::EndpointId endpointId) override + CHIP_ERROR SendCommand(MTRDevice * device, chip::EndpointId endpointId) override { ChipLogProgress(chipTool, "Sending cluster ({{asHex parent.code 8}}) WriteAttribute ({{asHex code 8}}) on endpoint %u", endpointId); dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); - CHIP{{asUpperCamelCase parent.name}} * cluster = [[CHIP{{asUpperCamelCase parent.name}} alloc] initWithDevice:device endpoint:endpointId queue:callbackQueue]; - CHIPWriteParams * params = [[CHIPWriteParams alloc] init]; + MTR{{asUpperCamelCase parent.name}} * cluster = [[MTR{{asUpperCamelCase parent.name}} alloc] initWithDevice:device endpoint:endpointId queue:callbackQueue]; + MTRWriteParams * params = [[MTRWriteParams alloc] init]; params.timedWriteTimeoutMs = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; params.dataVersion = mDataVersion.HasValue() ? [NSNumber numberWithUnsignedInt:mDataVersion.Value()] : nil; {{#if_chip_complex}} @@ -211,12 +211,12 @@ public: { } - CHIP_ERROR SendCommand(CHIPDevice * device, chip::EndpointId endpointId) override + CHIP_ERROR SendCommand(MTRDevice * device, chip::EndpointId endpointId) override { ChipLogProgress(chipTool, "Sending cluster ({{asHex parent.code 8}}) ReportAttribute ({{asHex code 8}}) on endpoint %u", endpointId); dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); - CHIP{{asUpperCamelCase parent.name}} * cluster = [[CHIP{{asUpperCamelCase parent.name}} alloc] initWithDevice:device endpoint:endpointId queue:callbackQueue]; - CHIPSubscribeParams * params = [[CHIPSubscribeParams alloc] init]; + MTR{{asUpperCamelCase parent.name}} * cluster = [[MTR{{asUpperCamelCase parent.name}} alloc] initWithDevice:device endpoint:endpointId queue:callbackQueue]; + MTRSubscribeParams * params = [[MTRSubscribeParams alloc] init]; params.keepPreviousSubscriptions = mKeepSubscriptions.HasValue() ? [NSNumber numberWithBool:mKeepSubscriptions.Value()] : nil; params.fabricFiltered = mFabricFiltered.HasValue() ? [NSNumber numberWithBool:mFabricFiltered.Value()] : nil; [cluster subscribe{{>attribute}}WithMinInterval:[NSNumber numberWithUnsignedInt:mMinInterval] diff --git a/examples/darwin-framework-tool/templates/tests/CHIPTestClustersObjc-src.zapt b/examples/darwin-framework-tool/templates/tests/MTRTestClustersObjc-src.zapt similarity index 56% rename from examples/darwin-framework-tool/templates/tests/CHIPTestClustersObjc-src.zapt rename to examples/darwin-framework-tool/templates/tests/MTRTestClustersObjc-src.zapt index 64c83ce7f9b7d0..bd3ec81e32920d 100644 --- a/examples/darwin-framework-tool/templates/tests/CHIPTestClustersObjc-src.zapt +++ b/examples/darwin-framework-tool/templates/tests/MTRTestClustersObjc-src.zapt @@ -1,13 +1,21 @@ {{> header}} #import -#import "CHIP/CHIP.h" +#import -#import "CHIPCallbackBridge_internal.h" // For CHIPDefaultSuccessCallbackBridge, etc -#import "CHIPCluster_internal.h" // For self.callbackQueue - -#import "zap-generated/cluster/CHIPTestClustersObjc.h" +#import "zap-generated/cluster/MTRTestClustersObjc.h" +#import "MTRCallbackBridge_internal.h" +#import "MTRDevice_Externs.h" +#import "MTRCluster_Externs.h" +#import "zap-generated/CHIPClusters.h" +#include +#include +#include +#include +#include +#include +#include #include #include @@ -17,13 +25,14 @@ using namespace chip::app::Clusters; {{#chip_client_clusters includeAll=true}} -@interface CHIPTest{{asUpperCamelCase name}} () -@property (readonly) chip::Controller::{{asUpperCamelCase name}}Cluster cppCluster; +@interface MTRTest{{asUpperCamelCase name}} () +// Must only touch cppCluster on the Matter queue. +@property (readonly) chip::Controller::{{asUpperCamelCase name}}Cluster * cppCluster; @end -@implementation CHIPTest{{asUpperCamelCase name}} +@implementation MTRTest{{asUpperCamelCase name}} -- (chip::Controller::ClusterBase *)getCluster +- (chip::Controller::{{asUpperCamelCase name}}Cluster **) cppClusterSlot { return &_cppCluster; } @@ -34,7 +43,7 @@ using namespace chip::app::Clusters; {{#*inline "callbackName"}}DefaultSuccess{{/inline}} - (void)write{{>attribute}}WithValue:({{asObjectiveCType type parent.name}})value completionHandler:(StatusCompletion)completionHandler { - new CHIP{{>callbackName}}CallbackBridge(self.callbackQueue, + new MTR{{>callbackName}}CallbackBridge(self.callbackQueue, {{! For now, don't change the bridge API; instead just use an adapter to invoke our completion handler. This is not great from a type-safety perspective, of course. }} @@ -46,9 +55,9 @@ using namespace chip::app::Clusters; using TypeInfo = {{asUpperCamelCase parent.name}}::Attributes::{{asUpperCamelCase name}}::TypeInfo; TypeInfo::Type cppValue; {{>encode_value target="cppValue" source="value" cluster=parent.name errorCode="return CHIP_ERROR_INVALID_ARGUMENT;" depth=0}} - auto successFn = CallbackcallbackName}}CallbackType>::FromCancelable(success); - auto failureFn = Callback::FromCancelable(failure); - return self.cppCluster.WriteAttribute(cppValue, successFn->mContext, successFn->mCall, failureFn->mCall); + auto successFn = Callback<{{>callbackName}}CallbackType>::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return self.cppCluster->WriteAttribute(cppValue, successFn->mContext, successFn->mCall, failureFn->mCall); }); } diff --git a/examples/darwin-framework-tool/templates/tests/CHIPTestClustersObjc.zapt b/examples/darwin-framework-tool/templates/tests/MTRTestClustersObjc.zapt similarity index 79% rename from examples/darwin-framework-tool/templates/tests/CHIPTestClustersObjc.zapt rename to examples/darwin-framework-tool/templates/tests/MTRTestClustersObjc.zapt index 4ca71fe8ebc43d..caedee02099c57 100644 --- a/examples/darwin-framework-tool/templates/tests/CHIPTestClustersObjc.zapt +++ b/examples/darwin-framework-tool/templates/tests/MTRTestClustersObjc.zapt @@ -1,8 +1,8 @@ {{> header}} -#import +#import -@class CHIPDevice; +@class MTRDevice; NS_ASSUME_NONNULL_BEGIN @@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN * Cluster {{name}} * {{description}} */ -@interface CHIPTest{{asUpperCamelCase name}} : CHIP{{asUpperCamelCase name}} +@interface MTRTest{{asUpperCamelCase name}} : MTR{{asUpperCamelCase name}} {{#chip_server_cluster_attributes}} {{#unless isWritableAttribute}} diff --git a/examples/darwin-framework-tool/templates/tests/partials/check_test_value.zapt b/examples/darwin-framework-tool/templates/tests/partials/check_test_value.zapt index 16847487714118..8f484719c16aa6 100644 --- a/examples/darwin-framework-tool/templates/tests/partials/check_test_value.zapt +++ b/examples/darwin-framework-tool/templates/tests/partials/check_test_value.zapt @@ -30,7 +30,7 @@ call. }} {{#zcl_struct_items_by_struct_name type}} {{#if (hasProperty ../expected label)}} - {{>check_test_value actual=(concat "((CHIP" (asUpperCamelCase ../cluster) "Cluster" (asUpperCamelCase ../type) " *)" ../actual ")." (asStructPropertyName label)) expected=(lookup ../expected label) cluster=../cluster}} + {{>check_test_value actual=(concat "((MTR" (asUpperCamelCase ../cluster) "Cluster" (asUpperCamelCase ../type) " *)" ../actual ")." (asStructPropertyName label)) expected=(lookup ../expected label) cluster=../cluster}} {{/if}} {{/zcl_struct_items_by_struct_name}} {{! Maybe we should add a check for properties in the expected object (other diff --git a/examples/darwin-framework-tool/templates/tests/partials/test_cluster.zapt b/examples/darwin-framework-tool/templates/tests/partials/test_cluster.zapt index 77abd2f0a024b2..73669801d59441 100644 --- a/examples/darwin-framework-tool/templates/tests/partials/test_cluster.zapt +++ b/examples/darwin-framework-tool/templates/tests/partials/test_cluster.zapt @@ -133,20 +133,20 @@ class {{filename}}: public TestCommandBridge {{/chip_tests_item_parameters}} return {{command}}("{{identity}}", value); {{else}} - CHIPDevice * device = GetDevice("{{identity}}"); - CHIPTest{{asUpperCamelCase cluster}} * cluster = [[CHIPTest{{asUpperCamelCase cluster}} alloc] initWithDevice:device endpoint:{{endpoint}} queue:mCallbackQueue]; + MTRDevice * device = GetDevice("{{identity}}"); + MTRTest{{asUpperCamelCase cluster}} * cluster = [[MTRTest{{asUpperCamelCase cluster}} alloc] initWithDevice:device endpoint:{{endpoint}} queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); {{#if isCommand}} {{#if commandObject.arguments.length}} - __auto_type * params = [[CHIP{{asUpperCamelCase cluster}}Cluster{{asUpperCamelCase command}}Params alloc] init]; + __auto_type * params = [[MTR{{asUpperCamelCase cluster}}Cluster{{asUpperCamelCase command}}Params alloc] init]; {{/if}} {{#chip_tests_item_parameters}} {{>test_value target=(concat "params." (asStructPropertyName label)) definedValue=definedValue cluster=parent.cluster depth=0}} {{/chip_tests_item_parameters}} [cluster {{asLowerCamelCase command}}With{{#if commandObject.arguments.length}}Params:params completionHandler{{else}}CompletionHandler{{/if}}: {{#if commandObject.hasSpecificResponse}} - ^(CHIP{{asUpperCamelCase cluster}}Cluster{{asUpperCamelCase commandObject.responseName}}Params * _Nullable values, NSError * _Nullable err) { + ^(MTR{{asUpperCamelCase cluster}}Cluster{{asUpperCamelCase commandObject.responseName}}Params * _Nullable values, NSError * _Nullable err) { {{else}} ^(NSError * _Nullable err) { {{/if}} @@ -154,7 +154,7 @@ class {{filename}}: public TestCommandBridge {{#chip_tests_item_parameters}} {{asObjectiveCBasicType type}} {{asLowerCamelCase name}}Argument = {{asTypedLiteral definedValue type}}; {{/chip_tests_item_parameters}} - CHIPSubscribeParams * params = [[CHIPSubscribeParams alloc] init]; + MTRSubscribeParams * params = [[MTRSubscribeParams alloc] init]; [cluster subscribeAttribute{{asUpperCamelCase attribute}}WithMinInterval:[NSNumber numberWithUnsignedInt:minIntervalArgument] maxInterval:[NSNumber numberWithUnsignedInt:maxIntervalArgument] params:params @@ -167,7 +167,7 @@ class {{filename}}: public TestCommandBridge {{> subscribeDataCallback }} = ^({{asObjectiveCClass attributeObject.type cluster forceList=attributeObject.isArray}} * _Nullable value, NSError * _Nullable err) { {{else if isReadAttribute}} {{#if_is_fabric_scoped_struct attributeObject.type}} - CHIPReadParams * params = [[CHIPReadParams alloc] init]; + MTRReadParams * params = [[MTRReadParams alloc] init]; params.fabricFiltered = [NSNumber numberWithBool:{{fabricFiltered}}]; {{/if_is_fabric_scoped_struct}} [cluster readAttribute{{asUpperCamelCase attribute}}With @@ -187,7 +187,7 @@ class {{filename}}: public TestCommandBridge NSLog(@"{{label}} Error: %@", err); {{#if optional}} - if (err.code == MatterInteractionErrorCodeUnsupportedAttribute) { + if (err.code == MTRInteractionErrorCodeUnsupportedAttribute) { NextTest(); return; } diff --git a/examples/darwin-framework-tool/templates/tests/partials/test_value.zapt b/examples/darwin-framework-tool/templates/tests/partials/test_value.zapt index 716e557f399221..f140fb4df15647 100644 --- a/examples/darwin-framework-tool/templates/tests/partials/test_value.zapt +++ b/examples/darwin-framework-tool/templates/tests/partials/test_value.zapt @@ -18,13 +18,13 @@ } {{else}} {{#if_is_struct type}} - {{target}} = [[CHIP{{asUpperCamelCase cluster}}Cluster{{asUpperCamelCase type}} alloc] init]; + {{target}} = [[MTR{{asUpperCamelCase cluster}}Cluster{{asUpperCamelCase type}} alloc] init]; {{#zcl_struct_items_by_struct_name type}} {{#if_include_struct_item_value ../definedValue name}} {{! target may be some place where we lost type information (e.g. an id), so add explicit cast when trying to assign to our properties. }} - {{>test_value target=(concat "((CHIP" (asUpperCamelCase ../cluster) "Cluster" (asUpperCamelCase ../type) " *)" ../target ")." (asStructPropertyName label)) definedValue=(lookup ../definedValue name) cluster=../cluster depth=(incrementDepth ../depth)}} + {{>test_value target=(concat "((MTR" (asUpperCamelCase ../cluster) "Cluster" (asUpperCamelCase ../type) " *)" ../target ")." (asStructPropertyName label)) definedValue=(lookup ../definedValue name) cluster=../cluster depth=(incrementDepth ../depth)}} {{/if_include_struct_item_value}} {{/zcl_struct_items_by_struct_name}} diff --git a/examples/darwin-framework-tool/templates/tests/templates.json b/examples/darwin-framework-tool/templates/tests/templates.json index 9311d32dd66062..0f8ea363c7e80e 100644 --- a/examples/darwin-framework-tool/templates/tests/templates.json +++ b/examples/darwin-framework-tool/templates/tests/templates.json @@ -51,14 +51,14 @@ "output": "test/Commands.h" }, { - "path": "CHIPTestClustersObjc.zapt", + "path": "MTRTestClustersObjc.zapt", "name": "Test Objc API Header", - "output": "cluster/CHIPTestClustersObjc.h" + "output": "cluster/MTRTestClustersObjc.h" }, { - "path": "CHIPTestClustersObjc-src.zapt", + "path": "MTRTestClustersObjc-src.zapt", "name": "Test Objc API", - "output": "cluster/CHIPTestClustersObjc.mm" + "output": "cluster/MTRTestClustersObjc.mm" } ] } diff --git a/examples/light-switch-app/efr32/BUILD.gn b/examples/light-switch-app/efr32/BUILD.gn index 7d870ecd737eb0..98b2c3b01af5c6 100644 --- a/examples/light-switch-app/efr32/BUILD.gn +++ b/examples/light-switch-app/efr32/BUILD.gn @@ -213,6 +213,11 @@ efr32_executable("light_switch_app") { } } + # Attestation Credentials + if (chip_build_platform_attestation_credentials_provider) { + deps += [ "${examples_plat_dir}:efr32-attestation-credentials" ] + } + if (chip_enable_ota_requestor) { defines += [ "EFR32_OTA_ENABLED" ] sources += [ "${examples_plat_dir}/OTAConfig.cpp" ] diff --git a/examples/light-switch-app/efr32/src/AppTask.cpp b/examples/light-switch-app/efr32/src/AppTask.cpp index fe982497bd6245..da0e20396ba733 100644 --- a/examples/light-switch-app/efr32/src/AppTask.cpp +++ b/examples/light-switch-app/efr32/src/AppTask.cpp @@ -41,9 +41,6 @@ #include -#include -#include - #include #include @@ -158,7 +155,6 @@ Identify gIdentify = { }; } // namespace using namespace chip::TLV; -using namespace ::chip::Credentials; using namespace ::chip::DeviceLayer; AppTask AppTask::sAppTask; @@ -196,11 +192,6 @@ CHIP_ERROR AppTask::Init() sWiFiNetworkCommissioningInstance.Init(); #endif - chip::DeviceLayer::PlatformMgr().LockChipStack(); - // Initialize device attestation config - SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); - chip::DeviceLayer::PlatformMgr().UnlockChipStack(); - // Create FreeRTOS sw timer for Function Selection. sFunctionTimer = xTimerCreate("FnTmr", // Just a text name, not used by the RTOS kernel 1, // == default timer period (mS) diff --git a/examples/light-switch-app/efr32/src/main.cpp b/examples/light-switch-app/efr32/src/main.cpp index 685d223daf8eed..7aa5aef9c6305b 100644 --- a/examples/light-switch-app/efr32/src/main.cpp +++ b/examples/light-switch-app/efr32/src/main.cpp @@ -25,12 +25,19 @@ #include "sl_system_kernel.h" #include #include +#include #include +#ifdef EFR32_ATTESTATION_CREDENTIALS +#include +#else +#include +#endif #define BLE_DEV_NAME "SiLabs-Light-Switch" using namespace ::chip; using namespace ::chip::Inet; using namespace ::chip::DeviceLayer; +using namespace ::chip::Credentials; #define UNUSED_PARAMETER(a) (a = a) @@ -49,6 +56,15 @@ int main(void) gExampleDeviceInfoProvider.SetStorageDelegate(&Server::GetInstance().GetPersistentStorage()); chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); + chip::DeviceLayer::PlatformMgr().LockChipStack(); + // Initialize device attestation config +#ifdef EFR32_ATTESTATION_CREDENTIALS + SetDeviceAttestationCredentialsProvider(EFR32::GetEFR32DacProvider()); +#else + SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); +#endif + chip::DeviceLayer::PlatformMgr().UnlockChipStack(); + EFR32_LOG("Starting App Task"); if (GetAppTask().StartAppTask() != CHIP_NO_ERROR) appError(CHIP_ERROR_INTERNAL); diff --git a/examples/lighting-app/ameba/main/DeviceCallbacks.cpp b/examples/lighting-app/ameba/main/DeviceCallbacks.cpp index 754a79651b7063..5cf63d6ba41faa 100644 --- a/examples/lighting-app/ameba/main/DeviceCallbacks.cpp +++ b/examples/lighting-app/ameba/main/DeviceCallbacks.cpp @@ -69,9 +69,6 @@ void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_ OnInternetConnectivityChange(event); break; - case DeviceEventType::kSessionEstablished: - OnSessionEstablished(event); - break; case DeviceEventType::kInterfaceIpAddressChanged: if ((event->InterfaceIpAddressChanged.Type == InterfaceIpChangeType::kIpV4_Assigned) || (event->InterfaceIpAddressChanged.Type == InterfaceIpChangeType::kIpV6_Assigned)) @@ -121,14 +118,6 @@ void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event } } -void DeviceCallbacks::OnSessionEstablished(const ChipDeviceEvent * event) -{ - if (event->SessionEstablished.IsCommissioner) - { - printf("Commissioner detected!"); - } -} - void DeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, ClusterId clusterId, AttributeId attributeId, uint8_t type, uint16_t size, uint8_t * value) { diff --git a/examples/lighting-app/ameba/main/include/DeviceCallbacks.h b/examples/lighting-app/ameba/main/include/DeviceCallbacks.h index 43c3a8a6906ab3..c85697f0d6b8be 100755 --- a/examples/lighting-app/ameba/main/include/DeviceCallbacks.h +++ b/examples/lighting-app/ameba/main/include/DeviceCallbacks.h @@ -39,6 +39,5 @@ class DeviceCallbacks : public chip::DeviceManager::CHIPDeviceManagerCallbacks private: void OnInternetConnectivityChange(const chip::DeviceLayer::ChipDeviceEvent * event); - void OnSessionEstablished(const chip::DeviceLayer::ChipDeviceEvent * event); void OnIdentifyPostAttributeChangeCallback(chip::EndpointId endpointId, chip::AttributeId attributeId, uint8_t * value); }; diff --git a/examples/lighting-app/bouffalolab/bl602/BUILD.gn b/examples/lighting-app/bouffalolab/bl602/BUILD.gn index ec6b1198c2d3c4..08cd7fda67ebe6 100644 --- a/examples/lighting-app/bouffalolab/bl602/BUILD.gn +++ b/examples/lighting-app/bouffalolab/bl602/BUILD.gn @@ -19,6 +19,12 @@ import("//build_overrides/chip.gni") import("${bl602_sdk_build_root}/bl602_executable.gni") import("${bl602_sdk_build_root}/bl602_sdk.gni") import("${build_root}/config/defaults.gni") +import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") + +if (chip_enable_pw_rpc) { + import("//build_overrides/pigweed.gni") + import("$dir_pw_build/target_types.gni") +} assert(current_os == "freertos") @@ -59,6 +65,10 @@ bl602_sdk("sdk") { "CONFIG_PSM_EASYFLASH_SIZE=16384", "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}", ] + + if (chip_enable_pw_rpc) { + defines += [ "PW_RPC_ENABLED" ] + } } bl602_executable("lighting_app") { @@ -76,6 +86,10 @@ bl602_executable("lighting_app") { "src/main.cpp", ] + if (chip_enable_pw_rpc) { + sources += [ "${examples_plat_dir}/uart.c" ] + } + deps = [ ":sdk", "${chip_root}/examples/common/QRCode", @@ -99,6 +113,54 @@ bl602_executable("lighting_app") { defines += [ "DISPLAY_ENABLED" ] } + if (chip_enable_pw_rpc) { + defines += [ + "PW_RPC_ENABLED", + "PW_RPC_ATTRIBUTE_SERVICE=1", + "PW_RPC_BUTTON_SERVICE=1", + "PW_RPC_DESCRIPTOR_SERVICE=1", + "PW_RPC_DEVICE_SERVICE=1", + "PW_RPC_LIGHTING_SERVICE=1", + + #"PW_RPC_OTCLI_SERVICE=1", + #"PW_RPC_THREAD_SERVICE=1", + #"PW_RPC_TRACING_SERVICE=1", + ] + + sources += [ + "${chip_root}/examples/common/pigweed/RpcService.cpp", + "${chip_root}/examples/common/pigweed/bouffalolab/bl602/PigweedLoggerMutex.cpp", + "${examples_plat_dir}/PigweedLogger.cpp", + "${examples_plat_dir}/Rpc.cpp", + ] + + deps += [ + "$dir_pw_hdlc:rpc_channel_output", + "$dir_pw_stream:sys_io_stream", + + #"$dir_pw_trace", + #"$dir_pw_trace_tokenized", + #"$dir_pw_trace_tokenized:trace_rpc_service", + "${chip_root}/config/bouffalolab/bl602/lib/pw_rpc:pw_rpc", + "${chip_root}/examples/common/pigweed:attributes_service.nanopb_rpc", + "${chip_root}/examples/common/pigweed:button_service.nanopb_rpc", + "${chip_root}/examples/common/pigweed:descriptor_service.nanopb_rpc", + "${chip_root}/examples/common/pigweed:device_service.nanopb_rpc", + "${chip_root}/examples/common/pigweed:lighting_service.nanopb_rpc", + + #"${chip_root}/examples/common/pigweed:ot_cli_service.nanopb_rpc", + #"${chip_root}/examples/common/pigweed:thread_service.nanopb_rpc", + "${examples_plat_dir}/pw_sys_io:pw_sys_io_bl602", + ] + + deps += pw_build_LINK_DEPS + + include_dirs += [ + "${chip_root}/examples/common", + "${chip_root}/examples/common/pigweed/bouffalolab/bl602", + ] + } + if (enable_heap_monitoring) { defines += [ "HEAP_MONITORING" ] sources += [ "${examples_plat_dir}/MemMonitoring.cpp" ] diff --git a/examples/lighting-app/bouffalolab/bl602/README.md b/examples/lighting-app/bouffalolab/bl602/README.md index 22873801a823c9..398562aaa17b63 100644 --- a/examples/lighting-app/bouffalolab/bl602/README.md +++ b/examples/lighting-app/bouffalolab/bl602/README.md @@ -39,6 +39,12 @@ The steps in this document were validated on Ubuntu 18.04 and 20.04. ./scripts/build/build_examples.py --target bl602-light build ``` +- Build the lighting-app with Pigweed RPC: + + ``` + ./scripts/examples/gn_bl602_example.sh lighting-app ./out/bl602-light 'import("//with_pw_rpc.gni")' + ``` + - Connect the board to your flashing station (MacOS, Ubuntu, Windows). - Set the board to the download mode: @@ -118,3 +124,20 @@ the BL602 lighting-app to commission it onto a Wi-Fi network: ``` $ sudo ./chip-tool colorcontrol move-to-hue-and-saturation 240 100 0 0 0 1 1 ``` + +### Running RPC Console + +- Build chip-console following this + [guide](../../../common/pigweed/rpc_console/README.md) + +- Start the console + + ``` + $ chip-console --device /dev/ttyUSB0 -b 2000000 + ``` + +- Get or Set the light state + + `rpcs.chip.rpc.Lighting.Get()` + + `rpcs.chip.rpc.Lighting.Set(on=True, level=128)` diff --git a/examples/lighting-app/bouffalolab/bl602/args.gni b/examples/lighting-app/bouffalolab/bl602/args.gni index 3425fc8d0035ba..7f4894d278fd7d 100644 --- a/examples/lighting-app/bouffalolab/bl602/args.gni +++ b/examples/lighting-app/bouffalolab/bl602/args.gni @@ -18,10 +18,12 @@ import("${chip_root}/src/platform/bouffalolab/BL602/args.gni") bl602_sdk_target = get_label_info(":sdk", "label_no_toolchain") pw_log_BACKEND = "${chip_root}/src/lib/support/pw_log_chip" -pw_assert_BACKEND = "$dir_pw_assert_log:check_backend" +pw_assert_BACKEND = "$dir_pw_assert_log" chip_enable_openthread = false +pw_rpc_CONFIG = "$dir_pw_rpc:disable_global_mutex" + # Disable lock tracking, since our FreeRTOS configuration does not set # INCLUDE_xSemaphoreGetMutexHolder chip_stack_lock_tracking = "none" diff --git a/examples/lighting-app/bouffalolab/bl602/include/AppConfig.h b/examples/lighting-app/bouffalolab/bl602/include/AppConfig.h index 4bc195187b2c69..584a61aa4f5aad 100644 --- a/examples/lighting-app/bouffalolab/bl602/include/AppConfig.h +++ b/examples/lighting-app/bouffalolab/bl602/include/AppConfig.h @@ -32,12 +32,11 @@ extern "C" { //#define APP_LIGHT_BUTTON (34) #define APP_FUNCTION_BUTTON (35) - +#define APP_LOCK_BUTTON (8) #define APP_BUTTON_DEBOUNCE_PERIOD_MS 50 #define APP_BUTTON_PRESSED 0 -#define APP_BUTTON_RELEASED 1 - +#define APP_BUTTON_LONGPRESSED 1 // Time it takes in ms for the simulated actuator to move from one // state to another. #define ACTUATOR_MOVEMENT_PERIOS_MS 2000 diff --git a/examples/lighting-app/bouffalolab/bl602/include/AppTask.h b/examples/lighting-app/bouffalolab/bl602/include/AppTask.h index d27d9332c21c25..f8e56c4cb43464 100644 --- a/examples/lighting-app/bouffalolab/bl602/include/AppTask.h +++ b/examples/lighting-app/bouffalolab/bl602/include/AppTask.h @@ -49,6 +49,7 @@ class AppTask void PostEvent(const AppEvent * event); void ButtonEventHandler(uint8_t btnIdx, uint8_t btnAction); void AppTask::OtaTask(void); + void LightStateUpdateEventHandler(void); private: friend AppTask & GetAppTask(void); @@ -68,7 +69,9 @@ class AppTask static void TimerEventHandler(TimerHandle_t xTimer); static void UpdateClusterState(void); - + static void FactoryResetButtonEventHandler(void); + static void LightingActionButtonEventHandler(void); + static void InitButtons(void); void StartTimer(uint32_t aTimeoutMs); enum Function_t diff --git a/examples/lighting-app/bouffalolab/bl602/include/DeviceCallbacks.h b/examples/lighting-app/bouffalolab/bl602/include/DeviceCallbacks.h index b3ee3e941a750d..bd865332b18602 100644 --- a/examples/lighting-app/bouffalolab/bl602/include/DeviceCallbacks.h +++ b/examples/lighting-app/bouffalolab/bl602/include/DeviceCallbacks.h @@ -39,7 +39,6 @@ class DeviceCallbacks : public chip::DeviceManager::CHIPDeviceManagerCallbacks private: void OnInternetConnectivityChange(const chip::DeviceLayer::ChipDeviceEvent * event); - void OnSessionEstablished(const chip::DeviceLayer::ChipDeviceEvent * event); void OnOnOffPostAttributeChangeCallback(chip::EndpointId endpointId, chip::AttributeId attributeId, uint8_t * value); void OnLevelControlAttributeChangeCallback(chip::EndpointId endpointId, chip::AttributeId attributeId, uint8_t * value); void OnColorControlAttributeChangeCallback(chip::EndpointId endpointId, chip::AttributeId attributeId, uint8_t * value); diff --git a/examples/lighting-app/bouffalolab/bl602/include/LEDWidget.h b/examples/lighting-app/bouffalolab/bl602/include/LEDWidget.h index a32bdd9151795d..2b218d02fd899b 100644 --- a/examples/lighting-app/bouffalolab/bl602/include/LEDWidget.h +++ b/examples/lighting-app/bouffalolab/bl602/include/LEDWidget.h @@ -45,7 +45,9 @@ class LEDWidget void Animate(); void SetColor(uint8_t Hue, uint8_t Saturation); - + void Toggle(); + uint8_t GetLevel(); + bool IsTurnedOn(); void HSB2rgb(uint16_t Hue, uint8_t Saturation, uint8_t brightness, uint8_t & red, uint8_t & green, uint8_t & blue); private: @@ -62,7 +64,7 @@ class LEDWidget bool mError; TimerHandle_t errorTimer; - void DoSet(bool state); + void DoSet(); friend void ClearErrorState(TimerHandle_t); }; diff --git a/examples/lighting-app/bouffalolab/bl602/src/AppTask.cpp b/examples/lighting-app/bouffalolab/bl602/src/AppTask.cpp index db3e23741d7ced..b2cab4c7bbea3d 100644 --- a/examples/lighting-app/bouffalolab/bl602/src/AppTask.cpp +++ b/examples/lighting-app/bouffalolab/bl602/src/AppTask.cpp @@ -41,10 +41,17 @@ #include #include +#include #include #include +#include +#include #include +#if PW_RPC_ENABLED +#include "Rpc.h" +#endif + #define FACTORY_RESET_TRIGGER_TIMEOUT 3000 #define FACTORY_RESET_CANCEL_WINDOW_TIMEOUT 3000 #define APP_EVENT_QUEUE_SIZE 10 @@ -54,7 +61,7 @@ static const char * const TAG = "lighting-app"; static xTaskHandle OTA_TASK_HANDLE; - +static LEDWidget statusLED; namespace { TimerHandle_t sFunctionTimer; // FreeRTOS app sw timer. @@ -143,6 +150,13 @@ CHIP_ERROR AppTask::Init() ConfigurationMgr().LogDeviceConfig(); PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE)); + + InitButtons(); + +#if PW_RPC_ENABLED + chip::rpc::Init(); +#endif + return err; } @@ -351,55 +365,24 @@ void AppTask::FunctionTimerEventHandler(AppEvent * aEvent) void AppTask::FunctionHandler(AppEvent * aEvent) { - // To trigger software update: press the APP_FUNCTION_BUTTON button briefly (< - // FACTORY_RESET_TRIGGER_TIMEOUT) To initiate factory reset: press the - // APP_FUNCTION_BUTTON for FACTORY_RESET_TRIGGER_TIMEOUT + - // FACTORY_RESET_CANCEL_WINDOW_TIMEOUT All LEDs start blinking after - // FACTORY_RESET_TRIGGER_TIMEOUT to signal factory reset has been initiated. - // To cancel factory reset: release the APP_FUNCTION_BUTTON once all LEDs - // start blinking within the FACTORY_RESET_CANCEL_WINDOW_TIMEOUT - if (aEvent->ButtonEvent.Action == APP_BUTTON_PRESSED) - { - if (!sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_NoneSelected) - { - sAppTask.StartTimer(FACTORY_RESET_TRIGGER_TIMEOUT); - sAppTask.mFunction = kFunction_StartBleAdv; - } + + if (aEvent->ButtonEvent.Action == APP_BUTTON_LONGPRESSED) + { + log_info("FactoryReset! please release boutton!!!\r\n"); + statusLED.Toggle(); + vTaskDelay(1000); + statusLED.Toggle(); + vTaskDelay(1000); + statusLED.Toggle(); + vTaskDelay(3000); + chip::Server::GetInstance().ScheduleFactoryReset(); } - else + else if (aEvent->ButtonEvent.Action == APP_BUTTON_PRESSED) { - // If the button was released before factory reset got initiated, start BLE advertissement in fast mode - if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_StartBleAdv) - { - sAppTask.CancelTimer(); - sAppTask.mFunction = kFunction_NoneSelected; - - if (!ConnectivityMgr().IsThreadProvisioned()) - { - // Enable BLE advertisements - ConnectivityMgr().SetBLEAdvertisingEnabled(true); - ConnectivityMgr().SetBLEAdvertisingMode(ConnectivityMgr().kFastAdvertising); - } - else - { - log_warn("Network is already provisioned, Ble advertissement not enabled\r\n"); - } - } - else if (sAppTask.mFunctionTimerActive && sAppTask.mFunction == kFunction_FactoryReset) - { -#if 0 // TODO: 3R - // Set lock status LED back to show state of lock. - sLockLED.Set(!BoltLockMgr().IsUnlocked()); -#endif - - sAppTask.CancelTimer(); - - // Change the function to none selected since factory reset has been - // canceled. - sAppTask.mFunction = kFunction_NoneSelected; - - log_info("Factory Reset has been Canceled\r\n"); - } + AppEvent Lightevent = {}; + Lightevent.Type = AppEvent::kEventType_Button; + Lightevent.Handler = LightActionEventHandler; + sAppTask.PostEvent(&Lightevent); } } @@ -535,8 +518,7 @@ void AppTask::DispatchEvent(AppEvent * aEvent) void AppTask::UpdateClusterState(void) { uint8_t newValue = LightMgr().IsLightOn(); - - // write the new on/off value + log_info("updating on/off = %x\r\n", newValue); EmberAfStatus status = emberAfWriteAttribute(1, ZCL_ON_OFF_CLUSTER_ID, ZCL_ON_OFF_ATTRIBUTE_ID, (uint8_t *) &newValue, ZCL_BOOLEAN_ATTRIBUTE_TYPE); if (status != EMBER_ZCL_STATUS_SUCCESS) @@ -557,3 +539,59 @@ void AppTask::OtaTask(void) return; } } + +void AppTask::FactoryResetButtonEventHandler(void) +{ + AppEvent button_event = {}; + button_event.Type = AppEvent::kEventType_Button; + button_event.ButtonEvent.Action = APP_BUTTON_LONGPRESSED; + + button_event.Handler = FunctionHandler; + log_info("FactoryResetButtonEventHandler\r\n"); + sAppTask.PostEvent(&button_event); +} + +void AppTask::LightingActionButtonEventHandler(void) +{ + AppEvent button_event = {}; + button_event.Type = AppEvent::kEventType_Button; + button_event.ButtonEvent.Action = APP_BUTTON_PRESSED; + + button_event.Handler = FunctionHandler; + log_info("LightingActionButtonEventHandler\r\n"); + sAppTask.PostEvent(&button_event); +} + +void AppTask::InitButtons(void) +{ + Button_Configure_FactoryResetEventHandler(&FactoryResetButtonEventHandler); + Button_Configure_LightingActionEventHandler(&LightingActionButtonEventHandler); +} + +void AppTask::LightStateUpdateEventHandler(void) +{ + uint8_t onoff, level; + do + { + if (EMBER_ZCL_STATUS_SUCCESS != + emberAfReadAttribute(1, ZCL_ON_OFF_CLUSTER_ID, ZCL_ON_OFF_ATTRIBUTE_ID, (uint8_t *) &onoff, sizeof(uint8_t))) + { + break; + } + if (EMBER_ZCL_STATUS_SUCCESS != + emberAfReadAttribute(1, ZCL_LEVEL_CONTROL_CLUSTER_ID, ZCL_CURRENT_LEVEL_ATTRIBUTE_ID, (uint8_t *) &level, + sizeof(uint8_t))) + { + break; + } + if (0 == onoff) + { + statusLED.SetBrightness(0); + statusLED.Set(0); + } + else + { + statusLED.SetBrightness(level); + } + } while (0); +} diff --git a/examples/lighting-app/bouffalolab/bl602/src/DeviceCallbacks.cpp b/examples/lighting-app/bouffalolab/bl602/src/DeviceCallbacks.cpp index 146559b3552d6b..0bdd2d706ab1ae 100644 --- a/examples/lighting-app/bouffalolab/bl602/src/DeviceCallbacks.cpp +++ b/examples/lighting-app/bouffalolab/bl602/src/DeviceCallbacks.cpp @@ -57,10 +57,6 @@ void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_ OnInternetConnectivityChange(event); break; - case DeviceEventType::kSessionEstablished: - OnSessionEstablished(event); - break; - case DeviceEventType::kCHIPoBLEConnectionEstablished: log_info("CHIPoBLE connection established\r\n"); break; @@ -152,14 +148,6 @@ void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event } } -void DeviceCallbacks::OnSessionEstablished(const ChipDeviceEvent * event) -{ - if (event->SessionEstablished.IsCommissioner) - { - log_info("Commissioner detected!\r\n"); - } -} - void DeviceCallbacks::OnOnOffPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { VerifyOrExit(attributeId == ZCL_ON_OFF_ATTRIBUTE_ID, log_info("Unhandled Attribute ID: '0x%04x\r\n", attributeId)); @@ -167,7 +155,7 @@ void DeviceCallbacks::OnOnOffPostAttributeChangeCallback(EndpointId endpointId, // At this point we can assume that value points to a bool value. mEndpointOnOffState[endpointId - 1] = *value; - statusLED1.Set(*value); + GetAppTask().LightStateUpdateEventHandler(); exit: return; @@ -182,7 +170,7 @@ void DeviceCallbacks::OnLevelControlAttributeChangeCallback(EndpointId endpointI VerifyOrExit(endpointId == 1 || endpointId == 2, log_error("Unexpected EndPoint ID: `0x%02x'\r\n", endpointId)); // At this point we can assume that value points to a bool value. - statusLED1.SetBrightness(brightness); + GetAppTask().LightStateUpdateEventHandler(); exit: return; diff --git a/examples/lighting-app/bouffalolab/bl602/src/LEDWidget.cpp b/examples/lighting-app/bouffalolab/bl602/src/LEDWidget.cpp index 0dab8b76bf7283..79f9076881160c 100644 --- a/examples/lighting-app/bouffalolab/bl602/src/LEDWidget.cpp +++ b/examples/lighting-app/bouffalolab/bl602/src/LEDWidget.cpp @@ -27,74 +27,11 @@ #include "AppTask.h" #include -#include - -#define IOT_DVK_3S 0 - -#if BOARD_ID == IOT_DVK_3S -hosal_pwm_dev_t pwmR = { .port = 0xff }; -#endif +#include static void showRGB(uint8_t red, uint8_t green, uint8_t blue) { - -#if BOARD_ID == IOT_DVK_3S - - uint32_t level = (red * 10000) / UINT8_MAX; - log_info("red level: %d\r\n", level); - - if (pwmR.port == 0xff) - { - pwmR.port = 0; - pwmR.config.pin = 0; - pwmR.config.duty_cycle = level; // duty_cycle range is 0~10000 correspond to 0~100% - pwmR.config.freq = 1000; - hosal_pwm_init(&pwmR); - vTaskDelay(50); - hosal_pwm_start(&pwmR); - } - else - { - pwmR.config.duty_cycle = level; // duty_cycle range is 0~10000 correspond to 0~100% - pwmR.config.freq = 1000; - hosal_pwm_para_chg(&pwmR, pwmR.config); - } -#else - - hosal_pwm_dev_t pwmR, pwmG, pwmB; - - uint32_t level = (red * 10000) / UINT8_MAX; - log_info("red level: %d\r\n", level); - pwmR.port = 0; - pwmR.config.pin = 20; - pwmR.config.duty_cycle = level; // duty_cycle range is 0~10000 correspond to 0~100% - pwmR.config.freq = 1000; - hosal_pwm_init(&pwmR); - // vTaskDelay(100); - - level = (green * 10000) / UINT8_MAX; - log_info("green level: %d\r\n", level); - pwmG.port = 1; - pwmG.config.pin = 21; - pwmG.config.duty_cycle = level; // duty_cycle range is 0~10000 correspond to 0~100% - pwmG.config.freq = 1000; - hosal_pwm_init(&pwmG); - // vTaskDelay(100); - - level = (blue * 10000) / UINT8_MAX; - log_info("blue level: %d\r\n", level); - pwmB.port = 2; - // not use debug port - // pwmB.config.pin = 17; - pwmB.config.duty_cycle = level; // duty_cycle range is 0~10000 correspond to 0~100% - pwmB.config.freq = 1000; - hosal_pwm_init(&pwmB); - vTaskDelay(50); - - hosal_pwm_start(&pwmG); - hosal_pwm_start(&pwmR); - hosal_pwm_start(&pwmB); -#endif + BL602_LightState_Update(red, green, blue); } void LEDWidget::Init(uint8_t gpioNum) @@ -116,9 +53,13 @@ void LEDWidget::Init(uint8_t gpioNum) void LEDWidget::Set(bool state) { - log_info("state: %d\r\n", state); + log_info("Setting state to %d", state ? 1 : 0); + if (state == mState) + return; + + mState = state; mBlinkOnTimeMS = mBlinkOffTimeMS = 0; - DoSet(state); + DoSet(); } void LEDWidget::SetBrightness(uint8_t brightness) @@ -129,11 +70,7 @@ void LEDWidget::SetBrightness(uint8_t brightness) log_info("brightness: %d, mHue: %d, mSaturation: %d, red: %d, green: %d, blue: %d\r\n", brightness, mHue, mSaturation, red, green, blue); showRGB(red, green, blue); - - if (brightness > 0) - { - mDefaultOnBrightness = brightness; - } + mDefaultOnBrightness = brightness; } void LEDWidget::Blink(uint32_t changeRateMS) @@ -168,20 +105,39 @@ void LEDWidget::Animate() } } -void LEDWidget::DoSet(bool state) +void LEDWidget::DoSet() { - bool stateChange = (mState != state); - mState = state; - uint8_t red, green, blue; - uint8_t brightness = state ? mDefaultOnBrightness : 0; - log_info("state: %d, mDefaultOnBrightness: %d, brightness: %d\r\n", state, mDefaultOnBrightness, brightness); + uint8_t brightness = mState ? mDefaultOnBrightness : 0; + log_info("state: %d, mDefaultOnBrightness: %d, brightness: %d\r\n", mState, mDefaultOnBrightness, brightness); HSB2rgb(mHue, mSaturation, brightness, red, green, blue); log_info("brightness: %d, mHue: %d, mSaturation: %d, red: %d, green: %d, blue: %d\r\n", brightness, mHue, mSaturation, red, green, blue); showRGB(red, green, blue); } +void LEDWidget::Toggle() +{ + log_info("Toggling state to %d", !mState); + mState = !mState; + if (mState == 1) + { + SetBrightness(UINT8_MAX); + } + else + { + SetBrightness(0); + } +} +uint8_t LEDWidget::GetLevel() +{ + return this->mDefaultOnBrightness; +} + +bool LEDWidget::IsTurnedOn() +{ + return this->mState; +} void LEDWidget::SetColor(uint8_t Hue, uint8_t Saturation) { uint8_t red, green, blue; diff --git a/examples/lighting-app/bouffalolab/bl602/src/main.cpp b/examples/lighting-app/bouffalolab/bl602/src/main.cpp index 679812bb274fc5..de96a44d69608c 100644 --- a/examples/lighting-app/bouffalolab/bl602/src/main.cpp +++ b/examples/lighting-app/bouffalolab/bl602/src/main.cpp @@ -35,7 +35,7 @@ #include -#if CONFIG_ENABLE_PW_RPC +#if PW_RPC_ENABLED #include "PigweedLogger.h" #include "Rpc.h" #endif @@ -73,8 +73,8 @@ extern "C" int main() { InitPlatform(); -#if CONFIG_ENABLE_PW_RPC - chip::rpc::Init(); +#if PW_RPC_ENABLED + PigweedLogger::init(); #endif log_info("==================================================\r\n"); diff --git a/examples/lighting-app/bouffalolab/bl602/with_pw_rpc.gni b/examples/lighting-app/bouffalolab/bl602/with_pw_rpc.gni new file mode 100644 index 00000000000000..77eac0ca9deff3 --- /dev/null +++ b/examples/lighting-app/bouffalolab/bl602/with_pw_rpc.gni @@ -0,0 +1,28 @@ +# Copyright (c) 2021 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. + +# add this gni as import in your build args to use pigweed in the example +# 'import("//with_pw_rpc.gni")' + +import("//build_overrides/chip.gni") +import("//build_overrides/pigweed.gni") +import("${chip_root}/config/bouffalolab/bl602/lib/pw_rpc/pw_rpc.gni") +import("${chip_root}/examples/platform/bouffalolab/bl602/args.gni") + +chip_enable_pw_rpc = true +chip_enable_openthread = false +chip_build_pw_trace_lib = false + +cpp_standard = "gnu++17" +#pw_trace_BACKEND = "$dir_pw_trace_tokenized" diff --git a/examples/lighting-app/efr32/BUILD.gn b/examples/lighting-app/efr32/BUILD.gn index 192833797494b2..56f0cf92688cf8 100644 --- a/examples/lighting-app/efr32/BUILD.gn +++ b/examples/lighting-app/efr32/BUILD.gn @@ -331,6 +331,11 @@ efr32_executable("lighting_app") { ] } + # Attestation Credentials + if (chip_build_platform_attestation_credentials_provider) { + deps += [ "${examples_plat_dir}:efr32-attestation-credentials" ] + } + output_dir = root_out_dir } diff --git a/examples/lighting-app/efr32/src/AppTask.cpp b/examples/lighting-app/efr32/src/AppTask.cpp index 7e1e8d9a811e82..3edc00dfa8855e 100644 --- a/examples/lighting-app/efr32/src/AppTask.cpp +++ b/examples/lighting-app/efr32/src/AppTask.cpp @@ -39,9 +39,6 @@ #include -#include -#include - #include #include @@ -163,7 +160,6 @@ Identify gIdentify = { } // namespace using namespace chip::TLV; -using namespace ::chip::Credentials; using namespace ::chip::DeviceLayer; AppTask AppTask::sAppTask; @@ -201,11 +197,6 @@ CHIP_ERROR AppTask::Init() sWiFiNetworkCommissioningInstance.Init(); #endif - chip::DeviceLayer::PlatformMgr().LockChipStack(); - // Initialize device attestation config - SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); - chip::DeviceLayer::PlatformMgr().UnlockChipStack(); - // Create FreeRTOS sw timer for Function Selection. sFunctionTimer = xTimerCreate("FnTmr", // Just a text name, not used by the RTOS kernel 1, // == default timer period (mS) diff --git a/examples/lighting-app/efr32/src/main.cpp b/examples/lighting-app/efr32/src/main.cpp index 54137f45c89043..79ef68cc720c88 100644 --- a/examples/lighting-app/efr32/src/main.cpp +++ b/examples/lighting-app/efr32/src/main.cpp @@ -25,12 +25,19 @@ #include "sl_system_kernel.h" #include #include +#include #include +#ifdef EFR32_ATTESTATION_CREDENTIALS +#include +#else +#include +#endif #define BLE_DEV_NAME "SiLabs-Light" using namespace ::chip; using namespace ::chip::Inet; using namespace ::chip::DeviceLayer; +using namespace ::chip::Credentials; #define UNUSED_PARAMETER(a) (a = a) @@ -49,6 +56,15 @@ int main(void) gExampleDeviceInfoProvider.SetStorageDelegate(&chip::Server::GetInstance().GetPersistentStorage()); chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); + chip::DeviceLayer::PlatformMgr().LockChipStack(); + // Initialize device attestation config +#ifdef EFR32_ATTESTATION_CREDENTIALS + SetDeviceAttestationCredentialsProvider(EFR32::GetEFR32DacProvider()); +#else + SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); +#endif + chip::DeviceLayer::PlatformMgr().UnlockChipStack(); + EFR32_LOG("Starting App Task"); if (GetAppTask().StartAppTask() != CHIP_NO_ERROR) appError(CHIP_ERROR_INTERNAL); diff --git a/examples/lighting-app/qpg/include/CHIPProjectConfig.h b/examples/lighting-app/qpg/include/CHIPProjectConfig.h index f19f47d8845051..8eba3acd571438 100755 --- a/examples/lighting-app/qpg/include/CHIPProjectConfig.h +++ b/examples/lighting-app/qpg/include/CHIPProjectConfig.h @@ -68,6 +68,15 @@ */ #define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1 +/** + * CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION + * + * A uint32_t identifying the software version running on the device. + */ +#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION +#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 0x0001 +#endif + /** * CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING * @@ -108,13 +117,6 @@ */ #define CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE (512) -/** - * CHIP_DEVICE_CONFIG_THREAD_ENABLE_CLI - * - * Enable Thread CLI interface at initialisation. - */ -#define CHIP_DEVICE_CONFIG_THREAD_ENABLE_CLI 1 - /** * @def CHIP_CONFIG_MAX_FABRICS * diff --git a/examples/lighting-app/qpg/src/AppTask.cpp b/examples/lighting-app/qpg/src/AppTask.cpp index 96cdfc9577a04e..13e526024c1edf 100644 --- a/examples/lighting-app/qpg/src/AppTask.cpp +++ b/examples/lighting-app/qpg/src/AppTask.cpp @@ -28,6 +28,9 @@ #include #include #include +#include +#include + #include #include #include @@ -66,6 +69,107 @@ StaticQueue_t sAppEventQueueStruct; StackType_t appStack[APP_TASK_STACK_SIZE / sizeof(StackType_t)]; StaticTask_t appTaskStruct; + +EmberAfIdentifyEffectIdentifier sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT; + +/********************************************************** + * Identify Callbacks + *********************************************************/ + +namespace { +void OnTriggerIdentifyEffectCompleted(chip::System::Layer * systemLayer, void * appState) +{ + sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT; +} +} // namespace + +void OnTriggerIdentifyEffect(Identify * identify) +{ + sIdentifyEffect = identify->mCurrentEffectIdentifier; + + if (identify->mCurrentEffectIdentifier == EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE) + { + ChipLogProgress(Zcl, "IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE - Not supported, use effect variant %d", + identify->mEffectVariant); + sIdentifyEffect = static_cast(identify->mEffectVariant); + } + + switch (sIdentifyEffect) + { + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK: + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE: + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY: + (void) chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds16(5), OnTriggerIdentifyEffectCompleted, + identify); + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_FINISH_EFFECT: + (void) chip::DeviceLayer::SystemLayer().CancelTimer(OnTriggerIdentifyEffectCompleted, identify); + (void) chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds16(1), OnTriggerIdentifyEffectCompleted, + identify); + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT: + (void) chip::DeviceLayer::SystemLayer().CancelTimer(OnTriggerIdentifyEffectCompleted, identify); + sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT; + break; + default: + ChipLogProgress(Zcl, "No identifier effect"); + } +} + +Identify gIdentify = { + chip::EndpointId{ 1 }, + [](Identify *) { ChipLogProgress(Zcl, "onIdentifyStart"); }, + [](Identify *) { ChipLogProgress(Zcl, "onIdentifyStop"); }, + EMBER_ZCL_IDENTIFY_IDENTIFY_TYPE_VISIBLE_LED, + OnTriggerIdentifyEffect, +}; + +/********************************************************** + * OffWithEffect Callbacks + *********************************************************/ + +void OnTriggerOffWithEffect(OnOffEffect * effect) +{ + chip::app::Clusters::OnOff::OnOffEffectIdentifier effectId = effect->mEffectIdentifier; + uint8_t effectVariant = effect->mEffectVariant; + + // Uses print outs until we can support the effects + if (effectId == EMBER_ZCL_ON_OFF_EFFECT_IDENTIFIER_DELAYED_ALL_OFF) + { + if (effectVariant == EMBER_ZCL_ON_OFF_DELAYED_ALL_OFF_EFFECT_VARIANT_FADE_TO_OFF_IN_0P8_SECONDS) + { + ChipLogProgress(Zcl, "EMBER_ZCL_ON_OFF_DELAYED_ALL_OFF_EFFECT_VARIANT_FADE_TO_OFF_IN_0P8_SECONDS"); + } + else if (effectVariant == EMBER_ZCL_ON_OFF_DELAYED_ALL_OFF_EFFECT_VARIANT_NO_FADE) + { + ChipLogProgress(Zcl, "EMBER_ZCL_ON_OFF_DELAYED_ALL_OFF_EFFECT_VARIANT_NO_FADE"); + } + else if (effectVariant == + EMBER_ZCL_ON_OFF_DELAYED_ALL_OFF_EFFECT_VARIANT_50_PERCENT_DIM_DOWN_IN_0P8_SECONDS_THEN_FADE_TO_OFF_IN_12_SECONDS) + { + ChipLogProgress(Zcl, + "EMBER_ZCL_ON_OFF_DELAYED_ALL_OFF_EFFECT_VARIANT_50_PERCENT_DIM_DOWN_IN_0P8_SECONDS_THEN_FADE_TO_OFF_" + "IN_12_SECONDS"); + } + } + else if (effectId == EMBER_ZCL_ON_OFF_EFFECT_IDENTIFIER_DYING_LIGHT) + { + if (effectVariant == + EMBER_ZCL_ON_OFF_DYING_LIGHT_EFFECT_VARIANT_20_PERCENTER_DIM_UP_IN_0P5_SECONDS_THEN_FADE_TO_OFF_IN_1_SECOND) + { + ChipLogProgress( + Zcl, "EMBER_ZCL_ON_OFF_DYING_LIGHT_EFFECT_VARIANT_20_PERCENTER_DIM_UP_IN_0P5_SECONDS_THEN_FADE_TO_OFF_IN_1_SECOND"); + } + } +} + +OnOffEffect gEffect = { + chip::EndpointId{ 1 }, + OnTriggerOffWithEffect, + EMBER_ZCL_ON_OFF_EFFECT_IDENTIFIER_DELAYED_ALL_OFF, + static_cast(EMBER_ZCL_ON_OFF_DELAYED_ALL_OFF_EFFECT_VARIANT_FADE_TO_OFF_IN_0P8_SECONDS), +}; + } // namespace AppTask AppTask::sAppTask; diff --git a/examples/lock-app/cc13x2x7_26x2x7/main/AppTask.cpp b/examples/lock-app/cc13x2x7_26x2x7/main/AppTask.cpp index ab0bf4047af4cb..a0d30130644e43 100644 --- a/examples/lock-app/cc13x2x7_26x2x7/main/AppTask.cpp +++ b/examples/lock-app/cc13x2x7_26x2x7/main/AppTask.cpp @@ -29,13 +29,16 @@ #include +#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR #include #include #include #include +#include +#endif + #include #include -#include #include @@ -63,6 +66,7 @@ static Button_Handle sAppRightHandle; AppTask AppTask::sAppTask; +#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR static DefaultOTARequestor sRequestorCore; static DefaultOTARequestorStorage sRequestorStorage; static DefaultOTARequestorDriver sRequestorUser; @@ -80,6 +84,7 @@ void InitializeOTARequestor(void) sDownloader.SetImageProcessorDelegate(&sImageProcessor); sRequestorUser.Init(&sRequestorCore, &sImageProcessor); } +#endif int AppTask::StartAppTask() { @@ -202,8 +207,9 @@ int AppTask::Init() ConfigurationMgr().LogDeviceConfig(); +#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR InitializeOTARequestor(); - +#endif // QR code will be used with CHIP Tool PrintOnboardingCodes(RendezvousInformationFlags(RendezvousInformationFlag::kBLE)); diff --git a/examples/lock-app/cyw30739/include/LockManager.h b/examples/lock-app/cyw30739/include/LockManager.h index 596e5e9f42d035..1cf92b5efe5de1 100644 --- a/examples/lock-app/cyw30739/include/LockManager.h +++ b/examples/lock-app/cyw30739/include/LockManager.h @@ -26,11 +26,73 @@ #include #include -using namespace ::chip; +namespace CYW30739DoorLock { +namespace ResourceRanges { +// Used to size arrays +static constexpr uint16_t kMaxUsers = 10; +static constexpr uint8_t kMaxCredentialsPerUser = 10; +static constexpr uint8_t kMaxWeekdaySchedulesPerUser = 10; +static constexpr uint8_t kMaxYeardaySchedulesPerUser = 10; +static constexpr uint8_t kMaxHolidaySchedules = 10; +static constexpr uint8_t kMaxCredentialSize = 8; + +// Indices received for user/credential/schedules are 1-indexed +static constexpr uint8_t kStartIndexValue = 1; + +static constexpr uint8_t kMaxCredentials = kMaxUsers * kMaxCredentialsPerUser; +} // namespace ResourceRanges + +namespace LockInitParams { + +struct LockParam +{ + // Read from zap attributes + uint16_t numberOfUsers = 0; + uint8_t numberOfCredentialsPerUser = 0; + uint8_t numberOfWeekdaySchedulesPerUser = 0; + uint8_t numberOfYeardaySchedulesPerUser = 0; + uint8_t numberOfHolidaySchedules = 0; +}; + +class ParamBuilder +{ +public: + ParamBuilder & SetNumberOfUsers(uint16_t numberOfUsers) + { + lockParam_.numberOfUsers = numberOfUsers; + return *this; + } + ParamBuilder & SetNumberOfCredentialsPerUser(uint8_t numberOfCredentialsPerUser) + { + lockParam_.numberOfCredentialsPerUser = numberOfCredentialsPerUser; + return *this; + } + ParamBuilder & SetNumberOfWeekdaySchedulesPerUser(uint8_t numberOfWeekdaySchedulesPerUser) + { + lockParam_.numberOfWeekdaySchedulesPerUser = numberOfWeekdaySchedulesPerUser; + return *this; + } + ParamBuilder & SetNumberOfYeardaySchedulesPerUser(uint8_t numberOfYeardaySchedulesPerUser) + { + lockParam_.numberOfYeardaySchedulesPerUser = numberOfYeardaySchedulesPerUser; + return *this; + } + ParamBuilder & SetNumberOfHolidaySchedules(uint8_t numberOfHolidaySchedules) + { + lockParam_.numberOfHolidaySchedules = numberOfHolidaySchedules; + return *this; + } + LockParam GetLockParam() { return lockParam_; } -#define DOOR_LOCK_MAX_CREDENTIAL_SIZE 8 +private: + LockParam lockParam_; +}; -static constexpr size_t DOOR_LOCK_CREDENTIAL_INFO_MAX_DATA_SIZE = 20; +} // namespace LockInitParams +} // namespace CYW30739DoorLock + +using namespace ::chip; +using namespace CYW30739DoorLock::ResourceRanges; class LockManager { @@ -59,7 +121,7 @@ class LockManager } Actor; CHIP_ERROR Init(chip::app::DataModel::Nullable state, - uint8_t maxNumberOfCredentialsPerUser); + CYW30739DoorLock::LockInitParams::LockParam lockParam); bool NextState(); bool IsActionInProgress(); bool InitiateAction(int32_t aActor, Action_t aAction); @@ -71,16 +133,39 @@ class LockManager bool Lock(chip::EndpointId endpointId, const Optional & pin, DlOperationError & err); bool Unlock(chip::EndpointId endpointId, const Optional & pin, DlOperationError & err); - bool GetUser(uint16_t userIndex, EmberAfPluginDoorLockUserInfo & user) const; - bool SetUser(uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, const chip::CharSpan & userName, - uint32_t uniqueId, DlUserStatus userStatus, DlUserType usertype, DlCredentialRule credentialRule, - const DlCredential * credentials, size_t totalCredentials); + bool GetUser(chip::EndpointId endpointId, uint16_t userIndex, EmberAfPluginDoorLockUserInfo & user); + bool SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, + const chip::CharSpan & userName, uint32_t uniqueId, DlUserStatus userStatus, DlUserType usertype, + DlCredentialRule credentialRule, const DlCredential * credentials, size_t totalCredentials); bool GetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, DlCredentialType credentialType, - EmberAfPluginDoorLockCredentialInfo & credential) const; + EmberAfPluginDoorLockCredentialInfo & credential); + + bool SetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, chip::FabricIndex creator, chip::FabricIndex modifier, + DlCredentialStatus credentialStatus, DlCredentialType credentialType, const chip::ByteSpan & credentialData); + + DlStatus GetWeekdaySchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex, + EmberAfPluginDoorLockWeekDaySchedule & schedule); + + DlStatus SetWeekdaySchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex, DlScheduleStatus status, + DlDaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute); + + DlStatus GetYeardaySchedule(chip::EndpointId endpointId, uint8_t yearDayIndex, uint16_t userIndex, + EmberAfPluginDoorLockYearDaySchedule & schedule); + + DlStatus SetYeardaySchedule(chip::EndpointId endpointId, uint8_t yearDayIndex, uint16_t userIndex, DlScheduleStatus status, + uint32_t localStartTime, uint32_t localEndTime); + + DlStatus GetHolidaySchedule(chip::EndpointId endpointId, uint8_t holidayIndex, EmberAfPluginDoorLockHolidaySchedule & schedule); + + DlStatus SetHolidaySchedule(chip::EndpointId endpointId, uint8_t holidayIndex, DlScheduleStatus status, uint32_t localStartTime, + uint32_t localEndTime, DlOperatingMode operatingMode); - bool SetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, DlCredentialStatus credentialStatus, - DlCredentialType credentialType, const chip::ByteSpan & credentialData); + bool IsValidUserIndex(uint16_t userIndex); + bool IsValidCredentialIndex(uint16_t credentialIndex, DlCredentialType type); + bool IsValidWeekdayScheduleIndex(uint8_t scheduleIndex); + bool IsValidYeardayScheduleIndex(uint8_t scheduleIndex); + bool IsValidHolidayScheduleIndex(uint8_t scheduleIndex); bool setLockState(chip::EndpointId endpointId, DlLockState lockState, const Optional & pin, DlOperationError & err); @@ -102,15 +187,18 @@ class LockManager static void TimerEventHandler(WICED_TIMER_PARAM_TYPE cb_params); static int ActuatorMovementTimerEventHandler(void * aEvent); - EmberAfPluginDoorLockUserInfo mLockUser; - EmberAfPluginDoorLockCredentialInfo mLockCredentials; + EmberAfPluginDoorLockUserInfo mLockUsers[kMaxUsers]; + EmberAfPluginDoorLockCredentialInfo mLockCredentials[kMaxCredentials]; + EmberAfPluginDoorLockWeekDaySchedule mWeekdaySchedule[kMaxUsers][kMaxWeekdaySchedulesPerUser]; + EmberAfPluginDoorLockYearDaySchedule mYeardaySchedule[kMaxUsers][kMaxYeardaySchedulesPerUser]; + EmberAfPluginDoorLockHolidaySchedule mHolidaySchedule[kMaxHolidaySchedules]; - char mUserName[DOOR_LOCK_MAX_USER_NAME_SIZE]; - uint8_t mCredentialData[DOOR_LOCK_MAX_CREDENTIAL_SIZE]; - chip::Platform::ScopedMemoryBuffer mCredentials; - uint8_t mMaxCredentialsPerUser; + char mUserNames[ArraySize(mLockUsers)][DOOR_LOCK_MAX_USER_NAME_SIZE]; + uint8_t mCredentialData[kMaxCredentials][kMaxCredentialSize]; + DlCredential mCredentials[kMaxUsers][kMaxCredentialsPerUser]; static LockManager sLock; + CYW30739DoorLock::LockInitParams::LockParam LockParams; }; inline LockManager & LockMgr() diff --git a/examples/lock-app/cyw30739/include/chip_lock.h b/examples/lock-app/cyw30739/include/chip_lock.h index b752e02e2fe067..85aaddb87057aa 100644 --- a/examples/lock-app/cyw30739/include/chip_lock.h +++ b/examples/lock-app/cyw30739/include/chip_lock.h @@ -23,6 +23,7 @@ // Application-defined error codes in the CHIP_ERROR space #define APP_ERROR_INIT_TIMER_FAILED CHIP_ERROR_NO_MEMORY // should use CHIP_APPLICATION_ERROR when it's ready +#define APP_ERROR_ALLOCATION_FAILED CHIP_APPLICATION_ERROR(0x07) // Application configurations #define ACTUATOR_MOVEMENT_PERIOS_MS 1000 diff --git a/examples/lock-app/cyw30739/src/LockManager.cpp b/examples/lock-app/cyw30739/src/LockManager.cpp index d5af8592543829..2a845b62abb3ac 100644 --- a/examples/lock-app/cyw30739/src/LockManager.cpp +++ b/examples/lock-app/cyw30739/src/LockManager.cpp @@ -19,25 +19,62 @@ #include "LockManager.h" #include "wiced_bt_event.h" +#include #include #include -using namespace chip::DeviceLayer::Internal; - LockManager LockManager::sLock; wiced_timer_t sLockTimer; -CHIP_ERROR LockManager::Init(chip::app::DataModel::Nullable state, - uint8_t maxNumberOfCredentialsPerUser) +using namespace chip::DeviceLayer::Internal; +using namespace CYW30739DoorLock::LockInitParams; + +CHIP_ERROR LockManager::Init(chip::app::DataModel::Nullable state, LockParam lockParam) { - // Allocate buffer for credentials - if (!mCredentials.Alloc(maxNumberOfCredentialsPerUser)) + LockParams = lockParam; + + if (LockParams.numberOfUsers > kMaxUsers) + { + ChipLogError(Zcl, + "Max number of users is greater than %d, the maximum amount of users currently supported on this platform", + kMaxUsers); + return APP_ERROR_ALLOCATION_FAILED; + } + + if (LockParams.numberOfCredentialsPerUser > kMaxCredentialsPerUser) { - printf("Failed to allocate array for lock credentials"); - return CHIP_ERROR_NO_MEMORY; + ChipLogError( + Zcl, + "Max number of credentials per user is greater than %d, the maximum amount of users currently supported on this " + "platform", + kMaxCredentialsPerUser); + return APP_ERROR_ALLOCATION_FAILED; + } + + if (LockParams.numberOfWeekdaySchedulesPerUser > kMaxWeekdaySchedulesPerUser) + { + ChipLogError( + Zcl, "Max number of schedules is greater than %d, the maximum amount of schedules currently supported on this platform", + kMaxWeekdaySchedulesPerUser); + return APP_ERROR_ALLOCATION_FAILED; + } + + if (LockParams.numberOfYeardaySchedulesPerUser > kMaxYeardaySchedulesPerUser) + { + ChipLogError( + Zcl, "Max number of schedules is greater than %d, the maximum amount of schedules currently supported on this platform", + kMaxYeardaySchedulesPerUser); + return APP_ERROR_ALLOCATION_FAILED; + } + + if (LockParams.numberOfHolidaySchedules > kMaxHolidaySchedules) + { + ChipLogError( + Zcl, "Max number of schedules is greater than %d, the maximum amount of schedules currently supported on this platform", + kMaxHolidaySchedules); + return APP_ERROR_ALLOCATION_FAILED; } - mMaxCredentialsPerUser = maxNumberOfCredentialsPerUser; wiced_result_t result; @@ -45,7 +82,7 @@ CHIP_ERROR LockManager::Init(chip::app::DataModel::Nullable(&mLockUser), - sizeof(EmberAfPluginDoorLockUserInfo), outLen); + CYW30739Config::ReadConfigValueBin(CYW30739Config::kConfigKey_LockUser, reinterpret_cast(&mLockUsers), + sizeof(EmberAfPluginDoorLockUserInfo) * ArraySize(mLockUsers), outLen); + CYW30739Config::ReadConfigValueBin(CYW30739Config::kConfigKey_Credential, reinterpret_cast(&mLockCredentials), - sizeof(EmberAfPluginDoorLockCredentialInfo), outLen); + sizeof(EmberAfPluginDoorLockCredentialInfo) * ArraySize(mLockCredentials), outLen); + + CYW30739Config::ReadConfigValueBin(CYW30739Config::kConfigKey_LockUserName, reinterpret_cast(mUserNames), + sizeof(mUserNames), outLen); - CYW30739Config::ReadConfigValueStr(CYW30739Config::kConfigKey_LockUserName, mUserName, DOOR_LOCK_USER_NAME_BUFFER_SIZE, outLen); + CYW30739Config::ReadConfigValueBin(CYW30739Config::kConfigKey_CredentialData, reinterpret_cast(mCredentialData), + sizeof(mCredentialData), outLen); - CYW30739Config::ReadConfigValueBin(CYW30739Config::kConfigKey_CredentialData, mCredentialData, sizeof(mCredentialData), outLen); + CYW30739Config::ReadConfigValueBin(CYW30739Config::kConfigKey_UserCredentials, reinterpret_cast(mCredentials), + sizeof(DlCredential) * LockParams.numberOfUsers * LockParams.numberOfCredentialsPerUser, + outLen); - CYW30739Config::ReadConfigValueBin(CYW30739Config::kConfigKey_UserCredentials, reinterpret_cast(mCredentials.Get()), - sizeof(DlCredential), outLen); + CYW30739Config::ReadConfigValueBin(CYW30739Config::kConfigKey_WeekDaySchedules, reinterpret_cast(mWeekdaySchedule), + sizeof(EmberAfPluginDoorLockWeekDaySchedule) * LockParams.numberOfWeekdaySchedulesPerUser * + LockParams.numberOfUsers, + outLen); + + CYW30739Config::ReadConfigValueBin(CYW30739Config::kConfigKey_YearDaySchedules, reinterpret_cast(mYeardaySchedule), + sizeof(EmberAfPluginDoorLockYearDaySchedule) * LockParams.numberOfYeardaySchedulesPerUser * + LockParams.numberOfUsers, + outLen); + + CYW30739Config::ReadConfigValueBin(CYW30739Config::kConfigKey_HolidaySchedules, + reinterpret_cast(&(mHolidaySchedule)), + sizeof(EmberAfPluginDoorLockHolidaySchedule) * LockParams.numberOfHolidaySchedules, outLen); return true; } @@ -131,13 +217,13 @@ void LockManager::StartTimer(uint32_t aTimeoutMs) { if (wiced_is_timer_in_use(&sLockTimer)) { - printf("app timer already started!\n"); + ChipLogError(Zcl, "app timer already started!"); CancelTimer(); } if (wiced_start_timer(&sLockTimer, aTimeoutMs) != WICED_BT_SUCCESS) { - printf("sLockTimer timer start() failed\n"); + ChipLogError(Zcl, "sLockTimer timer start() failed"); return; } } @@ -146,7 +232,7 @@ void LockManager::CancelTimer(void) { if (wiced_stop_timer(&sLockTimer) != WICED_BT_SUCCESS) { - printf("Lock timer timer stop() failed\n"); + ChipLogError(Zcl, "Lock timer timer stop() failed"); return; } } @@ -163,7 +249,7 @@ void LockManager::TimerEventHandler(WICED_TIMER_PARAM_TYPE cb_params) if (wiced_app_event_serialize(fn, (void *) lock) != WICED_TRUE) { - printf("wiced_app_event_serialize failed\n"); + ChipLogError(Zcl, "wiced_app_event_serialize failed "); } } @@ -205,39 +291,49 @@ bool LockManager::Unlock(chip::EndpointId endpointId, const Optional 0, false); // indices are one-indexed + + userIndex--; + + VerifyOrReturnValue(IsValidUserIndex(userIndex), false); - const auto & userInDb = mLockUser; - user.userStatus = userInDb.userStatus; + ChipLogProgress(Zcl, "Door Lock App: LockManager::GetUser [endpoint=%d,userIndex=%hu]", endpointId, userIndex); + + const auto & userInDb = mLockUsers[userIndex]; + + user.userStatus = userInDb.userStatus; if (DlUserStatus::kAvailable == user.userStatus) { - ChipLogDetail(Zcl, "Found unoccupied user [endpoint=%d]", mEndpointId); + ChipLogDetail(Zcl, "Found unoccupied user [endpoint=%d]", endpointId); return true; } user.userName = chip::CharSpan(userInDb.userName.data(), userInDb.userName.size()); - user.credentials = chip::Span(userInDb.credentials.data(), userInDb.credentials.size()); + user.credentials = chip::Span(mCredentials[userIndex], userInDb.credentials.size()); user.userUniqueId = userInDb.userUniqueId; user.userType = userInDb.userType; user.credentialRule = userInDb.credentialRule; - user.createdBy = userInDb.createdBy; - user.lastModifiedBy = userInDb.lastModifiedBy; + // So far there's no way to actually create the credential outside Matter, so here we always set the creation/modification + // source to Matter + user.creationSource = DlAssetSource::kMatterIM; + user.createdBy = userInDb.createdBy; + user.modificationSource = DlAssetSource::kMatterIM; + user.lastModifiedBy = userInDb.lastModifiedBy; ChipLogDetail(Zcl, "Found occupied user " "[endpoint=%d,name=\"%.*s\",credentialsCount=%u,uniqueId=%lx,type=%u,credentialRule=%u," "createdBy=%d,lastModifiedBy=%d]", - mEndpointId, static_cast(user.userName.size()), user.userName.data(), user.credentials.size(), + endpointId, static_cast(user.userName.size()), user.userName.data(), user.credentials.size(), user.userUniqueId, to_underlying(user.userType), to_underlying(user.credentialRule), user.createdBy, user.lastModifiedBy); return true; } -bool LockManager::SetUser(uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, +bool LockManager::SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, const chip::CharSpan & userName, uint32_t uniqueId, DlUserStatus userStatus, DlUserType usertype, DlCredentialRule credentialRule, const DlCredential * credentials, size_t totalCredentials) { @@ -245,27 +341,32 @@ bool LockManager::SetUser(uint16_t userIndex, chip::FabricIndex creator, chip::F "Door Lock App: LockManager::SetUser " "[endpoint=%d,userIndex=%d,creator=%d,modifier=%d,userName=%s,uniqueId=%ld " "userStatus=%u,userType=%u,credentialRule=%u,credentials=%p,totalCredentials=%u]", - mEndpointId, userIndex, creator, modifier, userName.data(), uniqueId, to_underlying(userStatus), + endpointId, userIndex, creator, modifier, userName.data(), uniqueId, to_underlying(userStatus), to_underlying(usertype), to_underlying(credentialRule), credentials, totalCredentials); - auto & userInStorage = mLockUser; + VerifyOrReturnValue(userIndex > 0, false); // indices are one-indexed + + userIndex--; + + VerifyOrReturnValue(IsValidUserIndex(userIndex), false); + + auto & userInStorage = mLockUsers[userIndex]; if (userName.size() > DOOR_LOCK_MAX_USER_NAME_SIZE) { - ChipLogError(Zcl, "Cannot set user - user name is too long [endpoint=%d,index=%d]", mEndpointId, userIndex); + ChipLogError(Zcl, "Cannot set user - user name is too long [endpoint=%d,index=%d]", endpointId, userIndex); return false; } - if (totalCredentials > mMaxCredentialsPerUser) + if (totalCredentials > LockParams.numberOfCredentialsPerUser) { ChipLogError(Zcl, "Cannot set user - total number of credentials is too big [endpoint=%d,index=%d,totalCredentials=%u]", - mEndpointId, userIndex, totalCredentials); + endpointId, userIndex, totalCredentials); return false; } - chip::Platform::CopyString(mUserName, userName); - mUserName[userName.size()] = 0; - userInStorage.userName = chip::CharSpan(mUserName, userName.size()); + chip::Platform::CopyString(mUserNames[userIndex], userName); + userInStorage.userName = chip::CharSpan(mUserNames[userIndex], userName.size()); userInStorage.userUniqueId = uniqueId; userInStorage.userStatus = userStatus; userInStorage.userType = usertype; @@ -275,35 +376,54 @@ bool LockManager::SetUser(uint16_t userIndex, chip::FabricIndex creator, chip::F for (size_t i = 0; i < totalCredentials; ++i) { - mCredentials[i] = credentials[i]; - mCredentials[i].CredentialType = 1; - mCredentials[i].CredentialIndex = i + 1; + mCredentials[userIndex][i] = credentials[i]; + mCredentials[userIndex][i].CredentialType = 1; + mCredentials[userIndex][i].CredentialIndex = i + 1; } - userInStorage.credentials = chip::Span(mCredentials.Get(), totalCredentials); + userInStorage.credentials = chip::Span(mCredentials[userIndex], totalCredentials); // Save user information in NVM flash - CYW30739Config::WriteConfigValueBin(CYW30739Config::kConfigKey_LockUser, reinterpret_cast(&userInStorage), - sizeof(EmberAfPluginDoorLockUserInfo)); + CYW30739Config::WriteConfigValueBin(CYW30739Config::kConfigKey_LockUser, reinterpret_cast(&mLockUsers), + sizeof(EmberAfPluginDoorLockUserInfo) * LockParams.numberOfUsers); - CYW30739Config::WriteConfigValueBin(CYW30739Config::kConfigKey_UserCredentials, - reinterpret_cast(mCredentials.Get()), sizeof(DlCredential)); + CYW30739Config::WriteConfigValueBin(CYW30739Config::kConfigKey_UserCredentials, reinterpret_cast(mCredentials), + sizeof(DlCredential) * LockParams.numberOfUsers * LockParams.numberOfCredentialsPerUser); - CYW30739Config::WriteConfigValueStr(CYW30739Config::kConfigKey_LockUserName, mUserName, sizeof(userName.size())); + CYW30739Config::WriteConfigValueBin(CYW30739Config::kConfigKey_LockUserName, reinterpret_cast(mUserNames), + sizeof(mUserNames)); - ChipLogProgress(Zcl, "Successfully set the user [mEndpointId=%d,index=%d]", mEndpointId, userIndex); + ChipLogProgress(Zcl, "Successfully set the user [mEndpointId=%d,index=%d]", endpointId, userIndex); return true; } bool LockManager::GetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, DlCredentialType credentialType, - EmberAfPluginDoorLockCredentialInfo & credential) const + EmberAfPluginDoorLockCredentialInfo & credential) { - ChipLogProgress(Zcl, "Lock App: LockManager::GetCredential [credentialType=%u]", to_underlying(credentialType)); - const auto & credentialInStorage = mLockCredentials; + VerifyOrReturnValue(credentialIndex > 0, false); // indices are one-indexed + + credentialIndex--; + + VerifyOrReturnValue(IsValidCredentialIndex(credentialIndex, credentialType), false); + + ChipLogProgress(Zcl, "Lock App: LockManager::GetCredential [credentialType=%u], credentialIndex=%d", + to_underlying(credentialType), credentialIndex); + + if (credentialType == DlCredentialType::kProgrammingPIN) + { + ChipLogError(Zcl, "Programming user not supported [credentialType=%u], credentialIndex=%d", to_underlying(credentialType), + credentialIndex); + + return true; + } + + const auto & credentialInStorage = mLockCredentials[credentialIndex]; credential.status = credentialInStorage.status; + ChipLogDetail(Zcl, "CredentialStatus: %d, CredentialIndex: %d ", (int) credential.status, credentialIndex); + if (DlCredentialStatus::kAvailable == credential.status) { ChipLogDetail(Zcl, "Found unoccupied credential "); @@ -311,6 +431,12 @@ bool LockManager::GetCredential(chip::EndpointId endpointId, uint16_t credential } credential.credentialType = credentialInStorage.credentialType; credential.credentialData = credentialInStorage.credentialData; + credential.createdBy = credentialInStorage.createdBy; + credential.lastModifiedBy = credentialInStorage.lastModifiedBy; + // So far there's no way to actually create the credential outside Matter, so here we always set the creation/modification + // source to Matter + credential.creationSource = DlAssetSource::kMatterIM; + credential.modificationSource = DlAssetSource::kMatterIM; ChipLogDetail(Zcl, "Found occupied credential [type=%u,dataSize=%u]", to_underlying(credential.credentialType), credential.credentialData.size()); @@ -318,44 +444,175 @@ bool LockManager::GetCredential(chip::EndpointId endpointId, uint16_t credential return true; } -bool LockManager::SetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, DlCredentialStatus credentialStatus, - DlCredentialType credentialType, const chip::ByteSpan & credentialData) +bool LockManager::SetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, chip::FabricIndex creator, + chip::FabricIndex modifier, DlCredentialStatus credentialStatus, DlCredentialType credentialType, + const chip::ByteSpan & credentialData) { + + VerifyOrReturnValue(credentialIndex > 0, false); // indices are one-indexed + + credentialIndex--; + + VerifyOrReturnValue(IsValidCredentialIndex(credentialIndex, credentialType), false); + ChipLogProgress(Zcl, "Door Lock App: LockManager::SetCredential " - "[credentialStatus=%u,credentialType=%u,credentialDataSize=%u]", - to_underlying(credentialStatus), to_underlying(credentialType), credentialData.size()); + "[credentialStatus=%u,credentialType=%u,credentialDataSize=%u,creator=%d,modifier=%d]", + to_underlying(credentialStatus), to_underlying(credentialType), credentialData.size(), creator, modifier); + + auto & credentialInStorage = mLockCredentials[credentialIndex]; - auto & credentialInStorage = mLockCredentials; - if (credentialData.size() > DOOR_LOCK_CREDENTIAL_INFO_MAX_DATA_SIZE) - { - ChipLogError(Zcl, - "Cannot get the credential - data size exceeds limit " - "[dataSize=%u,maxDataSize=%u]", - credentialData.size(), DOOR_LOCK_CREDENTIAL_INFO_MAX_DATA_SIZE); - return false; - } credentialInStorage.status = credentialStatus; credentialInStorage.credentialType = credentialType; + credentialInStorage.createdBy = creator; + credentialInStorage.lastModifiedBy = modifier; - memcpy(mCredentialData, credentialData.data(), credentialData.size()); - mCredentialData[credentialData.size()] = 0; + memcpy(mCredentialData[credentialIndex], credentialData.data(), credentialData.size()); + credentialInStorage.credentialData = chip::ByteSpan{ mCredentialData[credentialIndex], credentialData.size() }; - credentialInStorage.credentialData = chip::ByteSpan{ mCredentialData, credentialData.size() }; - - // Save user information in NVM flash - CYW30739Config::WriteConfigValueBin(CYW30739Config::kConfigKey_Credential, - reinterpret_cast(&credentialInStorage), - sizeof(EmberAfPluginDoorLockCredentialInfo)); + // Save credential information in NVM flash + CYW30739Config::WriteConfigValueBin(CYW30739Config::kConfigKey_Credential, reinterpret_cast(&mLockCredentials), + sizeof(EmberAfPluginDoorLockCredentialInfo) * LockParams.numberOfCredentialsPerUser); CYW30739Config::WriteConfigValueBin(CYW30739Config::kConfigKey_CredentialData, - reinterpret_cast(&mCredentialData), credentialData.size()); + reinterpret_cast(&mCredentialData), sizeof(mCredentialData)); ChipLogProgress(Zcl, "Successfully set the credential [credentialType=%u]", to_underlying(credentialType)); return true; } +DlStatus LockManager::GetWeekdaySchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex, + EmberAfPluginDoorLockWeekDaySchedule & schedule) +{ + + VerifyOrReturnValue(weekdayIndex > 0, DlStatus::kFailure); // indices are one-indexed + VerifyOrReturnValue(userIndex > 0, DlStatus::kFailure); // indices are one-indexed + + weekdayIndex--; + userIndex--; + + VerifyOrReturnValue(IsValidWeekdayScheduleIndex(weekdayIndex), DlStatus::kFailure); + VerifyOrReturnValue(IsValidUserIndex(userIndex), DlStatus::kFailure); + + schedule = mWeekdaySchedule[userIndex][weekdayIndex]; + + return DlStatus::kSuccess; +} + +DlStatus LockManager::SetWeekdaySchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex, + DlScheduleStatus status, DlDaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, + uint8_t endHour, uint8_t endMinute) +{ + + VerifyOrReturnValue(weekdayIndex > 0, DlStatus::kFailure); // indices are one-indexed + VerifyOrReturnValue(userIndex > 0, DlStatus::kFailure); // indices are one-indexed + + weekdayIndex--; + userIndex--; + + VerifyOrReturnValue(IsValidWeekdayScheduleIndex(weekdayIndex), DlStatus::kFailure); + VerifyOrReturnValue(IsValidUserIndex(userIndex), DlStatus::kFailure); + + auto & scheduleInStorage = mWeekdaySchedule[userIndex][weekdayIndex]; + + scheduleInStorage.daysMask = daysMask; + scheduleInStorage.startHour = startHour; + scheduleInStorage.startMinute = startMinute; + scheduleInStorage.endHour = endHour; + scheduleInStorage.endMinute = endMinute; + + // Save schedule information in NVM flash + CYW30739Config::WriteConfigValueBin( + CYW30739Config::kConfigKey_WeekDaySchedules, reinterpret_cast(mWeekdaySchedule), + sizeof(EmberAfPluginDoorLockWeekDaySchedule) * LockParams.numberOfWeekdaySchedulesPerUser * LockParams.numberOfUsers); + + return DlStatus::kSuccess; +} + +DlStatus LockManager::GetYeardaySchedule(chip::EndpointId endpointId, uint8_t yearDayIndex, uint16_t userIndex, + EmberAfPluginDoorLockYearDaySchedule & schedule) +{ + VerifyOrReturnValue(yearDayIndex > 0, DlStatus::kFailure); // indices are one-indexed + VerifyOrReturnValue(userIndex > 0, DlStatus::kFailure); // indices are one-indexed + + yearDayIndex--; + userIndex--; + + VerifyOrReturnValue(IsValidYeardayScheduleIndex(yearDayIndex), DlStatus::kFailure); + VerifyOrReturnValue(IsValidUserIndex(userIndex), DlStatus::kFailure); + + auto & scheduleInStorage = mYeardaySchedule[userIndex][yearDayIndex]; + + schedule = scheduleInStorage; + + return DlStatus::kSuccess; +} + +DlStatus LockManager::SetYeardaySchedule(chip::EndpointId endpointId, uint8_t yearDayIndex, uint16_t userIndex, + DlScheduleStatus status, uint32_t localStartTime, uint32_t localEndTime) +{ + VerifyOrReturnValue(yearDayIndex > 0, DlStatus::kFailure); // indices are one-indexed + VerifyOrReturnValue(userIndex > 0, DlStatus::kFailure); // indices are one-indexed + + yearDayIndex--; + userIndex--; + + VerifyOrReturnValue(IsValidYeardayScheduleIndex(yearDayIndex), DlStatus::kFailure); + VerifyOrReturnValue(IsValidUserIndex(userIndex), DlStatus::kFailure); + + auto & scheduleInStorage = mYeardaySchedule[userIndex][yearDayIndex]; + + scheduleInStorage.localStartTime = localStartTime; + scheduleInStorage.localEndTime = localEndTime; + + // Save schedule information in NVM flash + CYW30739Config::WriteConfigValueBin( + CYW30739Config::kConfigKey_YearDaySchedules, reinterpret_cast(mYeardaySchedule), + sizeof(EmberAfPluginDoorLockYearDaySchedule) * LockParams.numberOfYeardaySchedulesPerUser * LockParams.numberOfUsers); + + return DlStatus::kSuccess; +} + +DlStatus LockManager::GetHolidaySchedule(chip::EndpointId endpointId, uint8_t holidayIndex, + EmberAfPluginDoorLockHolidaySchedule & schedule) +{ + VerifyOrReturnValue(holidayIndex > 0, DlStatus::kFailure); // indices are one-indexed + + holidayIndex--; + + VerifyOrReturnValue(IsValidHolidayScheduleIndex(holidayIndex), DlStatus::kFailure); + + auto & scheduleInStorage = mHolidaySchedule[holidayIndex]; + + schedule = scheduleInStorage; + + return DlStatus::kSuccess; +} + +DlStatus LockManager::SetHolidaySchedule(chip::EndpointId endpointId, uint8_t holidayIndex, DlScheduleStatus status, + uint32_t localStartTime, uint32_t localEndTime, DlOperatingMode operatingMode) +{ + VerifyOrReturnValue(holidayIndex > 0, DlStatus::kFailure); // indices are one-indexed + + holidayIndex--; + + VerifyOrReturnValue(IsValidHolidayScheduleIndex(holidayIndex), DlStatus::kFailure); + + auto & scheduleInStorage = mHolidaySchedule[holidayIndex]; + + scheduleInStorage.localStartTime = localStartTime; + scheduleInStorage.localEndTime = localEndTime; + scheduleInStorage.operatingMode = operatingMode; + + // Save schedule information in NVM flash + CYW30739Config::WriteConfigValueBin(CYW30739Config::kConfigKey_HolidaySchedules, + reinterpret_cast(&(mHolidaySchedule)), + sizeof(EmberAfPluginDoorLockHolidaySchedule) * LockParams.numberOfHolidaySchedules); + + return DlStatus::kSuccess; +} + const char * LockManager::lockStateToString(DlLockState lockState) const { switch (lockState) @@ -378,30 +635,52 @@ bool LockManager::setLockState(chip::EndpointId endpointId, DlLockState lockStat if (mState == kState_UnlockCompleted) curState = DlLockState::kUnlocked; - if (curState == lockState) + if ((curState == lockState) && (curState == DlLockState::kLocked)) { - ChipLogDetail(Zcl, "Door Lock App: door is already locked, set lock state to \"%s\" [endpointId=%d]", - lockStateToString(lockState), mEndpointId); + ChipLogDetail(Zcl, "Door Lock App: door is already locked, ignoring command to set lock state to \"%s\" [endpointId=%d]", + lockStateToString(lockState), endpointId); + return true; + } + else if ((curState == lockState) && (curState == DlLockState::kUnlocked)) + { + ChipLogDetail(Zcl, + "Door Lock App: door is already unlocked, ignoring command to set unlock state to \"%s\" [endpointId=%d]", + lockStateToString(lockState), endpointId); + return true; } + // Assume pin is required until told otherwise + bool requirePin = true; + chip::app::Clusters::DoorLock::Attributes::RequirePINforRemoteOperation::Get(endpointId, &requirePin); + + // If a pin code is not given if (!pin.HasValue()) { - ChipLogDetail(Zcl, "Door Lock App: PIN code is not specified, setting door lock state to \"%s\" [endpointId=%d]", - lockStateToString(lockState), mEndpointId); + ChipLogDetail(Zcl, "Door Lock App: PIN code is not specified, but it is required [endpointId=%d]", mEndpointId); curState = lockState; - return true; + // If a pin code is not required + if (!requirePin) + { + ChipLogDetail(Zcl, "Door Lock App: setting door lock state to \"%s\" [endpointId=%d]", lockStateToString(lockState), + endpointId); + curState = lockState; + return true; + } + + return false; } // Check the PIN code - for (uint8_t i; i < 10; i++) + for (uint8_t i = 0; i < kMaxCredentials; i++) { - if (mLockCredentials.credentialType != DlCredentialType::kPin || mLockCredentials.status == DlCredentialStatus::kAvailable) + if (mLockCredentials[i].credentialType != DlCredentialType::kPin || + mLockCredentials[i].status == DlCredentialStatus::kAvailable) { continue; } - if (mLockCredentials.credentialData.data_equal(pin.Value())) + if (mLockCredentials[i].credentialData.data_equal(pin.Value())) { ChipLogDetail(Zcl, "Lock App: specified PIN code was found in the database, setting lock state to \"%s\" [endpointId=%d]", diff --git a/examples/lock-app/cyw30739/src/ZclCallbacks.cpp b/examples/lock-app/cyw30739/src/ZclCallbacks.cpp index ecbc2f78804b24..2b06dd4e1f3d1f 100644 --- a/examples/lock-app/cyw30739/src/ZclCallbacks.cpp +++ b/examples/lock-app/cyw30739/src/ZclCallbacks.cpp @@ -94,15 +94,17 @@ bool emberAfPluginDoorLockGetCredential(chip::EndpointId endpointId, uint16_t cr return LockMgr().GetCredential(endpointId, credentialIndex, credentialType, credential); } -bool emberAfPluginDoorLockSetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, DlCredentialStatus credentialStatus, +bool emberAfPluginDoorLockSetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, chip::FabricIndex creator, + chip::FabricIndex modifier, DlCredentialStatus credentialStatus, DlCredentialType credentialType, const chip::ByteSpan & credentialData) { - return LockMgr().SetCredential(endpointId, credentialIndex, credentialStatus, credentialType, credentialData); + return LockMgr().SetCredential(endpointId, credentialIndex, creator, modifier, credentialStatus, credentialType, + credentialData); } bool emberAfPluginDoorLockGetUser(chip::EndpointId endpointId, uint16_t userIndex, EmberAfPluginDoorLockUserInfo & user) { - return LockMgr().GetUser(userIndex, user); + return LockMgr().GetUser(endpointId, userIndex, user); } bool emberAfPluginDoorLockSetUser(chip::EndpointId endpointId, uint16_t userIndex, chip::FabricIndex creator, @@ -111,8 +113,8 @@ bool emberAfPluginDoorLockSetUser(chip::EndpointId endpointId, uint16_t userInde const DlCredential * credentials, size_t totalCredentials) { - return LockMgr().SetUser(userIndex, creator, modifier, userName, uniqueId, userStatus, usertype, credentialRule, credentials, - totalCredentials); + return LockMgr().SetUser(endpointId, userIndex, creator, modifier, userName, uniqueId, userStatus, usertype, credentialRule, + credentials, totalCredentials); } // TODO: These functions will be supported by door-lock-server in the future. These are set to return failure until implemented. diff --git a/examples/lock-app/cyw30739/src/main.cpp b/examples/lock-app/cyw30739/src/main.cpp index c214e63796e07e..4a32f49cfa2a9f 100644 --- a/examples/lock-app/cyw30739/src/main.cpp +++ b/examples/lock-app/cyw30739/src/main.cpp @@ -52,6 +52,7 @@ using namespace ::chip::DeviceLayer::Internal; using namespace ::chip::Credentials; using namespace ::chip::DeviceLayer; using namespace ::chip::Shell; +using namespace CYW30739DoorLock::LockInitParams; wiced_bool_t syncClusterToButtonAction = false; @@ -62,6 +63,7 @@ static void HandleThreadStateChangeEvent(const ChipDeviceEvent * event); static void ActionInitiated(LockManager::Action_t aAction, int32_t aActor); static void ActionCompleted(LockManager::Action_t aAction); static void WriteClusterState(uint8_t value); +static void UpdateClusterState(intptr_t context); #ifndef _countof #define _countof(a) (sizeof(a) / sizeof(a[0])) @@ -84,20 +86,20 @@ APPLICATION_START() wiced_result_t result; uint32_t i; - printf("\nChipLock App starting\n"); + ChipLogProgress(Zcl, "ChipLock App starting"); mbedtls_platform_set_calloc_free(CHIPPlatformMemoryCalloc, CHIPPlatformMemoryFree); err = chip::Platform::MemoryInit(); if (err != CHIP_NO_ERROR) { - printf("ERROR MemoryInit %ld\n", err.AsInteger()); + ChipLogError(Zcl, "ERROR MemoryInit %ld", err.AsInteger()); } result = app_button_init(); if (result != WICED_SUCCESS) { - printf("ERROR app_button_init %d\n", result); + ChipLogError(Zcl, "ERROR app_button_init %d", result); } /* Init. LED Manager. */ @@ -105,44 +107,44 @@ APPLICATION_START() { result = wiced_led_manager_init(&chip_lighting_led_config[i]); if (result != WICED_SUCCESS) - printf("wiced_led_manager_init fail i=%ld, (%d)\n", i, result); + ChipLogError(Zcl, "wiced_led_manager_init fail i=%ld, (%d)", i, result); } - printf("Initializing CHIP\n"); + ChipLogProgress(Zcl, "Initializing CHIP"); err = PlatformMgr().InitChipStack(); if (err != CHIP_NO_ERROR) { - printf("ERROR InitChipStack %ld\n", err.AsInteger()); + ChipLogError(Zcl, "ERROR InitChipStack %ld", err.AsInteger()); } #if CHIP_DEVICE_CONFIG_ENABLE_THREAD - printf("Initializing OpenThread stack\n"); + ChipLogProgress(Zcl, "Initializing OpenThread stack"); err = ThreadStackMgr().InitThreadStack(); if (err != CHIP_NO_ERROR) { - printf("ERROR InitThreadStack %ld\n", err.AsInteger()); + ChipLogError(Zcl, "ERROR InitThreadStack %ld", err.AsInteger()); } #endif err = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router); if (err != CHIP_NO_ERROR) { - printf("ERROR SetThreadDeviceType %ld\n", err.AsInteger()); + ChipLogError(Zcl, "ERROR SetThreadDeviceType %ld", err.AsInteger()); } - printf("Starting event loop task\n"); + ChipLogProgress(Zcl, "Starting event loop task"); err = PlatformMgr().StartEventLoopTask(); if (err != CHIP_NO_ERROR) { - printf("ERROR StartEventLoopTask %ld\n", err.AsInteger()); + ChipLogError(Zcl, "ERROR StartEventLoopTask %ld", err.AsInteger()); } #if CHIP_DEVICE_CONFIG_ENABLE_THREAD - printf("Starting thread task\n"); + ChipLogProgress(Zcl, "Starting thread task"); err = ThreadStackMgr().StartThreadTask(); if (err != CHIP_NO_ERROR) { - printf("ERROR StartThreadTask %ld\n", err.AsInteger()); + ChipLogError(Zcl, "ERROR StartThreadTask %ld", err.AsInteger()); } #endif @@ -151,7 +153,7 @@ APPLICATION_START() const int ret = Engine::Root().Init(); if (!chip::ChipError::IsSuccess(ret)) { - printf("ERROR Shell Init %d\n", ret); + ChipLogError(Zcl, "ERROR Shell Init %d", ret); } RegisterAppShellCommands(); Engine::Root().RunMainLoop(); @@ -161,8 +163,7 @@ APPLICATION_START() void InitApp(intptr_t args) { - ConfigurationMgr().LogDeviceConfig(); - + CHIP_ERROR err = CHIP_NO_ERROR; PlatformMgrImpl().AddEventHandler(EventHandler, 0); /* Start CHIP datamodel server */ @@ -185,25 +186,72 @@ void InitApp(intptr_t args) chip::DeviceLayer::PlatformMgr().LockChipStack(); chip::app::Clusters::DoorLock::Attributes::LockState::Get(endpointId, state); - uint8_t maxCredentialsPerUser = 0; - if (!DoorLockServer::Instance().GetNumberOfCredentialsSupportedPerUser(endpointId, maxCredentialsPerUser)) + uint8_t numberOfCredentialsPerUser = 0; + if (!DoorLockServer::Instance().GetNumberOfCredentialsSupportedPerUser(endpointId, numberOfCredentialsPerUser)) { ChipLogError(Zcl, "Unable to get number of credentials supported per user when initializing lock endpoint, defaulting to 5 " "[endpointId=%d]", endpointId); - maxCredentialsPerUser = 5; + numberOfCredentialsPerUser = 5; } - chip::DeviceLayer::PlatformMgr().UnlockChipStack(); - CHIP_ERROR err = LockMgr().Init(state, maxCredentialsPerUser); - if (err != CHIP_NO_ERROR) + uint16_t numberOfUsers = 0; + if (!DoorLockServer::Instance().GetNumberOfUserSupported(endpointId, numberOfUsers)) { - printf("LockMgr().Init() failed\n"); + ChipLogError(Zcl, + "Unable to get number of supported users when initializing lock endpoint, defaulting to 10 [endpointId=%d]", + endpointId); + numberOfUsers = 10; } + uint8_t numberOfWeekdaySchedulesPerUser = 0; + if (!DoorLockServer::Instance().GetNumberOfWeekDaySchedulesPerUserSupported(endpointId, numberOfWeekdaySchedulesPerUser)) + { + ChipLogError( + Zcl, + "Unable to get number of supported weekday schedules when initializing lock endpoint, defaulting to 10 [endpointId=%d]", + endpointId); + numberOfWeekdaySchedulesPerUser = 10; + } + + uint8_t numberOfYeardaySchedulesPerUser = 0; + if (!DoorLockServer::Instance().GetNumberOfYearDaySchedulesPerUserSupported(endpointId, numberOfYeardaySchedulesPerUser)) + { + ChipLogError( + Zcl, + "Unable to get number of supported yearday schedules when initializing lock endpoint, defaulting to 10 [endpointId=%d]", + endpointId); + numberOfYeardaySchedulesPerUser = 10; + } + + uint8_t numberOfHolidaySchedules = 0; + if (!DoorLockServer::Instance().GetNumberOfHolidaySchedulesSupported(endpointId, numberOfHolidaySchedules)) + { + ChipLogError( + Zcl, + "Unable to get number of supported holiday schedules when initializing lock endpoint, defaulting to 10 [endpointId=%d]", + endpointId); + numberOfHolidaySchedules = 10; + } + + chip::DeviceLayer::PlatformMgr().UnlockChipStack(); + + err = LockMgr().Init(state, + ParamBuilder() + .SetNumberOfUsers(numberOfUsers) + .SetNumberOfCredentialsPerUser(numberOfCredentialsPerUser) + .SetNumberOfWeekdaySchedulesPerUser(numberOfWeekdaySchedulesPerUser) + .SetNumberOfYeardaySchedulesPerUser(numberOfYeardaySchedulesPerUser) + .SetNumberOfHolidaySchedules(numberOfHolidaySchedules) + .GetLockParam()); + LockMgr().SetCallbacks(ActionInitiated, ActionCompleted); + chip::DeviceLayer::PlatformMgr().ScheduleWork(UpdateClusterState, reinterpret_cast(nullptr)); + + ConfigurationMgr().LogDeviceConfig(); + #if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR OTAConfig::Init(); #endif @@ -229,11 +277,11 @@ void ActionInitiated(LockManager::Action_t aAction, int32_t aActor) // and start flashing the LEDs rapidly to indicate action initiation. if (aAction == LockManager::LOCK_ACTION) { - printf("Lock Action has been initiated\n"); + ChipLogDetail(Zcl, "Lock Action has been initiated"); } else if (aAction == LockManager::UNLOCK_ACTION) { - printf("Unlock Action has been initiated\n"); + ChipLogDetail(Zcl, "Unlock Action has been initiated"); } if (aActor == LockManager::ACTOR_BUTTON) @@ -244,12 +292,12 @@ void ActionInitiated(LockManager::Action_t aAction, int32_t aActor) // Action initiated, update the light led if (aAction == LockManager::LOCK_ACTION) { - printf("Lock Action has been initiated"); + ChipLogDetail(Zcl, "Lock Action has been initiated"); wiced_led_manager_disable_led(PLATFORM_LED_2); } else if (aAction == LockManager::UNLOCK_ACTION) { - printf("Unlock Action has been initiated"); + ChipLogDetail(Zcl, "Unlock Action has been initiated"); wiced_led_manager_enable_led(PLATFORM_LED_2); } } @@ -267,7 +315,7 @@ void UpdateClusterState(intptr_t context) if (status != EMBER_ZCL_STATUS_SUCCESS) { - printf("ERR: updating lock state %x", status); + ChipLogError(Zcl, "ERR: updating lock state %x", status); } } @@ -278,11 +326,11 @@ void ActionCompleted(LockManager::Action_t aAction) // Turn off the lock LED if in an UNLOCKED state. if (aAction == LockManager::LOCK_ACTION) { - printf("Lock Action has been completed\n"); + ChipLogDetail(Zcl, "Lock Action has been completed"); } else if (aAction == LockManager::UNLOCK_ACTION) { - printf("Unlock Action has been completed\n"); + ChipLogDetail(Zcl, "Unlock Action has been completed"); } if (syncClusterToButtonAction) diff --git a/examples/lock-app/efr32/BUILD.gn b/examples/lock-app/efr32/BUILD.gn index 679ed1f46cda3d..4add2a9528504b 100644 --- a/examples/lock-app/efr32/BUILD.gn +++ b/examples/lock-app/efr32/BUILD.gn @@ -328,6 +328,11 @@ efr32_executable("lock_app") { ] } + # Attestation Credentials + if (chip_build_platform_attestation_credentials_provider) { + deps += [ "${examples_plat_dir}:efr32-attestation-credentials" ] + } + output_dir = root_out_dir } group("efr32") { diff --git a/examples/lock-app/efr32/src/AppTask.cpp b/examples/lock-app/efr32/src/AppTask.cpp index ddb8a463c6054a..ac3914476a3f1e 100644 --- a/examples/lock-app/efr32/src/AppTask.cpp +++ b/examples/lock-app/efr32/src/AppTask.cpp @@ -43,9 +43,6 @@ #include -#include -#include - #include #include @@ -173,7 +170,6 @@ Identify gIdentify = { } // namespace using namespace chip::TLV; -using namespace ::chip::Credentials; using namespace ::chip::DeviceLayer; AppTask AppTask::sAppTask; @@ -211,11 +207,6 @@ CHIP_ERROR AppTask::Init() sWiFiNetworkCommissioningInstance.Init(); #endif - chip::DeviceLayer::PlatformMgr().LockChipStack(); - // Initialize device attestation config - SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); - chip::DeviceLayer::PlatformMgr().UnlockChipStack(); - // Create FreeRTOS sw timer for Function Selection. sFunctionTimer = xTimerCreate("FnTmr", // Just a text name, not used by the RTOS kernel 1, // == default timer period (mS) diff --git a/examples/lock-app/efr32/src/main.cpp b/examples/lock-app/efr32/src/main.cpp index cbc0c3643f07ff..a8ba160e7e2915 100644 --- a/examples/lock-app/efr32/src/main.cpp +++ b/examples/lock-app/efr32/src/main.cpp @@ -25,12 +25,19 @@ #include "sl_system_kernel.h" #include #include +#include #include +#ifdef EFR32_ATTESTATION_CREDENTIALS +#include +#else +#include +#endif #define BLE_DEV_NAME "SiLabs-Door-Lock" using namespace ::chip; using namespace ::chip::Inet; using namespace ::chip::DeviceLayer; +using namespace ::chip::Credentials; #define UNUSED_PARAMETER(a) (a = a) @@ -49,6 +56,15 @@ int main(void) gExampleDeviceInfoProvider.SetStorageDelegate(&Server::GetInstance().GetPersistentStorage()); chip::DeviceLayer::SetDeviceInfoProvider(&gExampleDeviceInfoProvider); + chip::DeviceLayer::PlatformMgr().LockChipStack(); + // Initialize device attestation config +#ifdef EFR32_ATTESTATION_CREDENTIALS + SetDeviceAttestationCredentialsProvider(EFR32::GetEFR32DacProvider()); +#else + SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); +#endif + chip::DeviceLayer::PlatformMgr().UnlockChipStack(); + EFR32_LOG("Starting App Task"); if (GetAppTask().StartAppTask() != CHIP_NO_ERROR) appError(CHIP_ERROR_INTERNAL); diff --git a/examples/lock-app/qpg/include/CHIPProjectConfig.h b/examples/lock-app/qpg/include/CHIPProjectConfig.h index 9072c450895ead..5938654612351c 100755 --- a/examples/lock-app/qpg/include/CHIPProjectConfig.h +++ b/examples/lock-app/qpg/include/CHIPProjectConfig.h @@ -106,13 +106,6 @@ */ #define CHIP_DEVICE_CONFIG_EVENT_LOGGING_DEBUG_BUFFER_SIZE (512) -/** - * CHIP_DEVICE_CONFIG_THREAD_ENABLE_CLI - * - * Enable Thread CLI interface at initialisation. - */ -#define CHIP_DEVICE_CONFIG_THREAD_ENABLE_CLI 1 - /** * @def CHIP_CONFIG_MAX_FABRICS * diff --git a/examples/lock-app/qpg/src/ZclCallbacks.cpp b/examples/lock-app/qpg/src/ZclCallbacks.cpp index ef68ea5b933c39..47163c0ab204a6 100644 --- a/examples/lock-app/qpg/src/ZclCallbacks.cpp +++ b/examples/lock-app/qpg/src/ZclCallbacks.cpp @@ -28,13 +28,21 @@ using namespace ::chip; using namespace ::chip::app::Clusters; -void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size, - uint8_t * value) +void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & path, uint8_t type, uint16_t size, uint8_t * value) { - if (attributePath.mClusterId == OnOff::Id && attributePath.mAttributeId == OnOff::Attributes::OnOff::Id) + if (path.mClusterId != OnOff::Id) { - BoltLockMgr().InitiateAction(0, *value ? BoltLockManager::LOCK_ACTION : BoltLockManager::UNLOCK_ACTION); + ChipLogProgress(Zcl, "Unknown cluster ID: " ChipLogFormatMEI, ChipLogValueMEI(path.mClusterId)); + return; } + + if (path.mAttributeId != OnOff::Attributes::OnOff::Id) + { + ChipLogProgress(Zcl, "Unknown attribute ID: " ChipLogFormatMEI, ChipLogValueMEI(path.mAttributeId)); + return; + } + + BoltLockMgr().InitiateAction(0, *value ? BoltLockManager::LOCK_ACTION : BoltLockManager::UNLOCK_ACTION); } /** @brief OnOff Cluster Init diff --git a/examples/ota-requestor-app/ameba/main/DeviceCallbacks.cpp b/examples/ota-requestor-app/ameba/main/DeviceCallbacks.cpp index 2db5f21cee2c85..259ff3d726f529 100644 --- a/examples/ota-requestor-app/ameba/main/DeviceCallbacks.cpp +++ b/examples/ota-requestor-app/ameba/main/DeviceCallbacks.cpp @@ -71,9 +71,6 @@ void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_ OnInternetConnectivityChange(event); break; - case DeviceEventType::kSessionEstablished: - OnSessionEstablished(event); - break; case DeviceEventType::kInterfaceIpAddressChanged: if ((event->InterfaceIpAddressChanged.Type == InterfaceIpChangeType::kIpV4_Assigned) || (event->InterfaceIpAddressChanged.Type == InterfaceIpChangeType::kIpV6_Assigned)) @@ -140,14 +137,6 @@ void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event } } -void DeviceCallbacks::OnSessionEstablished(const ChipDeviceEvent * event) -{ - if (event->SessionEstablished.IsCommissioner) - { - ChipLogProgress(DeviceLayer, "Commissioner detected!"); - } -} - void DeviceCallbacks::OnOnOffPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { VerifyOrExit(attributeId == ZCL_ON_OFF_ATTRIBUTE_ID, diff --git a/examples/ota-requestor-app/ameba/main/include/DeviceCallbacks.h b/examples/ota-requestor-app/ameba/main/include/DeviceCallbacks.h index 003b6e700db0eb..18ebb25ed75f36 100644 --- a/examples/ota-requestor-app/ameba/main/include/DeviceCallbacks.h +++ b/examples/ota-requestor-app/ameba/main/include/DeviceCallbacks.h @@ -39,7 +39,6 @@ class DeviceCallbacks : public chip::DeviceManager::CHIPDeviceManagerCallbacks private: void OnInternetConnectivityChange(const chip::DeviceLayer::ChipDeviceEvent * event); - void OnSessionEstablished(const chip::DeviceLayer::ChipDeviceEvent * event); void OnOnOffPostAttributeChangeCallback(chip::EndpointId endpointId, chip::AttributeId attributeId, uint8_t * value); void OnIdentifyPostAttributeChangeCallback(chip::EndpointId endpointId, chip::AttributeId attributeId, uint8_t * value); }; diff --git a/examples/persistent-storage/qpg/main.cpp b/examples/persistent-storage/qpg/main.cpp index b53692e19e448b..cae4e0eab862c0 100644 --- a/examples/persistent-storage/qpg/main.cpp +++ b/examples/persistent-storage/qpg/main.cpp @@ -47,25 +47,29 @@ void TestTask(void * pvParameter) } } +void Application_Init(void) +{ + /* Launch application task */ + qvCHIP_Printf(LOG_MODULE_ID, "============================"); + qvCHIP_Printf(LOG_MODULE_ID, "Qorvo " APP_NAME " Launching"); + qvCHIP_Printf(LOG_MODULE_ID, "============================"); + + // Run tests + xTaskCreateStatic(TestTask, APP_NAME, 2048, NULL, 1, appStack, &appTaskStruct); +} + int main(void) { int result; /* Initialize Qorvo stack */ - result = qvCHIP_init(); + result = qvCHIP_init(Application_Init); if (result < 0) { goto exit; } - /* Launch application task */ - qvCHIP_Printf(LOG_MODULE_ID, "============================"); - qvCHIP_Printf(LOG_MODULE_ID, "Qorvo " APP_NAME " Launching"); - qvCHIP_Printf(LOG_MODULE_ID, "============================"); - - // Run tests - xTaskCreateStatic(TestTask, APP_NAME, 2048, NULL, 1, appStack, &appTaskStruct); qvCHIP_Printf(LOG_MODULE_ID, "Starting FreeRTOS scheduler"); vTaskStartScheduler(); diff --git a/examples/platform/bouffalolab/bl602/InitPlatform.cpp b/examples/platform/bouffalolab/bl602/InitPlatform.cpp index 1df65555ed1dfe..674c200b3be176 100644 --- a/examples/platform/bouffalolab/bl602/InitPlatform.cpp +++ b/examples/platform/bouffalolab/bl602/InitPlatform.cpp @@ -44,8 +44,83 @@ extern "C" { #include #include #include +#include #include +#define IOT_DVK_3S 1 + +#if BOARD_ID == IOT_DVK_3S +hosal_pwm_dev_t pwmR = { .port = 0xff }; +#else +hosal_pwm_dev_t pwmR, pwmG, pwmB; +#endif + +static void (*Button_FactoryResetEventHandler)(void) = nullptr; +static void (*Button_LightingActionEventHandler)(void) = nullptr; +void Button_Configure_FactoryResetEventHandler(void (*callback)(void)) +{ + Button_FactoryResetEventHandler = callback; +} + +void Button_Configure_LightingActionEventHandler(void (*callback)(void)) +{ + Button_LightingActionEventHandler = callback; +} + +static void Platform_Light_Init(void) +{ +#if BOARD_ID == IOT_DVK_3S + if (pwmR.port == 0xff) + { + pwmR.port = 0; + pwmR.config.pin = 0; + pwmR.config.duty_cycle = 0; // duty_cycle range is 0~10000 correspond to 0~100% + pwmR.config.freq = 1000; + hosal_pwm_init(&pwmR); + vTaskDelay(50); + hosal_pwm_start(&pwmR); + } +#else + pwmR.port = 0; + pwmR.config.pin = 20; + pwmR.config.duty_cycle = 0; // duty_cycle range is 0~10000 correspond to 0~100% + pwmR.config.freq = 1000; + hosal_pwm_init(&pwmR); + + pwmG.port = 1; + pwmG.config.pin = 21; + pwmG.config.duty_cycle = 0; // duty_cycle range is 0~10000 correspond to 0~100% + pwmG.config.freq = 1000; + hosal_pwm_init(&pwmG); + + pwmB.port = 2; + pwmB.config.pin = 17; + pwmB.config.duty_cycle = 0; // duty_cycle range is 0~10000 correspond to 0~100% + pwmB.config.freq = 1000; + hosal_pwm_init(&pwmB); + + vTaskDelay(50); + hosal_pwm_start(&pwmR); + hosal_pwm_start(&pwmG); + hosal_pwm_start(&pwmB); +#endif +} + +void BL602_LightState_Update(uint8_t red, uint8_t green, uint8_t blue) +{ +#if BOARD_ID == IOT_DVK_3S + uint32_t level = (red * 10000) / UINT8_MAX; + log_info("red level: %d\r\n", level); + hosal_pwm_duty_set(&pwmR, level); +#else + uint32_t r_level = (red * 10000) / UINT8_MAX; + uint32_t g_level = (green * 10000) / UINT8_MAX; + uint32_t b_level = (blue * 10000) / UINT8_MAX; + hosal_pwm_duty_set(&pwmR, r_level); + hosal_pwm_duty_set(&pwmG, g_level); + hosal_pwm_duty_set(&pwmB, b_level); +#endif +} void user_vAssertCalled(void) __attribute__((weak, alias("vAssertCalled"))); void vAssertCalled(void) { @@ -174,10 +249,10 @@ static void event_cb_key_event(input_event_t * event, void * private_data) log_info("[KEY_1] [EVT] INIT DONE %lld\r\n", aos_now_ms()); log_info("short press \r\n"); - log_info("factory reset. erasing easyflash...\r\n"); - ef_port_erase_all(); - log_info("factory reset. rebooting...\r\n"); - hal_reboot(); + if (Button_LightingActionEventHandler != nullptr) + { + (*Button_LightingActionEventHandler)(); + } } break; case KEY_2: { @@ -188,7 +263,10 @@ static void event_cb_key_event(input_event_t * event, void * private_data) case KEY_3: { log_info("[KEY_3] [EVT] INIT DONE %lld\r\n", aos_now_ms()); log_info("longlong press \r\n"); - // xTaskCreate(task_factory_reset, "factory-reset", 256, NULL, 10, NULL); + if (Button_FactoryResetEventHandler != nullptr) + { + (*Button_FactoryResetEventHandler)(); + } } break; default: { @@ -210,7 +288,7 @@ void InitPlatform(void) hal_gpio_init_from_dts(fdt, offset); fdt_button_module_init((const void *) fdt, (int) offset); } - + Platform_Light_Init(); aos_register_event_filter(EV_KEY, event_cb_key_event, NULL); } diff --git a/examples/platform/bouffalolab/bl602/InitPlatform.h b/examples/platform/bouffalolab/bl602/InitPlatform.h index c8300268216c5c..85d7d09f719dc5 100644 --- a/examples/platform/bouffalolab/bl602/InitPlatform.h +++ b/examples/platform/bouffalolab/bl602/InitPlatform.h @@ -27,6 +27,9 @@ extern "C" { #include void InitPlatform(void); +void Button_Configure_FactoryResetEventHandler(void (*callback)(void)); +void Button_Configure_LightingActionEventHandler(void (*callback)(void)); +void BL602_LightState_Update(uint8_t red, uint8_t green, uint8_t blue); #ifdef __cplusplus } diff --git a/examples/platform/bouffalolab/bl602/PigweedLogger.cpp b/examples/platform/bouffalolab/bl602/PigweedLogger.cpp index 5ab24767a47ab2..608e2ece55a27e 100644 --- a/examples/platform/bouffalolab/bl602/PigweedLogger.cpp +++ b/examples/platform/bouffalolab/bl602/PigweedLogger.cpp @@ -29,7 +29,7 @@ #include "semphr.h" #include #include -#include +#include #include "pw_span/span.h" #include diff --git a/examples/platform/bouffalolab/bl602/Rpc.cpp b/examples/platform/bouffalolab/bl602/Rpc.cpp new file mode 100644 index 00000000000000..0ff69e920b5ac1 --- /dev/null +++ b/examples/platform/bouffalolab/bl602/Rpc.cpp @@ -0,0 +1,229 @@ +/* + * + * 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 "AppTask.h" +#include "FreeRTOS.h" +#include "PigweedLoggerMutex.h" +#include "pigweed/RpcService.h" +#include "pw_sys_io_bl602/init.h" +#include "task.h" +extern "C" { +#include "bl_sys.h" +} +#if defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE +#include "pigweed/rpc_services/Attributes.h" +#endif // defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE + +#if defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE +#include "pigweed/rpc_services/Button.h" +#endif // defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE + +#if defined(PW_RPC_DESCRIPTOR_SERVICE) && PW_RPC_DESCRIPTOR_SERVICE +#include "pigweed/rpc_services/Descriptor.h" +#endif // defined(PW_RPC_DESCRIPTOR_SERVICE) && PW_RPC_DESCRIPTOR_SERVICE + +#if defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE +#include "pigweed/rpc_services/Device.h" +#endif // defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE + +#if defined(PW_RPC_LIGHTING_SERVICE) && PW_RPC_LIGHTING_SERVICE +#include "pigweed/rpc_services/Lighting.h" +#endif // defined(PW_RPC_LIGHTING_SERVICE) && PW_RPC_LIGHTING_SERVICE + +#if defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE +#include "pigweed/rpc_services/Locking.h" +#endif // defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE + +#if defined(PW_RPC_OTCLI_SERVICE) && PW_RPC_OTCLI_SERVICE +#include "pigweed/rpc_services/OtCli.h" +#endif // defined(PW_RPC_OTCLI_SERVICE) && PW_RPC_OTCLI_SERVICE + +#if defined(PW_RPC_THREAD_SERVICE) && PW_RPC_THREAD_SERVICE +#include "pigweed/rpc_services/Thread.h" +#endif // defined(PW_RPC_THREAD_SERVICE) && PW_RPC_THREAD_SERVICE + +#if defined(PW_RPC_TRACING_SERVICE) && PW_RPC_TRACING_SERVICE +#define PW_TRACE_BUFFER_SIZE_BYTES 1024 +#include "pw_trace/trace.h" +#include "pw_trace_tokenized/trace_rpc_service_nanopb.h" + +// Define trace time for pw_trace +PW_TRACE_TIME_TYPE pw_trace_GetTraceTime() +{ + return (PW_TRACE_TIME_TYPE) chip::System::SystemClock().GetMonotonicMicroseconds64().count(); +} +// Microsecond time source +size_t pw_trace_GetTraceTimeTicksPerSecond() +{ + return 1000000; +} + +#endif // defined(PW_RPC_TRACING_SERVICE) && PW_RPC_TRACING_SERVICE + +namespace chip { +namespace rpc { + +#if defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE +class BL602Button final : public Button +{ +public: + pw::Status Event(const chip_rpc_ButtonEvent & request, pw_protobuf_Empty & response) override + { + GetAppTask().ButtonEventHandler(request.idx, request.pushed); + return pw::OkStatus(); + } +}; +#endif // defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE + +#if defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE +class BL602Device final : public Device +{ +public: + pw::Status Reboot(const pw_protobuf_Empty & request, pw_protobuf_Empty & response) override + { + if (!mRebootTimer) + { + mRebootTimer = + xTimerCreateStatic("Reboot", kRebootTimerPeriodTicks, false, nullptr, RebootHandler, &mRebootTimerBuffer); + xTimerStart(mRebootTimer, 0); + } + return pw::OkStatus(); + } + + pw::Status FactoryReset(const pw_protobuf_Empty & request, pw_protobuf_Empty & response) override + { + if (!mRebootTimer) + { + mRebootTimer = xTimerCreateStatic("FactoryReset", kRebootTimerPeriodTicks, false, nullptr, FactoryResetHandler, + &mRebootTimerBuffer); + xTimerStart(mRebootTimer, 0); + } + return pw::OkStatus(); + } + +private: + static constexpr TickType_t kRebootTimerPeriodTicks = 1000; + TimerHandle_t mRebootTimer; + StaticTimer_t mRebootTimerBuffer; + + static void RebootHandler(TimerHandle_t) { bl_sys_reset_system(); } + + static void FactoryResetHandler(TimerHandle_t) { DeviceLayer::ConfigurationMgr().InitiateFactoryReset(); } +}; +#endif // defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE + +namespace { + +#define RPC_TASK_STACK_SIZE 1536 +#define RPC_TASK_PRIORITY 1 +static TaskHandle_t sRpcTaskHandle; +StaticTask_t sRpcTaskBuffer; +StackType_t sRpcTaskStack[RPC_TASK_STACK_SIZE]; + +#if defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE +Attributes attributes_service; +#endif // defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE + +#if defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE +BL602Button button_service; +#endif // defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE + +#if defined(PW_RPC_DESCRIPTOR_SERVICE) && PW_RPC_DESCRIPTOR_SERVICE +Descriptor descriptor_service; +#endif // defined(PW_RPC_DESCRIPTOR_SERVICE) && PW_RPC_DESCRIPTOR_SERVICE + +#if defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE +BL602Device device_service; +#endif // defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE + +#if defined(PW_RPC_LIGHTING_SERVICE) && PW_RPC_LIGHTING_SERVICE +Lighting lighting_service; +#endif // defined(PW_RPC_LIGHTING_SERVICE) && PW_RPC_LIGHTING_SERVICE + +#if defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE +Locking locking; +#endif // defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE + +#if defined(PW_RPC_OTCLI_SERVICE) && PW_RPC_OTCLI_SERVICE +OtCli ot_cli_service; +#endif // defined(PW_RPC_OTCLI_SERVICE) && PW_RPC_OTCLI_SERVICE + +#if defined(PW_RPC_THREAD_SERVICE) && PW_RPC_THREAD_SERVICE +Thread thread; +#endif // defined(PW_RPC_THREAD_SERVICE) && PW_RPC_THREAD_SERVICE + +#if defined(PW_RPC_TRACING_SERVICE) && PW_RPC_TRACING_SERVICE +pw::trace::TraceService trace_service; +#endif // defined(PW_RPC_TRACING_SERVICE) && PW_RPC_TRACING_SERVICE + +void RegisterServices(pw::rpc::Server & server) +{ +#if defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE + server.RegisterService(attributes_service); +#endif // defined(PW_RPC_ATTRIBUTE_SERVICE) && PW_RPC_ATTRIBUTE_SERVICE + +#if defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE + server.RegisterService(button_service); +#endif // defined(PW_RPC_BUTTON_SERVICE) && PW_RPC_BUTTON_SERVICE + +#if defined(PW_RPC_DESCRIPTOR_SERVICE) && PW_RPC_DESCRIPTOR_SERVICE + server.RegisterService(descriptor_service); +#endif // defined(PW_RPC_DESCRIPTOR_SERVICE) && PW_RPC_DESCRIPTOR_SERVICE + +#if defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE + server.RegisterService(device_service); +#endif // defined(PW_RPC_DEVICE_SERVICE) && PW_RPC_DEVICE_SERVICE + +#if defined(PW_RPC_LIGHTING_SERVICE) && PW_RPC_LIGHTING_SERVICE + server.RegisterService(lighting_service); +#endif // defined(PW_RPC_LIGHTING_SERVICE) && PW_RPC_LIGHTING_SERVICE + +#if defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE + server.RegisterService(locking); +#endif // defined(PW_RPC_LOCKING_SERVICE) && PW_RPC_LOCKING_SERVICE + +#if defined(PW_RPC_OTCLI_SERVICE) && PW_RPC_OTCLI_SERVICE + server.RegisterService(ot_cli_service); +#endif // defined(PW_RPC_OTCLI_SERVICE) && PW_RPC_OTCLI_SERVICE + +#if defined(PW_RPC_THREAD_SERVICE) && PW_RPC_THREAD_SERVICE + server.RegisterService(thread); +#endif // defined(PW_RPC_THREAD_SERVICE) && PW_RPC_THREAD_SERVICE + +#if defined(PW_RPC_TRACING_SERVICE) && PW_RPC_TRACING_SERVICE + server.RegisterService(trace_service); + PW_TRACE_SET_ENABLED(true); +#endif // defined(PW_RPC_TRACING_SERVICE) && PW_RPC_TRACING_SERVICE +} + +} // namespace + +void RunRpcService(void *) +{ + Start(RegisterServices, &logger_mutex); +} + +void Init() +{ + // Start App task. + sRpcTaskHandle = xTaskCreateStatic(RunRpcService, "RPC_TASK", ArraySize(sRpcTaskStack), nullptr, RPC_TASK_PRIORITY, + sRpcTaskStack, &sRpcTaskBuffer); +} + +} // namespace rpc +} // namespace chip diff --git a/examples/platform/bouffalolab/bl602/Rpc.h b/examples/platform/bouffalolab/bl602/Rpc.h new file mode 100644 index 00000000000000..dcb25862a9cd1e --- /dev/null +++ b/examples/platform/bouffalolab/bl602/Rpc.h @@ -0,0 +1,30 @@ +/* + * + * 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 + +namespace chip { +namespace rpc { + +class LightingService; + +void Init(); +void RunRpcService(void *); + +} // namespace rpc +} // namespace chip diff --git a/examples/platform/bouffalolab/bl602/pw_sys_io/BUILD.gn b/examples/platform/bouffalolab/bl602/pw_sys_io/BUILD.gn index c7001f3271284c..6cea51cc6c4ef4 100644 --- a/examples/platform/bouffalolab/bl602/pw_sys_io/BUILD.gn +++ b/examples/platform/bouffalolab/bl602/pw_sys_io/BUILD.gn @@ -17,7 +17,7 @@ import("//build_overrides/pigweed.gni") import("$dir_pw_build/target_types.gni") -examples_plat_dir = "${chip_root}/examples/platform/bl602" +examples_plat_dir = "${chip_root}/examples/platform/bouffalolab/bl602" config("default_config") { include_dirs = [ "public" ] diff --git a/examples/platform/bouffalolab/bl602/pw_sys_io/public/pw_sys_io_efr32/init.h b/examples/platform/bouffalolab/bl602/pw_sys_io/public/pw_sys_io_bl602/init.h similarity index 100% rename from examples/platform/bouffalolab/bl602/pw_sys_io/public/pw_sys_io_efr32/init.h rename to examples/platform/bouffalolab/bl602/pw_sys_io/public/pw_sys_io_bl602/init.h diff --git a/examples/platform/bouffalolab/bl602/pw_sys_io/sys_io_efr32.cc b/examples/platform/bouffalolab/bl602/pw_sys_io/sys_io_bl602.cc similarity index 100% rename from examples/platform/bouffalolab/bl602/pw_sys_io/sys_io_efr32.cc rename to examples/platform/bouffalolab/bl602/pw_sys_io/sys_io_bl602.cc diff --git a/examples/platform/bouffalolab/bl602/uart.c b/examples/platform/bouffalolab/bl602/uart.c index d47ac3938ed177..25f483993d5845 100644 --- a/examples/platform/bouffalolab/bl602/uart.c +++ b/examples/platform/bouffalolab/bl602/uart.c @@ -16,292 +16,126 @@ * limitations under the License. */ #include "uart.h" -#include "AppConfig.h" -#include "assert.h" -#include "em_core.h" -#include "em_usart.h" -#include "hal-config.h" -#include "sl_uartdrv_usart_vcom_config.h" -#include "uartdrv.h" -#include +#include "hosal_uart.h" #include -#if !defined(MIN) -#define MIN(A, B) ((A) < (B) ? (A) : (B)) -#endif - -#define HELPER1(x) USART##x##_RX_IRQn -#define HELPER2(x) HELPER1(x) -#define USART_IRQ HELPER2(SL_UARTDRV_USART_VCOM_PERIPHERAL_NO) - -#define HELPER3(x) USART##x##_RX_IRQHandler -#define HELPER4(x) HELPER3(x) -#define USART_IRQHandler HELPER4(SL_UARTDRV_USART_VCOM_PERIPHERAL_NO) - -DEFINE_BUF_QUEUE(EMDRV_UARTDRV_MAX_CONCURRENT_RX_BUFS, sUartRxQueue); -DEFINE_BUF_QUEUE(EMDRV_UARTDRV_MAX_CONCURRENT_TX_BUFS, sUartTxQueue); - -typedef struct -{ - // The data buffer - uint8_t * pBuffer; - // The offset of the first item written to the list. - volatile uint16_t Head; - // The offset of the next item to be written to the list. - volatile uint16_t Tail; - // Maxium size of data that can be hold in buffer before overwriting - uint16_t MaxSize; -} Fifo_t; - -#define UART_CONSOLE_ERR -1 // Negative value in case of UART Console action failed. Triggers a failure for PW_RPC #define MAX_BUFFER_SIZE 256 -#define MAX_DMA_BUFFER_SIZE (MAX_BUFFER_SIZE / 2) -// In order to reduce the probability of data loss during the dmaFull callback handler we use -// two duplicate receive buffers so we can always have one "active" receive queue. -static uint8_t sRxDmaBuffer[MAX_DMA_BUFFER_SIZE]; -static uint8_t sRxDmaBuffer2[MAX_DMA_BUFFER_SIZE]; -static uint16_t lastCount; // Nb of bytes already processed from the active dmaBuffer -// Rx buffer for the receive Fifo -static uint8_t sRxFifoBuffer[MAX_BUFFER_SIZE]; -static Fifo_t sReceiveFifo; +extern hosal_uart_dev_t uart_stdio; -static UARTDRV_HandleData_t sUartHandleData; -static UARTDRV_Handle_t sUartHandle = &sUartHandleData; +typedef struct _uartFifo +{ + uint16_t head; + uint16_t tail; + uint8_t rxbuf[MAX_BUFFER_SIZE]; +} UartFifo_t; -static void UART_rx_callback(UARTDRV_Handle_t handle, Ecode_t transferStatus, uint8_t * data, UARTDRV_Count_t transferCount); +static UartFifo_t UartFifo_v; -static bool InitFifo(Fifo_t * fifo, uint8_t * pDataBuffer, uint16_t bufferSize) +static uint16_t availableDataSize() { - if (fifo == NULL || pDataBuffer == NULL) + if (UartFifo_v.tail >= UartFifo_v.head) { - return false; + return UartFifo_v.tail - UartFifo_v.head; + } + else + { + return MAX_BUFFER_SIZE - UartFifo_v.head + UartFifo_v.tail; } - - fifo->pBuffer = pDataBuffer; - fifo->MaxSize = bufferSize; - fifo->Tail = fifo->Head = 0; - - return true; } -/* - * @brief Get the amount of unprocessed bytes in the fifo buffer - * @param Ptr to the fifo - * @return Nb of "unread" bytes available in the fifo - */ -static uint16_t AvailableDataCount(Fifo_t * fifo) +static uint16_t readFromFifo(uint8_t * dstBuf, uint16_t NbBytesToRead) { - uint16_t size = 0; + uint16_t currentDataSize = availableDataSize(); + uint16_t sizeToRead = (NbBytesToRead >= currentDataSize) ? currentDataSize : NbBytesToRead; + uint16_t bytesBeforeWrap = MAX_BUFFER_SIZE - UartFifo_v.head; - // if equal there is no data return 0 directly - if (fifo->Tail != fifo->Head) + if (sizeToRead) { - // determine if a wrap around occurred to get the right data size available. - size = (fifo->Tail < fifo->Head) ? (fifo->MaxSize - fifo->Head + fifo->Tail) : (fifo->Tail - fifo->Head); - } + if (bytesBeforeWrap >= sizeToRead) + { + memcpy(dstBuf, UartFifo_v.rxbuf + UartFifo_v.head, sizeToRead); + } + else + { + memcpy(dstBuf, UartFifo_v.rxbuf + UartFifo_v.head, bytesBeforeWrap); + memcpy(dstBuf + bytesBeforeWrap, UartFifo_v.rxbuf, sizeToRead - bytesBeforeWrap); + } - return size; -} + UartFifo_v.head = (UartFifo_v.head + sizeToRead) % MAX_BUFFER_SIZE; + } -/* - * @brief Get the available space in the fifo buffer to insert new data - * @param Ptr to the fifo - * @return Nb of free bytes left in te buffer - */ -static uint16_t RemainingSpace(Fifo_t * fifo) -{ - return fifo->MaxSize - AvailableDataCount(fifo); + return sizeToRead; } -/* - * @brief Write data in the fifo as a circular buffer - * @param Ptr to the fifo, ptr of the data to write, nb of bytes to write - */ -static void WriteToFifo(Fifo_t * fifo, uint8_t * pDataToWrite, uint16_t SizeToWrite) +static void writeToFifo(uint8_t * buf, uint16_t NbBytesToWrite) { - assert(fifo); - assert(pDataToWrite); - assert(SizeToWrite <= fifo->MaxSize); + uint16_t currentCapacity = MAX_BUFFER_SIZE - availableDataSize(); - // Overwrite is not allowed - if (RemainingSpace(fifo) >= SizeToWrite) + if (currentCapacity >= NbBytesToWrite) { - uint16_t nBytesBeforWrap = (fifo->MaxSize - fifo->Tail); - if (SizeToWrite > nBytesBeforWrap) + uint16_t bytesBeforeWrap = MAX_BUFFER_SIZE - UartFifo_v.tail; + if (bytesBeforeWrap >= NbBytesToWrite) { - // The number of bytes to write is bigger than the remaining bytes - // in the buffer, we have to wrap around - memcpy(fifo->pBuffer + fifo->Tail, pDataToWrite, nBytesBeforWrap); - memcpy(fifo->pBuffer, pDataToWrite + nBytesBeforWrap, SizeToWrite - nBytesBeforWrap); + memcpy(UartFifo_v.rxbuf + UartFifo_v.tail, buf, NbBytesToWrite); } else { - memcpy(fifo->pBuffer + fifo->Tail, pDataToWrite, SizeToWrite); + memcpy(UartFifo_v.rxbuf + UartFifo_v.tail, buf, bytesBeforeWrap); + memcpy(UartFifo_v.rxbuf, buf + bytesBeforeWrap, NbBytesToWrite - bytesBeforeWrap); } - fifo->Tail = (fifo->Tail + SizeToWrite) % fifo->MaxSize; // increment tail with wraparound + UartFifo_v.tail = (UartFifo_v.tail + NbBytesToWrite) % MAX_BUFFER_SIZE; } } -/* - * @brief Write data in the fifo as a circular buffer - * @param Ptr to the fifo, ptr to contain the data to process, nb of bytes to pull from the fifo - * @return Nb of bytes that were retrieved. - */ -static uint8_t RetrieveFromFifo(Fifo_t * fifo, uint8_t * pData, uint16_t SizeToRead) +static int uartRxCallback(void * p_arg) { - assert(fifo); - assert(pData); - assert(SizeToRead <= fifo->MaxSize); - - uint16_t ReadSize = MIN(SizeToRead, AvailableDataCount(fifo)); - uint16_t nBytesBeforWrap = (fifo->MaxSize - fifo->Head); + uint8_t data_buf[32]; - if (ReadSize > nBytesBeforWrap) + int ret = hosal_uart_receive(&uart_stdio, data_buf, sizeof(data_buf)); + if (ret) { - memcpy(pData, fifo->pBuffer + fifo->Head, nBytesBeforWrap); - memcpy(pData + nBytesBeforWrap, fifo->pBuffer, ReadSize - nBytesBeforWrap); + writeToFifo(data_buf, ret); } - else - { - memcpy(pData, (fifo->pBuffer + fifo->Head), ReadSize); - } - - fifo->Head = (fifo->Head + ReadSize) % fifo->MaxSize; // increment tail with wraparound - return ReadSize; + return 0; } -/* - * @brief Init the the UART for serial communication, Start DMA reception - * and init Fifo to handle the received data from this uart - * - * @Note This UART is used for pigweed rpc - */ -void uartConsoleInit(void) +static int uartTxCallback(void * p_arg) { - UARTDRV_Init_t uartInit = { - .port = USART0, - .baudRate = HAL_SERIAL_APP_BAUD_RATE, -#if defined(_USART_ROUTELOC0_MASK) - .portLocationTx = BSP_SERIAL_APP_TX_LOC, - .portLocationRx = BSP_SERIAL_APP_RX_LOC, -#elif defined(_USART_ROUTE_MASK) -#error This configuration is not supported -#elif defined(_GPIO_USART_ROUTEEN_MASK) - .txPort = BSP_SERIAL_APP_TX_PORT, /* USART Tx port number */ - .rxPort = BSP_SERIAL_APP_RX_PORT, /* USART Rx port number */ - .txPin = BSP_SERIAL_APP_TX_PIN, /* USART Tx pin number */ - .rxPin = BSP_SERIAL_APP_RX_PIN, /* USART Rx pin number */ - .uartNum = 0, /* UART instance number */ -#endif -#if defined(USART_CTRL_MVDIS) - .mvdis = false, -#endif - .stopBits = (USART_Stopbits_TypeDef) USART_FRAME_STOPBITS_ONE, - .parity = (USART_Parity_TypeDef) USART_FRAME_PARITY_NONE, - .oversampling = (USART_OVS_TypeDef) USART_CTRL_OVS_X16, - .fcType = HAL_SERIAL_APP_FLOW_CONTROL, - .ctsPort = BSP_SERIAL_APP_CTS_PORT, - .ctsPin = BSP_SERIAL_APP_CTS_PIN, - .rtsPort = BSP_SERIAL_APP_RTS_PORT, - .rtsPin = BSP_SERIAL_APP_RTS_PIN, - .rxQueue = (UARTDRV_Buffer_FifoQueue_t *) &sUartRxQueue, - .txQueue = (UARTDRV_Buffer_FifoQueue_t *) &sUartTxQueue, -#if defined(_USART_ROUTELOC1_MASK) - .portLocationCts = BSP_SERIAL_APP_CTS_LOC, - .portLocationRts = BSP_SERIAL_APP_RTS_LOC, -#endif - }; + hosal_uart_ioctl(&uart_stdio, HOSAL_UART_TX_TRIGGER_OFF, NULL); - // Init a fifo for the data received on the uart - InitFifo(&sReceiveFifo, sRxFifoBuffer, MAX_BUFFER_SIZE); - - UARTDRV_InitUart(sUartHandle, &uartInit); - // Activate 2 dma queues to always have one active - UARTDRV_Receive(sUartHandle, sRxDmaBuffer, MAX_DMA_BUFFER_SIZE, UART_rx_callback); - UARTDRV_Receive(sUartHandle, sRxDmaBuffer2, MAX_DMA_BUFFER_SIZE, UART_rx_callback); - - // Enable USART0 interrupt to wake OT task when data arrives - NVIC_ClearPendingIRQ(USART_IRQ); - NVIC_EnableIRQ(USART_IRQ); - USART_IntEnable(SL_UARTDRV_USART_VCOM_PERIPHERAL, USART_IF_RXDATAV); + return 0; } -void USART_IRQHandler(void) -{ -#ifndef PW_RPC_ENABLED - otSysEventSignalPending(); -#endif -} - -/* - * @brief Callback triggered when a UARTDRV DMA buffer is full - */ -static void UART_rx_callback(UARTDRV_Handle_t handle, Ecode_t transferStatus, uint8_t * data, UARTDRV_Count_t transferCount) +void uartConsoleInit(void) { - (void) transferStatus; - - uint8_t writeSize = (transferCount - lastCount); - if (RemainingSpace(&sReceiveFifo) >= writeSize) - { - WriteToFifo(&sReceiveFifo, data + lastCount, writeSize); - lastCount = 0; - } + memset(&UartFifo_v, 0, offsetof(UartFifo_t, rxbuf)); - UARTDRV_Receive(sUartHandle, data, transferCount, UART_rx_callback); -#ifndef PW_RPC_ENABLED - otSysEventSignalPending(); -#endif + hosal_uart_finalize(&uart_stdio); + hosal_uart_init(&uart_stdio); + hosal_uart_callback_set(&uart_stdio, HOSAL_UART_RX_CALLBACK, uartRxCallback, NULL); + hosal_uart_callback_set(&uart_stdio, HOSAL_UART_TX_CALLBACK, uartTxCallback, NULL); + hosal_uart_ioctl(&uart_stdio, HOSAL_UART_MODE_SET, (void *) HOSAL_UART_MODE_INT); } -/* - * @brief Read the data available from the console Uart - * @param Buffer that contains the data to write, number bytes to write. - * @return Amount of bytes written or ERROR (-1) - */ int16_t uartConsoleWrite(const char * Buf, uint16_t BufLength) { if (Buf == NULL || BufLength < 1) { - return UART_CONSOLE_ERR; + return -1; } - // Use of ForceTransmit here. Transmit with DMA was causing errors with PW_RPC - // TODO Use DMA and find/fix what causes the issue with PW - if (UARTDRV_ForceTransmit(sUartHandle, (uint8_t *) Buf, BufLength) == ECODE_EMDRV_UARTDRV_OK) - { - return BufLength; - } - - return UART_CONSOLE_ERR; + return hosal_uart_send(&uart_stdio, Buf, BufLength); } -/* - * @brief Read the data available from the console Uart - * @param Buffer for the data to be read, number bytes to read. - * @return Amount of bytes that was read from the rx fifo or ERROR (-1) - */ int16_t uartConsoleRead(char * Buf, uint16_t NbBytesToRead) { - uint8_t * data; - UARTDRV_Count_t count, remaining; - if (Buf == NULL || NbBytesToRead < 1) { - return UART_CONSOLE_ERR; - } - - if (NbBytesToRead > AvailableDataCount(&sReceiveFifo)) - { - // Not enough data available in the fifo for the read size request - // If there is data available in dma buffer, get it now. - CORE_ATOMIC_SECTION(UARTDRV_GetReceiveStatus(sUartHandle, &data, &count, &remaining); if (count > lastCount) { - WriteToFifo(&sReceiveFifo, data + lastCount, count - lastCount); - lastCount = count; - }) + return -1; } - return (int16_t) RetrieveFromFifo(&sReceiveFifo, (uint8_t *) Buf, NbBytesToRead); + return readFromFifo(Buf, NbBytesToRead); } diff --git a/examples/platform/efr32/BUILD.gn b/examples/platform/efr32/BUILD.gn index 185651c5de3a61..ba36aeff00c83b 100644 --- a/examples/platform/efr32/BUILD.gn +++ b/examples/platform/efr32/BUILD.gn @@ -64,3 +64,26 @@ source_set("efr-matter-shell") { ] } } + +config("attestation-credentials-config") { + include_dirs = [ "${chip_root}" ] + + defines = [ + # Set to 1 to enable EFR32 attestation credentials + "EFR32_ATTESTATION_CREDENTIALS", + ] +} + +source_set("efr32-attestation-credentials") { + sources = [ + "EFR32DeviceAttestationCreds.cpp", + "EFR32DeviceAttestationCreds.h", + ] + + public_deps = [ + "${chip_root}/src/credentials", + "${chip_root}/src/platform:platform_base", + ] + + public_configs = [ ":attestation-credentials-config" ] +} diff --git a/examples/platform/efr32/EFR32DeviceAttestationCreds.cpp b/examples/platform/efr32/EFR32DeviceAttestationCreds.cpp new file mode 100644 index 00000000000000..4f7453b79451ef --- /dev/null +++ b/examples/platform/efr32/EFR32DeviceAttestationCreds.cpp @@ -0,0 +1,95 @@ +/* + * + * 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 "EFR32DeviceAttestationCreds.h" +#include +#include +#include +#include + +#include "efr32_creds.h" +#include "psa/crypto.h" +#include "sl_token_api.h" + +namespace chip { +namespace Credentials { +namespace EFR32 { + +namespace { + +class DeviceAttestationCredsEFR32 : public DeviceAttestationCredentialsProvider +{ +public: + CHIP_ERROR GetCertificationDeclaration(MutableByteSpan & out_buffer) override + { + ByteSpan cd_span(kCertificationDeclaration); + return CopySpanToMutableSpan(cd_span, out_buffer); + } + + CHIP_ERROR GetFirmwareInformation(MutableByteSpan & out_firmware_info_buffer) override + { + // TODO: We need a real example FirmwareInformation to be populated. + out_firmware_info_buffer.reduce_size(0); + return CHIP_NO_ERROR; + } + + CHIP_ERROR GetDeviceAttestationCert(MutableByteSpan & out_buffer) override + { + uint8_t cert_buf[MFG_MATTER_DAC_SIZE]; + ByteSpan cert_span(cert_buf); + + int err = sl_token_get_data(CREATOR_MFG_MATTER_DAC, 0, cert_buf, sizeof(cert_buf)); + VerifyOrReturnError(!err, CHIP_ERROR_INTERNAL); + ChipLogByteSpan(DeviceLayer, cert_span); + return CopySpanToMutableSpan(cert_span, out_buffer); + } + + CHIP_ERROR GetProductAttestationIntermediateCert(MutableByteSpan & out_pai_buffer) override + { + uint8_t cert_buf[MFG_MATTER_PAI_SIZE]; + ByteSpan cert_span(cert_buf); + + int err = sl_token_get_data(CREATOR_MFG_MATTER_PAI, 0, cert_buf, sizeof(cert_buf)); + VerifyOrReturnError(!err, CHIP_ERROR_INTERNAL); + ChipLogByteSpan(DeviceLayer, cert_span); + return CopySpanToMutableSpan(cert_span, out_pai_buffer); + } + + CHIP_ERROR SignWithDeviceAttestationKey(const ByteSpan & digest_to_sign, MutableByteSpan & out_buffer) override + { + psa_key_id_t key_id = MFG_MATTER_DAC_KEY_ID; + uint8_t signature[64] = { 0 }; + size_t signature_size = sizeof(signature); + + psa_status_t err = psa_sign_message(key_id, PSA_ALG_ECDSA(PSA_ALG_SHA_256), digest_to_sign.data(), digest_to_sign.size(), + signature, signature_size, &signature_size); + VerifyOrReturnError(!err, CHIP_ERROR_INTERNAL); + + return CopySpanToMutableSpan(ByteSpan(signature, signature_size), out_buffer); + } +}; + +} // namespace + +DeviceAttestationCredentialsProvider * GetEFR32DacProvider() +{ + static DeviceAttestationCredsEFR32 dac_provider; + return &dac_provider; +} + +} // namespace EFR32 +} // namespace Credentials +} // namespace chip diff --git a/examples/platform/efr32/EFR32DeviceAttestationCreds.h b/examples/platform/efr32/EFR32DeviceAttestationCreds.h new file mode 100644 index 00000000000000..3dbc48a01b0872 --- /dev/null +++ b/examples/platform/efr32/EFR32DeviceAttestationCreds.h @@ -0,0 +1,39 @@ +/* + * + * 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 + +// The "sl_token_manager.h" include belongs to the .cpp file, but the formatter change the order +// of the headers, causing a compilation error, so the include had to be added here instead +#include "sl_token_manager.h" +#include + +namespace chip { +namespace Credentials { +namespace EFR32 { + +/** + * @brief Get implementation of a sample DAC provider to validate device + * attestation procedure. + * + * @returns a singleton DeviceAttestationCredentialsProvider that relies on no + * storage abstractions. + */ +DeviceAttestationCredentialsProvider * GetEFR32DacProvider(); + +} // namespace EFR32 +} // namespace Credentials +} // namespace chip diff --git a/examples/platform/efr32/efr32_creds.h b/examples/platform/efr32/efr32_creds.h new file mode 100644 index 00000000000000..52514adec3969f --- /dev/null +++ b/examples/platform/efr32/efr32_creds.h @@ -0,0 +1,66 @@ +/** + * This is a boilerplat header to define the EFR32 authentication credentials. + * Applications must provide their own version of this header, and include: + * - The content of the CSA-provided Certification Declaration + * - The location and size of the PAI, and DAC + * - The key ID of the key-pair associated with the DAC + * + * These credentials MUST be provided if the build variable "chip_build_device_attestation_credentials" is set to true. + */ +#ifndef EFR32_EXAMPLE_DEVICE_CREDENTIALS +#define EFR32_EXAMPLE_DEVICE_CREDENTIALS + +//-> format_version = 1 +//-> vendor_id = 0xFFF1 +//-> product_id_array = [ 0x8000, 0x8001, 0x8002, 0x8003, 0x8004, 0x8005, 0x8006, 0x8007, 0x8008, 0x8009, 0x800A, 0x800B, +// 0x800C, 0x800D, 0x800E, 0x800F, 0x8010, 0x8011, 0x8012, 0x8013, 0x8014, 0x8015, 0x8016, 0x8017, 0x8018, 0x8019, 0x801A, +// 0x801B, 0x801C, 0x801D, 0x801E, 0x801F, 0x8020, 0x8021, 0x8022, 0x8023, 0x8024, 0x8025, 0x8026, 0x8027, 0x8028, 0x8029, +// 0x802A, 0x802B, 0x802C, 0x802D, 0x802E, 0x802F, 0x8030, 0x8031, 0x8032, 0x8033, 0x8034, 0x8035, 0x8036, 0x8037, 0x8038, +// 0x8039, 0x803A, 0x803B, 0x803C, 0x803D, 0x803E, 0x803F, 0x8040, 0x8041, 0x8042, 0x8043, 0x8044, 0x8045, 0x8046, 0x8047, +// 0x8048, 0x8049, 0x804A, 0x804B, 0x804C, 0x804D, 0x804E, 0x804F, 0x8050, 0x8051, 0x8052, 0x8053, 0x8054, 0x8055, 0x8056, +// 0x8057, 0x8058, 0x8059, 0x805A, 0x805B, 0x805C, 0x805D, 0x805E, 0x805F, 0x8060, 0x8061, 0x8062, 0x8063 ] +//-> device_type_id = 0x0016 +//-> certificate_id = "ZIG20142ZB330003-24" +//-> security_level = 0 +//-> security_information = 0 +//-> version_number = 0x2694 +//-> certification_type = 0 +//-> dac_origin_vendor_id is not present +//-> dac_origin_product_id is not present +const uint8_t kCertificationDeclaration[541] = { + 0x30, 0x82, 0x02, 0x19, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x02, 0xa0, 0x82, 0x02, 0x0a, 0x30, 0x82, + 0x02, 0x06, 0x02, 0x01, 0x03, 0x31, 0x0d, 0x30, 0x0b, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x30, + 0x82, 0x01, 0x71, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x01, 0xa0, 0x82, 0x01, 0x62, 0x04, 0x82, 0x01, + 0x5e, 0x15, 0x24, 0x00, 0x01, 0x25, 0x01, 0xf1, 0xff, 0x36, 0x02, 0x05, 0x00, 0x80, 0x05, 0x01, 0x80, 0x05, 0x02, 0x80, 0x05, + 0x03, 0x80, 0x05, 0x04, 0x80, 0x05, 0x05, 0x80, 0x05, 0x06, 0x80, 0x05, 0x07, 0x80, 0x05, 0x08, 0x80, 0x05, 0x09, 0x80, 0x05, + 0x0a, 0x80, 0x05, 0x0b, 0x80, 0x05, 0x0c, 0x80, 0x05, 0x0d, 0x80, 0x05, 0x0e, 0x80, 0x05, 0x0f, 0x80, 0x05, 0x10, 0x80, 0x05, + 0x11, 0x80, 0x05, 0x12, 0x80, 0x05, 0x13, 0x80, 0x05, 0x14, 0x80, 0x05, 0x15, 0x80, 0x05, 0x16, 0x80, 0x05, 0x17, 0x80, 0x05, + 0x18, 0x80, 0x05, 0x19, 0x80, 0x05, 0x1a, 0x80, 0x05, 0x1b, 0x80, 0x05, 0x1c, 0x80, 0x05, 0x1d, 0x80, 0x05, 0x1e, 0x80, 0x05, + 0x1f, 0x80, 0x05, 0x20, 0x80, 0x05, 0x21, 0x80, 0x05, 0x22, 0x80, 0x05, 0x23, 0x80, 0x05, 0x24, 0x80, 0x05, 0x25, 0x80, 0x05, + 0x26, 0x80, 0x05, 0x27, 0x80, 0x05, 0x28, 0x80, 0x05, 0x29, 0x80, 0x05, 0x2a, 0x80, 0x05, 0x2b, 0x80, 0x05, 0x2c, 0x80, 0x05, + 0x2d, 0x80, 0x05, 0x2e, 0x80, 0x05, 0x2f, 0x80, 0x05, 0x30, 0x80, 0x05, 0x31, 0x80, 0x05, 0x32, 0x80, 0x05, 0x33, 0x80, 0x05, + 0x34, 0x80, 0x05, 0x35, 0x80, 0x05, 0x36, 0x80, 0x05, 0x37, 0x80, 0x05, 0x38, 0x80, 0x05, 0x39, 0x80, 0x05, 0x3a, 0x80, 0x05, + 0x3b, 0x80, 0x05, 0x3c, 0x80, 0x05, 0x3d, 0x80, 0x05, 0x3e, 0x80, 0x05, 0x3f, 0x80, 0x05, 0x40, 0x80, 0x05, 0x41, 0x80, 0x05, + 0x42, 0x80, 0x05, 0x43, 0x80, 0x05, 0x44, 0x80, 0x05, 0x45, 0x80, 0x05, 0x46, 0x80, 0x05, 0x47, 0x80, 0x05, 0x48, 0x80, 0x05, + 0x49, 0x80, 0x05, 0x4a, 0x80, 0x05, 0x4b, 0x80, 0x05, 0x4c, 0x80, 0x05, 0x4d, 0x80, 0x05, 0x4e, 0x80, 0x05, 0x4f, 0x80, 0x05, + 0x50, 0x80, 0x05, 0x51, 0x80, 0x05, 0x52, 0x80, 0x05, 0x53, 0x80, 0x05, 0x54, 0x80, 0x05, 0x55, 0x80, 0x05, 0x56, 0x80, 0x05, + 0x57, 0x80, 0x05, 0x58, 0x80, 0x05, 0x59, 0x80, 0x05, 0x5a, 0x80, 0x05, 0x5b, 0x80, 0x05, 0x5c, 0x80, 0x05, 0x5d, 0x80, 0x05, + 0x5e, 0x80, 0x05, 0x5f, 0x80, 0x05, 0x60, 0x80, 0x05, 0x61, 0x80, 0x05, 0x62, 0x80, 0x05, 0x63, 0x80, 0x18, 0x24, 0x03, 0x16, + 0x2c, 0x04, 0x13, 0x5a, 0x49, 0x47, 0x32, 0x30, 0x31, 0x34, 0x32, 0x5a, 0x42, 0x33, 0x33, 0x30, 0x30, 0x30, 0x33, 0x2d, 0x32, + 0x34, 0x24, 0x05, 0x00, 0x24, 0x06, 0x00, 0x25, 0x07, 0x94, 0x26, 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, 0x20, 0x24, 0xe5, 0xd1, 0xf4, 0x7a, 0x7d, 0x7b, 0x0d, 0x20, + 0x6a, 0x26, 0xef, 0x69, 0x9b, 0x7c, 0x97, 0x57, 0xb7, 0x2d, 0x46, 0x90, 0x89, 0xde, 0x31, 0x92, 0xe6, 0x78, 0xc7, 0x45, 0xe7, + 0xf6, 0x0c, 0x02, 0x21, 0x00, 0xf8, 0xaa, 0x2f, 0xa7, 0x11, 0xfc, 0xb7, 0x9b, 0x97, 0xe3, 0x97, 0xce, 0xda, 0x66, 0x7b, 0xae, + 0x46, 0x4e, 0x2b, 0xd3, 0xff, 0xdf, 0xc3, 0xcc, 0xed, 0x7a, 0xa8, 0xca, 0x5f, 0x4c, 0x1a, 0x7c +}; + +#define CREATOR_MFG_MATTER_PAI (USERDATA_TOKENS | 0x400) // 4 bytes +#define CREATOR_MFG_MATTER_DAC (USERDATA_TOKENS | 0x600) // 4 bytes + +#define MFG_MATTER_PAI_SIZE 463 +#define MFG_MATTER_DAC_SIZE 492 +#define MFG_MATTER_DAC_KEY_ID PSA_KEY_ID_USER_MIN + 1 + +#endif // EFR32_EXAMPLE_DEVICE_CREDENTIALS diff --git a/examples/platform/esp32/common/CommonDeviceCallbacks.cpp b/examples/platform/esp32/common/CommonDeviceCallbacks.cpp index ddc25a14c90d07..e975dce62914f2 100644 --- a/examples/platform/esp32/common/CommonDeviceCallbacks.cpp +++ b/examples/platform/esp32/common/CommonDeviceCallbacks.cpp @@ -54,10 +54,6 @@ void CommonDeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, i OnInternetConnectivityChange(event); break; - case DeviceEventType::kSessionEstablished: - OnSessionEstablished(event); - break; - case DeviceEventType::kCHIPoBLEConnectionEstablished: ESP_LOGI(TAG, "CHIPoBLE connection established"); break; @@ -164,11 +160,3 @@ void CommonDeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * ESP_LOGE(TAG, "Lost IPv6 connectivity..."); } } - -void CommonDeviceCallbacks::OnSessionEstablished(const ChipDeviceEvent * event) -{ - if (event->SessionEstablished.IsCommissioner) - { - ESP_LOGI(TAG, "Commissioner detected!"); - } -} diff --git a/examples/platform/esp32/common/CommonDeviceCallbacks.h b/examples/platform/esp32/common/CommonDeviceCallbacks.h index 841f86bd764db4..a87014cbf00858 100644 --- a/examples/platform/esp32/common/CommonDeviceCallbacks.h +++ b/examples/platform/esp32/common/CommonDeviceCallbacks.h @@ -28,7 +28,6 @@ class CommonDeviceCallbacks : public chip::DeviceManager::CHIPDeviceManagerCallb private: void OnInternetConnectivityChange(const chip::DeviceLayer::ChipDeviceEvent * event); - void OnSessionEstablished(const chip::DeviceLayer::ChipDeviceEvent * event); }; class DeviceCallbacksDelegate diff --git a/examples/platform/linux/Options.cpp b/examples/platform/linux/Options.cpp index 4074c155889d48..f1b1d6cfacac46 100644 --- a/examples/platform/linux/Options.cpp +++ b/examples/platform/linux/Options.cpp @@ -80,7 +80,7 @@ OptionDef sDeviceOptionDefs[] = { #if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE { "ble-device", kArgumentRequired, kDeviceOption_BleDevice }, #endif // CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE -#if CHIP_DEVICE_CONFIG_ENABLE_WPA +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI { "wifi", kNoArgument, kDeviceOption_WiFi }, #endif // CHIP_DEVICE_CONFIG_ENABLE_WPA #if CHIP_ENABLE_OPENTHREAD diff --git a/examples/platform/qpg/BUILD.gn b/examples/platform/qpg/BUILD.gn index ddfd0ce5be3704..e0f44da9aa1645 100644 --- a/examples/platform/qpg/BUILD.gn +++ b/examples/platform/qpg/BUILD.gn @@ -39,6 +39,7 @@ source_set("qpg-matter-shell") { defines = [ "OPENTHREAD_CONFIG_CLI_TRANSPORT=OT_CLI_TRANSPORT_CONSOLE", "ENABLE_CHIP_SHELL", + "CHIP_DEVICE_CONFIG_THREAD_ENABLE_CLI=1", ] sources = [ diff --git a/examples/platform/qpg/app/main.cpp b/examples/platform/qpg/app/main.cpp index dc71281d592e5d..56eca7761cabbd 100644 --- a/examples/platform/qpg/app/main.cpp +++ b/examples/platform/qpg/app/main.cpp @@ -69,9 +69,20 @@ constexpr int extDiscTimeoutSecs = 20; /***************************************************************************** * Application Function Definitions *****************************************************************************/ +CHIP_ERROR CHIP_Init(void); -int Application_Init(void) +void Application_Init(void) { + CHIP_ERROR error; + + /* Initialize CHIP stack */ + error = CHIP_Init(); + if (error != CHIP_NO_ERROR) + { + ChipLogError(NotSpecified, "CHIP_Init failed"); + return; + } + /* Launch application task */ ChipLogProgress(NotSpecified, "============================"); ChipLogProgress(NotSpecified, "Qorvo " APP_NAME " Launching"); @@ -81,10 +92,8 @@ int Application_Init(void) if (ret != CHIP_NO_ERROR) { ChipLogError(NotSpecified, "GetAppTask().Init() failed"); - return -1; + return; } - - return 0; } CHIP_ERROR CHIP_Init(void) @@ -172,32 +181,15 @@ CHIP_ERROR CHIP_Init(void) int main(void) { int result; - CHIP_ERROR error; /* Initialize Qorvo stack */ - result = qvCHIP_init(); - if (result < 0) - { - goto exit; - } - - /* Initialize CHIP stack */ - error = CHIP_Init(); - if (error != CHIP_NO_ERROR) - { - goto exit; - } - - /* Application task */ - result = Application_Init(); + result = qvCHIP_init(Application_Init); if (result < 0) { - goto exit; + return 0; } /* Start FreeRTOS */ vTaskStartScheduler(); - -exit: return 0; } diff --git a/examples/platform/qpg/ota/ota.cpp b/examples/platform/qpg/ota/ota.cpp index 43639400c1b224..2ae61482c75729 100644 --- a/examples/platform/qpg/ota/ota.cpp +++ b/examples/platform/qpg/ota/ota.cpp @@ -50,6 +50,19 @@ OTAImageProcessorImpl gImageProcessor; * Application Function Definitions *****************************************************************************/ +bool OtaHeaderValidationCb(qvCHIP_Ota_ImageHeader_t imageHeader) +{ + // Check that the image matches vendor and product ID and that the version is higher than what we currently have + if (imageHeader.vendorId != CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID || + imageHeader.productId != CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID || + imageHeader.softwareVersion <= CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION) + { + return false; + } + + return true; +} + void InitializeOTARequestor(void) { // Initialize and interconnect the Requestor and Image Processor objects @@ -60,6 +73,9 @@ void InitializeOTARequestor(void) gImageProcessor.SetOTADownloader(&gDownloader); gDownloader.SetImageProcessorDelegate(&gImageProcessor); gRequestorUser.Init(&gRequestorCore, &gImageProcessor); + + // Initialize OTA image validation callback + qvCHIP_OtaSetHeaderValidationCb(OtaHeaderValidationCb); } void TriggerOTAQuery(void) diff --git a/examples/platform/qpg/project_include/OpenThreadConfig.h b/examples/platform/qpg/project_include/OpenThreadConfig.h index 460208fc6b9671..117632ff8ab3f8 100644 --- a/examples/platform/qpg/project_include/OpenThreadConfig.h +++ b/examples/platform/qpg/project_include/OpenThreadConfig.h @@ -73,7 +73,7 @@ #define OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE 0 #define OPENTHREAD_CONFIG_COAP_API_ENABLE 0 -#define OPENTHREAD_CONFIG_JOINER_ENABLE 1 +#define OPENTHREAD_CONFIG_JOINER_ENABLE 0 #define OPENTHREAD_CONFIG_COMMISSIONER_ENABLE 0 #define OPENTHREAD_CONFIG_UDP_FORWARD_ENABLE 0 #define OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE 0 diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/DeviceCallbacks.cpp b/examples/pump-app/cc13x2x7_26x2x7/main/DeviceCallbacks.cpp index f29ce063f5c8e4..5fc2be33ce6910 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/DeviceCallbacks.cpp +++ b/examples/pump-app/cc13x2x7_26x2x7/main/DeviceCallbacks.cpp @@ -56,10 +56,6 @@ void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_ event->ServiceProvisioningChange.ServiceConfigUpdated); break; - case DeviceEventType::kSessionEstablished: - OnSessionEstablished(event); - break; - case DeviceEventType::kCHIPoBLEConnectionEstablished: PLAT_LOG("CHIPoBLE connection established"); break; @@ -193,14 +189,6 @@ void DeviceCallbacks::OnThreadConnectivityChange(const ChipDeviceEvent * event) } } -void DeviceCallbacks::OnSessionEstablished(const ChipDeviceEvent * event) -{ - if (event->SessionEstablished.IsCommissioner) - { - PLAT_LOG("Commissioner detected!"); - } -} - void DeviceCallbacks::OnOnOffPostAttributeChangeCallback(EndpointId endpointId, AttributeId attributeId, uint8_t * value) { VerifyOrExit(attributeId == OnOff::Attributes::OnOff::Id, PLAT_LOG("Unhandled Attribute ID: '0x%04x", attributeId)); diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/include/DeviceCallbacks.h b/examples/pump-app/cc13x2x7_26x2x7/main/include/DeviceCallbacks.h index c200460d0b46c6..7e2633b54bb9db 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/include/DeviceCallbacks.h +++ b/examples/pump-app/cc13x2x7_26x2x7/main/include/DeviceCallbacks.h @@ -43,7 +43,6 @@ class DeviceCallbacks : public chip::DeviceManager::CHIPDeviceManagerCallbacks private: void OnInternetConnectivityChange(const chip::DeviceLayer::ChipDeviceEvent * event); void OnThreadConnectivityChange(const chip::DeviceLayer::ChipDeviceEvent * event); - void OnSessionEstablished(const chip::DeviceLayer::ChipDeviceEvent * event); void OnIdentifyPostAttributeChangeCallback(chip::EndpointId endpointId, chip::AttributeId attributeId, uint8_t * value); void OnOnOffPostAttributeChangeCallback(chip::EndpointId endpointId, chip::AttributeId attributeId, uint8_t * value); void OnLevelControlAttributeChangeCallback(chip::EndpointId endpointId, chip::AttributeId attributeId, uint8_t * value); diff --git a/examples/shell/cc13x2x7_26x2x7/main/AppTask.cpp b/examples/shell/cc13x2x7_26x2x7/main/AppTask.cpp index b1411b6b6707da..41323b44c6faa1 100644 --- a/examples/shell/cc13x2x7_26x2x7/main/AppTask.cpp +++ b/examples/shell/cc13x2x7_26x2x7/main/AppTask.cpp @@ -30,6 +30,13 @@ #include #include +#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR +#include +#include +#include +#include +#include +#endif #include #include #include @@ -56,6 +63,26 @@ extern "C" { int cc13x2_26x2LogInit(void); } +#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR +static DefaultOTARequestor sRequestorCore; +static DefaultOTARequestorStorage sRequestorStorage; +static DefaultOTARequestorDriver sRequestorUser; +static BDXDownloader sDownloader; +static OTAImageProcessorImpl sImageProcessor; + +void InitializeOTARequestor(void) +{ + // Initialize and interconnect the Requestor and Image Processor objects + SetRequestorInstance(&sRequestorCore); + + sRequestorStorage.Init(Server::GetInstance().GetPersistentStorage()); + sRequestorCore.Init(Server::GetInstance(), sRequestorStorage, sRequestorUser, sDownloader); + sImageProcessor.SetOTADownloader(&sDownloader); + sDownloader.SetImageProcessorDelegate(&sImageProcessor); + sRequestorUser.Init(&sRequestorCore, &sImageProcessor); +} +#endif + CHIP_ERROR AppTask::StartAppTask() { CHIP_ERROR err = CHIP_NO_ERROR; @@ -124,7 +151,9 @@ CHIP_ERROR AppTask::Init() // Initialize device attestation config SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); - +#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR + InitializeOTARequestor(); +#endif return err; } diff --git a/examples/tv-app/android/java/DeviceCallbacks.cpp b/examples/tv-app/android/java/DeviceCallbacks.cpp index 3388d216c60d67..07673ffae1acfa 100644 --- a/examples/tv-app/android/java/DeviceCallbacks.cpp +++ b/examples/tv-app/android/java/DeviceCallbacks.cpp @@ -80,19 +80,9 @@ void DeviceCallbacks::OnPlatformEvent(const ChipDeviceEvent * event) case DeviceEventType::kCommissioningComplete: OnCommissioningComplete(event); break; - case DeviceEventType::kSessionEstablished: - OnSessionEstablished(event); - break; } } -void DeviceCallbacks::OnSessionEstablished(const ChipDeviceEvent * event) -{ - if (event->SessionEstablished.IsCommissioner) - { - ChipLogProgress(AppServer, "Commissioner detected!"); - } -} void DeviceCallbacks::OnCommissioningComplete(const ChipDeviceEvent * event) { JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); diff --git a/examples/tv-app/android/java/DeviceCallbacks.h b/examples/tv-app/android/java/DeviceCallbacks.h index 15c336a10a9156..1f0df0cd5e886a 100644 --- a/examples/tv-app/android/java/DeviceCallbacks.h +++ b/examples/tv-app/android/java/DeviceCallbacks.h @@ -30,6 +30,5 @@ class DeviceCallbacks private: jobject mProvider = nullptr; jmethodID mCommissioningCompleteMethod = nullptr; - void OnSessionEstablished(const chip::DeviceLayer::ChipDeviceEvent * event); void OnCommissioningComplete(const chip::DeviceLayer::ChipDeviceEvent * event); }; diff --git a/examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp b/examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp index 7b97d976ad3831..d240921fb36a4d 100644 --- a/examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp +++ b/examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp @@ -141,13 +141,8 @@ void CastingServer::ReadServerClusters(EndpointId endpointId) return; } - chip::Controller::DescriptorCluster cluster; - CHIP_ERROR err = cluster.Associate(operationalDeviceProxy, endpointId); - if (err != CHIP_NO_ERROR) - { - ChipLogError(AppServer, "Associate() failed: %" CHIP_ERROR_FORMAT, err.Format()); - return; - } + chip::Controller::DescriptorCluster cluster(*operationalDeviceProxy->GetExchangeManager(), + operationalDeviceProxy->GetSecureSession().Value(), endpointId); TargetEndpointInfo * endpointInfo = mTargetVideoPlayerInfo.GetOrAddEndpoint(endpointId); @@ -193,13 +188,8 @@ CHIP_ERROR CastingServer::ContentLauncherLaunchURL(const char * contentUrl, cons return CHIP_ERROR_PEER_NODE_NOT_FOUND; } - ContentLauncherCluster cluster; - CHIP_ERROR err = cluster.Associate(operationalDeviceProxy, kTvEndpoint); - if (err != CHIP_NO_ERROR) - { - ChipLogError(AppServer, "Associate() failed: %" CHIP_ERROR_FORMAT, err.Format()); - return err; - } + ContentLauncherCluster cluster(*operationalDeviceProxy->GetExchangeManager(), + operationalDeviceProxy->GetSecureSession().Value(), kTvEndpoint); CastingServer::GetInstance()->mLaunchURLResponseCallback = launchURLResponseCallback; LaunchURL::Type request; request.contentURL = chip::CharSpan::fromCharString(contentUrl); diff --git a/examples/window-app/common/src/WindowApp.cpp b/examples/window-app/common/src/WindowApp.cpp index 4c846ecf6a8c05..a15abd5f9dbcff 100644 --- a/examples/window-app/common/src/WindowApp.cpp +++ b/examples/window-app/common/src/WindowApp.cpp @@ -21,8 +21,7 @@ #include #include #include -#include -#include + #include #include @@ -112,9 +111,6 @@ WindowApp::Cover * WindowApp::GetCover(chip::EndpointId endpoint) CHIP_ERROR WindowApp::Init() { - // Initialize device attestation config - SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); - ConfigurationMgr().LogDeviceConfig(); // Timers diff --git a/examples/window-app/common/window-app.matter b/examples/window-app/common/window-app.matter index 469f37af82ade8..f39ee1a95c9252 100644 --- a/examples/window-app/common/window-app.matter +++ b/examples/window-app/common/window-app.matter @@ -31,6 +31,9 @@ server cluster Identify = 3 { attribute int16u identifyTime = 0; readonly attribute enum8 identifyType = 1; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute attrib_id attributeList[] = 65531; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -49,6 +52,9 @@ server cluster Identify = 3 { server cluster Groups = 4 { readonly attribute bitmap8 nameSupport = 0; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute attrib_id attributeList[] = 65531; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -103,7 +109,7 @@ server cluster Groups = 4 { command access(invoke: manage) AddGroupIfIdentifying(AddGroupIfIdentifyingRequest): DefaultSuccess = 5; } -client cluster Scenes = 5 { +server cluster Scenes = 5 { bitmap ScenesCopyMode : BITMAP8 { kCopyAllScenes = 0x1; } @@ -123,7 +129,10 @@ client cluster Scenes = 5 { 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 attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; request struct AddSceneRequest { @@ -640,6 +649,7 @@ server cluster GeneralCommissioning = 48 { readonly attribute BasicCommissioningInfo basicCommissioningInfo = 1; readonly attribute RegulatoryLocationType regulatoryConfig = 2; readonly attribute RegulatoryLocationType locationCapability = 3; + readonly attribute boolean supportsConcurrentConnection = 4; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute attrib_id attributeList[] = 65531; @@ -1529,6 +1539,9 @@ server cluster WindowCovering = 258 { readonly attribute int16u installedClosedLimitTilt = 19; attribute access(write: manage) Mode mode = 23; readonly attribute SafetyStatus safetyStatus = 26; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute attrib_id attributeList[] = 65531; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; @@ -1671,6 +1684,7 @@ endpoint 0 { callback attribute basicCommissioningInfo; callback attribute regulatoryConfig; callback attribute locationCapability; + callback attribute supportsConcurrentConnection default = 1; callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute attributeList; @@ -1871,17 +1885,35 @@ endpoint 0 { } endpoint 1 { device type windowcovering = 514; - binding cluster Scenes; server cluster Identify { ram attribute identifyTime; - ram attribute identifyType; + ram attribute identifyType default = 0x05; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; ram attribute featureMap; ram attribute clusterRevision default = 4; } server cluster Groups { ram attribute nameSupport; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; + ram attribute featureMap; + ram attribute clusterRevision default = 4; + } + + server cluster Scenes { + ram attribute sceneCount; + ram attribute currentScene; + ram attribute currentGroup; + ram attribute sceneValid; + ram attribute nameSupport; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; ram attribute featureMap; ram attribute clusterRevision default = 4; } @@ -1891,6 +1923,9 @@ endpoint 1 { callback attribute serverList; callback attribute clientList; callback attribute partsList; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; ram attribute featureMap; callback attribute clusterRevision default = 1; } @@ -1918,16 +1953,44 @@ endpoint 1 { persist attribute installedClosedLimitTilt default = 0xFFFF; persist attribute mode; ram attribute safetyStatus; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; ram attribute featureMap default = 0x0017; ram attribute clusterRevision default = 5; } } endpoint 2 { device type windowcovering = 514; - binding cluster Scenes; + + server cluster Identify { + ram attribute identifyTime; + ram attribute identifyType default = 0x05; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; + ram attribute featureMap; + ram attribute clusterRevision default = 4; + } server cluster Groups { ram attribute nameSupport; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; + ram attribute featureMap; + ram attribute clusterRevision default = 4; + } + + server cluster Scenes { + ram attribute sceneCount; + ram attribute currentScene; + ram attribute currentGroup; + ram attribute sceneValid; + ram attribute nameSupport; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; ram attribute featureMap; ram attribute clusterRevision default = 4; } @@ -1937,6 +2000,9 @@ endpoint 2 { callback attribute serverList; callback attribute clientList; callback attribute partsList; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; ram attribute featureMap; callback attribute clusterRevision default = 1; } @@ -1964,6 +2030,9 @@ endpoint 2 { persist attribute installedClosedLimitTilt default = 0xFFFF; persist attribute mode; ram attribute safetyStatus; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; ram attribute featureMap default = 0x0017; ram attribute clusterRevision default = 5; } diff --git a/examples/window-app/common/window-app.zap b/examples/window-app/common/window-app.zap index cc222307fa7e4b..6d97a2b6a54e9e 100644 --- a/examples/window-app/common/window-app.zap +++ b/examples/window-app/common/window-app.zap @@ -51,6 +51,14 @@ "source": "client", "incoming": 1, "outgoing": 1 + }, + { + "name": "TriggerEffect", + "code": 64, + "mfgCode": null, + "source": "client", + "incoming": 0, + "outgoing": 0 } ], "attributes": [ @@ -82,7 +90,7 @@ "commands": [], "attributes": [ { - "name": "identify time", + "name": "IdentifyTime", "code": 0, "mfgCode": null, "side": "server", @@ -91,10 +99,90 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "0x0", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "IdentifyType", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "enum8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x05", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { @@ -234,7 +322,7 @@ ], "attributes": [ { - "name": "name support", + "name": "NameSupport", "code": 0, "mfgCode": null, "side": "server", @@ -249,6 +337,70 @@ "maxInterval": 65344, "reportableChange": 0 }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "ClusterRevision", "code": 65533, @@ -489,6 +641,86 @@ "maxInterval": 65344, "reportableChange": 0 }, + { + "name": "LastConfiguredBy", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "node_id", + "included": 0, + "storageOption": "RAM", + "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": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "ClusterRevision", "code": 65533, @@ -560,7 +792,7 @@ "commands": [], "attributes": [ { - "name": "device list", + "name": "DeviceList", "code": 0, "mfgCode": null, "side": "server", @@ -576,7 +808,7 @@ "reportableChange": 0 }, { - "name": "server list", + "name": "ServerList", "code": 1, "mfgCode": null, "side": "server", @@ -592,7 +824,7 @@ "reportableChange": 0 }, { - "name": "client list", + "name": "ClientList", "code": 2, "mfgCode": null, "side": "server", @@ -608,7 +840,7 @@ "reportableChange": 0 }, { - "name": "parts list", + "name": "PartsList", "code": 3, "mfgCode": null, "side": "server", @@ -2434,7 +2666,7 @@ "code": 3, "mfgCode": null, "source": "server", - "incoming": 0, + "incoming": 1, "outgoing": 1 }, { @@ -2511,6 +2743,22 @@ "maxInterval": 65534, "reportableChange": 0 }, + { + "name": "SupportsConcurrentConnection", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "GeneratedCommandList", "code": 65528, @@ -5915,178 +6163,145 @@ "reportableChange": 0 } ] - }, - { - "name": "Window Covering", - "code": 258, + } + ] + }, + { + "name": "MA-windowcovering", + "deviceTypeName": "MA-windowcovering", + "deviceTypeCode": 514, + "deviceTypeProfileId": 259, + "clusters": [ + { + "name": "Identify", + "code": 3, "mfgCode": null, - "define": "WINDOW_COVERING_CLUSTER", + "define": "IDENTIFY_CLUSTER", "side": "client", "enabled": 0, "commands": [ { - "name": "UpOrOpen", + "name": "Identify", "code": 0, "mfgCode": null, "source": "client", "incoming": 1, - "outgoing": 0 - }, - { - "name": "DownOrClose", - "code": 1, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 + "outgoing": 1 }, { - "name": "StopMotion", - "code": 2, + "name": "TriggerEffect", + "code": 64, "mfgCode": null, "source": "client", "incoming": 1, - "outgoing": 0 + "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 - } - ] + "attributes": [] }, { - "name": "Window Covering", - "code": 258, + "name": "Identify", + "code": 3, "mfgCode": null, - "define": "WINDOW_COVERING_CLUSTER", + "define": "IDENTIFY_CLUSTER", "side": "server", - "enabled": 0, + "enabled": 1, "commands": [], "attributes": [ { - "name": "Type", + "name": "IdentifyTime", "code": 0, "mfgCode": null, "side": "server", - "type": "Type", + "type": "int16u", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x00", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "ConfigStatus", - "code": 7, - "mfgCode": null, - "side": "server", - "type": "ConfigStatus", - "included": 1, - "storageOption": "NVM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x03", + "defaultValue": "0x0", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "InstalledOpenLimitLift", - "code": 16, + "name": "IdentifyType", + "code": 1, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "enum8", "included": 1, - "storageOption": "NVM", + "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "0x05", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "InstalledClosedLimitLift", - "code": 17, + "name": "GeneratedCommandList", + "code": 65528, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "array", "included": 1, - "storageOption": "NVM", + "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0xFFFF", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "InstalledOpenLimitTilt", - "code": 18, + "name": "AcceptedCommandList", + "code": 65529, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "array", "included": 1, - "storageOption": "NVM", + "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "InstalledClosedLimitTilt", - "code": 19, + "name": "AttributeList", + "code": 65531, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "array", "included": 1, - "storageOption": "NVM", + "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0xFFFF", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "Mode", - "code": 23, + "name": "FeatureMap", + "code": 65532, "mfgCode": null, "side": "server", - "type": "Mode", + "type": "bitmap32", "included": 1, - "storageOption": "NVM", + "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x14", + "defaultValue": "0", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { @@ -6099,45 +6314,69 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "5", + "defaultValue": "4", "reportable": 1, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 } ] - } - ] - }, - { - "name": "MA-windowcovering", - "deviceTypeName": "MA-windowcovering", - "deviceTypeCode": 514, - "deviceTypeProfileId": 259, - "clusters": [ + }, { - "name": "Identify", - "code": 3, + "name": "Groups", + "code": 4, "mfgCode": null, - "define": "IDENTIFY_CLUSTER", + "define": "GROUPS_CLUSTER", "side": "client", "enabled": 0, "commands": [ { - "name": "Identify", + "name": "AddGroup", "code": 0, "mfgCode": null, "source": "client", "incoming": 1, - "outgoing": 0 + "outgoing": 1 }, { - "name": "TriggerEffect", - "code": 64, + "name": "ViewGroup", + "code": 1, "mfgCode": null, "source": "client", "incoming": 1, - "outgoing": 0 + "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": [ @@ -6160,202 +6399,35 @@ ] }, { - "name": "Identify", - "code": 3, + "name": "Groups", + "code": 4, "mfgCode": null, - "define": "IDENTIFY_CLUSTER", + "define": "GROUPS_CLUSTER", "side": "server", "enabled": 1, - "commands": [], - "attributes": [ + "commands": [ { - "name": "identify time", + "name": "AddGroupResponse", "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 + "source": "server", + "incoming": 1, + "outgoing": 1 }, { - "name": "identify type", + "name": "ViewGroupResponse", "code": 1, "mfgCode": null, - "side": "server", - "type": "enum8", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 + "source": "server", + "incoming": 1, + "outgoing": 1 }, { - "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": "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": "FeatureMap", - "code": 65532, - "mfgCode": null, - "side": "client", - "type": "bitmap32", - "included": 0, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "client", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "4", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "Groups", - "code": 4, - "mfgCode": null, - "define": "GROUPS_CLUSTER", - "side": "server", - "enabled": 1, - "commands": [ - { - "name": "AddGroupResponse", - "code": 0, - "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 - }, - { - "name": "ViewGroupResponse", - "code": 1, - "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 - }, - { - "name": "GetGroupMembershipResponse", - "code": 2, + "name": "GetGroupMembershipResponse", + "code": 2, "mfgCode": null, "source": "server", - "incoming": 0, + "incoming": 1, "outgoing": 1 }, { @@ -6363,13 +6435,13 @@ "code": 3, "mfgCode": null, "source": "server", - "incoming": 0, + "incoming": 1, "outgoing": 1 } ], "attributes": [ { - "name": "name support", + "name": "NameSupport", "code": 0, "mfgCode": null, "side": "server", @@ -6390,7 +6462,7 @@ "mfgCode": null, "side": "server", "type": "array", - "included": 0, + "included": 1, "storageOption": "External", "singleton": 0, "bounded": 0, @@ -6406,7 +6478,7 @@ "mfgCode": null, "side": "server", "type": "array", - "included": 0, + "included": 1, "storageOption": "External", "singleton": 0, "bounded": 0, @@ -6422,7 +6494,7 @@ "mfgCode": null, "side": "server", "type": "array", - "included": 0, + "included": 1, "storageOption": "External", "singleton": 0, "bounded": 0, @@ -6472,7 +6544,7 @@ "mfgCode": null, "define": "SCENES_CLUSTER", "side": "client", - "enabled": 1, + "enabled": 0, "commands": [ { "name": "AddScene", @@ -6535,7 +6607,7 @@ "code": 64, "mfgCode": null, "source": "client", - "incoming": 1, + "incoming": 0, "outgoing": 0 }, { @@ -6543,7 +6615,7 @@ "code": 65, "mfgCode": null, "source": "client", - "incoming": 1, + "incoming": 0, "outgoing": 0 }, { @@ -6551,27 +6623,11 @@ "code": 66, "mfgCode": null, "source": "client", - "incoming": 1, + "incoming": 0, "outgoing": 0 } ], "attributes": [ - { - "name": "FeatureMap", - "code": 65532, - "mfgCode": null, - "side": "client", - "type": "bitmap32", - "included": 0, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, { "name": "ClusterRevision", "code": 65533, @@ -6596,7 +6652,7 @@ "mfgCode": null, "define": "SCENES_CLUSTER", "side": "server", - "enabled": 0, + "enabled": 1, "commands": [ { "name": "AddSceneResponse", @@ -6674,1390 +6730,20 @@ "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": "LastConfiguredBy", - "code": 5, - "mfgCode": null, - "side": "server", - "type": "node_id", - "included": 0, - "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": "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": 0, - "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": "Descriptor", - "code": 29, - "mfgCode": null, - "define": "DESCRIPTOR_CLUSTER", - "side": "client", - "enabled": 0, - "commands": [], - "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, - "commands": [], - "attributes": [ - { - "name": "device list", - "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": "server list", - "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": "client list", - "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": "parts list", - "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", - "code": 40, - "mfgCode": null, - "define": "BASIC_CLUSTER", - "side": "client", - "enabled": 0, - "commands": [], - "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", - "code": 40, - "mfgCode": null, - "define": "BASIC_CLUSTER", - "side": "server", - "enabled": 0, - "commands": [], - "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": "Network Commissioning", - "code": 49, - "mfgCode": null, - "define": "NETWORK_COMMISSIONING_CLUSTER", - "side": "client", - "enabled": 0, - "commands": [ - { - "name": "ScanNetworks", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "AddOrUpdateWiFiNetwork", - "code": 2, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "RemoveNetwork", - "code": 4, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "ConnectNetwork", - "code": 6, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "ReorderNetwork", - "code": 8, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 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": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "Network Commissioning", - "code": 49, - "mfgCode": null, - "define": "NETWORK_COMMISSIONING_CLUSTER", - "side": "server", - "enabled": 0, - "commands": [ - { - "name": "ScanNetworksResponse", - "code": 1, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "NetworkConfigResponse", - "code": 5, - "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 - }, - { - "name": "ConnectNetworkResponse", - "code": 7, - "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 - } - ], - "attributes": [ - { - "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": "Thread Network Diagnostics", - "code": 53, - "mfgCode": null, - "define": "THREAD_NETWORK_DIAGNOSTICS_CLUSTER", - "side": "client", - "enabled": 0, - "commands": [], - "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": "Thread Network Diagnostics", - "code": 53, - "mfgCode": null, - "define": "THREAD_NETWORK_DIAGNOSTICS_CLUSTER", - "side": "server", - "enabled": 0, - "commands": [], - "attributes": [ - { - "name": "channel", - "code": 0, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "RoutingRole", - "code": 1, - "mfgCode": null, - "side": "server", - "type": "RoutingRole", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "NetworkName", - "code": 2, - "mfgCode": null, - "side": "server", - "type": "char_string", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "0", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "PanId", - "code": 3, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "ExtendedPanId", - "code": 4, - "mfgCode": null, - "side": "server", - "type": "int64u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000000000000000", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "MeshLocalPrefix", - "code": 5, - "mfgCode": null, - "side": "server", - "type": "octet_string", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "OverrunCount", - "code": 6, - "mfgCode": null, - "side": "server", - "type": "int64u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000000000000000", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "NeighborTableList", - "code": 7, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "RouteTableList", - "code": 8, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "PartitionId", - "code": 9, - "mfgCode": null, - "side": "server", - "type": "int32u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "weighting", - "code": 10, - "mfgCode": null, - "side": "server", - "type": "int8u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "DataVersion", - "code": 11, - "mfgCode": null, - "side": "server", - "type": "int8u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "StableDataVersion", - "code": 12, - "mfgCode": null, - "side": "server", - "type": "int8u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "LeaderRouterId", - "code": 13, - "mfgCode": null, - "side": "server", - "type": "int8u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "DetachedRoleCount", - "code": 14, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "ChildRoleCount", - "code": 15, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "RouterRoleCount", - "code": 16, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "LeaderRoleCount", - "code": 17, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "AttachAttemptCount", - "code": 18, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "PartitionIdChangeCount", - "code": 19, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "BetterPartitionAttachAttemptCount", - "code": 20, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "ParentChangeCount", - "code": 21, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "TxTotalCount", - "code": 22, - "mfgCode": null, - "side": "server", - "type": "int32u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "TxUnicastCount", - "code": 23, - "mfgCode": null, - "side": "server", - "type": "int32u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "TxBroadcastCount", - "code": 24, - "mfgCode": null, - "side": "server", - "type": "int32u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "TxAckRequestedCount", - "code": 25, - "mfgCode": null, - "side": "server", - "type": "int32u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "TxAckedCount", - "code": 26, - "mfgCode": null, - "side": "server", - "type": "int32u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "TxNoAckRequestedCount", - "code": 27, - "mfgCode": null, - "side": "server", - "type": "int32u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "TxDataCount", - "code": 28, - "mfgCode": null, - "side": "server", - "type": "int32u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "TxDataPollCount", - "code": 29, - "mfgCode": null, - "side": "server", - "type": "int32u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "TxBeaconCount", - "code": 30, - "mfgCode": null, - "side": "server", - "type": "int32u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "TxBeaconRequestCount", - "code": 31, - "mfgCode": null, - "side": "server", - "type": "int32u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "TxOtherCount", - "code": 32, - "mfgCode": null, - "side": "server", - "type": "int32u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "TxRetryCount", - "code": 33, - "mfgCode": null, - "side": "server", - "type": "int32u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "TxDirectMaxRetryExpiryCount", - "code": 34, - "mfgCode": null, - "side": "server", - "type": "int32u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "TxIndirectMaxRetryExpiryCount", - "code": 35, - "mfgCode": null, - "side": "server", - "type": "int32u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "TxErrCcaCount", - "code": 36, - "mfgCode": null, - "side": "server", - "type": "int32u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "0x00", "reportable": 1, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "TxErrAbortCount", - "code": 37, + "name": "CurrentGroup", + "code": 2, "mfgCode": null, "side": "server", - "type": "int32u", + "type": "group_id", "included": 1, - "storageOption": "External", + "storageOption": "RAM", "singleton": 0, "bounded": 0, "defaultValue": "0x0000", @@ -8067,344 +6753,387 @@ "reportableChange": 0 }, { - "name": "TxErrBusyChannelCount", - "code": 38, + "name": "SceneValid", + "code": 3, "mfgCode": null, "side": "server", - "type": "int32u", + "type": "boolean", "included": 1, - "storageOption": "External", + "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "0x00", "reportable": 1, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "RxTotalCount", - "code": 39, + "name": "NameSupport", + "code": 4, "mfgCode": null, "side": "server", - "type": "int32u", + "type": "bitmap8", "included": 1, - "storageOption": "External", + "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "", "reportable": 1, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "RxUnicastCount", - "code": 40, + "name": "LastConfiguredBy", + "code": 5, "mfgCode": null, "side": "server", - "type": "int32u", - "included": 1, - "storageOption": "External", + "type": "node_id", + "included": 0, + "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "RxBroadcastCount", - "code": 41, + "name": "GeneratedCommandList", + "code": 65528, "mfgCode": null, "side": "server", - "type": "int32u", + "type": "array", "included": 1, "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "RxDataCount", - "code": 42, + "name": "AcceptedCommandList", + "code": 65529, "mfgCode": null, "side": "server", - "type": "int32u", + "type": "array", "included": 1, "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "RxDataPollCount", - "code": 43, + "name": "AttributeList", + "code": 65531, "mfgCode": null, "side": "server", - "type": "int32u", + "type": "array", "included": 1, "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "RxBeaconCount", - "code": 44, + "name": "FeatureMap", + "code": 65532, "mfgCode": null, "side": "server", - "type": "int32u", + "type": "bitmap32", "included": 1, - "storageOption": "External", + "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "0", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "RxBeaconRequestCount", - "code": 45, + "name": "ClusterRevision", + "code": 65533, "mfgCode": null, "side": "server", - "type": "int32u", + "type": "int16u", "included": 1, - "storageOption": "External", + "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "4", "reportable": 1, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 - }, + } + ] + }, + { + "name": "Descriptor", + "code": 29, + "mfgCode": null, + "define": "DESCRIPTOR_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [], + "attributes": [ { - "name": "RxOtherCount", - "code": 46, + "name": "ClusterRevision", + "code": 65533, "mfgCode": null, - "side": "server", - "type": "int32u", + "side": "client", + "type": "int16u", "included": 1, - "storageOption": "External", + "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "1", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 - }, + } + ] + }, + { + "name": "Descriptor", + "code": 29, + "mfgCode": null, + "define": "DESCRIPTOR_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [], + "attributes": [ { - "name": "RxAddressFilteredCount", - "code": 47, + "name": "DeviceList", + "code": 0, "mfgCode": null, "side": "server", - "type": "int32u", + "type": "array", "included": 1, "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "RxDestAddrFilteredCount", - "code": 48, + "name": "ServerList", + "code": 1, "mfgCode": null, "side": "server", - "type": "int32u", + "type": "array", "included": 1, "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "RxDuplicatedCount", - "code": 49, + "name": "ClientList", + "code": 2, "mfgCode": null, "side": "server", - "type": "int32u", + "type": "array", "included": 1, "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "RxErrNoFrameCount", - "code": 50, + "name": "PartsList", + "code": 3, "mfgCode": null, "side": "server", - "type": "int32u", + "type": "array", "included": 1, "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "RxErrUnknownNeighborCount", - "code": 51, + "name": "GeneratedCommandList", + "code": 65528, "mfgCode": null, "side": "server", - "type": "int32u", + "type": "array", "included": 1, "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "RxErrInvalidSrcAddrCount", - "code": 52, + "name": "AcceptedCommandList", + "code": 65529, "mfgCode": null, "side": "server", - "type": "int32u", + "type": "array", "included": 1, "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "RxErrSecCount", - "code": 53, + "name": "AttributeList", + "code": 65531, "mfgCode": null, "side": "server", - "type": "int32u", + "type": "array", "included": 1, "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "RxErrFcsCount", - "code": 54, + "name": "FeatureMap", + "code": 65532, "mfgCode": null, "side": "server", - "type": "int32u", + "type": "bitmap32", "included": 1, - "storageOption": "External", + "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "0", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "RxErrOtherCount", - "code": 55, + "name": "ClusterRevision", + "code": 65533, "mfgCode": null, "side": "server", - "type": "int32u", + "type": "int16u", "included": 1, "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "1", "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, + "commands": [], + "attributes": [] + }, + { + "name": "Binding", + "code": 30, + "mfgCode": null, + "define": "BINDING_CLUSTER", + "side": "server", + "enabled": 0, + "commands": [], + "attributes": [ { - "name": "SecurityPolicy", - "code": 59, + "name": "Binding", + "code": 0, "mfgCode": null, "side": "server", - "type": "SecurityPolicy", + "type": "array", "included": 1, "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "ChannelMask", - "code": 60, + "name": "GeneratedCommandList", + "code": 65528, "mfgCode": null, "side": "server", - "type": "octet_string", + "type": "array", "included": 1, "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "OperationalDatasetComponents", - "code": 61, + "name": "AcceptedCommandList", + "code": 65529, "mfgCode": null, "side": "server", - "type": "OperationalDatasetComponents", + "type": "array", "included": 1, "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "ActiveNetworkFaultsList", - "code": 62, + "name": "AttributeList", + "code": 65531, "mfgCode": null, "side": "server", "type": "array", @@ -8414,8 +7143,8 @@ "bounded": 0, "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { @@ -8428,7 +7157,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x000F", + "defaultValue": "0", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -8446,8 +7175,8 @@ "bounded": 0, "defaultValue": "1", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 } ] @@ -8897,6 +7626,54 @@ "maxInterval": 65344, "reportableChange": 0 }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "FeatureMap", "code": 65532, @@ -8954,26 +7731,17 @@ "source": "client", "incoming": 1, "outgoing": 1 - } - ], - "attributes": [ + }, { - "name": "ClusterRevision", - "code": 65533, + "name": "TriggerEffect", + "code": 64, "mfgCode": null, - "side": "client", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "4", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 + "source": "client", + "incoming": 0, + "outgoing": 0 } - ] + ], + "attributes": [] }, { "name": "Identify", @@ -8981,11 +7749,11 @@ "mfgCode": null, "define": "IDENTIFY_CLUSTER", "side": "server", - "enabled": 0, + "enabled": 1, "commands": [], "attributes": [ { - "name": "identify time", + "name": "IdentifyTime", "code": 0, "mfgCode": null, "side": "server", @@ -8994,10 +7762,90 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "0x0", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "IdentifyType", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "enum8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x05", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { @@ -9076,22 +7924,6 @@ } ], "attributes": [ - { - "name": "FeatureMap", - "code": 65532, - "mfgCode": null, - "side": "client", - "type": "bitmap32", - "included": 0, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, { "name": "ClusterRevision", "code": 65533, @@ -9123,7 +7955,7 @@ "code": 0, "mfgCode": null, "source": "server", - "incoming": 0, + "incoming": 1, "outgoing": 1 }, { @@ -9131,7 +7963,7 @@ "code": 1, "mfgCode": null, "source": "server", - "incoming": 0, + "incoming": 1, "outgoing": 1 }, { @@ -9139,7 +7971,7 @@ "code": 2, "mfgCode": null, "source": "server", - "incoming": 0, + "incoming": 1, "outgoing": 1 }, { @@ -9147,13 +7979,13 @@ "code": 3, "mfgCode": null, "source": "server", - "incoming": 0, + "incoming": 1, "outgoing": 1 } ], "attributes": [ { - "name": "name support", + "name": "NameSupport", "code": 0, "mfgCode": null, "side": "server", @@ -9174,7 +8006,7 @@ "mfgCode": null, "side": "server", "type": "array", - "included": 0, + "included": 1, "storageOption": "External", "singleton": 0, "bounded": 0, @@ -9190,7 +8022,7 @@ "mfgCode": null, "side": "server", "type": "array", - "included": 0, + "included": 1, "storageOption": "External", "singleton": 0, "bounded": 0, @@ -9206,7 +8038,7 @@ "mfgCode": null, "side": "server", "type": "array", - "included": 0, + "included": 1, "storageOption": "External", "singleton": 0, "bounded": 0, @@ -9256,7 +8088,7 @@ "mfgCode": null, "define": "SCENES_CLUSTER", "side": "client", - "enabled": 1, + "enabled": 0, "commands": [ { "name": "AddScene", @@ -9319,7 +8151,7 @@ "code": 64, "mfgCode": null, "source": "client", - "incoming": 1, + "incoming": 0, "outgoing": 0 }, { @@ -9327,7 +8159,7 @@ "code": 65, "mfgCode": null, "source": "client", - "incoming": 1, + "incoming": 0, "outgoing": 0 }, { @@ -9335,27 +8167,11 @@ "code": 66, "mfgCode": null, "source": "client", - "incoming": 1, + "incoming": 0, "outgoing": 0 } ], "attributes": [ - { - "name": "FeatureMap", - "code": 65532, - "mfgCode": null, - "side": "client", - "type": "bitmap32", - "included": 0, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, { "name": "ClusterRevision", "code": 65533, @@ -9380,7 +8196,7 @@ "mfgCode": null, "define": "SCENES_CLUSTER", "side": "server", - "enabled": 0, + "enabled": 1, "commands": [ { "name": "AddSceneResponse", @@ -9529,110 +8345,8 @@ "reportableChange": 0 }, { - "name": "AttributeList", - "code": 65531, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "FeatureMap", - "code": 65532, - "mfgCode": null, - "side": "server", - "type": "bitmap32", - "included": 0, - "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": "Descriptor", - "code": 29, - "mfgCode": null, - "define": "DESCRIPTOR_CLUSTER", - "side": "client", - "enabled": 0, - "commands": [], - "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, - "commands": [], - "attributes": [ - { - "name": "device list", - "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": "server list", - "code": 1, + "name": "GeneratedCommandList", + "code": 65528, "mfgCode": null, "side": "server", "type": "array", @@ -9647,8 +8361,8 @@ "reportableChange": 0 }, { - "name": "client list", - "code": 2, + "name": "AcceptedCommandList", + "code": 65529, "mfgCode": null, "side": "server", "type": "array", @@ -9663,8 +8377,8 @@ "reportableChange": 0 }, { - "name": "parts list", - "code": 3, + "name": "AttributeList", + "code": 65531, "mfgCode": null, "side": "server", "type": "array", @@ -9701,22 +8415,22 @@ "side": "server", "type": "int16u", "included": 1, - "storageOption": "External", + "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "1", + "defaultValue": "4", "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, + "minInterval": 0, + "maxInterval": 65344, "reportableChange": 0 } ] }, { - "name": "Basic", - "code": 40, + "name": "Descriptor", + "code": 29, "mfgCode": null, - "define": "BASIC_CLUSTER", + "define": "DESCRIPTOR_CLUSTER", "side": "client", "enabled": 0, "commands": [], @@ -9729,340 +8443,265 @@ "type": "int16u", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, "defaultValue": "1", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 } ] }, { - "name": "Basic", - "code": 40, + "name": "Descriptor", + "code": 29, "mfgCode": null, - "define": "BASIC_CLUSTER", + "define": "DESCRIPTOR_CLUSTER", "side": "server", - "enabled": 0, - "commands": [], - "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 - }, + "enabled": 1, + "commands": [], + "attributes": [ { - "name": "Location", - "code": 6, + "name": "DeviceList", + "code": 0, "mfgCode": null, "side": "server", - "type": "char_string", + "type": "array", "included": 1, "storageOption": "External", - "singleton": 1, + "singleton": 0, "bounded": 0, - "defaultValue": "XX", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "HardwareVersion", - "code": 7, + "name": "ServerList", + "code": 1, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "array", "included": 1, "storageOption": "External", - "singleton": 1, + "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "HardwareVersionString", - "code": 8, + "name": "ClientList", + "code": 2, "mfgCode": null, "side": "server", - "type": "char_string", + "type": "array", "included": 1, "storageOption": "External", - "singleton": 1, + "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "SoftwareVersion", - "code": 9, + "name": "PartsList", + "code": 3, "mfgCode": null, "side": "server", - "type": "int32u", + "type": "array", "included": 1, "storageOption": "External", - "singleton": 1, + "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "SoftwareVersionString", - "code": 10, + "name": "GeneratedCommandList", + "code": 65528, "mfgCode": null, "side": "server", - "type": "char_string", + "type": "array", "included": 1, "storageOption": "External", - "singleton": 1, + "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "ManufacturingDate", - "code": 11, + "name": "AcceptedCommandList", + "code": 65529, "mfgCode": null, "side": "server", - "type": "char_string", + "type": "array", "included": 1, "storageOption": "External", - "singleton": 1, + "singleton": 0, "bounded": 0, - "defaultValue": "20210614123456ZZ", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "PartNumber", - "code": 12, + "name": "AttributeList", + "code": 65531, "mfgCode": null, "side": "server", - "type": "char_string", + "type": "array", "included": 1, "storageOption": "External", - "singleton": 1, + "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "ProductURL", - "code": 13, + "name": "FeatureMap", + "code": 65532, "mfgCode": null, "side": "server", - "type": "long_char_string", + "type": "bitmap32", "included": 1, - "storageOption": "External", - "singleton": 1, + "storageOption": "RAM", + "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "0", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "ProductLabel", - "code": 14, + "name": "ClusterRevision", + "code": 65533, "mfgCode": null, "side": "server", - "type": "char_string", + "type": "int16u", "included": 1, "storageOption": "External", - "singleton": 1, + "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "1", "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, + "commands": [], + "attributes": [] + }, + { + "name": "Binding", + "code": 30, + "mfgCode": null, + "define": "BINDING_CLUSTER", + "side": "server", + "enabled": 0, + "commands": [], + "attributes": [ { - "name": "SerialNumber", - "code": 15, + "name": "Binding", + "code": 0, "mfgCode": null, "side": "server", - "type": "char_string", + "type": "array", "included": 1, "storageOption": "External", - "singleton": 1, + "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "LocalConfigDisabled", - "code": 16, + "name": "GeneratedCommandList", + "code": 65528, "mfgCode": null, "side": "server", - "type": "boolean", + "type": "array", "included": 1, - "storageOption": "NVM", - "singleton": 1, + "storageOption": "External", + "singleton": 0, "bounded": 0, - "defaultValue": "0", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "Reachable", - "code": 17, + "name": "AcceptedCommandList", + "code": 65529, "mfgCode": null, "side": "server", - "type": "boolean", + "type": "array", "included": 1, - "storageOption": "RAM", - "singleton": 1, + "storageOption": "External", + "singleton": 0, "bounded": 0, - "defaultValue": "1", + "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "UniqueID", - "code": 18, + "name": "AttributeList", + "code": 65531, "mfgCode": null, "side": "server", - "type": "char_string", + "type": "array", "included": 1, "storageOption": "External", - "singleton": 1, + "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 }, { - "name": "CapabilityMinima", - "code": 19, + "name": "FeatureMap", + "code": 65532, "mfgCode": null, "side": "server", - "type": "CapabilityMinimaStruct", + "type": "bitmap32", "included": 1, - "storageOption": "External", + "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "0", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -10076,12 +8715,12 @@ "type": "int16u", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, "defaultValue": "1", "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, + "minInterval": 1, + "maxInterval": 65534, "reportableChange": 0 } ] @@ -10531,6 +9170,54 @@ "maxInterval": 65344, "reportableChange": 0 }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "FeatureMap", "code": 65532, diff --git a/examples/window-app/efr32/BUILD.gn b/examples/window-app/efr32/BUILD.gn index d829fa9d15116b..c526f50cbf9204 100644 --- a/examples/window-app/efr32/BUILD.gn +++ b/examples/window-app/efr32/BUILD.gn @@ -278,6 +278,11 @@ efr32_executable("window_app") { "-Wl,SILABS_WIFI=1", ] } + + # Attestation Credentials + if (chip_build_platform_attestation_credentials_provider) { + deps += [ "${examples_plat_dir}:efr32-attestation-credentials" ] + } } group("efr32") { diff --git a/examples/window-app/efr32/src/main.cpp b/examples/window-app/efr32/src/main.cpp index eef12ddf99371d..41cc1bac8f4e87 100644 --- a/examples/window-app/efr32/src/main.cpp +++ b/examples/window-app/efr32/src/main.cpp @@ -25,10 +25,17 @@ #include "sl_system_kernel.h" #include #include +#include #include +#ifdef EFR32_ATTESTATION_CREDENTIALS +#include +#else +#include +#endif #define BLE_DEV_NAME "Silabs-Window" using namespace ::chip::DeviceLayer; +using namespace ::chip::Credentials; #define UNUSED_PARAMETER(a) (a = a) @@ -54,6 +61,12 @@ int main(void) EFR32_LOG("Starting App"); chip::DeviceLayer::PlatformMgr().LockChipStack(); err = app.Init(); + // Initialize device attestation config +#ifdef EFR32_ATTESTATION_CREDENTIALS + SetDeviceAttestationCredentialsProvider(EFR32::GetEFR32DacProvider()); +#else + SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); +#endif chip::DeviceLayer::PlatformMgr().UnlockChipStack(); if (err != CHIP_NO_ERROR) diff --git a/integrations/cloudbuild/build-all.yaml b/integrations/cloudbuild/build-all.yaml index 869a1a5c371ae0..044253e57eb63b 100644 --- a/integrations/cloudbuild/build-all.yaml +++ b/integrations/cloudbuild/build-all.yaml @@ -1,5 +1,5 @@ steps: - - name: "connectedhomeip/chip-build-vscode:0.5.79" + - name: "connectedhomeip/chip-build-vscode:0.5.84" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -12,14 +12,14 @@ steps: path: /pwenv timeout: 900s - - name: "connectedhomeip/chip-build-vscode:0.5.79" + - name: "connectedhomeip/chip-build-vscode:0.5.84" env: - PW_ENVIRONMENT_ROOT=/pwenv args: - >- ./scripts/build/build_examples.py --enable-flashbundle --target-glob '*' --skip-target-glob - '{tizen-*,*-tests,*-chip-test}' build --create-archives + '{tizen-*,*-tests*,*-chip-test}' build --create-archives /workspace/artifacts/ id: CompileAll waitFor: @@ -43,4 +43,4 @@ artifacts: # slow. options: machineType: "E2_HIGHCPU_32" - diskSizeGb: 200 + diskSizeGb: 500 diff --git a/integrations/cloudbuild/chef.yaml b/integrations/cloudbuild/chef.yaml index 3d0d22900b0f5c..83bd2d971ccb81 100644 --- a/integrations/cloudbuild/chef.yaml +++ b/integrations/cloudbuild/chef.yaml @@ -1,5 +1,5 @@ steps: - - name: "connectedhomeip/chip-build-vscode:0.5.79" + - name: "connectedhomeip/chip-build-vscode:0.5.84" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -12,7 +12,7 @@ steps: path: /pwenv timeout: 900s - - name: "connectedhomeip/chip-build-vscode:0.5.79" + - name: "connectedhomeip/chip-build-vscode:0.5.84" env: - PW_ENVIRONMENT_ROOT=/pwenv args: diff --git a/integrations/cloudbuild/smoke-test.yaml b/integrations/cloudbuild/smoke-test.yaml index 2101356729c7c5..46c7bc7ab9ccf6 100644 --- a/integrations/cloudbuild/smoke-test.yaml +++ b/integrations/cloudbuild/smoke-test.yaml @@ -1,5 +1,5 @@ steps: - - name: "connectedhomeip/chip-build-vscode:0.5.79" + - name: "connectedhomeip/chip-build-vscode:0.5.84" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -12,7 +12,7 @@ steps: path: /pwenv timeout: 900s - - name: "connectedhomeip/chip-build-vscode:0.5.79" + - name: "connectedhomeip/chip-build-vscode:0.5.84" id: ESP32 env: - PW_ENVIRONMENT_ROOT=/pwenv @@ -28,7 +28,7 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.5.79" + - name: "connectedhomeip/chip-build-vscode:0.5.84" id: NRFConnect env: - PW_ENVIRONMENT_ROOT=/pwenv @@ -45,7 +45,7 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.5.79" + - name: "connectedhomeip/chip-build-vscode:0.5.84" id: EFR32 env: - PW_ENVIRONMENT_ROOT=/pwenv @@ -62,14 +62,14 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.5.79" + - name: "connectedhomeip/chip-build-vscode:0.5.84" id: Linux env: - PW_ENVIRONMENT_ROOT=/pwenv args: - >- ./scripts/build/build_examples.py --enable-flashbundle - --target-glob 'linux-*' --skip-target-glob '*-tests' build + --target-glob 'linux-*' --skip-target-glob '*-tests*' build --create-archives /workspace/artifacts/ waitFor: - Bootstrap @@ -79,7 +79,7 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.5.79" + - name: "connectedhomeip/chip-build-vscode:0.5.84" id: Android env: - PW_ENVIRONMENT_ROOT=/pwenv @@ -110,4 +110,4 @@ artifacts: # building instead of docker download/checkout/bootstrap) options: machineType: "E2_HIGHCPU_32" - diskSizeGb: 200 + diskSizeGb: 500 diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index 04486da645a944..cc43e37e3989ee 100644 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -270,6 +270,7 @@ def HostTargets(): builder.AppendVariant(name="ipv6only", enable_ipv4=False), builder.AppendVariant(name="no-ble", enable_ble=False), builder.AppendVariant(name="no-wifi", enable_wifi=False), + builder.AppendVariant(name="no-thread", enable_thread=False), builder.AppendVariant(name="tsan", conflicts=['asan'], use_tsan=True), builder.AppendVariant(name="asan", conflicts=['tsan'], use_asan=True), builder.AppendVariant(name="libfuzzer", requires=[ @@ -277,7 +278,6 @@ def HostTargets(): builder.AppendVariant(name="clang", use_clang=True), builder.AppendVariant(name="test", extra_tests=True), - builder.WhitelistVariantNameForGlob('no-interactive-ipv6only') builder.WhitelistVariantNameForGlob('ipv6only') for target in app_targets: @@ -288,12 +288,7 @@ def HostTargets(): builder.targets.append(target) for target in builder.AllVariants(): - if cross_compile and 'chip-tool' in target.name and 'arm64' in target.name and '-no-interactive' not in target.name: - # Interactive builds will not compile by default on arm cross compiles - # because libreadline is not part of the default sysroot - yield target.GlobBlacklist('Arm crosscompile does not support libreadline-dev') - else: - yield target + yield target # Without extra build variants yield target_native.Extend('chip-cert', app=HostApp.CERT_TOOL) @@ -305,9 +300,14 @@ def HostTargets(): yield target_native.Extend('address-resolve-tool-platform-mdns-ipv6only', app=HostApp.ADDRESS_RESOLVE, use_platform_mdns=True, enable_ipv4=False).GlobBlacklist("Reduce default build variants") + nodeps_args = dict(enable_ipv4=False, enable_ble=False, enable_wifi=False, enable_thread=False) + yield target_native.Extend('chip-tool-nodeps', app=HostApp.CHIP_TOOL, **nodeps_args) + yield target_native.Extend('all-clusters-app-nodeps', app=HostApp.ALL_CLUSTERS, **nodeps_args) + test_target = Target(HostBoard.NATIVE.PlatformName(), HostBuilder) - for board in [HostBoard.NATIVE, HostBoard.FAKE]: - yield test_target.Extend(board.BoardName() + '-tests', board=board, app=HostApp.TESTS) + yield test_target.Extend(HostBoard.NATIVE.BoardName() + '-tests', board=HostBoard.NATIVE, app=HostApp.TESTS) + yield test_target.Extend(HostBoard.NATIVE.BoardName() + '-tests-clang', board=HostBoard.NATIVE, app=HostApp.TESTS, use_clang=True) + yield test_target.Extend(HostBoard.FAKE.BoardName() + '-tests', board=HostBoard.FAKE, app=HostApp.TESTS) def Esp32Targets(): @@ -412,7 +412,7 @@ def NrfTargets(): ] # Enable nrf52840dongle for all-clusters and lighting app only - yield target.Extend('nrf52840dongle-all-clusters', board=NrfBoard.NRF52840DONGLE, app=NrfApp.ALL_CLUSTERS) + yield target.Extend('nrf52840dongle-all-clusters', board=NrfBoard.NRF52840DONGLE, app=NrfApp.ALL_CLUSTERS).GlobBlacklist('Out of flash when linking') yield target.Extend('nrf52840dongle-all-clusters-minimal', board=NrfBoard.NRF52840DONGLE, app=NrfApp.ALL_CLUSTERS_MINIMAL) yield target.Extend('nrf52840dongle-light', board=NrfBoard.NRF52840DONGLE, app=NrfApp.LIGHT) diff --git a/scripts/build/builders/host.py b/scripts/build/builders/host.py index 765e9bcb17e1d3..1f487259ca2972 100644 --- a/scripts/build/builders/host.py +++ b/scripts/build/builders/host.py @@ -192,9 +192,11 @@ def PlatformName(self): class HostBuilder(GnBuilder): - def __init__(self, root, runner, app: HostApp, board=HostBoard.NATIVE, enable_ipv4=True, - enable_ble=True, enable_wifi=True, use_tsan=False, use_asan=False, separate_event_loop=True, - use_libfuzzer=False, use_clang=False, interactive_mode=True, extra_tests=False, + def __init__(self, root, runner, app: HostApp, board=HostBoard.NATIVE, + enable_ipv4=True, enable_ble=True, enable_wifi=True, + enable_thread=True, use_tsan=False, use_asan=False, + separate_event_loop=True, use_libfuzzer=False, use_clang=False, + interactive_mode=True, extra_tests=False, use_platform_mdns=False, enable_rpcs=False): super(HostBuilder, self).__init__( root=os.path.join(root, 'examples', app.ExamplePath()), @@ -216,6 +218,9 @@ def __init__(self, root, runner, app: HostApp, board=HostBoard.NATIVE, enable_ip if not enable_wifi: self.extra_gn_options.append('chip_enable_wifi=false') + if not enable_thread: + self.extra_gn_options.append('chip_enable_openthread=false') + if use_tsan: self.extra_gn_options.append('is_tsan=true') @@ -234,6 +239,11 @@ def __init__(self, root, runner, app: HostApp, board=HostBoard.NATIVE, enable_ip if use_clang: self.extra_gn_options.append('is_clang=true') + if self.board == HostBoard.FAKE: + # Fake uses "//build/toolchain/fake:fake_x64_gcc" + # so setting clang is not correct + raise Exception('Fake host board is always gcc (not clang)') + if use_platform_mdns: self.extra_gn_options.append('chip_mdns="platform"') diff --git a/scripts/build/testdata/all_targets_except_host.txt b/scripts/build/testdata/all_targets_except_host.txt index 4611cdeacd917b..082430b019ac39 100644 --- a/scripts/build/testdata/all_targets_except_host.txt +++ b/scripts/build/testdata/all_targets_except_host.txt @@ -214,7 +214,7 @@ nrf-nrf52840dk-lock nrf-nrf52840dk-pump nrf-nrf52840dk-pump-controller nrf-nrf52840dk-shell -nrf-nrf52840dongle-all-clusters +nrf-nrf52840dongle-all-clusters (NOGLOB: Out of flash when linking) nrf-nrf52840dongle-all-clusters-minimal nrf-nrf52840dongle-light nrf-nrf5340dk-all-clusters diff --git a/scripts/build/testdata/build_linux_on_x64.txt b/scripts/build/testdata/build_linux_on_x64.txt index 15cb6388a0ca6f..6633aab1c72dbc 100644 --- a/scripts/build/testdata/build_linux_on_x64.txt +++ b/scripts/build/testdata/build_linux_on_x64.txt @@ -31,10 +31,15 @@ bash -c ' PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \ gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/bridge-app/linux '"'"'--args=chip_inet_config_enable_ipv4=false target_cpu="arm64" is_clang=true chip_crypto="mbedtls" sysroot="SYSROOT_AARCH64"'"'"' {out}/linux-arm64-bridge-ipv6only' -# Generating linux-arm64-chip-tool-no-interactive-ipv6only +# Generating linux-arm64-chip-tool bash -c ' PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \ - gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/chip-tool '"'"'--args=chip_inet_config_enable_ipv4=false config_use_interactive_mode=false target_cpu="arm64" is_clang=true chip_crypto="mbedtls" sysroot="SYSROOT_AARCH64"'"'"' {out}/linux-arm64-chip-tool-no-interactive-ipv6only' + gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/chip-tool '"'"'--args=target_cpu="arm64" is_clang=true chip_crypto="mbedtls" sysroot="SYSROOT_AARCH64"'"'"' {out}/linux-arm64-chip-tool' + +# Generating linux-arm64-chip-tool-ipv6only +bash -c ' +PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \ + gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/chip-tool '"'"'--args=chip_inet_config_enable_ipv4=false target_cpu="arm64" is_clang=true chip_crypto="mbedtls" sysroot="SYSROOT_AARCH64"'"'"' {out}/linux-arm64-chip-tool-ipv6only' # Generating linux-arm64-light bash -c ' @@ -150,6 +155,9 @@ gn gen --check --fail-on-unused-args --export-compile-commands --root={root} {ou # Generating linux-x64-all-clusters gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/all-clusters-app/linux {out}/linux-x64-all-clusters +# Generating linux-x64-all-clusters-app-nodeps +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/all-clusters-app/linux '--args=chip_inet_config_enable_ipv4=false chip_config_network_layer_ble=false chip_enable_wifi=false chip_enable_openthread=false' {out}/linux-x64-all-clusters-app-nodeps + # Generating linux-x64-all-clusters-ipv6only gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/all-clusters-app/linux --args=chip_inet_config_enable_ipv4=false {out}/linux-x64-all-clusters-ipv6only @@ -174,8 +182,8 @@ gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/exa # Generating linux-x64-chip-tool-ipv6only gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/chip-tool --args=chip_inet_config_enable_ipv4=false {out}/linux-x64-chip-tool-ipv6only -# Generating linux-x64-chip-tool-no-interactive-ipv6only -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/chip-tool '--args=chip_inet_config_enable_ipv4=false config_use_interactive_mode=false' {out}/linux-x64-chip-tool-no-interactive-ipv6only +# Generating linux-x64-chip-tool-nodeps +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/chip-tool '--args=chip_inet_config_enable_ipv4=false chip_config_network_layer_ble=false chip_enable_wifi=false chip_enable_openthread=false' {out}/linux-x64-chip-tool-nodeps # Generating linux-x64-light gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/linux {out}/linux-x64-light @@ -231,6 +239,9 @@ gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/exa # Generating linux-x64-tests gn gen --check --fail-on-unused-args --export-compile-commands --root={root} --args=chip_build_tests=true {out}/linux-x64-tests +# Generating linux-x64-tests-clang +gn gen --check --fail-on-unused-args --export-compile-commands --root={root} '--args=is_clang=true chip_build_tests=true' {out}/linux-x64-tests-clang + # Generating linux-x64-thermostat gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/thermostat/linux {out}/linux-x64-thermostat @@ -267,8 +278,11 @@ ninja -C {out}/linux-arm64-bridge # Building linux-arm64-bridge-ipv6only ninja -C {out}/linux-arm64-bridge-ipv6only -# Building linux-arm64-chip-tool-no-interactive-ipv6only -ninja -C {out}/linux-arm64-chip-tool-no-interactive-ipv6only +# Building linux-arm64-chip-tool +ninja -C {out}/linux-arm64-chip-tool + +# Building linux-arm64-chip-tool-ipv6only +ninja -C {out}/linux-arm64-chip-tool-ipv6only # Building linux-arm64-light ninja -C {out}/linux-arm64-light @@ -342,6 +356,9 @@ ninja -C {out}/linux-x64-address-resolve-tool src/lib/address_resolve:address-re # Building linux-x64-all-clusters ninja -C {out}/linux-x64-all-clusters +# Building linux-x64-all-clusters-app-nodeps +ninja -C {out}/linux-x64-all-clusters-app-nodeps + # Building linux-x64-all-clusters-ipv6only ninja -C {out}/linux-x64-all-clusters-ipv6only @@ -366,8 +383,8 @@ ninja -C {out}/linux-x64-chip-tool # Building linux-x64-chip-tool-ipv6only ninja -C {out}/linux-x64-chip-tool-ipv6only -# Building linux-x64-chip-tool-no-interactive-ipv6only -ninja -C {out}/linux-x64-chip-tool-no-interactive-ipv6only +# Building linux-x64-chip-tool-nodeps +ninja -C {out}/linux-x64-chip-tool-nodeps # Building linux-x64-light ninja -C {out}/linux-x64-light @@ -423,6 +440,9 @@ ninja -C {out}/linux-x64-shell-ipv6only # Building linux-x64-tests ninja -C {out}/linux-x64-tests check +# Building linux-x64-tests-clang +ninja -C {out}/linux-x64-tests-clang check + # Building linux-x64-thermostat ninja -C {out}/linux-x64-thermostat diff --git a/scripts/build/testdata/glob_star_targets_except_host.txt b/scripts/build/testdata/glob_star_targets_except_host.txt index 94dce9283947eb..e8bcb0bf1568d2 100644 --- a/scripts/build/testdata/glob_star_targets_except_host.txt +++ b/scripts/build/testdata/glob_star_targets_except_host.txt @@ -94,7 +94,6 @@ nrf-nrf52840dk-lock nrf-nrf52840dk-pump nrf-nrf52840dk-pump-controller nrf-nrf52840dk-shell -nrf-nrf52840dongle-all-clusters nrf-nrf52840dongle-all-clusters-minimal nrf-nrf52840dongle-light nrf-nrf5340dk-all-clusters diff --git a/scripts/constraints.txt b/scripts/constraints.txt index 37921989b47417..e0d1d1323d4f36 100644 --- a/scripts/constraints.txt +++ b/scripts/constraints.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile +# This file is autogenerated by pip-compile with python 3.10 # To update, run: # # pip-compile --output-file=constraints.txt requirements.txt @@ -14,10 +14,12 @@ appdirs==1.4.4 appnope==0.1.2 # via -r requirements.txt attrs==21.2.0 - # via pytest + # via + # jsonschema + # pytest backcall==0.2.0 # via ipython -beautifulsoup4==4.10.0 +beautifulsoup4==4.11.1 # via mbed-os-tools bitstring==3.1.7 # via -r requirements.esp32.txt @@ -33,23 +35,31 @@ cffi==1.14.5 # via cryptography chardet==4.0.0 # via requests -click==7.1.2 +click==8.1.3 # via # -r requirements.esp32.txt # -r requirements.txt # flask - # mbed-tools + # idf-component-manager # pip-tools colorama==0.4.4 # via + # -r requirements.txt + # idf-component-manager # mbed-os-tools # west coloredlogs==15.0.1 # via -r requirements.txt construct==2.10.54 # via -r requirements.esp32.txt +contextlib2==21.6.0 + # via + # idf-component-manager + # schema cryptography==3.4.7 - # via -r requirements.esp32.txt + # via + # -r requirements.esp32.txt + # -r requirements.txt cxxfilt==0.2.2 # via -r requirements.txt dbus-python==1.2.16 ; sys_platform == "linux" @@ -64,22 +74,23 @@ ecdsa==0.17.0 # via -r requirements.esp32.txt fastcore==1.3.26 # via ghapi -fasteners==0.16.3 +fasteners==0.17.3 # via mbed-os-tools filelock==3.0.12 # via virtualenv -flask-compress==1.10.0 - # via gdbgui -flask-socketio==2.9.6 - # via gdbgui flask==0.12.5 # via # flask-compress # flask-socketio # gdbgui +flask-compress==1.10.0 + # via gdbgui +flask-socketio==2.9.6 + # via gdbgui future==0.18.2 # via # -r requirements.esp32.txt + # idf-component-manager # mbed-os-tools # mobly gdbgui==0.13.2.0 @@ -88,14 +99,16 @@ gevent==1.5.0 # via gdbgui ghapi==0.1.19 # via -r requirements.txt -gitdb==4.0.7 +gitdb==4.0.9 # via gitpython -gitpython==3.1.14 - # via mbed-tools +gitpython==3.1.27 ; platform_machine != "aarch64" and sys_platform == "linux" + # via -r requirements.mbed.txt greenlet==1.1.0 # via gevent humanfriendly==9.2 # via coloredlogs +idf-component-manager==1.1.4 + # via -r requirements.esp32.txt idna==2.10 # via requests iniconfig==1.1.1 @@ -104,31 +117,31 @@ intelhex==2.3.0 # via # -r requirements.txt # mbed-os-tools -ipython-genutils==0.2.0 - # via traitlets ipython==7.24.1 # via -r requirements.txt +ipython-genutils==0.2.0 + # via traitlets itsdangerous==2.0.1 # via flask jedi==0.18.0 # via ipython jinja2==3.0.1 - # via - # flask - # mbed-tools + # via flask jsonschema==4.4.0 # via -r requirements.txt junit-xml==1.9 # via mbed-os-tools kconfiglib==13.7.1 # via -r requirements.esp32.txt +lark==1.1.2 + # via -r requirements.txt lockfile==0.12.2 # via # -r requirements.txt # mbed-os-tools -mako==1.1.4 +mako==1.2.1 # via pdoc3 -markdown==3.3.4 +markdown==3.3.7 # via pdoc3 markupsafe==2.0.1 # via @@ -138,13 +151,11 @@ matplotlib-inline==0.1.2 # via ipython mbed-ls==1.8.11 ; platform_machine != "aarch64" and sys_platform == "linux" # via -r requirements.mbed.txt -mbed-os-tools==1.8.11 +mbed-os-tools==1.8.13 # via mbed-ls -mbed-tools==7.49.1 ; platform_machine != "aarch64" and sys_platform == "linux" - # via -r requirements.mbed.txt mobly==1.10.1 # via -r requirements.txt -numpy>=1.22 +numpy==1.23.0 # via pandas packaging==20.9 # via @@ -156,8 +167,8 @@ pandas==1.4.3 ; platform_machine != "aarch64" and platform_machine != "arm64" # via -r requirements.txt parso==0.8.2 # via jedi -pdoc3==0.9.2 - # via mbed-tools +pdoc3==0.10.0 ; platform_machine != "aarch64" and sys_platform == "linux" + # via -r requirements.mbed.txt pep517==0.10.0 # via pip-tools pexpect==4.8.0 @@ -174,7 +185,7 @@ portpicker==1.4.0 # via # -r requirements.txt # mobly -prettytable==2.2.1 +prettytable==2.5.0 # via # mbed-ls # mbed-os-tools @@ -185,11 +196,10 @@ protobuf==3.17.3 psutil==5.8.0 # via # -r requirements.txt - # mbed-tools # mobly ptyprocess==0.7.0 # via pexpect -py==1.10.0 +py==1.11.0 # via pytest pycparser==2.20 # via cffi @@ -209,11 +219,12 @@ pyparsing==2.3.1 # via # -r requirements.esp32.txt # packaging +pyrsistent==0.18.1 + # via jsonschema pyserial==3.5 # via # -r requirements.esp32.txt # mbed-os-tools - # mbed-tools # mobly pytest==6.2.5 ; platform_machine != "aarch64" and sys_platform == "linux" # via -r requirements.mbed.txt @@ -221,8 +232,8 @@ python-dateutil==2.8.1 # via # pandas # pykwalify -python-dotenv==0.17.1 - # via mbed-tools +python-dotenv==0.20.0 ; platform_machine != "aarch64" and sys_platform == "linux" + # via -r requirements.mbed.txt python-engineio==3.14.2 # via python-socketio python-socketio==4.6.1 @@ -231,10 +242,11 @@ python-socketio==4.6.1 # flask-socketio pytz==2021.1 # via pandas -pyudev==0.22.0 - # via mbed-tools +pyudev==0.23.2 ; platform_machine != "aarch64" and sys_platform == "linux" + # via -r requirements.mbed.txt pyyaml==5.4.1 # via + # idf-component-manager # mobly # west reedsolo==1.5.4 @@ -242,17 +254,20 @@ reedsolo==1.5.4 requests==2.25.1 # via # -r requirements.txt + # idf-component-manager # mbed-os-tools - # mbed-tools -ruamel.yaml.clib==0.2.2 - # via ruamel.yaml -ruamel.yaml==0.17.9 + # requests-toolbelt +requests-toolbelt==0.9.1 + # via idf-component-manager +ruamel-yaml==0.17.9 # via pykwalify +schema==0.7.5 + # via idf-component-manager six==1.16.0 # via # anytree # ecdsa - # fasteners + # idf-component-manager # junit-xml # mbed-os-tools # protobuf @@ -261,26 +276,30 @@ six==1.16.0 # python-socketio # pyudev # virtualenv -smmap==4.0.0 +smmap==5.0.0 # via gitdb -soupsieve==2.2.1 +soupsieve==2.3.2.post1 # via beautifulsoup4 -tabulate==0.8.9 - # via mbed-tools +stringcase==1.2.0 + # via -r requirements.txt +tabulate==0.8.10 + # via -r requirements.txt timeout-decorator==0.5.0 # via mobly toml==0.10.2 # via # pep517 # pytest +tornado==6.1 + # via -r requirements.txt tqdm==4.61.1 - # via mbed-tools + # via idf-component-manager traitlets==5.0.5 # via # ipython # matplotlib-inline -typing-extensions==3.10.0.0 - # via mbed-tools +typing-extensions==4.3.0 ; platform_machine != "aarch64" and sys_platform == "linux" + # via -r requirements.mbed.txt urllib3==1.26.5 # via requests virtualenv==20.4.7 @@ -297,7 +316,6 @@ west==0.12.0 # via -r requirements.txt wheel==0.36.2 # via -r requirements.txt -tornado==6.1 # The following packages are considered to be unsafe in a requirements file: # pip diff --git a/scripts/examples/gn_bl602_example.sh b/scripts/examples/gn_bl602_example.sh index 9b6d02b3927b3f..3bd72ca563fbcc 100755 --- a/scripts/examples/gn_bl602_example.sh +++ b/scripts/examples/gn_bl602_example.sh @@ -17,27 +17,37 @@ # set -e -# Build script for GN BL602 examples GitHub workflow. + +BL602_BOARD=BL-HWC-G1 + +# Build script for GN examples GitHub workflow. + +MATTER_ROOT=$(dirname "$0")/../../ + source "$(dirname "$0")/../../scripts/activate.sh" -set -x -env +USAGE="./scripts/examples/gn_bl602_example.sh example_dir output_dir" + +if [ $# -lt 2 ]; then + echo "Usage: $USAGE" + exit 1 +fi -# Build steps -EXAMPLE_DIR=$1 +EXAMPLE_DIR=examples/$1/bouffalolab/bl602/ +shift +OUTPUT_DIR=$1 shift -OUTPUT_DIR=out/example_app -BL602_BOARD=BL-HWC-G1 -MATTER_BL_ROOT=$PWD -export BL602_SDK_ROOT="$MATTER_BL_ROOT"/third_party/bouffalolab/bl602_sdk/repo -export PATH="$BL602_SDK_ROOT/toolchain/riscv/Linux/bin:$PATH" -if [[ ! -z "$1" ]]; then - OUTPUT_DIR=$1 - shift +export BL_IOT_SDK_PATH="$MATTER_ROOT"/third_party/bouffalolab/bl602_sdk/repo + +if [[ "$OSTYPE" == "linux-gnu"* ]]; then + export PATH="$BL_IOT_SDK_PATH/toolchain/riscv/Linux/bin:$PATH" +elif [[ "$OSTYPE" == "darwin"* ]]; then + export PATH="$BL_IOT_SDK_PATH/toolchain/riscv/Darwin/bin:$PATH" fi GN_ARGS=() + NINJA_ARGS=() for arg; do @@ -58,6 +68,6 @@ for arg; do esac done -#gn clean out/lighting_app_bl602 -gn gen "$OUTPUT_DIR" --root="$EXAMPLE_DIR" --args="${GN_ARGS[*]}" +gn gen --fail-on-unused-args --root="$EXAMPLE_DIR" "$OUTPUT_DIR" --args="${GN_ARGS[*]}" + ninja -C "$OUTPUT_DIR" "${NINJA_ARGS[@]}" diff --git a/scripts/idl/generators/java/ChipClustersCpp.jinja b/scripts/idl/generators/java/ChipClustersCpp.jinja index d32f20c9f40c4d..be46bfcce5eef8 100644 --- a/scripts/idl/generators/java/ChipClustersCpp.jinja +++ b/scripts/idl/generators/java/ChipClustersCpp.jinja @@ -113,9 +113,8 @@ using namespace chip::Controller; JNI_METHOD(jlong, {{cluster.name | capitalcase}}Cluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - {{cluster.name | capitalcase}}Cluster * cppCluster = new {{cluster.name | capitalcase}}Cluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + DeviceProxy * device = reinterpret_cast(devicePtr); + {{cluster.name | capitalcase}}Cluster * cppCluster = new {{cluster.name | capitalcase}}Cluster(*device->GetExchangeManager(), device->GetSecureSession().Value(), endpointId); return reinterpret_cast(cppCluster); } @@ -210,4 +209,4 @@ JNI_METHOD(void, {{cluster.name}}Cluster, subscribe{{attr.definition.name | capi } {%- endif -%} -{% endfor %} \ No newline at end of file +{% endfor %} diff --git a/scripts/idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp b/scripts/idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp index a166279b925079..1b1b091ef91d2b 100644 --- a/scripts/idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp +++ b/scripts/idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp @@ -27,9 +27,8 @@ using namespace chip::Controller; JNI_METHOD(jlong, DemoClusterCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - DemoClusterCluster * cppCluster = new DemoClusterCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + DeviceProxy * device = reinterpret_cast(devicePtr); + DemoClusterCluster * cppCluster = new DemoClusterCluster(*device->GetExchangeManager(), device->GetSecureSession().Value(), endpointId); return reinterpret_cast(cppCluster); } diff --git a/scripts/idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp b/scripts/idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp index 6dbcef98b2173f..cc3f8d87d5790a 100644 --- a/scripts/idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp +++ b/scripts/idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp @@ -27,9 +27,8 @@ using namespace chip::Controller; JNI_METHOD(jlong, DemoClusterCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - DemoClusterCluster * cppCluster = new DemoClusterCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + DeviceProxy * device = reinterpret_cast(devicePtr); + DemoClusterCluster * cppCluster = new DemoClusterCluster(*device->GetExchangeManager(), device->GetSecureSession().Value(), endpointId); return reinterpret_cast(cppCluster); } diff --git a/scripts/idl/tests/outputs/optional_argument/jni/MyClusterClient-InvokeSubscribeImpl.cpp b/scripts/idl/tests/outputs/optional_argument/jni/MyClusterClient-InvokeSubscribeImpl.cpp index 7c63c12f242f00..e984b0bd176753 100644 --- a/scripts/idl/tests/outputs/optional_argument/jni/MyClusterClient-InvokeSubscribeImpl.cpp +++ b/scripts/idl/tests/outputs/optional_argument/jni/MyClusterClient-InvokeSubscribeImpl.cpp @@ -27,9 +27,8 @@ using namespace chip::Controller; JNI_METHOD(jlong, MyClusterCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - MyClusterCluster * cppCluster = new MyClusterCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + DeviceProxy * device = reinterpret_cast(devicePtr); + MyClusterCluster * cppCluster = new MyClusterCluster(*device->GetExchangeManager(), device->GetSecureSession().Value(), endpointId); return reinterpret_cast(cppCluster); } diff --git a/scripts/idl/tests/outputs/several_clusters/jni/FirstClient-InvokeSubscribeImpl.cpp b/scripts/idl/tests/outputs/several_clusters/jni/FirstClient-InvokeSubscribeImpl.cpp index ffebaf6a9d6569..1837cc6de068c8 100644 --- a/scripts/idl/tests/outputs/several_clusters/jni/FirstClient-InvokeSubscribeImpl.cpp +++ b/scripts/idl/tests/outputs/several_clusters/jni/FirstClient-InvokeSubscribeImpl.cpp @@ -27,9 +27,8 @@ using namespace chip::Controller; JNI_METHOD(jlong, FirstCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - FirstCluster * cppCluster = new FirstCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + DeviceProxy * device = reinterpret_cast(devicePtr); + FirstCluster * cppCluster = new FirstCluster(*device->GetExchangeManager(), device->GetSecureSession().Value(), endpointId); return reinterpret_cast(cppCluster); } diff --git a/scripts/idl/tests/outputs/several_clusters/jni/SecondClient-InvokeSubscribeImpl.cpp b/scripts/idl/tests/outputs/several_clusters/jni/SecondClient-InvokeSubscribeImpl.cpp index f58cc9867f6017..22d4d2ed55aae6 100644 --- a/scripts/idl/tests/outputs/several_clusters/jni/SecondClient-InvokeSubscribeImpl.cpp +++ b/scripts/idl/tests/outputs/several_clusters/jni/SecondClient-InvokeSubscribeImpl.cpp @@ -27,9 +27,8 @@ using namespace chip::Controller; JNI_METHOD(jlong, SecondCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - SecondCluster * cppCluster = new SecondCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + DeviceProxy * device = reinterpret_cast(devicePtr); + SecondCluster * cppCluster = new SecondCluster(*device->GetExchangeManager(), device->GetSecureSession().Value(), endpointId); return reinterpret_cast(cppCluster); } diff --git a/scripts/idl/tests/outputs/several_clusters/jni/ThirdClient-InvokeSubscribeImpl.cpp b/scripts/idl/tests/outputs/several_clusters/jni/ThirdClient-InvokeSubscribeImpl.cpp index 0711447fb05fb9..0e3f87807203b4 100644 --- a/scripts/idl/tests/outputs/several_clusters/jni/ThirdClient-InvokeSubscribeImpl.cpp +++ b/scripts/idl/tests/outputs/several_clusters/jni/ThirdClient-InvokeSubscribeImpl.cpp @@ -27,9 +27,8 @@ using namespace chip::Controller; JNI_METHOD(jlong, ThirdCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - ThirdCluster * cppCluster = new ThirdCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + DeviceProxy * device = reinterpret_cast(devicePtr); + ThirdCluster * cppCluster = new ThirdCluster(*device->GetExchangeManager(), device->GetSecureSession().Value(), endpointId); return reinterpret_cast(cppCluster); } diff --git a/scripts/idl/tests/outputs/simple_attribute/jni/MyClusterClient-InvokeSubscribeImpl.cpp b/scripts/idl/tests/outputs/simple_attribute/jni/MyClusterClient-InvokeSubscribeImpl.cpp index 147e5f51d663d0..88f214f58b716a 100644 --- a/scripts/idl/tests/outputs/simple_attribute/jni/MyClusterClient-InvokeSubscribeImpl.cpp +++ b/scripts/idl/tests/outputs/simple_attribute/jni/MyClusterClient-InvokeSubscribeImpl.cpp @@ -27,9 +27,8 @@ using namespace chip::Controller; JNI_METHOD(jlong, MyClusterCluster, initWithDevice)(JNIEnv * env, jobject self, jlong devicePtr, jint endpointId) { chip::DeviceLayer::StackLock lock; - MyClusterCluster * cppCluster = new MyClusterCluster(); - - cppCluster->Associate(reinterpret_cast(devicePtr), endpointId); + DeviceProxy * device = reinterpret_cast(devicePtr); + MyClusterCluster * cppCluster = new MyClusterCluster(*device->GetExchangeManager(), device->GetSecureSession().Value(), endpointId); return reinterpret_cast(cppCluster); } diff --git a/scripts/requirements.mbed.txt b/scripts/requirements.mbed.txt index 557c64af524fed..ba352d47418d90 100644 --- a/scripts/requirements.mbed.txt +++ b/scripts/requirements.mbed.txt @@ -1,3 +1,8 @@ -mbed-tools>=7.49.1 ; platform_machine != 'aarch64' and sys_platform == 'linux' +#mbed-tools>=7.49.1 ; platform_machine != 'aarch64' and sys_platform == 'linux' pytest==6.2.5 ; platform_machine != 'aarch64' and sys_platform == 'linux' mbed-ls==1.8.11 ; platform_machine != 'aarch64' and sys_platform == 'linux' +pdoc3 ; platform_machine != 'aarch64' and sys_platform == 'linux' +gitpython ; platform_machine != 'aarch64' and sys_platform == 'linux' +python-dotenv ; platform_machine != 'aarch64' and sys_platform == 'linux' +pyudev ; platform_machine != 'aarch64' and sys_platform == 'linux' +typing-extensions ; platform_machine != 'aarch64' and sys_platform == 'linux' diff --git a/scripts/requirements.txt b/scripts/requirements.txt index 8dddef9c01fe63..abbc8778cfb725 100644 --- a/scripts/requirements.txt +++ b/scripts/requirements.txt @@ -46,6 +46,7 @@ anytree cxxfilt ghapi pandas ; platform_machine != 'aarch64' and platform_machine != 'arm64' +tabulate # scripts/build click diff --git a/scripts/tests/chiptest/__init__.py b/scripts/tests/chiptest/__init__.py index cb80b46021cbb9..806a6a462de8d7 100644 --- a/scripts/tests/chiptest/__init__.py +++ b/scripts/tests/chiptest/__init__.py @@ -21,32 +21,34 @@ def target_for_name(name: str): - if name.startswith('TV_') or name.startswith('Test_TC_MC_'): + if name.startswith("TV_") or name.startswith("Test_TC_MC_"): return TestTarget.TV - if name.startswith('DL_') or name.startswith('Test_TC_DL_'): + if name.startswith("DL_") or name.startswith("Test_TC_DLRK_"): return TestTarget.LOCK - if name.startswith('OTA_'): + if name.startswith("OTA_"): return TestTarget.OTA return TestTarget.ALL_CLUSTERS def tests_with_command(chip_tool: str, is_manual: bool): """Executes `chip_tool` binary to see what tests are available, using cmd - to get the list. + to get the list. """ - cmd = 'list' + cmd = "list" if is_manual: - cmd += '-manual' + cmd += "-manual" - result = subprocess.run([chip_tool, 'tests', cmd], capture_output=True) + result = subprocess.run([chip_tool, "tests", cmd], capture_output=True) - for name in result.stdout.decode('utf8').split('\n'): + for name in result.stdout.decode("utf8").split("\n"): if not name: continue target = target_for_name(name) - yield TestDefinition(run_name=name, name=name, target=target, is_manual=is_manual) + yield TestDefinition( + run_name=name, name=name, target=target, is_manual=is_manual + ) def AllTests(chip_tool: str): @@ -58,6 +60,10 @@ def AllTests(chip_tool: str): __all__ = [ - 'TestTarget', 'TestDefinition', 'AllTests', 'ApplicationPaths', - 'linux', 'runner', + "TestTarget", + "TestDefinition", + "AllTests", + "ApplicationPaths", + "linux", + "runner", ] diff --git a/scripts/tools/check_includes_config.py b/scripts/tools/check_includes_config.py index 5f74d1e64adce8..2dffe78715f760 100644 --- a/scripts/tools/check_includes_config.py +++ b/scripts/tools/check_includes_config.py @@ -106,6 +106,8 @@ # Not intended for embedded clients (#11705). 'src/app/ClusterStateCache.h': {'list', 'map', 'set', 'vector', 'queue'}, 'src/app/BufferedReadCallback.h': {'vector'}, + 'src/lib/support/IniEscaping.cpp': {'string'}, + 'src/lib/support/IniEscaping.h': {'string'}, # Itself in DENY. 'src/lib/support/CHIPListUtils.h': {'set'}, diff --git a/scripts/tools/generate_esp32_chip_factory_bin.py b/scripts/tools/generate_esp32_chip_factory_bin.py index 51f3f37c38fece..76975d706317af 100755 --- a/scripts/tools/generate_esp32_chip_factory_bin.py +++ b/scripts/tools/generate_esp32_chip_factory_bin.py @@ -41,6 +41,105 @@ TOOLS = {} +FACTORY_DATA = { + # CommissionableDataProvider + 'discriminator': { + 'type': 'data', + 'encoding': 'u32', + 'value': None, + }, + 'iteration-count': { + 'type': 'data', + 'encoding': 'u32', + 'value': None, + }, + 'salt': { + 'type': 'data', + 'encoding': 'string', + 'value': None, + }, + 'verifier': { + 'type': 'data', + 'encoding': 'string', + 'value': None, + }, + + # CommissionableDataProvider + 'dac-cert': { + 'type': 'file', + 'encoding': 'binary', + 'value': None, + }, + 'dac-key': { + 'type': 'file', + 'encoding': 'binary', + 'value': None, + }, + 'dac-pub-key': { + 'type': 'file', + 'encoding': 'binary', + 'value': None, + }, + 'pai-cert': { + 'type': 'file', + 'encoding': 'binary', + 'value': None, + }, + 'cert-dclrn': { + 'type': 'file', + 'encoding': 'binary', + 'value': None, + }, + + # DeviceInstanceInforProvider + 'vendor-id': { + 'type': 'data', + 'encoding': 'u32', + 'value': None, + }, + 'vendor-name': { + 'type': 'data', + 'encoding': 'string', + 'value': None, + }, + 'product-id': { + 'type': 'data', + 'encoding': 'u32', + 'value': None, + }, + 'product-name': { + 'type': 'data', + 'encoding': 'string', + 'value': None, + }, + 'serial-num': { + 'type': 'data', + 'encoding': 'string', + 'value': None, + }, + 'hardware-ver': { + 'type': 'data', + 'encoding': 'u32', + 'value': None, + }, + 'hw-ver-str': { + 'type': 'data', + 'encoding': 'string', + 'value': None, + }, + 'mfg-date': { + 'type': 'data', + 'encoding': 'string', + 'value': None, + }, + 'unique-id': { + 'type': 'data', + 'encoding': 'hex2bin', + 'value': None, + } +} + + def check_tools_exists(): TOOLS['spake2p'] = shutil.which('spake2p') if TOOLS['spake2p'] is None: @@ -48,6 +147,18 @@ def check_tools_exists(): sys.exit(1) +def check_str_range(s, min_len, max_len, name): + if s and ((len(s) < min_len) or (len(s) > max_len)): + logging.error('%s must be between %d and %d characters', name, min_len, max_len) + sys.exit(1) + + +def check_int_range(value, min_value, max_value, name): + if value and ((value < min_value) or (value > max_value)): + logging.error('%s is out of range, should be in range [%d, %d]', name, min_value, max_value) + sys.exit(1) + + def validate_args(args): # Validate the passcode if args.passcode is not None: @@ -55,10 +166,17 @@ def validate_args(args): logging.error('Invalid passcode:' + str(args.passcode)) sys.exit(1) - # Validate the discriminator - if (args.discriminator is not None) and (args.discriminator not in range(0x0000, 0x0FFF)): - logging.error('Invalid discriminator:' + str(args.discriminator)) - sys.exit(1) + check_int_range(args.discriminator, 0x0000, 0x0FFF, 'Discriminator') + check_int_range(args.product_id, 0x0000, 0xFFFF, 'Product id') + check_int_range(args.vendor_id, 0x0000, 0xFFFF, 'Vendor id') + check_int_range(args.hw_ver, 0x0000, 0xFFFF, 'Hardware version') + + check_str_range(args.serial_num, 1, 32, 'Serial number') + check_str_range(args.vendor_name, 1, 32, 'Vendor name') + check_str_range(args.product_name, 1, 32, 'Product name') + check_str_range(args.hw_ver_str, 1, 64, 'Hardware version string') + check_str_range(args.mfg_date, 8, 16, 'Manufacturing date') + check_str_range(args.unique_id, 32, 32, 'Unique id') logging.info('Discriminator:{} Passcode:{}'.format(args.discriminator, args.passcode)) @@ -80,6 +198,37 @@ def gen_spake2p_params(passcode): return dict(zip(output[0].split(','), output[1].split(','))) +def populate_factory_data(args, spake2p_params): + FACTORY_DATA['discriminator']['value'] = args.discriminator + FACTORY_DATA['iteration-count']['value'] = spake2p_params['Iteration Count'] + FACTORY_DATA['salt']['value'] = spake2p_params['Salt'] + FACTORY_DATA['verifier']['value'] = spake2p_params['Verifier'] + FACTORY_DATA['dac-cert']['value'] = os.path.abspath(args.dac_cert) + FACTORY_DATA['pai-cert']['value'] = os.path.abspath(args.pai_cert) + FACTORY_DATA['cert-dclrn']['value'] = os.path.abspath(args.cd) + FACTORY_DATA['dac-key']['value'] = os.path.abspath('dac_raw_privkey.bin') + FACTORY_DATA['dac-pub-key']['value'] = os.path.abspath('dac_raw_pubkey.bin') + + if args.serial_num is not None: + FACTORY_DATA['serial-num']['value'] = args.serial_num + if args.unique_id is not None: + FACTORY_DATA['unique-id']['value'] = args.unique_id + if args.mfg_date is not None: + FACTORY_DATA['mfg-date']['value'] = args.mfg_date + if args.vendor_id is not None: + FACTORY_DATA['vendor-id']['value'] = args.vendor_id + if args.vendor_name is not None: + FACTORY_DATA['vendor-name']['value'] = args.vendor_name + if args.product_id is not None: + FACTORY_DATA['product-id']['value'] = args.product_id + if args.product_name is not None: + FACTORY_DATA['product-name']['value'] = args.product_name + if args.hw_ver is not None: + FACTORY_DATA['hardware-ver']['value'] = args.hw_ver + if (args.hw_ver_str is not None): + FACTORY_DATA['hw-ver-str']['value'] = args.hw_ver_str + + def gen_raw_ec_keypair_from_der(key_file, pubkey_raw_file, privkey_raw_file): with open(key_file, 'rb') as f: key_data = f.read() @@ -104,24 +253,14 @@ def gen_raw_ec_keypair_from_der(key_file, pubkey_raw_file, privkey_raw_file): f.write(public_number_y.to_bytes(32, byteorder='big')) -def generate_nvs_bin(args, spake2p_params): - dac_raw_privkey = 'dac_raw_privkey.bin' - dac_raw_pubkey = 'dac_raw_pubkey.bin' - gen_raw_ec_keypair_from_der(args.dac_key, dac_raw_pubkey, dac_raw_privkey) - +def generate_nvs_bin(args): csv_content = 'key,type,encoding,value\n' csv_content += 'chip-factory,namespace,,\n' - csv_content += 'discriminator,data,u32,{}\n'.format(args.discriminator) - csv_content += 'iteration-count,data,u32,{}\n'.format(spake2p_params['Iteration Count']) - csv_content += 'salt,data,string,{}\n'.format(spake2p_params['Salt']) - csv_content += 'verifier,data,string,{}\n'.format(spake2p_params['Verifier']) - - csv_content += 'dac-cert,file,binary,{}\n'.format(os.path.abspath(args.dac_cert)) - csv_content += 'dac-key,file,binary,{}\n'.format(os.path.abspath(dac_raw_privkey)) - csv_content += 'dac-pub-key,file,binary,{}\n'.format(os.path.abspath(dac_raw_pubkey)) - csv_content += 'pai-cert,file,binary,{}\n'.format(os.path.abspath(args.pai_cert)) - csv_content += 'cert-dclrn,file,binary,{}\n'.format(os.path.abspath(args.cd)) + for k, v in FACTORY_DATA.items(): + if v['value'] is None: + continue + csv_content += f"{k},{v['type']},{v['encoding']},{v['value']}\n" with open('nvs_partition.csv', 'w') as f: f.write(csv_content) @@ -134,10 +273,6 @@ def generate_nvs_bin(args, spake2p_params): nvs_partition_gen.generate(nvs_args) - os.remove('nvs_partition.csv') - os.remove(dac_raw_privkey) - os.remove(dac_raw_pubkey) - def print_flashing_help(): logging.info('To flash the generated partition.bin, run the following command:') @@ -147,15 +282,24 @@ def print_flashing_help(): logging.info('default \"nvs\" partition addr is 0x9000') +def clean_up(): + os.remove('nvs_partition.csv') + os.remove(FACTORY_DATA['dac-pub-key']['value']) + os.remove(FACTORY_DATA['dac-key']['value']) + + def main(): def any_base_int(s): return int(s, 0) parser = argparse.ArgumentParser(description='Chip Factory NVS binary generator tool') + # These will be used by CommissionalbeDataProvider parser.add_argument('-p', '--passcode', type=any_base_int, required=True, - help='The discriminator for pairing, range: 0x01-0x5F5E0FE') + help='The setup passcode for pairing, range: 0x01-0x5F5E0FE') parser.add_argument('-d', '--discriminator', type=any_base_int, required=True, - help='The passcode for pairing, range: 0x00-0x0FFF') + help='The discriminator for pairing, range: 0x00-0x0FFF') + + # These will be used by DeviceAttestationCredentialsProvider parser.add_argument('--dac-cert', type=str, required=True, help='The path to the DAC certificate in der format') parser.add_argument('--dac-key', type=str, required=True, @@ -164,6 +308,19 @@ def any_base_int(s): return int(s, 0) help='The path to the PAI certificate in der format') parser.add_argument('--cd', type=str, required=True, help='The path to the certificate declaration der format') + + # These will be used by DeviceInstanceInfoProvider + parser.add_argument('--vendor-id', type=any_base_int, required=False, help='Vendor id') + parser.add_argument('--vendor-name', type=str, required=False, help='Vendor name') + parser.add_argument('--product-id', type=any_base_int, required=False, help='Product id') + parser.add_argument('--product-name', type=str, required=False, help='Product name') + parser.add_argument('--hw-ver', type=any_base_int, required=False, help='Hardware version') + parser.add_argument('--hw-ver-str', type=str, required=False, help='Hardware version string') + parser.add_argument('--mfg-date', type=str, required=False, help='Manufacturing date in format YYYY-MM-DD') + parser.add_argument('--serial-num', type=str, required=False, help='Serial number') + parser.add_argument('--unique-id', type=str, required=False, + help='128-bit unique identifier, provide 32-byte hex string, e.g. "1234567890abcdef1234567890abcdef"') + parser.add_argument('-s', '--size', type=any_base_int, required=False, default=0x6000, help='The size of the partition.bin, default: 0x6000') @@ -171,8 +328,11 @@ def any_base_int(s): return int(s, 0) validate_args(args) check_tools_exists() spake2p_params = gen_spake2p_params(args.passcode) - generate_nvs_bin(args, spake2p_params) + populate_factory_data(args, spake2p_params) + gen_raw_ec_keypair_from_der(args.dac_key, FACTORY_DATA['dac-pub-key']['value'], FACTORY_DATA['dac-key']['value']) + generate_nvs_bin(args) print_flashing_help() + clean_up() if __name__ == "__main__": diff --git a/src/android/CHIPTool/.idea/runConfigurations.xml b/src/android/CHIPTool/.idea/runConfigurations.xml deleted file mode 100644 index 7f68460d8b38ac..00000000000000 --- a/src/android/CHIPTool/.idea/runConfigurations.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/WildcardFragment.kt b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/WildcardFragment.kt index d17bff19d2e1ab..063e8886f310a3 100644 --- a/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/WildcardFragment.kt +++ b/src/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/WildcardFragment.kt @@ -13,8 +13,11 @@ import androidx.lifecycle.lifecycleScope import chip.devicecontroller.ChipDeviceController import chip.devicecontroller.ChipIdLookup import chip.devicecontroller.ReportCallback +import chip.devicecontroller.ReportEventCallback +import chip.devicecontroller.ResubscriptionAttemptCallback import chip.devicecontroller.SubscriptionEstablishedCallback import chip.devicecontroller.model.ChipAttributePath +import chip.devicecontroller.model.ChipEventPath import chip.devicecontroller.model.ChipPathId import chip.devicecontroller.model.NodeState import com.google.chip.chiptool.ChipClient @@ -23,9 +26,12 @@ import java.lang.StringBuilder import kotlinx.android.synthetic.main.wildcard_fragment.attributeIdEd import kotlinx.android.synthetic.main.wildcard_fragment.clusterIdEd import kotlinx.android.synthetic.main.wildcard_fragment.endpointIdEd +import kotlinx.android.synthetic.main.wildcard_fragment.eventIdEd import kotlinx.android.synthetic.main.wildcard_fragment.outputTv import kotlinx.android.synthetic.main.wildcard_fragment.view.readBtn +import kotlinx.android.synthetic.main.wildcard_fragment.view.readEventBtn import kotlinx.android.synthetic.main.wildcard_fragment.view.subscribeBtn +import kotlinx.android.synthetic.main.wildcard_fragment.view.subscribeEventBtn import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch @@ -49,6 +55,28 @@ class WildcardFragment : Fragment() { Log.i(TAG, debugString) requireActivity().runOnUiThread { outputTv.text = debugString } } + + override fun onDone() { + Log.i(TAG, "wildcard report Done") + } + } + + private val reportEventCallback = object : ReportEventCallback { + override fun onError(eventPath: ChipEventPath, ex: Exception) { + Log.e(TAG, "Report error for $eventPath: $ex") + } + + override fun onReport(nodeState: NodeState) { + Log.i(TAG, "Received wildcard report") + + val debugString = nodeStateToDebugString(nodeState) + Log.i(TAG, debugString) + requireActivity().runOnUiThread { outputTv.text = debugString } + } + + override fun onDone() { + Log.i(TAG, "wildcard report Done") + } } override fun onCreateView( @@ -58,8 +86,10 @@ class WildcardFragment : Fragment() { ): View { scope = viewLifecycleOwner.lifecycleScope return inflater.inflate(R.layout.wildcard_fragment, container, false).apply { - subscribeBtn.setOnClickListener { scope.launch { showSubscribeDialog() } } - readBtn.setOnClickListener { scope.launch { read() } } + subscribeBtn.setOnClickListener { scope.launch { showSubscribeDialog(ATTRIBUTE) } } + readBtn.setOnClickListener { scope.launch { read(ATTRIBUTE) } } + subscribeEventBtn.setOnClickListener { scope.launch { showSubscribeDialog(EVENT) } } + readEventBtn.setOnClickListener { scope.launch { read(EVENT) } } addressUpdateFragment = childFragmentManager.findFragmentById(R.id.addressUpdateFragment) as AddressUpdateFragment @@ -76,6 +106,10 @@ class WildcardFragment : Fragment() { val attributeName = ChipIdLookup.attributeIdToName(clusterId, attributeId) stringBuilder.append("\t\t$attributeName: ${attributeState.value}\n") } + clusterState.eventStates.forEach { (eventId, eventState) -> + val eventName = ChipIdLookup.eventIdToName(clusterId, eventId) + stringBuilder.append("\t\t$eventName: ${eventState.value}\n") + } stringBuilder.append("\t}\n") } stringBuilder.append("}\n") @@ -83,37 +117,63 @@ class WildcardFragment : Fragment() { return stringBuilder.toString() } - private suspend fun subscribe(minInterval: Int, maxInterval: Int) { + private suspend fun subscribe(type: Int, minInterval: Int, maxInterval: Int) { val subscriptionEstablishedCallback = SubscriptionEstablishedCallback { Log.i(TAG, "Subscription to device established") } + val resubscriptionAttemptCallback = + ResubscriptionAttemptCallback { terminationCause, nextResubscribeIntervalMsec + -> Log.i(TAG, "ResubscriptionAttempt terminationCause:$terminationCause, nextResubscribeIntervalMsec:$nextResubscribeIntervalMsec") } + val endpointId = getChipPathIdForText(endpointIdEd.text.toString()) val clusterId = getChipPathIdForText(clusterIdEd.text.toString()) val attributeId = getChipPathIdForText(attributeIdEd.text.toString()) - val attributePath = ChipAttributePath.newInstance(endpointId, clusterId, attributeId) - - deviceController.subscribeToPath(subscriptionEstablishedCallback, - reportCallback, - ChipClient.getConnectedDevicePointer(requireContext(), - addressUpdateFragment.deviceId), - listOf(attributePath), - minInterval, - maxInterval) + val eventId = getChipPathIdForText(eventIdEd.text.toString()) + + if (type == ATTRIBUTE) { + val attributePath = ChipAttributePath.newInstance(endpointId, clusterId, attributeId) + deviceController.subscribeToPath(subscriptionEstablishedCallback, + reportCallback, + ChipClient.getConnectedDevicePointer(requireContext(), + addressUpdateFragment.deviceId), + listOf(attributePath), + minInterval, + maxInterval) + } else if (type == EVENT) { + val eventPath = ChipEventPath.newInstance(endpointId, clusterId, eventId) + deviceController.subscribeToEventPath(subscriptionEstablishedCallback, + resubscriptionAttemptCallback, + reportEventCallback, + ChipClient.getConnectedDevicePointer(requireContext(), + addressUpdateFragment.deviceId), + listOf(eventPath), + minInterval, + maxInterval) + } } - private suspend fun read() { + private suspend fun read(type: Int) { val endpointId = getChipPathIdForText(endpointIdEd.text.toString()) val clusterId = getChipPathIdForText(clusterIdEd.text.toString()) val attributeId = getChipPathIdForText(attributeIdEd.text.toString()) - val attributePath = ChipAttributePath.newInstance(endpointId, clusterId, attributeId) - - deviceController.readPath(reportCallback, - ChipClient.getConnectedDevicePointer(requireContext(), - addressUpdateFragment.deviceId), - listOf(attributePath)) + val eventId = getChipPathIdForText(eventIdEd.text.toString()) + + if (type == ATTRIBUTE) { + val attributePath = ChipAttributePath.newInstance(endpointId, clusterId, attributeId) + deviceController.readPath(reportCallback, + ChipClient.getConnectedDevicePointer(requireContext(), + addressUpdateFragment.deviceId), + listOf(attributePath)) + } else if (type == EVENT) { + val eventPath = ChipEventPath.newInstance(endpointId, clusterId, eventId) + deviceController.readEventPath(reportEventCallback, + ChipClient.getConnectedDevicePointer(requireContext(), + addressUpdateFragment.deviceId), + listOf(eventPath)) + } } - private fun showSubscribeDialog() { + private fun showSubscribeDialog(type: Int) { val dialogView = requireActivity().layoutInflater.inflate(R.layout.subscribe_dialog, null) val dialog = AlertDialog.Builder(requireContext()).apply { setView(dialogView) @@ -123,7 +183,7 @@ class WildcardFragment : Fragment() { val maxIntervalEd = dialogView.findViewById(R.id.maxIntervalEd) dialogView.findViewById