diff --git a/.flake8 b/.flake8 index c53238a9262656..65b1c2a93da0e8 100644 --- a/.flake8 +++ b/.flake8 @@ -3,55 +3,4 @@ max-line-length = 132 exclude = third_party .* out/* - scripts/idl/* ./examples/common/QRCode/* - # temporarily scan only directories with fixed files - # TODO: Remove the paths below when all bugs are fixed - src/tools/chip-cert/* - build/chip/java/tests/* - build/chip/linux/* - build/config/linux/* - credentials/fetch-paa-certs-from-dcl.py - docs/_extensions/external_content.py - examples/common/pigweed/rpc_console/py/chip_rpc/console.py - examples/lighting-app/python/lighting.py - scripts/build/build/target.py - scripts/build/build/targets.py - scripts/build/builders/android.py - scripts/build/builders/bouffalolab.py - scripts/build/builders/cc13x2x7_26x2x7.py - scripts/build/builders/genio.py - scripts/build/builders/gn.py - scripts/build/builders/imx.py - scripts/build/builders/infineon.py - scripts/codegen.py - scripts/codepregen.py - scripts/error_table.py - scripts/examples/gn_to_cmakelists.py - scripts/flashing/bouffalolab_firmware_utils.py - scripts/flashing/cyw30739_firmware_utils.py - scripts/gen_chip_version.py - scripts/helpers/bloat_check.py - scripts/pregenerate/using_codegen.py - scripts/pregenerate/using_zap.py - scripts/run-clang-tidy-on-compile-commands.py - scripts/tools/check_zcl_file_sync.py - scripts/tools/convert_ini.py - scripts/tools/memory/memdf/__init__.py - scripts/tools/memory/report_summary.py - scripts/tools/silabs/FactoryDataProvider.py - scripts/tools/zap/generate.py - scripts/tools/zap/prune_outputs.py - scripts/tools/zap/version_update.py - scripts/tools/zap/zap_download.py - scripts/tools/zap_convert_all.py - src/app/ota_image_tool.py - src/app/zap_cluster_list.py - src/controller/python/chip/yaml/__init__.py - src/controller/python/chip/yaml/format_converter.py - src/controller/python/chip/yaml/runner.py - src/controller/python/py_matter_yamltest_repl_adapter/matter_yamltest_repl_adapter/runner.py - src/lib/asn1/gen_asn1oid.py - src/pybindings/pycontroller/build-chip-wheel.py - src/pybindings/pycontroller/pychip/__init__.py - src/setup_payload/python/generate_setup_payload.py diff --git a/.github/ISSUE_TEMPLATE/091-cert-blocker.yaml b/.github/ISSUE_TEMPLATE/091-cert-blocker.yaml index d0d6aa6f90b307..659135117d1938 100644 --- a/.github/ISSUE_TEMPLATE/091-cert-blocker.yaml +++ b/.github/ISSUE_TEMPLATE/091-cert-blocker.yaml @@ -1,12 +1,46 @@ -name: "\U0001F4DC Cert Blocker" -description: Create a report to identify matter certification blockers -title: "[CERT-BLOCKER] " +name: "\U0001F4DC Test Case Failure / Cert Blocker" +description: Create a report to identify matter certification test failures +title: "[CERT-TEST-FAILURE] " labels: [bug, "cert blocker", "needs triage"] body: - type: markdown attributes: value: | Thanks for reporting an issue against the Matter SDK! We need information about the cert blocker to follow up, so please help us out by filling out this information. + - type: dropdown + attributes: + label: Feature Area + description: What feature area is the test failing in? + multiple: true + options: + - Area:AirPurifiers + - Area:AirQualitySensor + - Area:ConcentrationMeasurement + - Area:DeviceAppearance + - Area:Dishwashers + - Area:DoorLockEnhancements + - Area:EventList + - Area:ICDPhase2 + - Area:ModeSelect + - Area:OperationalState + - Area:Refrigerators + - Area:RobotVacuums + - Area:RoomAirConditioner + - Area:Scenes + - Area:SmokeCO2 + - Area:TemperatureControlledCabinet + - Area:TimeSync + - Other + validations: + required: true + - type: input + id: testcase + attributes: + label: Test Case + description: "Which test case is failing?" + placeholder: "TC-XXXX" + validations: + required: true - type: textarea id: repro attributes: @@ -60,12 +94,6 @@ body: - core validations: required: true - - type: input - id: platform-versions - attributes: - label: Platform Version(s) - description: "What platform version(s) are affected [optional]" - placeholder: "eg: 1.2.1, N/A" - type: textarea attributes: label: Anything else? @@ -77,4 +105,4 @@ body: required: false - type: markdown attributes: - value: "Thanks for submitting a cert blocker!" + value: "Thanks for submitting a test case/cert blocker!" diff --git a/.github/ISSUE_TEMPLATE/097-ci-test-failure.yaml b/.github/ISSUE_TEMPLATE/097-ci-test-failure.yaml new file mode 100644 index 00000000000000..a99f5a6361715d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/097-ci-test-failure.yaml @@ -0,0 +1,59 @@ +name: "\U0001F6E0 Test Issue" +description: Test issue +title: "[Test Failed] " +labels: ["build issue", "needs triage", "tests"] +body: + - type: markdown + attributes: + value: | + Thanks for reporting an issue against the Matter SDK's tests! We need information about the bug report to follow up, so please help us out by filling out this information. + - type: textarea + id: repro + attributes: + label: Test issue(s) + description: "What are the tests that failed? Please include links to failed jobs if possible." + value: | + 1. + 2. + 3. + ... + validations: + required: true + - type: dropdown + attributes: + label: Platform + description: What platforms are affected? + multiple: true + options: + - ameba + - android + - cc13x2_cc26x2 + - darwin + - efr32 + - esp32 + - freeRTOS + - IMX8 + - k32w + - nrf connect + - nrf + - python + - raspi + - vscode + - windows + - other + - core (please add to version below) + - all + validations: + required: false + - type: textarea + attributes: + label: Anything else? + description: | + Links? References? Anything that will give us more context about the issue you are encountering! + + Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in. + validations: + required: false + - type: markdown + attributes: + value: "Thanks for helping improve our tests" diff --git a/.github/actions/perform-codeql-analysis/action.yaml b/.github/actions/perform-codeql-analysis/action.yaml index ff63a60665f08c..af12a9e716ee61 100644 --- a/.github/actions/perform-codeql-analysis/action.yaml +++ b/.github/actions/perform-codeql-analysis/action.yaml @@ -8,14 +8,12 @@ runs: using: "composite" steps: - name: Perform CodeQL Analysis - if: ${{ inputs.run-codeql }} uses: github/codeql-action/analyze@v2 with: category: "/language:${{ inputs.language }}" upload: False output: sarif-results - name: filter-sarif - if: ${{ inputs.run-codeql }} uses: advanced-security/filter-sarif@v1 with: patterns: | @@ -25,12 +23,10 @@ runs: output: "sarif-results/${{ inputs.language }}.sarif" - name: Upload SARIF - if: ${{ inputs.run-codeql }} uses: github/codeql-action/upload-sarif@v2 with: sarif_file: "sarif-results/${{ inputs.language }}.sarif" - name: Upload loc as a Build Artifact - if: ${{ inputs.run-codeql }} uses: actions/upload-artifact@v2.2.0 with: name: sarif-results diff --git a/.github/issue-labeler.yml b/.github/issue-labeler.yml new file mode 100644 index 00000000000000..b4b6f70c8ada15 --- /dev/null +++ b/.github/issue-labeler.yml @@ -0,0 +1,43 @@ +darwin: + - "(ios|homepod|darwin|mac|macos)" + +linux: + - "(linux)" + +# Special Keywords for Cert Blockers +air purifiers: + - "(Area:AirPurifiers)" +air quality sensors: + - "(Area:AirQualitySensor)" +concentration measurement: + - "(Area:ConcentrationMeasurement)" +device appearance: + - "(Area:DeviceAppearance)" +dishwashers: + - "(Area:Dishwashers)" +door lock enhancements: + - "(Area:DoorLockEnhancements)" +event list: + - "(Area;EventList)" +icd: + - "(Area:ICDPhase2)" +icd phase 2: + - "(Area:ICDPhase2)" +mode select: + - "(Area:ModeSelect)" +operational state: + - "(Area:OperationalState)" +refrigerators: + - "(Area:Refrigerators)" +robot vacuums: + - "(Area:RobotVacuums)" +room air conditioners: + - "(Area:RoomAirConditioner)" +scenes: + - "(Area:Scenes)" +smoke & c02: + - "(Area:SmokeCO2)" +temperature controlled cabinet: + - "(Area:TemperatureControlledCabinet)" +time sync: + - "(Area:TimeSync)" diff --git a/.github/workflows/cherry-picks.yaml b/.github/workflows/cherry-picks.yaml index 0fd7802dc461f4..d7ef371214f890 100644 --- a/.github/workflows/cherry-picks.yaml +++ b/.github/workflows/cherry-picks.yaml @@ -20,7 +20,7 @@ jobs: ) steps: - name: Checkout - uses: actions/checkout@v3.5.2 + uses: actions/checkout@v3 with: fetch-depth: 0 - name: Cherry-Pick into sve branch diff --git a/.github/workflows/darwin.yaml b/.github/workflows/darwin.yaml index 27e850824bc2c1..1db7aa8a082846 100644 --- a/.github/workflows/darwin.yaml +++ b/.github/workflows/darwin.yaml @@ -80,10 +80,7 @@ jobs: # Disable -Wunguarded-availability-new because we internally use # APIs we added after our deployment target version. Maybe we # should change the deployment target version instead? - # - # Disable BLE because the app does not have the permission to use - # it and that may crash the CI. - run: xcodebuild -target "Matter" -sdk macosx OTHER_CFLAGS='${inherited} -Werror -Wconversion -Wno-unguarded-availability-new' CHIP_IS_BLE=NO + run: xcodebuild -target "Matter" -sdk macosx OTHER_CFLAGS='${inherited} -Werror -Wconversion -Wno-unguarded-availability-new' working-directory: src/darwin/Framework - name: Clean Build run: xcodebuild clean @@ -116,12 +113,16 @@ 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) & + ../../../out/debug/chip-all-clusters-app --interface-id -1 --dac_provider ../../../credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/test_case_vector.json --product-id 32768 --discriminator 3839 --secured-device-port 5539 --KVS /tmp/chip-all-clusters-app-kvs2 > >(tee /tmp/darwin/framework-tests/all-cluster-app-origin-vid.log) 2> >(tee /tmp/darwin/framework-tests/all-cluster-app-origin-vid-err.log >&2) & # Make sure each ota-requestor is using a different port, discriminator, and KVS from # all-clusters-app and from other requestors. # # And a different port from the test harness too; the test harness uses port 5541. ../../../out/debug/chip-ota-requestor-app --interface-id -1 --secured-device-port 5542 --discriminator 1111 --KVS /tmp/chip-ota-requestor-kvs1 --otaDownloadPath /tmp/chip-ota-requestor-downloaded-image1 --autoApplyImage > >(tee /tmp/darwin/framework-tests/ota-requestor-app-1.log) 2> >(tee /tmp/darwin/framework-tests/ota-requestor-app-err-1.log >&2) & ../../../out/debug/chip-ota-requestor-app --interface-id -1 --secured-device-port 5543 --discriminator 1112 --KVS /tmp/chip-ota-requestor-kvs2 --otaDownloadPath /tmp/chip-ota-requestor-downloaded-image2 --autoApplyImage > >(tee /tmp/darwin/framework-tests/ota-requestor-app-2.log) 2> >(tee /tmp/darwin/framework-tests/ota-requestor-app-err-2.log >&2) & + # Disable BLE because the app does not have the permission to use + # it and that may crash the CI. + # # -enableUndefinedBehaviorSanitizer instruments the code in Matter.framework, # but to instrument the code in the underlying libCHIP we need to pass CHIP_IS_UBSAN=YES TEST_RUNNER_ASAN_OPTIONS=__CURRENT_VALUE__:detect_stack_use_after_return=1 xcodebuild test -target "Matter" -scheme "Matter Framework Tests" -sdk macosx -enableAddressSanitizer YES -enableUndefinedBehaviorSanitizer YES OTHER_CFLAGS='${inherited} -Werror -Wconversion -Wno-unguarded-availability-new' CHIP_IS_UBSAN=YES CHIP_IS_BLE=NO > >(tee /tmp/darwin/framework-tests/darwin-tests-asan.log) 2> >(tee /tmp/darwin/framework-tests/darwin-tests-asan-err.log >&2) diff --git a/.github/workflows/docbuild.yaml b/.github/workflows/docbuild.yaml index ac2a8072c8045e..f49a9e660b4d12 100644 --- a/.github/workflows/docbuild.yaml +++ b/.github/workflows/docbuild.yaml @@ -22,7 +22,7 @@ jobs: steps: - name: Checkout the code - uses: actions/checkout@v3.5.2 + uses: actions/checkout@v3 with: path: matter fetch-depth: 0 diff --git a/.github/workflows/doxygen.yaml b/.github/workflows/doxygen.yaml index b65b2c02b2bc7d..02f78481b89063 100644 --- a/.github/workflows/doxygen.yaml +++ b/.github/workflows/doxygen.yaml @@ -89,7 +89,7 @@ jobs: - name: "Print Actor" run: echo ${{github.actor}} - name: Checkout - uses: actions/checkout@v3.5.2 + uses: actions/checkout@v3 - name: Generate run: scripts/helpers/doxygen.sh - name: Extract branch name diff --git a/.github/workflows/examples-linux-standalone.yaml b/.github/workflows/examples-linux-standalone.yaml index 3bd48a1960b8ba..3613a6e39781fc 100644 --- a/.github/workflows/examples-linux-standalone.yaml +++ b/.github/workflows/examples-linux-standalone.yaml @@ -94,6 +94,8 @@ jobs: linux debug all-clusters-app \ out/linux-x64-all-clusters/chip-all-clusters-app \ /tmp/bloat_reports/ + - name: Clean out build output + run: rm -rf ./out - name: Build example Standalone All Clusters Minimal Server run: | ./scripts/run_in_build_env.sh \ @@ -134,6 +136,8 @@ jobs: linux debug+rpc+ui lighting-app \ out/linux-x64-light-rpc-with-ui/chip-lighting-app \ /tmp/bloat_reports/ + - name: Clean out build output + run: rm -rf ./out - name: Build example Standalone Bridge run: | ./scripts/run_in_build_env.sh \ @@ -164,6 +168,8 @@ jobs: linux debug ota-requestor-app \ out/linux-x64-ota-requestor/chip-ota-requestor-app \ /tmp/bloat_reports/ + - name: Clean out build output + run: rm -rf ./out - name: Build example Standalone Lock App run: | ./scripts/run_in_build_env.sh \ diff --git a/.github/workflows/examples-nrfconnect.yaml b/.github/workflows/examples-nrfconnect.yaml index 985f3b5c7fff82..c0adbf2c5db492 100644 --- a/.github/workflows/examples-nrfconnect.yaml +++ b/.github/workflows/examples-nrfconnect.yaml @@ -25,7 +25,7 @@ concurrency: env: CHIP_NO_LOG_TIMESTAMPS: true - + jobs: nrfconnect: name: nRF Connect SDK @@ -131,7 +131,7 @@ jobs: /tmp/bloat_reports/ - name: Build example nRF Connect SDK All Clusters App on nRF52840 DK run: | - scripts/examples/nrfconnect_example.sh all-clusters-app nrf52840dk_nrf52840 -DCONF_FILE=prj_dfu.conf + scripts/examples/nrfconnect_example.sh all-clusters-app nrf52840dk_nrf52840 .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ nrfconnect nrf52840dk_nrf52840 all-clusters-app \ examples/all-clusters-app/nrfconnect/build/zephyr/zephyr.elf \ diff --git a/.github/workflows/examples-openiotsdk.yaml b/.github/workflows/examples-openiotsdk.yaml index 15bfa0b5bab8df..888904a5eb9338 100644 --- a/.github/workflows/examples-openiotsdk.yaml +++ b/.github/workflows/examples-openiotsdk.yaml @@ -26,7 +26,7 @@ concurrency: env: CHIP_NO_LOG_TIMESTAMPS: true - + jobs: openiotsdk: name: Open IoT SDK examples building @@ -81,6 +81,26 @@ jobs: examples/lock-app/openiotsdk/build/chip-openiotsdk-lock-app-example.elf \ /tmp/bloat_reports/ + - name: Build tv-app example + id: build_tv_app + timeout-minutes: 10 + run: | + scripts/examples/openiotsdk_example.sh tv-app + .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ + openiotsdk release tv-app \ + examples/tv-app/openiotsdk/build/chip-openiotsdk-tv-app-example.elf \ + /tmp/bloat_reports/ + + - name: Build all-clusters-app example + id: build_all_clusters_app + timeout-minutes: 10 + run: | + scripts/examples/openiotsdk_example.sh all-clusters-app + .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \ + openiotsdk release all-clusters-app \ + examples/all-clusters-app/openiotsdk/build/chip-openiotsdk-all-clusters-app-example.elf \ + /tmp/bloat_reports/ + - name: Build unit tests (mbedtls) id: build_unit_tests_mbedtls run: | @@ -100,6 +120,24 @@ jobs: 'scripts/run_in_ns.sh ${TEST_NETWORK_NAME}ns scripts/examples/openiotsdk_example.sh --no-activate -C test -n ${TEST_NETWORK_NAME}tap lock-app' scripts/setup/openiotsdk/network_setup.sh -n $TEST_NETWORK_NAME down + - name: "Test: tv-app example" + if: steps.build_tv_app.outcome == 'success' + timeout-minutes: 10 + run: | + scripts/setup/openiotsdk/network_setup.sh -n $TEST_NETWORK_NAME up + scripts/run_in_python_env.sh out/venv \ + 'scripts/run_in_ns.sh ${TEST_NETWORK_NAME}ns scripts/examples/openiotsdk_example.sh --no-activate -C test -n ${TEST_NETWORK_NAME}tap tv-app' + scripts/setup/openiotsdk/network_setup.sh -n $TEST_NETWORK_NAME down + + - name: "Test: all-clusters-app example" + if: steps.build_all_clusters_app.outcome == 'success' + timeout-minutes: 5 + run: | + scripts/setup/openiotsdk/network_setup.sh -n $TEST_NETWORK_NAME up + scripts/run_in_python_env.sh out/venv \ + 'scripts/run_in_ns.sh ${TEST_NETWORK_NAME}ns scripts/examples/openiotsdk_example.sh --no-activate -C test -n ${TEST_NETWORK_NAME}tap all-clusters-app' + scripts/setup/openiotsdk/network_setup.sh -n $TEST_NETWORK_NAME down + - name: "Test: unit-tests (mbedtls)" if: steps.build_unit_tests_mbedtls.outcome == 'success' run: | diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 05c0adcccff319..6e82cfa288639b 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -36,7 +36,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-telink:0.7.14 + image: connectedhomeip/chip-build-telink:0.7.24 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/full-android.yaml b/.github/workflows/full-android.yaml index 2ec4fdcca3e7ae..bf2c2f391b961a 100644 --- a/.github/workflows/full-android.yaml +++ b/.github/workflows/full-android.yaml @@ -51,7 +51,7 @@ jobs: # Note you likely still need to have non submodules setup for the # local machine, like: # git submodule deinit --all - - uses: actions/checkout@v3.5.2 + - uses: actions/checkout@v3 if: ${{ env.ACT }} name: Checkout (ACT for local build) - name: Checkout submodules & Bootstrap diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml index 913c5672e3c09e..8bfd0dcf51f572 100644 --- a/.github/workflows/gradle-wrapper-validation.yml +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -6,5 +6,5 @@ jobs: name: "Validation" runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3.5.2 + - uses: actions/checkout@v3 - uses: gradle/wrapper-validation-action@v1 diff --git a/.github/workflows/issue-labeler.yaml b/.github/workflows/issue-labeler.yaml new file mode 100644 index 00000000000000..b1c8e2304469bd --- /dev/null +++ b/.github/workflows/issue-labeler.yaml @@ -0,0 +1,20 @@ +name: "Issue Labeler" +on: + issues: + types: [opened, edited] + +permissions: + issues: write + contents: read + +jobs: + triage: + runs-on: ubuntu-latest + steps: + - uses: github/issue-labeler@v3.2 #May not be the latest version + with: + configuration-path: .github/issue-labeler.yml + not-before: 2020-01-15T02:54:32Z + enable-versioned-regex: 0 + sync-labels: 1 + repo-token: ${{ github.token }} \ No newline at end of file diff --git a/.github/workflows/java-tests.yaml b/.github/workflows/java-tests.yaml index f56b1c42d77c5c..a61175403e801c 100644 --- a/.github/workflows/java-tests.yaml +++ b/.github/workflows/java-tests.yaml @@ -46,7 +46,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3.5.2 + uses: actions/checkout@v3 - name: Checkout submodules & Bootstrap uses: ./.github/actions/checkout-submodules-and-bootstrap with: @@ -79,7 +79,8 @@ jobs: chip.tlv.TlvReadWriteTest \ chip.tlv.TlvReaderTest \ chip.jsontlv.JsonToTlvToJsonTest \ - chip.onboardingpayload.ManualCodeTest + chip.onboardingpayload.ManualCodeTest \ + chip.onboardingpayload.QRCodeTest - name: Build Java Matter Controller and all clusters app run: | scripts/run_in_build_env.sh './scripts/build_python.sh --install_virtual_env out/venv' diff --git a/.github/workflows/kotlin-detekt.yaml b/.github/workflows/kotlin-detekt.yaml deleted file mode 100644 index 4296edb438ffaa..00000000000000 --- a/.github/workflows/kotlin-detekt.yaml +++ /dev/null @@ -1,22 +0,0 @@ -name: Kotlin - Detekt - -on: - pull_request: - paths: - - "**/*.kt" - - ".github/workflows/kotlin-detekt.yaml" - -jobs: - detekt: - runs-on: ubuntu-latest - - steps: - - name: "checkout" - uses: actions/checkout@v2 - - - name: "detekt" - uses: natiginfo/action-detekt-all@1.23.0 - # Detekt seems not to like circular symlinks, so we set up - # explicit paths below - with: - args: --parallel --build-upon-default-config --config kotlin-detect-config.yaml --input examples/android/CHIPTest,examples/android/CHIPTool,examples/java-matter-controller/java,src/controller/java diff --git a/.github/workflows/kotlin-style.yaml b/.github/workflows/kotlin-style.yaml new file mode 100644 index 00000000000000..921e89528d7ee5 --- /dev/null +++ b/.github/workflows/kotlin-style.yaml @@ -0,0 +1,64 @@ +name: Kotlin + +on: + pull_request: + paths: + - "**/*.kt" + - ".github/workflows/kotlin-style.yaml" + - "kotlin-detect-config.yaml" + +concurrency: + 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 + + +jobs: + detekt: + name: Static code analysis + runs-on: ubuntu-latest + + steps: + - name: "checkout" + uses: actions/checkout@v3 + + - name: "detekt" + uses: natiginfo/action-detekt-all@1.23.0 + # Detekt seems not to like circular symlinks, so we set up + # explicit paths below + with: + args: --parallel --build-upon-default-config --config kotlin-detect-config.yaml --input examples/android/CHIPTest,examples/android/CHIPTool,examples/java-matter-controller/java,src/controller/java + + ktlint: + name: "Format check" + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-java@v3 + with: + distribution: 'adopt' + java-version: '17' + + - name: Download ktfmt + run: | + cd /tmp + wget "https://repo1.maven.org/maven2/com/facebook/ktfmt/0.44/ktfmt-0.44-jar-with-dependencies.jar" + + - name: Format kotlin files + run: | + find src examples -name '*.kt' \ + | xargs java -jar /tmp/ktfmt-0.44-jar-with-dependencies.jar --google-style + + - name: Ensure git works in current working directory + run: git config --global --add safe.directory `pwd` + + - name: Check for uncommited changes + run: | + git add . + # Show the full diff + git diff-index -p HEAD -- + # Also show just the files that are different, to make it easy + # to tell at a glance what might be going on. And throw in + # --exit-code to make this job fail if there is a difference. + git diff-index --exit-code HEAD -- diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 5299b65f3972f1..877a46ee3719a8 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -60,7 +60,7 @@ jobs: # Note you likely still need to have non submodules setup for the # local machine, like: # git submodule deinit --all - - uses: actions/checkout@v3.5.2 + - uses: actions/checkout@v3 if: ${{ env.ACT }} name: Checkout (ACT for local build) - name: Checkout submodules & Bootstrap @@ -156,6 +156,7 @@ jobs: src/app/zap-templates/zcl/data-model/chip/rvc-clean-mode-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/rvc-run-mode-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/scene.xml \ + src/app/zap-templates/zcl/data-model/chip/smoke-co-alarm-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/software-diagnostics-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/switch-cluster.xml \ src/app/zap-templates/zcl/data-model/chip/target-navigator-cluster.xml \ @@ -411,7 +412,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3.5.2 + uses: actions/checkout@v3 - name: Checkout submodules & Bootstrap uses: ./.github/actions/checkout-submodules-and-bootstrap with: @@ -442,12 +443,14 @@ jobs: scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_decode 1" --script "src/python_testing/TC_SC_3_6.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_decode 1" --script "src/python_testing/TC_DA_1_7.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --bool-arg allow_sdk_dac:true"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_decode 1 --enable-key 000102030405060708090a0b0c0d0e0f" --script "src/python_testing/TC_TestEventTrigger.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --bool-arg allow_sdk_dac:true"' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_decode 1" --script "src/python_testing/TC_ACE_1_2.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_decode 1" --script "src/python_testing/TC_ACE_1_4.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --int-arg PIXIT.ACE.APPENDPOINT:1 PIXIT.ACE.APPDEVTYPEID:0x0100 --string-arg PIXIT.ACE.APPCLUSTER:OnOff PIXIT.ACE.APPATTRIBUTE:OnOff"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_decode 1" --script "src/python_testing/TC_ACE_1_3.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_decode 1" --script "src/python_testing/TC_CGEN_2_4.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_decode 1" --script "src/python_testing/TC_DA_1_2.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_decode 1" --script "src/python_testing/TC_DA_1_5.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_decode 1" --script "src/python_testing/TestCommissioningTimeSync.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021"' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace_decode 1" --script "src/python_testing/TC_IDM_1_2.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TestMatterTestingSupport.py"' - name: Uploading core files uses: actions/upload-artifact@v3 @@ -481,7 +484,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3.5.2 + uses: actions/checkout@v3 - name: Setup Environment # coreutils for stdbuf run: brew install coreutils diff --git a/.pullapprove.yml b/.pullapprove.yml index f92717408353a7..b44aa4016267f4 100644 --- a/.pullapprove.yml +++ b/.pullapprove.yml @@ -46,10 +46,10 @@ overrides: ############################################################ # Require Issues ############################################################ -# disabling until we have PRs up to date -# - if: "'*issue*' not in statuses.successful" -# status: failure -# explanation: "An issue is required for all PRs" + # disabling until we have PRs up to date + # - if: "'*issue*' not in statuses.successful" + # status: failure + # explanation: "An issue is required for all PRs" ############################################################ # Fast tracking @@ -96,6 +96,14 @@ groups: teams: [reviewers-apple] reviews: request: 10 + shared-reviewers-bosch: + type: optional + conditions: + - files.include('*') + reviewers: + teams: [reviewers-bosch] + reviews: + request: 10 shared-reviewers-comcast: type: optional conditions: @@ -104,6 +112,14 @@ groups: teams: [reviewers-comcast] reviews: request: 10 + shared-reviewers-dyson: + type: optional + conditions: + - files.include('*') + reviewers: + teams: [reviewers-dyson] + reviews: + request: 10 shared-reviewers-espressif: type: optional conditions: @@ -120,6 +136,14 @@ groups: teams: [reviewers-google] reviews: request: 10 + shared-reviewers-irobot: + type: optional + conditions: + - files.include('*') + reviewers: + teams: [reviewers-irobot] + reviews: + request: 10 shared-reviewers-lg: type: optional conditions: @@ -182,6 +206,14 @@ groups: teams: [reviewers-tcl] reviews: request: 10 + shared-reviewers-qorvo: + type: optional + conditions: + - files.include('*') + reviewers: + teams: [reviewers-qorvo] + reviews: + request: 10 ############################################################ # Base Required Reviewers diff --git a/BUILD.gn b/BUILD.gn index 6cc0d55261ff2b..5b3a9e480b6336 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -54,6 +54,7 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") { "${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", + "${chip_root}/src/lib/format/tests:fuzz-payload-decoder", ] } } diff --git a/build/chip/chip_codegen.gni b/build/chip/chip_codegen.gni index 64c0642da29e65..1a6927bf4686f4 100644 --- a/build/chip/chip_codegen.gni +++ b/build/chip/chip_codegen.gni @@ -53,9 +53,19 @@ template("_chip_build_time_codegen") { rebase_path(target_gen_dir, root_build_dir), "--expected-outputs", rebase_path(_expected_outputs, root_build_dir), - rebase_path(_idl_file, root_build_dir), ] + if (defined(invoker.options)) { + foreach(option, invoker.options) { + args += [ + "--option", + option, + ] + } + } + + args += [ rebase_path(_idl_file, root_build_dir) ] + inputs = [ _idl_file, _expected_outputs, @@ -313,12 +323,15 @@ template("chip_codegen") { "generator", "input", "outputs", + "options", "public_configs", ]) } } else { _name = target_name + not_needed(invoker, [ "options" ]) + # This constructs a path like: # FROM all-clusters-app.matter (inside examples/all-clusters-app/all-clusters-common/) # USING "cpp-app" for generator: diff --git a/build/chip/linux/gen_gdbus_wrapper.py b/build/chip/linux/gen_gdbus_wrapper.py index 8657d06693d222..2391655fdecddf 100755 --- a/build/chip/linux/gen_gdbus_wrapper.py +++ b/build/chip/linux/gen_gdbus_wrapper.py @@ -65,10 +65,10 @@ def main(argv): ] + extra_args + [options.input_file] subprocess.check_call(gdbus_args) sed_args = ["sed", "-i", - "s/config\.h/BuildConfig.h/g", options.output_c] + r"s/config\.h/BuildConfig.h/g", options.output_c] if sys.platform == "darwin": sed_args = ["sed", "-i", "", - "s/config\.h/BuildConfig.h/g", options.output_c] + r"s/config\.h/BuildConfig.h/g", options.output_c] subprocess.check_call(sed_args) if options.output_h: diff --git a/build/config/linux/pkg-config.py b/build/config/linux/pkg-config.py index 664deb766597c1..ded24789504596 100755 --- a/build/config/linux/pkg-config.py +++ b/build/config/linux/pkg-config.py @@ -108,7 +108,7 @@ def MatchesAnyRegexp(flag, list_of_regexps): """Returns true if the first argument matches any regular expression in the given list.""" for regexp in list_of_regexps: - if regexp.search(flag) != None: + if regexp.search(flag) is not None: return True return False @@ -145,7 +145,7 @@ def main(): # Make a list of regular expressions to strip out. strip_out = [] - if options.strip_out != None: + if options.strip_out is not None: for regexp in options.strip_out: strip_out.append(re.compile(regexp)) diff --git a/config/esp32/components/chip/CMakeLists.txt b/config/esp32/components/chip/CMakeLists.txt index d279ce37dc4535..d35791cf1ed3c0 100644 --- a/config/esp32/components/chip/CMakeLists.txt +++ b/config/esp32/components/chip/CMakeLists.txt @@ -309,11 +309,21 @@ if(CONFIG_ENABLE_PW_RPC) list(APPEND chip_libraries "${CMAKE_CURRENT_BINARY_DIR}/lib/libPwRpc.a") endif() +# When using the pregenerated files, there is a edge case where an error appears for +# undeclared argument chip_code_pre_generated_directory. To get around with it we are +# disabling the --fail-on-unused-args flag. +# For more, see: https://github.com/project-chip/connectedhomeip/issues/27636 +if (CHIP_CODEGEN_PREGEN_DIR) + set(GN_CONFIGURE_COMMAND ${GN_EXECUTABLE} --root=${GN_ROOT_TARGET} gen --check ${CMAKE_CURRENT_BINARY_DIR}) +else () + set(GN_CONFIGURE_COMMAND ${GN_EXECUTABLE} --root=${GN_ROOT_TARGET} gen --check --fail-on-unused-args ${CMAKE_CURRENT_BINARY_DIR}) +endif () + externalproject_add( chip_gn SOURCE_DIR ${CHIP_ROOT} BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} - CONFIGURE_COMMAND ${GN_EXECUTABLE} --root=${GN_ROOT_TARGET} gen --check --fail-on-unused-args ${CMAKE_CURRENT_BINARY_DIR} + CONFIGURE_COMMAND ${GN_CONFIGURE_COMMAND} BUILD_COMMAND ninja "esp32" INSTALL_COMMAND "" BUILD_BYPRODUCTS ${chip_libraries} diff --git a/config/nrfconnect/chip-module/CMakeLists.txt b/config/nrfconnect/chip-module/CMakeLists.txt index 43149d2306e3c1..d897f8335add17 100644 --- a/config/nrfconnect/chip-module/CMakeLists.txt +++ b/config/nrfconnect/chip-module/CMakeLists.txt @@ -122,7 +122,7 @@ matter_add_gn_arg_bool ("chip_logging" CONFIG_LOG) matter_add_gn_arg_bool ("chip_enable_openthread" CONFIG_NET_L2_OPENTHREAD) matter_add_gn_arg_bool ("chip_openthread_ftd" CONFIG_OPENTHREAD_FTD) matter_add_gn_arg_bool ("chip_config_network_layer_ble" CONFIG_BT) -matter_add_gn_arg_bool ("chip_inet_config_enable_ipv4" CONFIG_NET_IPV4) +matter_add_gn_arg_bool ("chip_inet_config_enable_ipv4" CONFIG_CHIP_IPV4) matter_add_gn_arg_bool ("chip_enable_nfc" CONFIG_CHIP_NFC_COMMISSIONING) matter_add_gn_arg_bool ("chip_enable_ota_requestor" CONFIG_CHIP_OTA_REQUESTOR) matter_add_gn_arg_bool ("chip_persist_subscriptions" CONFIG_CHIP_PERSISTENT_SUBSCRIPTIONS) diff --git a/config/nrfconnect/chip-module/Kconfig b/config/nrfconnect/chip-module/Kconfig index 059d5112652b3f..95e49ac59e0262 100644 --- a/config/nrfconnect/chip-module/Kconfig +++ b/config/nrfconnect/chip-module/Kconfig @@ -251,3 +251,12 @@ config CHIP_LOG_SIZE_OPTIMIZATION information that is too detailed to be used in most cases. You can find full configuration enabled by this option in the platform/nrfconnect/CHIPPlatformConfig.h file. + +config CHIP_IPV4 + bool "IPv4 support for Matter" + default n + depends on NET_IPV4 + help + If disabled, it allows to build nRF Connect SDK application + with IPv4 support independently of the Matter stack still + running over IPv6. diff --git a/config/openiotsdk/CMakeLists.txt b/config/openiotsdk/CMakeLists.txt index 70bb737b217563..eca153e3f59505 100644 --- a/config/openiotsdk/CMakeLists.txt +++ b/config/openiotsdk/CMakeLists.txt @@ -50,6 +50,7 @@ matter_common_gn_args( LIB_SHELL CONFIG_CHIP_LIB_SHELL LIB_TESTS CONFIG_CHIP_LIB_TESTS PROJECT_CONFIG ${CONFIG_CHIP_PROJECT_CONFIG} + PROJECT_CONFIG_INC_DIR ${CONFIG_CHIP_PROJECT_CONFIG_INCLUDE_DIRS} ) matter_add_gn_arg_string("target_cpu" "${CMAKE_SYSTEM_PROCESSOR}") matter_add_gn_arg_string("openiotsdk_ar" ${CMAKE_AR}) diff --git a/config/openiotsdk/cmake/chip.cmake b/config/openiotsdk/cmake/chip.cmake index 5875d10dd88a4f..7b5d77fddf0fdb 100644 --- a/config/openiotsdk/cmake/chip.cmake +++ b/config/openiotsdk/cmake/chip.cmake @@ -23,6 +23,7 @@ get_filename_component(GEN_DIR ${CHIP_ROOT}/zzz_generated/ REALPATH) # Default CHIP build configuration set(CONFIG_CHIP_PROJECT_CONFIG "main/include/CHIPProjectConfig.h" CACHE STRING "") +set(CONFIG_CHIP_PROJECT_CONFIG_INCLUDE_DIRS "" CACHE STRING "") set(CONFIG_CHIP_LIB_TESTS NO CACHE BOOL "") set(CONFIG_CHIP_LIB_SHELL NO CACHE BOOL "") diff --git a/config/python/CHIPProjectConfig.h b/config/python/CHIPProjectConfig.h index 87940a900ce991..5effaaa13c6479 100644 --- a/config/python/CHIPProjectConfig.h +++ b/config/python/CHIPProjectConfig.h @@ -59,4 +59,6 @@ #define CHIP_DEVICE_CONFIG_ENABLE_COMMISSIONER_DISCOVERY 1 #define CHIP_DEVICE_CONFIG_ENABLE_BOTH_COMMISSIONER_AND_COMMISSIONEE 1 +#define CONFIG_BUILD_FOR_HOST_UNIT_TEST 1 + #endif /* CHIPPROJECTCONFIG_H */ diff --git a/credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/cd.der b/credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/cd.der new file mode 100644 index 00000000000000..0207a504661184 Binary files /dev/null and b/credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/cd.der differ diff --git a/credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/dac-Cert.der b/credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/dac-Cert.der new file mode 100644 index 00000000000000..28185b2ea281a5 Binary files /dev/null and b/credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/dac-Cert.der differ diff --git a/credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/dac-Cert.pem b/credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/dac-Cert.pem new file mode 100644 index 00000000000000..126af90aba0434 --- /dev/null +++ b/credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/dac-Cert.pem @@ -0,0 +1,13 @@ +-----BEGIN CERTIFICATE----- +MIIB5DCCAYqgAwIBAgIIQnRkU92joPUwCgYIKoZIzj0EAwIwRjEYMBYGA1UEAwwP +TWF0dGVyIFRlc3QgUEFJMRQwEgYKKwYBBAGConwCAQwERkZGMjEUMBIGCisGAQQB +gqJ8AgIMBDgwMDEwIBcNMjMwNzA0MDAwMDAwWhgPOTk5OTEyMzEyMzU5NTlaMEYx +GDAWBgNVBAMMD01hdHRlciBUZXN0IERBQzEUMBIGCisGAQQBgqJ8AgEMBEZGRjIx +FDASBgorBgEEAYKifAICDAQ4MDAxMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE +i04n/UbQFbyOugwYJbPcRxEPRvWQJPwpjHvmI3JqYso9ISyz/LSXJ3QNIvl3t9Ag +tsXw17bMH1B6zs6dHX0wCaNgMF4wDAYDVR0TAQH/BAIwADAOBgNVHQ8BAf8EBAMC +B4AwHQYDVR0OBBYEFFUzcz8rO7UyEFl6mPUK9IEkAB+yMB8GA1UdIwQYMBaAFCQ5 +GiylqAHg0XSk/s8q5SViI6CHMAoGCCqGSM49BAMCA0gAMEUCIEfmQX7nVhBYgoeJ +sC8b1EyEtJ0WWhDZvfKDc9wQaTU3AiEA6F7LCTx6psvb+aKl9I8hnA98/+88jvTm +b44v4ee9HJo= +-----END CERTIFICATE----- diff --git a/credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/dac-Key.der b/credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/dac-Key.der new file mode 100644 index 00000000000000..38a80666179098 Binary files /dev/null and b/credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/dac-Key.der differ diff --git a/credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/dac-Key.pem b/credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/dac-Key.pem new file mode 100644 index 00000000000000..e8e08d3ca36e8d --- /dev/null +++ b/credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/dac-Key.pem @@ -0,0 +1,5 @@ +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEIKjwudFL/3eYC+HY1t64HLjc/AAyc/J0CyTL6Mo0ugKLoAoGCCqGSM49 +AwEHoUQDQgAEi04n/UbQFbyOugwYJbPcRxEPRvWQJPwpjHvmI3JqYso9ISyz/LSX +J3QNIvl3t9AgtsXw17bMH1B6zs6dHX0wCQ== +-----END EC PRIVATE KEY----- diff --git a/credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/pai-Cert.der b/credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/pai-Cert.der new file mode 100644 index 00000000000000..c208eaed93a1d4 Binary files /dev/null and b/credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/pai-Cert.der differ diff --git a/credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/pai-Cert.pem b/credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/pai-Cert.pem new file mode 100644 index 00000000000000..123132dc482872 --- /dev/null +++ b/credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/pai-Cert.pem @@ -0,0 +1,12 @@ +-----BEGIN CERTIFICATE----- +MIIBvzCCAWSgAwIBAgIIVwXbuTJAkMEwCgYIKoZIzj0EAwIwGjEYMBYGA1UEAwwP +TWF0dGVyIFRlc3QgUEFBMCAXDTIzMDcwNDAwMDAwMFoYDzk5OTkxMjMxMjM1OTU5 +WjBGMRgwFgYDVQQDDA9NYXR0ZXIgVGVzdCBQQUkxFDASBgorBgEEAYKifAIBDARG +RkYyMRQwEgYKKwYBBAGConwCAgwEODAwMTBZMBMGByqGSM49AgEGCCqGSM49AwEH +A0IABDge/ZTB1ASbzUW4A2gpRdE0ZcNUlkCUaXAlkgkGpdafI83gOvLhWcZisA40 +QsppJD9OeWP0eIW8+6cdi13E2w6jZjBkMBIGA1UdEwEB/wQIMAYBAf8CAQAwDgYD +VR0PAQH/BAQDAgEGMB0GA1UdDgQWBBQkORospagB4NF0pP7PKuUlYiOghzAfBgNV +HSMEGDAWgBR4XOcFuGuPTm/Hk6pgy0PqaWiC1TAKBggqhkjOPQQDAgNJADBGAiEA +uxLDhQ3owmVZ8gopMaMGekcofyjciv4luAyTA5fJR7UCIQD2fHv76wj+YVSA2WRC +U5gZvNcYNtH8DUvvnSE8Fxwmtw== +-----END CERTIFICATE----- diff --git a/credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/pai-Key.der b/credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/pai-Key.der new file mode 100644 index 00000000000000..751b0d641aa14f Binary files /dev/null and b/credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/pai-Key.der differ diff --git a/credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/pai-Key.pem b/credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/pai-Key.pem new file mode 100644 index 00000000000000..15b8e658aacf66 --- /dev/null +++ b/credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/pai-Key.pem @@ -0,0 +1,5 @@ +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEIFW0zHlTJnU1Gp1mq7I9bVCFS/IYC/nsQ8wkVyJfgAfuoAoGCCqGSM49 +AwEHoUQDQgAEOB79lMHUBJvNRbgDaClF0TRlw1SWQJRpcCWSCQal1p8jzeA68uFZ +xmKwDjRCymkkP055Y/R4hbz7px2LXcTbDg== +-----END EC PRIVATE KEY----- diff --git a/credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/test_case_vector.json b/credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/test_case_vector.json new file mode 100644 index 00000000000000..cba8781bcd3450 --- /dev/null +++ b/credentials/development/commissioner_dut/struct_cd_origin_pid_vid_correct/test_case_vector.json @@ -0,0 +1,9 @@ +{ + "description": "CD Test Vector: Origin VID/PID different than VID/PID (correct use of origin)", + "is_success_case": "true", + "dac_cert": "308201e43082018aa003020102020842746453dda3a0f5300a06082a8648ce3d04030230463118301606035504030c0f4d617474657220546573742050414931143012060a2b0601040182a27c02010c044646463231143012060a2b0601040182a27c02020c04383030313020170d3233303730343030303030305a180f39393939313233313233353935395a30463118301606035504030c0f4d617474657220546573742044414331143012060a2b0601040182a27c02010c044646463231143012060a2b0601040182a27c02020c04383030313059301306072a8648ce3d020106082a8648ce3d030107034200048b4e27fd46d015bc8eba0c1825b3dc47110f46f59024fc298c7be623726a62ca3d212cb3fcb49727740d22f977b7d020b6c5f0d7b6cc1f507acece9d1d7d3009a360305e300c0603551d130101ff04023000300e0603551d0f0101ff040403020780301d0603551d0e041604145533733f2b3bb53210597a98f50af48124001fb2301f0603551d2304183016801424391a2ca5a801e0d174a4fecf2ae5256223a087300a06082a8648ce3d0403020348003045022047e6417ee7561058828789b02f1bd44c84b49d165a10d9bdf28373dc10693537022100e85ecb093c7aa6cbdbf9a2a5f48f219c0f7cffef3c8ef4e66f8e2fe1e7bd1c9a", + "pai_cert": "308201bf30820164a00302010202085705dbb9324090c1300a06082a8648ce3d040302301a3118301606035504030c0f4d61747465722054657374205041413020170d3233303730343030303030305a180f39393939313233313233353935395a30463118301606035504030c0f4d617474657220546573742050414931143012060a2b0601040182a27c02010c044646463231143012060a2b0601040182a27c02020c04383030313059301306072a8648ce3d020106082a8648ce3d03010703420004381efd94c1d4049bcd45b803682945d13465c354964094697025920906a5d69f23cde03af2e159c662b00e3442ca69243f4e7963f47885bcfba71d8b5dc4db0ea366306430120603551d130101ff040830060101ff020100300e0603551d0f0101ff040403020106301d0603551d0e0416041424391a2ca5a801e0d174a4fecf2ae5256223a087301f0603551d23041830168014785ce705b86b8f4e6fc793aa60cb43ea696882d5300a06082a8648ce3d0403020349003046022100bb12c3850de8c26559f20a2931a3067a47287f28dc8afe25b80c930397c947b5022100f67c7bfbeb08fe615480d96442539819bcd71836d1fc0d4bef9d213c171c26b7", + "certification_declaration": "3081f006092a864886f70d010702a081e23081df020103310d300b0609608648016503040201304d06092a864886f70d010701a040043e152400012501f1ff360205008018250334122c04135a494732303134315a423333303030312d3234240500240600250776982408002509f2ff250a018018317c307a020103801462fa823359acfaa9963e1cfa140addf504f37160300b0609608648016503040201300a06082a8648ce3d040302044630440220494f87a430b234de3eaeb2dd756d49f5a952f99611b5e9049d864499670cad1c0220492f157848ef15bb597fb46ab387f639107bb53fc6d0dbe11b3fefc8e3baea8d", + "dac_private_key": "a8f0b9d14bff77980be1d8d6deb81cb8dcfc003273f2740b24cbe8ca34ba028b", + "dac_public_key": "048b4e27fd46d015bc8eba0c1825b3dc47110f46f59024fc298c7be623726a62ca3d212cb3fcb49727740d22f977b7d020b6c5f0d7b6cc1f507acece9d1d7d3009" +} diff --git a/credentials/fetch-paa-certs-from-dcl.py b/credentials/fetch-paa-certs-from-dcl.py index 56950a8c86e239..d440398c472be7 100644 --- a/credentials/fetch-paa-certs-from-dcl.py +++ b/credentials/fetch-paa-certs-from-dcl.py @@ -26,7 +26,6 @@ import re import subprocess import sys -from contextlib import nullcontext import click import requests diff --git a/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-2CDPs-Cert.der b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-2CDPs-Cert.der new file mode 100644 index 00000000000000..880b441bd42cc6 Binary files /dev/null and b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-2CDPs-Cert.der differ diff --git a/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-2CDPs-Cert.pem b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-2CDPs-Cert.pem new file mode 100644 index 00000000000000..e9568978ab1aea --- /dev/null +++ b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-2CDPs-Cert.pem @@ -0,0 +1,15 @@ +-----BEGIN CERTIFICATE----- +MIICUDCCAfagAwIBAgIISW372zteskMwCgYIKoZIzj0EAwIwRjEYMBYGA1UEAwwP +TWF0dGVyIFRlc3QgUEFJMRQwEgYKKwYBBAGConwCAQwERkZGMTEUMBIGCisGAQQB +gqJ8AgIMBDgwMDAwIBcNMjEwNjI4MTQyMzQzWhgPOTk5OTEyMzEyMzU5NTlaMFQx +JjAkBgNVBAMMHU1hdHRlciBUZXN0IERBQyAwMDAwIFR3byBDRFBzMRQwEgYKKwYB +BAGConwCAQwERkZGMTEUMBIGCisGAQQBgqJ8AgIMBDgwMDAwWTATBgcqhkjOPQIB +BggqhkjOPQMBBwNCAARKrV70IfqHoglq9IBcx7bK3w/30LA1NNMRJ5LYnAHfE7cV +AfLEBWiSm/ibuygPsGeTDUwoQvlzUhJXOY+2MpLco4G9MIG6MAwGA1UdEwEB/wQC +MAAwDgYDVR0PAQH/BAQDAgeAMB0GA1UdDgQWBBRF3Pw1yhkocaPuFrIVi2gb4+mK +jDAfBgNVHSMEGDAWgBSvQrcJTevVFexuzzO4ERUiXzJSiDAsBgNVHR8EJTAjMCGg +H6AdhhtodHRwczovL2V4YW1wbGUuY29tL2NybC5wZW0wLAYDVR0fBCUwIzAhoB+g +HYYbaHR0cDovL2V4YW1wbGUuY29tL2NybDIucGVtMAoGCCqGSM49BAMCA0gAMEUC +ICo4AL07AB1JwKlxGLhw/UsJVGsGYQev7ZWa7wxbASuPAiEA4YlR6OPubKM9Z7Jg +jBq99l+UvHneNRsmIWpB3JKzESI= +-----END CERTIFICATE----- diff --git a/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-2CDPs-Key.der b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-2CDPs-Key.der new file mode 100644 index 00000000000000..6db711ca7bde9c Binary files /dev/null and b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-2CDPs-Key.der differ diff --git a/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-2CDPs-Key.pem b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-2CDPs-Key.pem new file mode 100644 index 00000000000000..39a7c256c79722 --- /dev/null +++ b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-2CDPs-Key.pem @@ -0,0 +1,5 @@ +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEIJj6QtgPRpxFxnBqp0m+IYABttjI2ijEbkXYSlxoqN9+oAoGCCqGSM49 +AwEHoUQDQgAESq1e9CH6h6IJavSAXMe2yt8P99CwNTTTESeS2JwB3xO3FQHyxAVo +kpv4m7soD7Bnkw1MKEL5c1ISVzmPtjKS3A== +-----END EC PRIVATE KEY----- diff --git a/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-2URIs-Cert.der b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-2URIs-Cert.der new file mode 100644 index 00000000000000..3e725cc85cd818 Binary files /dev/null and b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-2URIs-Cert.der differ diff --git a/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-2URIs-Cert.pem b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-2URIs-Cert.pem new file mode 100644 index 00000000000000..966c5025d8811f --- /dev/null +++ b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-2URIs-Cert.pem @@ -0,0 +1,15 @@ +-----BEGIN CERTIFICATE----- +MIICSjCCAfCgAwIBAgIIXzwUpXaaVS0wCgYIKoZIzj0EAwIwRjEYMBYGA1UEAwwP +TWF0dGVyIFRlc3QgUEFJMRQwEgYKKwYBBAGConwCAQwERkZGMTEUMBIGCisGAQQB +gqJ8AgIMBDgwMDAwIBcNMjEwNjI4MTQyMzQzWhgPOTk5OTEyMzEyMzU5NTlaMFox +LDAqBgNVBAMMI01hdHRlciBUZXN0IERBQyAwMDAwIENEUCAoVHdvIFVSSXMpMRQw +EgYKKwYBBAGConwCAQwERkZGMTEUMBIGCisGAQQBgqJ8AgIMBDgwMDAwWTATBgcq +hkjOPQIBBggqhkjOPQMBBwNCAATaRkJ2yopbD59Iy6YH/+2S9qgTFGdh+Hu5AO9s +Q2voAeanxcjpYgnLEQRq76+OKwOZtin1IANCtIw0epGZh+NXo4GxMIGuMAwGA1Ud +EwEB/wQCMAAwDgYDVR0PAQH/BAQDAgeAMB0GA1UdDgQWBBTMrHgJmsR/rXoOuQEs +yPQiiAmrYTAfBgNVHSMEGDAWgBSvQrcJTevVFexuzzO4ERUiXzJSiDBOBgNVHR8E +RzBFMCCgHqAchhpodHRwOi8vZXhhbXBsZS5jb20vY3JsLnBlbTAhoB+gHYYbaHR0 +cDovL2V4YW1wbGUuY29tL2NybDIucGVtMAoGCCqGSM49BAMCA0gAMEUCIGoUNMNM +07VMHKebxQhC593V7bd4xaKF6a5UYf8ddjl/AiEA7U3iA9Ja1dNx+7NNXJz3vqkS +1ohFXkrf4C9/CWQ/iLw= +-----END CERTIFICATE----- diff --git a/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-2URIs-Key.der b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-2URIs-Key.der new file mode 100644 index 00000000000000..db0b5753f9dd5c Binary files /dev/null and b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-2URIs-Key.der differ diff --git a/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-2URIs-Key.pem b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-2URIs-Key.pem new file mode 100644 index 00000000000000..63ce1fe337d991 --- /dev/null +++ b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-2URIs-Key.pem @@ -0,0 +1,5 @@ +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEIL3FzD2bhQ0UC24d6vXSt8tj/HH2TmyomvM0uZhDfm3HoAoGCCqGSM49 +AwEHoUQDQgAE2kZCdsqKWw+fSMumB//tkvaoExRnYfh7uQDvbENr6AHmp8XI6WIJ +yxEEau+vjisDmbYp9SADQrSMNHqRmYfjVw== +-----END EC PRIVATE KEY----- diff --git a/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Cert.der b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Cert.der new file mode 100644 index 00000000000000..5733c1377e82ce Binary files /dev/null and b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Cert.der differ diff --git a/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Cert.pem b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Cert.pem new file mode 100644 index 00000000000000..c4fb6b4f2ffcf2 --- /dev/null +++ b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Cert.pem @@ -0,0 +1,14 @@ +-----BEGIN CERTIFICATE----- +MIICIzCCAcmgAwIBAgIIcWVtG3ouFqQwCgYIKoZIzj0EAwIwRjEYMBYGA1UEAwwP +TWF0dGVyIFRlc3QgUEFJMRQwEgYKKwYBBAGConwCAQwERkZGMTEUMBIGCisGAQQB +gqJ8AgIMBDgwMDAwIBcNMjEwNjI4MTQyMzQzWhgPOTk5OTEyMzEyMzU5NTlaMFYx +KDAmBgNVBAMMH01hdHRlciBUZXN0IERBQyAwMDAwIENEUCAoSFRUUCkxFDASBgor +BgEEAYKifAIBDARGRkYxMRQwEgYKKwYBBAGConwCAgwEODAwMDBZMBMGByqGSM49 +AgEGCCqGSM49AwEHA0IABOMBHt6fUVqz6bqTJf7yO5bNcVw66jjOgR6I/G3nrDAm +I/unBos+CdP+VJsRzF8OWWxO284+e6InH7jQmvQhnj2jgY4wgYswDAYDVR0TAQH/ +BAIwADAOBgNVHQ8BAf8EBAMCB4AwHQYDVR0OBBYEFGhDyDOjOZ+YQhU+sazPL5VY +XxpQMB8GA1UdIwQYMBaAFK9CtwlN69UV7G7PM7gRFSJfMlKIMCsGA1UdHwQkMCIw +IKAeoByGGmh0dHA6Ly9leGFtcGxlLmNvbS9jcmwucGVtMAoGCCqGSM49BAMCA0gA +MEUCIGVKTBM7ydpNFHg1q/wk1Szso6CPovTm6sKuYEEfNvWkAiEAqhyhkx+8mv/W +RzKr8x6o9hPBZx8PIqQxZ+KOnayTHhg= +-----END CERTIFICATE----- diff --git a/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-HTTPS-Cert.der b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-HTTPS-Cert.der new file mode 100644 index 00000000000000..4022bc555b6494 Binary files /dev/null and b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-HTTPS-Cert.der differ diff --git a/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-HTTPS-Cert.pem b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-HTTPS-Cert.pem new file mode 100644 index 00000000000000..1cc3bfe2334852 --- /dev/null +++ b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-HTTPS-Cert.pem @@ -0,0 +1,14 @@ +-----BEGIN CERTIFICATE----- +MIICJTCCAcugAwIBAgIINKhBW30/Kx4wCgYIKoZIzj0EAwIwRjEYMBYGA1UEAwwP +TWF0dGVyIFRlc3QgUEFJMRQwEgYKKwYBBAGConwCAQwERkZGMTEUMBIGCisGAQQB +gqJ8AgIMBDgwMDAwIBcNMjEwNjI4MTQyMzQzWhgPOTk5OTEyMzEyMzU5NTlaMFcx +KTAnBgNVBAMMIE1hdHRlciBUZXN0IERBQyAwMDAwIENEUCAoSFRUUFMpMRQwEgYK +KwYBBAGConwCAQwERkZGMTEUMBIGCisGAQQBgqJ8AgIMBDgwMDAwWTATBgcqhkjO +PQIBBggqhkjOPQMBBwNCAATZKyTeUWuOzT5oYt6H/Dv3fnARcccLWYz/XwJ/Argg +5/oHutTk2L4mHAj7MZXVqDSCOijMRwO3xRV+FJ5eqngFo4GPMIGMMAwGA1UdEwEB +/wQCMAAwDgYDVR0PAQH/BAQDAgeAMB0GA1UdDgQWBBSjAjP4b0DRGsVfgKXAqSpQ +b+qfMTAfBgNVHSMEGDAWgBSvQrcJTevVFexuzzO4ERUiXzJSiDAsBgNVHR8EJTAj +MCGgH6AdhhtodHRwczovL2V4YW1wbGUuY29tL2NybC5wZW0wCgYIKoZIzj0EAwID +SAAwRQIgU+zq2jxdS7dQy+f40QlZEtTI5fsf7zAkH8+VgylA0JoCIQC1V168pxuE +fnfV1dFBBruHvzedkqSd6o0QoOGLSBAuHw== +-----END CERTIFICATE----- diff --git a/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-HTTPS-Key.der b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-HTTPS-Key.der new file mode 100644 index 00000000000000..1c41899873d8c2 Binary files /dev/null and b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-HTTPS-Key.der differ diff --git a/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-HTTPS-Key.pem b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-HTTPS-Key.pem new file mode 100644 index 00000000000000..ccd6216112c5e8 --- /dev/null +++ b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-HTTPS-Key.pem @@ -0,0 +1,5 @@ +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEIASkFQOGOdFOYpJvRhpiVdejCwvcrGqYzfiLFnAqcp87oAoGCCqGSM49 +AwEHoUQDQgAE2Ssk3lFrjs0+aGLeh/w7935wEXHHC1mM/18CfwK4IOf6B7rU5Ni+ +JhwI+zGV1ag0gjoozEcDt8UVfhSeXqp4BQ== +-----END EC PRIVATE KEY----- diff --git a/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Key.der b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Key.der new file mode 100644 index 00000000000000..7d63f00c9bcfa4 Binary files /dev/null and b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Key.der differ diff --git a/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Key.pem b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Key.pem new file mode 100644 index 00000000000000..48fe09ad29812d --- /dev/null +++ b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Key.pem @@ -0,0 +1,5 @@ +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEIAZZ8hZ3GOkPEiO670Qo8bDOxHK1X7sH6ofXOYmc9zFqoAoGCCqGSM49 +AwEHoUQDQgAE4wEe3p9RWrPpupMl/vI7ls1xXDrqOM6BHoj8beesMCYj+6cGiz4J +0/5UmxHMXw5ZbE7bzj57oicfuNCa9CGePQ== +-----END EC PRIVATE KEY----- diff --git a/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Long-Cert.der b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Long-Cert.der new file mode 100644 index 00000000000000..1ece300335a5fe Binary files /dev/null and b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Long-Cert.der differ diff --git a/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Long-Cert.pem b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Long-Cert.pem new file mode 100644 index 00000000000000..4cadfd7818c829 --- /dev/null +++ b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Long-Cert.pem @@ -0,0 +1,15 @@ +-----BEGIN CERTIFICATE----- +MIICUzCCAfmgAwIBAgIIHW5tUEGGAAcwCgYIKoZIzj0EAwIwRjEYMBYGA1UEAwwP +TWF0dGVyIFRlc3QgUEFJMRQwEgYKKwYBBAGConwCAQwERkZGMTEUMBIGCisGAQQB +gqJ8AgIMBDgwMDAwIBcNMjEwNjI4MTQyMzQzWhgPOTk5OTEyMzEyMzU5NTlaMDsx +DTALBgNVBAMMBExvbmcxFDASBgorBgEEAYKifAIBDARGRkYxMRQwEgYKKwYBBAGC +onwCAgwEODAwMDBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABEMo+7hxQow14iSz +f56AZANfssxy+PFxGFNGwyDhqIW15AkJXuyFX31Sr5eh0G92cWyHNn4ZiM6hGdbX +9CUrxy+jgdkwgdYwDAYDVR0TAQH/BAIwADAOBgNVHQ8BAf8EBAMCB4AwHQYDVR0O +BBYEFPZMe/GotuC6EI6960/h9nd8ySwpMB8GA1UdIwQYMBaAFK9CtwlN69UV7G7P +M7gRFSJfMlKIMHYGA1UdHwRvMG0wa6BpoGeGZWh0dHBzOi8vZXhhbXBsZS5jb20v +dGhpcy1pcy1hbi1leGFtcGxlLW9mLWNybC1kaXN0cmlidXRpb24tcG9pbnQtZXh0 +ZW5zaW9uLXdoaWNoLWlzLTEwMS1jaGFycy9jcmwucGVtMAoGCCqGSM49BAMCA0gA +MEUCIENDYnRVRbgQ6zM9WS0/RoI8U/VhGfCGROJ5TLpK2rexAiEAr1GXakRNQ566 +F7ihY3WBUwmT9hjCdBiH0+beR5GkyaQ= +-----END CERTIFICATE----- diff --git a/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Long-Key.der b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Long-Key.der new file mode 100644 index 00000000000000..5282d103be84bb Binary files /dev/null and b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Long-Key.der differ diff --git a/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Long-Key.pem b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Long-Key.pem new file mode 100644 index 00000000000000..d868b79ee31833 --- /dev/null +++ b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Long-Key.pem @@ -0,0 +1,5 @@ +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEINFUmafW3jhThp3mpGxLUtE7c1kW1Kq9UCaqrR5yeWbroAoGCCqGSM49 +AwEHoUQDQgAEQyj7uHFCjDXiJLN/noBkA1+yzHL48XEYU0bDIOGohbXkCQle7IVf +fVKvl6HQb3ZxbIc2fhmIzqEZ1tf0JSvHLw== +-----END EC PRIVATE KEY----- diff --git a/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Wrong-Prefix-Cert.der b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Wrong-Prefix-Cert.der new file mode 100644 index 00000000000000..2ad2f7c7190a4d Binary files /dev/null and b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Wrong-Prefix-Cert.der differ diff --git a/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Wrong-Prefix-Cert.pem b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Wrong-Prefix-Cert.pem new file mode 100644 index 00000000000000..c53dbb8fbd6498 --- /dev/null +++ b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Wrong-Prefix-Cert.pem @@ -0,0 +1,13 @@ +-----BEGIN CERTIFICATE----- +MIICBTCCAaugAwIBAgIIcAYIqqHXrW0wCgYIKoZIzj0EAwIwRjEYMBYGA1UEAwwP +TWF0dGVyIFRlc3QgUEFJMRQwEgYKKwYBBAGConwCAQwERkZGMTEUMBIGCisGAQQB +gqJ8AgIMBDgwMDAwIBcNMjEwNjI4MTQyMzQzWhgPOTk5OTEyMzEyMzU5NTlaMDsx +DTALBgNVBAMMBExvbmcxFDASBgorBgEEAYKifAIBDARGRkYxMRQwEgYKKwYBBAGC +onwCAgwEODAwMDBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABPzNyCm6Yjd8xsez +bqfBr3bNFcMovEtujQd4ull/u/MK5xK2V9L58rkV+CNMh+KjO/XnWXbgTmrQPYUL +0WQ588+jgYswgYgwDAYDVR0TAQH/BAIwADAOBgNVHQ8BAf8EBAMCB4AwHQYDVR0O +BBYEFAcwHO+LnkQm0uRuxvo607dEHe+9MB8GA1UdIwQYMBaAFK9CtwlN69UV7G7P +M7gRFSJfMlKIMCgGA1UdHwQhMB8wHaAboBmGF3d3dy5leGFtcGxlLmNvbS9jcmwu +cGVtMAoGCCqGSM49BAMCA0gAMEUCIQDmuIge7Q6mcILAYH5G9sqEBDGr4JHWF12B +DDih5PBFdwIgOQZfvvn9pBs3r8ux9t8JDhpEO6xuZSw72sED9NOsTnY= +-----END CERTIFICATE----- diff --git a/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Wrong-Prefix-Key.der b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Wrong-Prefix-Key.der new file mode 100644 index 00000000000000..ab268e2e51f69e Binary files /dev/null and b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Wrong-Prefix-Key.der differ diff --git a/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Wrong-Prefix-Key.pem b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Wrong-Prefix-Key.pem new file mode 100644 index 00000000000000..f9c33a94072281 --- /dev/null +++ b/credentials/test/attestation/Chip-Test-DAC-FFF1-8000-0000-CDP-Wrong-Prefix-Key.pem @@ -0,0 +1,5 @@ +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEIKUdzfzZVduHJDVshxIakL0TGFN4p6mMcfRwRKKm2+vboAoGCCqGSM49 +AwEHoUQDQgAE/M3IKbpiN3zGx7Nup8Gvds0Vwyi8S26NB3i6WX+78wrnErZX0vny +uRX4I0yH4qM79edZduBOatA9hQvRZDnzzw== +-----END EC PRIVATE KEY----- diff --git a/credentials/test/gen-test-attestation-certs.sh b/credentials/test/gen-test-attestation-certs.sh index 83bc7668a62bb2..04d0ba6130dac8 100755 --- a/credentials/test/gen-test-attestation-certs.sh +++ b/credentials/test/gen-test-attestation-certs.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # -# Copyright (c) 2021-2022 Project CHIP Authors +# Copyright (c) 2021-2023 Project CHIP Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -340,6 +340,59 @@ cert_lifetime=4294967295 "$chip_cert_tool" gen-att-cert --type i --subject-cn "Matter Test PAI" --subject-vid "$vid" --valid-from "$cert_valid_from" --lifetime "$cert_lifetime" --ca-key "$paa_key_file".pem --ca-cert "$paa_cert_file".pem --key "$pai_key_file".pem --out "$pai_cert_file".pem } +# Set #8: +# - Generate DACs with CRL Distribution Point (CDP) Extensions (Valid and Invalid cases) +{ + vid=FFF1 + pid=8000 + dac=0000 + + pai_key_file="$dest_dir/Chip-Test-PAI-$vid-$pid-Key" + pai_cert_file="$dest_dir/Chip-Test-PAI-$vid-$pid-Cert" + + dac_key_file="$dest_dir/Chip-Test-DAC-$vid-$pid-$dac-CDP-Key" + dac_cert_file="$dest_dir/Chip-Test-DAC-$vid-$pid-$dac-CDP-Cert" + + cdp_example="URI:http://example.com/crl.pem" + + "$chip_cert_tool" gen-att-cert --type d --subject-cn "Matter Test DAC $dac CDP (HTTP)" --subject-vid "$vid" --subject-pid "$pid" --valid-from "$cert_valid_from" --lifetime "$cert_lifetime" --cpd-ext "$cdp_example" --ca-key "$pai_key_file".pem --ca-cert "$pai_cert_file".pem --out-key "$dac_key_file".pem --out "$dac_cert_file".pem + + dac_key_file="$dest_dir/Chip-Test-DAC-$vid-$pid-$dac-CDP-HTTPS-Key" + dac_cert_file="$dest_dir/Chip-Test-DAC-$vid-$pid-$dac-CDP-HTTPS-Cert" + + cdp_example="URI:https://example.com/crl.pem" + + "$chip_cert_tool" gen-att-cert --type d --subject-cn "Matter Test DAC $dac CDP (HTTPS)" --subject-vid "$vid" --subject-pid "$pid" --valid-from "$cert_valid_from" --lifetime "$cert_lifetime" --cpd-ext "$cdp_example" --ca-key "$pai_key_file".pem --ca-cert "$pai_cert_file".pem --out-key "$dac_key_file".pem --out "$dac_cert_file".pem + + dac_key_file="$dest_dir/Chip-Test-DAC-$vid-$pid-$dac-2CDPs-Key" + dac_cert_file="$dest_dir/Chip-Test-DAC-$vid-$pid-$dac-2CDPs-Cert" + + cdp_example2="URI:http://example.com/crl2.pem" + + "$chip_cert_tool" gen-att-cert --type d --subject-cn "Matter Test DAC $dac Two CDPs" --subject-vid "$vid" --subject-pid "$pid" --valid-from "$cert_valid_from" --lifetime "$cert_lifetime" --cpd-ext "$cdp_example" --cpd-ext "$cdp_example2" --ca-key "$pai_key_file".pem --ca-cert "$pai_cert_file".pem --out-key "$dac_key_file".pem --out "$dac_cert_file".pem + + dac_key_file="$dest_dir/Chip-Test-DAC-$vid-$pid-$dac-CDP-2URIs-Key" + dac_cert_file="$dest_dir/Chip-Test-DAC-$vid-$pid-$dac-CDP-2URIs-Cert" + + cdp_example2in1="URI:http://example.com/crl.pem,URI:http://example.com/crl2.pem" + + "$chip_cert_tool" gen-att-cert --type d --subject-cn "Matter Test DAC $dac CDP (Two URIs)" --subject-vid "$vid" --subject-pid "$pid" --valid-from "$cert_valid_from" --lifetime "$cert_lifetime" --cpd-ext "$cdp_example2in1" --ca-key "$pai_key_file".pem --ca-cert "$pai_cert_file".pem --out-key "$dac_key_file".pem --out "$dac_cert_file".pem + + dac_key_file="$dest_dir/Chip-Test-DAC-$vid-$pid-$dac-CDP-Long-Key" + dac_cert_file="$dest_dir/Chip-Test-DAC-$vid-$pid-$dac-CDP-Long-Cert" + + cdp_example="URI:https://example.com/this-is-an-example-of-crl-distribution-point-extension-which-is-101-chars/crl.pem" + + "$chip_cert_tool" gen-att-cert --type d --subject-cn "Long" --subject-vid "$vid" --subject-pid "$pid" --valid-from "$cert_valid_from" --lifetime "$cert_lifetime" --cpd-ext "$cdp_example" --ca-key "$pai_key_file".pem --ca-cert "$pai_cert_file".pem --out-key "$dac_key_file".pem --out "$dac_cert_file".pem + + dac_key_file="$dest_dir/Chip-Test-DAC-$vid-$pid-$dac-CDP-Wrong-Prefix-Key" + dac_cert_file="$dest_dir/Chip-Test-DAC-$vid-$pid-$dac-CDP-Wrong-Prefix-Cert" + + cdp_example="URI:www.example.com/crl.pem" + + "$chip_cert_tool" gen-att-cert --type d --subject-cn "Long" --subject-vid "$vid" --subject-pid "$pid" --valid-from "$cert_valid_from" --lifetime "$cert_lifetime" --cpd-ext "$cdp_example" --ca-key "$pai_key_file".pem --ca-cert "$pai_cert_file".pem --out-key "$dac_key_file".pem --out "$dac_cert_file".pem +} + # In addition to PEM format also create certificates in DER form. for cert_file_pem in "$dest_dir"/*Cert.pem; do cert_file_der="${cert_file_pem/.pem/.der}" @@ -357,7 +410,7 @@ if [ ! -z "$output_cstyle_file" ]; then copyright_note='/* * - * Copyright (c) 2021-2022 Project CHIP Authors + * Copyright (c) 2021-2023 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -380,6 +433,8 @@ if [ ! -z "$output_cstyle_file" ]; then ' header_includes=' #pragma once + +#include ' namespaces_open=' diff --git a/docs/_extensions/external_content.py b/docs/_extensions/external_content.py index 99340cab259d02..9a8e5effcfaf39 100644 --- a/docs/_extensions/external_content.py +++ b/docs/_extensions/external_content.py @@ -81,7 +81,7 @@ def adjust_includes( def _adjust_path(path): # ignore absolute paths, section links, hyperlinks and same folder - if path.startswith(("/", "#", "http", "www")) or not "/" in path: + if path.startswith(("/", "#", "http", "www")) or "/" not in path: return path # for files that are being copied modify reference to and out of /docs diff --git a/docs/guides/index.md b/docs/guides/index.md index 1cbfcabcf17c61..275ead9feaabd3 100644 --- a/docs/guides/index.md +++ b/docs/guides/index.md @@ -47,6 +47,8 @@ esp32/README - [Python Matter-Repl](./matter-repl.md) - [python-chip-controller - Advanced](./python_chip_controller_advanced_usage.md) - [python-chip-controller - Building](./python_chip_controller_building.md) +- [CHEF test devices](../../examples/chef/README.md) + - [New device type adding](../../examples/chef/NEW_CHEF_DEVICES.md) ## Development Guides diff --git a/docs/guides/matter-repl.md b/docs/guides/matter-repl.md index 1bc5cf495fac52..e7ebba5b3e18cd 100644 --- a/docs/guides/matter-repl.md +++ b/docs/guides/matter-repl.md @@ -241,7 +241,7 @@ Some tests provides the option to exclude them. For example, you can use `--disable-test ClusterObjectTests.TestTimedRequestTimeout` to exclude the "TestTimedRequestTimeout" test case. -It is recommanded to use the test wrapper to run mobile-device-test.py, for +It is recommended to use the test wrapper to run mobile-device-test.py, for example, you can run: ``` diff --git a/docs/guides/openiotsdk_examples.md b/docs/guides/openiotsdk_examples.md index 289fa33aace366..d779f34b6c5358 100644 --- a/docs/guides/openiotsdk_examples.md +++ b/docs/guides/openiotsdk_examples.md @@ -10,6 +10,8 @@ The list of currently supported Matter examples: ``` shell lock-app +tv-app +all-clusters-app ``` You can use these examples as a reference for creating your own applications. diff --git a/docs/guides/repl/Matter_Multi_Fabric_Commissioning.ipynb b/docs/guides/repl/Matter_Multi_Fabric_Commissioning.ipynb index fe60b08a1c709c..5738ee612c9967 100644 --- a/docs/guides/repl/Matter_Multi_Fabric_Commissioning.ipynb +++ b/docs/guides/repl/Matter_Multi_Fabric_Commissioning.ipynb @@ -958,7 +958,7 @@ "source": [ "### Establish CASE and Read OpCreds\n", "\n", - "To prove that we do indeed have two distinct fabrics and controllers on each fabric, let's go ahead and update the label of each fabric. To do so, you'd need to succcessfully establish a CASE session through a controller on the respective fabric, and call the 'UpdateLabel' command.\n", + "To prove that we do indeed have two distinct fabrics and controllers on each fabric, let's go ahead and update the label of each fabric. To do so, you'd need to successfully establish a CASE session through a controller on the respective fabric, and call the 'UpdateLabel' command.\n", "\n", "Underneath the covers, each device controller will do operational discovery of the NodeId being read and establish a CASE session before issuing the IM interaction." ] diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter index 9e867f1be026a7..a0991594cef32f 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter @@ -2542,6 +2542,175 @@ server cluster AirQuality = 91 { readonly attribute int16u clusterRevision = 65533; } +/** This cluster provides an interface for observing and managing the state of smoke and CO alarms. */ +server cluster SmokeCoAlarm = 92 { + enum AlarmStateEnum : ENUM8 { + kNormal = 0; + kWarning = 1; + kCritical = 2; + } + + enum ContaminationStateEnum : ENUM8 { + kNormal = 0; + kLow = 1; + kWarning = 2; + kCritical = 3; + } + + enum EndOfServiceEnum : ENUM8 { + kNormal = 0; + kExpired = 1; + } + + enum ExpressedStateEnum : ENUM8 { + kNormal = 0; + kSmokeAlarm = 1; + kCOAlarm = 2; + kBatteryAlert = 3; + kTesting = 4; + kHardwareFault = 5; + kEndOfService = 6; + kInterconnectSmoke = 7; + kInterconnectCO = 8; + } + + enum MuteStateEnum : ENUM8 { + kNotMuted = 0; + kMuted = 1; + } + + enum SensitivityEnum : ENUM8 { + kHigh = 0; + kStandard = 1; + kLow = 2; + } + + bitmap Feature : BITMAP32 { + kSmokeAlarm = 0x1; + kCOAlarm = 0x2; + } + + critical event SmokeAlarm = 0 { + AlarmStateEnum alarmSeverityLevel = 0; + } + + critical event COAlarm = 1 { + AlarmStateEnum alarmSeverityLevel = 0; + } + + info event LowBattery = 2 { + AlarmStateEnum alarmSeverityLevel = 0; + } + + info event HardwareFault = 3 { + } + + info event EndOfService = 4 { + } + + info event SelfTestComplete = 5 { + } + + info event AlarmMuted = 6 { + } + + info event MuteEnded = 7 { + } + + critical event InterconnectSmokeAlarm = 8 { + AlarmStateEnum alarmSeverityLevel = 0; + } + + critical event InterconnectCOAlarm = 9 { + AlarmStateEnum alarmSeverityLevel = 0; + } + + info event AllClear = 10 { + } + + readonly attribute ExpressedStateEnum expressedState = 0; + readonly attribute AlarmStateEnum smokeState = 1; + readonly attribute AlarmStateEnum COState = 2; + readonly attribute AlarmStateEnum batteryAlert = 3; + readonly attribute MuteStateEnum deviceMuted = 4; + readonly attribute boolean testInProgress = 5; + readonly attribute boolean hardwareFaultAlert = 6; + readonly attribute EndOfServiceEnum endOfServiceAlert = 7; + readonly attribute AlarmStateEnum interconnectSmokeAlarm = 8; + readonly attribute AlarmStateEnum interconnectCOAlarm = 9; + readonly attribute ContaminationStateEnum contaminationState = 10; + attribute SensitivityEnum sensitivityLevel = 11; + readonly attribute epoch_s expiryDate = 12; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + command SelfTestRequest(): DefaultSuccess = 0; +} + +/** This cluster supports remotely monitoring and, where supported, changing the operational state of any device where a state machine is a part of the operation. */ +server cluster OperationalState = 96 { + enum ErrorStateEnum : ENUM8 { + kNoError = 0; + kUnableToStartOrResume = 1; + kUnableToCompleteOperation = 2; + kCommandInvalidInState = 3; + } + + enum OperationalStateEnum : ENUM8 { + kStopped = 0; + kRunning = 1; + kPaused = 2; + kError = 3; + } + + struct ErrorStateStruct { + enum8 errorStateID = 0; + optional char_string<64> errorStateLabel = 1; + optional char_string<64> errorStateDetails = 2; + } + + struct OperationalStateStruct { + enum8 operationalStateID = 0; + optional char_string<64> operationalStateLabel = 1; + } + + critical event OperationalError = 0 { + ErrorStateStruct errorState = 0; + } + + info event OperationCompletion = 1 { + ENUM8 completionErrorCode = 0; + optional nullable elapsed_s totalOperationalTime = 1; + optional nullable elapsed_s pausedTime = 2; + } + + readonly attribute nullable CHAR_STRING phaseList[] = 0; + readonly attribute nullable int8u currentPhase = 1; + readonly attribute nullable elapsed_s countdownTime = 2; + readonly attribute OperationalStateStruct operationalStateList[] = 3; + readonly attribute OperationalStateStruct operationalState = 4; + readonly attribute ErrorStateStruct operationalError = 5; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + response struct OperationalCommandResponse = 4 { + ErrorStateStruct commandResponseState = 0; + } + + command Pause(): OperationalCommandResponse = 0; + command Stop(): OperationalCommandResponse = 1; + command Start(): OperationalCommandResponse = 2; + command Resume(): OperationalCommandResponse = 3; +} + /** Attributes and commands for monitoring HEPA filters in a device */ server cluster HepaFilterMonitoring = 113 { enum ChangeIndicationEnum : ENUM8 { @@ -2555,11 +2724,24 @@ server cluster HepaFilterMonitoring = 113 { kDown = 1; } + enum ProductIdentifierTypeEnum : ENUM8 { + kUPC = 0; + kGTIN8 = 1; + kEAN = 2; + kGTIN14 = 3; + kOEM = 4; + } + bitmap Feature : BITMAP32 { kCondition = 0x1; kWarning = 0x2; } + struct ReplacementProductStruct { + ProductIdentifierTypeEnum productIdentifierType = 0; + char_string<20> productIdentifierValue = 1; + } + readonly attribute percent condition = 0; readonly attribute DegradationDirectionEnum degradationDirection = 1; readonly attribute ChangeIndicationEnum changeIndication = 2; @@ -2585,11 +2767,24 @@ server cluster ActivatedCarbonFilterMonitoring = 114 { kDown = 1; } + enum ProductIdentifierTypeEnum : ENUM8 { + kUPC = 0; + kGTIN8 = 1; + kEAN = 2; + kGTIN14 = 3; + kOEM = 4; + } + bitmap Feature : BITMAP32 { kCondition = 0x1; kWarning = 0x2; } + struct ReplacementProductStruct { + ProductIdentifierTypeEnum productIdentifierType = 0; + char_string<20> productIdentifierValue = 1; + } + readonly attribute percent condition = 0; readonly attribute DegradationDirectionEnum degradationDirection = 1; readonly attribute ChangeIndicationEnum changeIndication = 2; @@ -2615,11 +2810,24 @@ server cluster CeramicFilterMonitoring = 115 { kDown = 1; } + enum ProductIdentifierTypeEnum : ENUM8 { + kUPC = 0; + kGTIN8 = 1; + kEAN = 2; + kGTIN14 = 3; + kOEM = 4; + } + bitmap Feature : BITMAP32 { kCondition = 0x1; kWarning = 0x2; } + struct ReplacementProductStruct { + ProductIdentifierTypeEnum productIdentifierType = 0; + char_string<20> productIdentifierValue = 1; + } + readonly attribute percent condition = 0; readonly attribute DegradationDirectionEnum degradationDirection = 1; readonly attribute ChangeIndicationEnum changeIndication = 2; @@ -2645,11 +2853,24 @@ server cluster ElectrostaticFilterMonitoring = 116 { kDown = 1; } + enum ProductIdentifierTypeEnum : ENUM8 { + kUPC = 0; + kGTIN8 = 1; + kEAN = 2; + kGTIN14 = 3; + kOEM = 4; + } + bitmap Feature : BITMAP32 { kCondition = 0x1; kWarning = 0x2; } + struct ReplacementProductStruct { + ProductIdentifierTypeEnum productIdentifierType = 0; + char_string<20> productIdentifierValue = 1; + } + readonly attribute percent condition = 0; readonly attribute DegradationDirectionEnum degradationDirection = 1; readonly attribute ChangeIndicationEnum changeIndication = 2; @@ -2675,11 +2896,24 @@ server cluster UvFilterMonitoring = 117 { kDown = 1; } + enum ProductIdentifierTypeEnum : ENUM8 { + kUPC = 0; + kGTIN8 = 1; + kEAN = 2; + kGTIN14 = 3; + kOEM = 4; + } + bitmap Feature : BITMAP32 { kCondition = 0x1; kWarning = 0x2; } + struct ReplacementProductStruct { + ProductIdentifierTypeEnum productIdentifierType = 0; + char_string<20> productIdentifierValue = 1; + } + readonly attribute percent condition = 0; readonly attribute DegradationDirectionEnum degradationDirection = 1; readonly attribute ChangeIndicationEnum changeIndication = 2; @@ -2705,11 +2939,24 @@ server cluster IonizingFilterMonitoring = 118 { kDown = 1; } + enum ProductIdentifierTypeEnum : ENUM8 { + kUPC = 0; + kGTIN8 = 1; + kEAN = 2; + kGTIN14 = 3; + kOEM = 4; + } + bitmap Feature : BITMAP32 { kCondition = 0x1; kWarning = 0x2; } + struct ReplacementProductStruct { + ProductIdentifierTypeEnum productIdentifierType = 0; + char_string<20> productIdentifierValue = 1; + } + readonly attribute percent condition = 0; readonly attribute DegradationDirectionEnum degradationDirection = 1; readonly attribute ChangeIndicationEnum changeIndication = 2; @@ -2735,11 +2982,24 @@ server cluster ZeoliteFilterMonitoring = 119 { kDown = 1; } + enum ProductIdentifierTypeEnum : ENUM8 { + kUPC = 0; + kGTIN8 = 1; + kEAN = 2; + kGTIN14 = 3; + kOEM = 4; + } + bitmap Feature : BITMAP32 { kCondition = 0x1; kWarning = 0x2; } + struct ReplacementProductStruct { + ProductIdentifierTypeEnum productIdentifierType = 0; + char_string<20> productIdentifierValue = 1; + } + readonly attribute percent condition = 0; readonly attribute DegradationDirectionEnum degradationDirection = 1; readonly attribute ChangeIndicationEnum changeIndication = 2; @@ -2765,11 +3025,24 @@ server cluster OzoneFilterMonitoring = 120 { kDown = 1; } + enum ProductIdentifierTypeEnum : ENUM8 { + kUPC = 0; + kGTIN8 = 1; + kEAN = 2; + kGTIN14 = 3; + kOEM = 4; + } + bitmap Feature : BITMAP32 { kCondition = 0x1; kWarning = 0x2; } + struct ReplacementProductStruct { + ProductIdentifierTypeEnum productIdentifierType = 0; + char_string<20> productIdentifierValue = 1; + } + readonly attribute percent condition = 0; readonly attribute DegradationDirectionEnum degradationDirection = 1; readonly attribute ChangeIndicationEnum changeIndication = 2; @@ -2795,11 +3068,24 @@ server cluster WaterTankMonitoring = 121 { kDown = 1; } + enum ProductIdentifierTypeEnum : ENUM8 { + kUPC = 0; + kGTIN8 = 1; + kEAN = 2; + kGTIN14 = 3; + kOEM = 4; + } + bitmap Feature : BITMAP32 { kCondition = 0x1; kWarning = 0x2; } + struct ReplacementProductStruct { + ProductIdentifierTypeEnum productIdentifierType = 0; + char_string<20> productIdentifierValue = 1; + } + readonly attribute percent condition = 0; readonly attribute DegradationDirectionEnum degradationDirection = 1; readonly attribute ChangeIndicationEnum changeIndication = 2; @@ -2825,11 +3111,24 @@ server cluster FuelTankMonitoring = 122 { kDown = 1; } + enum ProductIdentifierTypeEnum : ENUM8 { + kUPC = 0; + kGTIN8 = 1; + kEAN = 2; + kGTIN14 = 3; + kOEM = 4; + } + bitmap Feature : BITMAP32 { kCondition = 0x1; kWarning = 0x2; } + struct ReplacementProductStruct { + ProductIdentifierTypeEnum productIdentifierType = 0; + char_string<20> productIdentifierValue = 1; + } + readonly attribute percent condition = 0; readonly attribute DegradationDirectionEnum degradationDirection = 1; readonly attribute ChangeIndicationEnum changeIndication = 2; @@ -2855,11 +3154,24 @@ server cluster InkCartridgeMonitoring = 123 { kDown = 1; } + enum ProductIdentifierTypeEnum : ENUM8 { + kUPC = 0; + kGTIN8 = 1; + kEAN = 2; + kGTIN14 = 3; + kOEM = 4; + } + bitmap Feature : BITMAP32 { kCondition = 0x1; kWarning = 0x2; } + struct ReplacementProductStruct { + ProductIdentifierTypeEnum productIdentifierType = 0; + char_string<20> productIdentifierValue = 1; + } + readonly attribute percent condition = 0; readonly attribute DegradationDirectionEnum degradationDirection = 1; readonly attribute ChangeIndicationEnum changeIndication = 2; @@ -2885,11 +3197,24 @@ server cluster TonerCartridgeMonitoring = 124 { kDown = 1; } + enum ProductIdentifierTypeEnum : ENUM8 { + kUPC = 0; + kGTIN8 = 1; + kEAN = 2; + kGTIN14 = 3; + kOEM = 4; + } + bitmap Feature : BITMAP32 { kCondition = 0x1; kWarning = 0x2; } + struct ReplacementProductStruct { + ProductIdentifierTypeEnum productIdentifierType = 0; + char_string<20> productIdentifierValue = 1; + } + readonly attribute percent condition = 0; readonly attribute DegradationDirectionEnum degradationDirection = 1; readonly attribute ChangeIndicationEnum changeIndication = 2; @@ -6341,6 +6666,52 @@ endpoint 1 { ram attribute clusterRevision default = 1; } + server cluster SmokeCoAlarm { + emits event SmokeAlarm; + emits event COAlarm; + emits event LowBattery; + emits event HardwareFault; + emits event EndOfService; + emits event SelfTestComplete; + emits event AlarmMuted; + emits event MuteEnded; + emits event InterconnectSmokeAlarm; + emits event InterconnectCOAlarm; + emits event AllClear; + persist attribute expressedState default = 0; + persist attribute smokeState default = 0; + persist attribute COState default = 0; + persist attribute batteryAlert default = 0; + persist attribute deviceMuted default = 0; + ram attribute testInProgress default = 0; + persist attribute hardwareFaultAlert default = 0; + persist attribute endOfServiceAlert default = 0; + ram attribute interconnectSmokeAlarm default = 0; + ram attribute interconnectCOAlarm default = 0; + ram attribute contaminationState default = 0; + ram attribute sensitivityLevel default = 1; + ram attribute expiryDate default = 0; + ram attribute featureMap default = 3; + ram attribute clusterRevision default = 1; + } + + server cluster OperationalState { + emits event OperationalError; + emits event OperationCompletion; + callback attribute phaseList; + callback attribute currentPhase; + callback attribute countdownTime; + callback attribute operationalStateList; + callback attribute operationalState; + callback attribute operationalError; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute eventList; + callback attribute attributeList; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; + } + server cluster HepaFilterMonitoring { ram attribute condition; ram attribute degradationDirection; diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap index 518c6e563eaa70..e78ffef66e0cc4 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap @@ -5703,7 +5703,7 @@ "side": "server", "type": "int8u", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "3", @@ -5719,7 +5719,7 @@ "side": "server", "type": "int8u", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, "defaultValue": "", @@ -13890,6 +13890,755 @@ } ] }, + { + "name": "Smoke CO Alarm", + "code": 92, + "mfgCode": null, + "define": "SMOKE_CO_ALARM_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "SelfTestRequest", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "client", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Smoke CO Alarm", + "code": 92, + "mfgCode": null, + "define": "SMOKE_CO_ALARM_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "ExpressedState", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "ExpressedStateEnum", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SmokeState", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "AlarmStateEnum", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "COState", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "AlarmStateEnum", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "BatteryAlert", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "AlarmStateEnum", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "DeviceMuted", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "MuteStateEnum", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TestInProgress", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "HardwareFaultAlert", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EndOfServiceAlert", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "EndOfServiceEnum", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "InterconnectSmokeAlarm", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "AlarmStateEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "InterconnectCOAlarm", + "code": 9, + "mfgCode": null, + "side": "server", + "type": "AlarmStateEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ContaminationState", + "code": 10, + "mfgCode": null, + "side": "server", + "type": "ContaminationStateEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SensitivityLevel", + "code": 11, + "mfgCode": null, + "side": "server", + "type": "SensitivityEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ExpiryDate", + "code": 12, + "mfgCode": null, + "side": "server", + "type": "epoch_s", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 0, + "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": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EventList", + "code": 65530, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 0, + "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": 0, + "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": "3", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ], + "events": [ + { + "name": "SmokeAlarm", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "COAlarm", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "LowBattery", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "HardwareFault", + "code": 3, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "EndOfService", + "code": 4, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "SelfTestComplete", + "code": 5, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "AlarmMuted", + "code": 6, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "MuteEnded", + "code": 7, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "InterconnectSmokeAlarm", + "code": 8, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "InterconnectCOAlarm", + "code": 9, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "AllClear", + "code": 10, + "mfgCode": null, + "side": "server", + "included": 1 + } + ] + }, + { + "name": "Operational State", + "code": 96, + "mfgCode": null, + "define": "OPERATIONAL_STATE_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "Pause", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "Stop", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "Start", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "Resume", + "code": 3, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "client", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Operational State", + "code": 96, + "mfgCode": null, + "define": "OPERATIONAL_STATE_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "OperationalCommandResponse", + "code": 4, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "PhaseList", + "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": "CurrentPhase", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CountdownTime", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "elapsed_s", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "OperationalStateList", + "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": "OperationalState", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "OperationalStateStruct", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "OperationalError", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "ErrorStateStruct", + "included": 1, + "storageOption": "External", + "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": "EventList", + "code": 65530, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ], + "events": [ + { + "name": "OperationalError", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "OperationCompletion", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1 + } + ] + }, { "name": "HEPA Filter Monitoring", "code": 113, diff --git a/examples/all-clusters-app/all-clusters-common/include/operational-state-delegate-impl.h b/examples/all-clusters-app/all-clusters-common/include/operational-state-delegate-impl.h new file mode 100644 index 00000000000000..d3fa6bd913dd14 --- /dev/null +++ b/examples/all-clusters-app/all-clusters-common/include/operational-state-delegate-impl.h @@ -0,0 +1,151 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include +#include +#include + +namespace chip { +namespace app { +namespace Clusters { +namespace OperationalState { + +// This is an application level delegate to handle operational state commands according to the specific business logic. +class OperationalStateDelegate : public Delegate +{ + +public: + /** + * Get current operational state. + * @param op The GenericOperationalState to fill with the current operational state value. + * @return void. + */ + void GetCurrentOperationalState(GenericOperationalState & op) override; + + /** + * Get the list of supported operational states. + * Fills in the provided GenericOperationalState with the state at index `index` if there is one, + * or returns CHIP_ERROR_NOT_FOUND if the index is out of range for the list of states. + * @param index The index of the state, with 0 representing the first state. + * @param operationalState The GenericOperationalState is filled. + */ + CHIP_ERROR GetOperationalStateAtIndex(size_t index, GenericOperationalState & operationalState) override; + + /** + * Get the list of supported operational phases. + * Fills in the provided GenericOperationalPhase with the phase at index `index` if there is one, + * or returns CHIP_ERROR_NOT_FOUND if the index is out of range for the list of phases. + * @param index The index of the phase, with 0 representing the first phase. + * @param operationalPhase The GenericOperationalPhase is filled. + */ + CHIP_ERROR GetOperationalPhaseAtIndex(size_t index, GenericOperationalPhase & operationalPhase) override; + + /** + * Get current operational error. + * @param error The GenericOperationalError to fill with the current operational error value + */ + void GetCurrentOperationalError(GenericOperationalError & error) override; + + /** + * Get current phase + * @param phase The app::DataModel::Nullable to fill with the current phase value + */ + void GetCurrentPhase(app::DataModel::Nullable & phase) override; + + /** + * Get countdown time + * @param time The app::DataModel::Nullable to fill with the coutdown time value + */ + void GetCountdownTime(app::DataModel::Nullable & time) override; + + /** + * Set operational error. + * @param opErrState The new operational error. + */ + CHIP_ERROR SetOperationalError(const GenericOperationalError & opErrState) override; + + /** + * Set current operational state. + * @param opState The operational state that should now be the current one. + */ + CHIP_ERROR SetOperationalState(const GenericOperationalState & opState) override; + + /** + * Set operational phase. + * @param phase The operational phase that should now be the current one. + */ + CHIP_ERROR SetPhase(const app::DataModel::Nullable & phase) override; + + /** + * Set coutdown time. + * @param time The coutdown time that should now be the current one. + */ + CHIP_ERROR SetCountdownTime(const app::DataModel::Nullable & time) override; + + // command callback + /** + * Handle Command Callback in application: Pause + * @param[out] get operational error after callback. + */ + void HandlePauseStateCallback(GenericOperationalError & err) override; + + /** + * Handle Command Callback in application: Resume + * @param[out] get operational error after callback. + */ + void HandleResumeStateCallback(GenericOperationalError & err) override; + + /** + * Handle Command Callback in application: Start + * @param[out] get operational error after callback. + */ + void HandleStartStateCallback(GenericOperationalError & err) override; + + /** + * Handle Command Callback in application: Stop + * @param[out] get operational error after callback. + */ + void HandleStopStateCallback(GenericOperationalError & err) override; + + OperationalStateDelegate(GenericOperationalState aOperationalState, GenericOperationalError aOperationalError, + Span aOperationalStateList, + Span aOperationalPhaseList, + app::DataModel::Nullable aPhase = DataModel::Nullable(), + app::DataModel::Nullable aCountdownTime = DataModel::Nullable()) : + mOperationalState(aOperationalState), + mOperationalError(aOperationalError), mOperationalStateList(aOperationalStateList), + mOperationalPhaseList(aOperationalPhaseList), mOperationalPhase(aPhase), mCountdownTime(aCountdownTime) + {} + ~OperationalStateDelegate() = default; + +private: + GenericOperationalState mOperationalState; + GenericOperationalError mOperationalError; + app::DataModel::List mOperationalStateList; + Span mOperationalPhaseList; + app::DataModel::Nullable mOperationalPhase; + app::DataModel::Nullable mCountdownTime; +}; + +} // namespace OperationalState +} // namespace Clusters +} // namespace app +} // namespace chip diff --git a/examples/all-clusters-app/all-clusters-common/src/operational-state-delegate-impl.cpp b/examples/all-clusters-app/all-clusters-common/src/operational-state-delegate-impl.cpp new file mode 100644 index 00000000000000..ce6c5945497e76 --- /dev/null +++ b/examples/all-clusters-app/all-clusters-common/src/operational-state-delegate-impl.cpp @@ -0,0 +1,122 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include + +namespace chip { +namespace app { +namespace Clusters { +namespace OperationalState { + +using chip::Protocols::InteractionModel::Status; + +CHIP_ERROR OperationalStateDelegate::SetOperationalState(const GenericOperationalState & opState) +{ + mOperationalState = opState; + return CHIP_NO_ERROR; +} + +CHIP_ERROR OperationalStateDelegate::SetPhase(const app::DataModel::Nullable & phase) +{ + mOperationalPhase = phase; + return CHIP_NO_ERROR; +} + +CHIP_ERROR OperationalStateDelegate::SetCountdownTime(const app::DataModel::Nullable & time) +{ + mCountdownTime = time; + return CHIP_NO_ERROR; +} + +void OperationalStateDelegate::GetCurrentOperationalState(GenericOperationalState & op) +{ + op = mOperationalState; +} + +CHIP_ERROR OperationalStateDelegate::SetOperationalError(const GenericOperationalError & opErrState) +{ + mOperationalError = opErrState; + return CHIP_NO_ERROR; +} + +void OperationalStateDelegate::GetCurrentOperationalError(GenericOperationalError & error) +{ + error = mOperationalError; +} + +void OperationalStateDelegate::GetCurrentPhase(app::DataModel::Nullable & phase) +{ + phase = mOperationalPhase; +} + +void OperationalStateDelegate::GetCountdownTime(app::DataModel::Nullable & time) +{ + time = mCountdownTime; +} + +CHIP_ERROR OperationalStateDelegate::GetOperationalStateAtIndex(size_t index, GenericOperationalState & operationalState) +{ + if (index > mOperationalStateList.size() - 1) + { + return CHIP_ERROR_NOT_FOUND; + } + operationalState = mOperationalStateList[index]; + return CHIP_NO_ERROR; +} + +CHIP_ERROR OperationalStateDelegate::GetOperationalPhaseAtIndex(size_t index, GenericOperationalPhase & operationalPhase) +{ + if (index > mOperationalPhaseList.size() - 1) + { + return CHIP_ERROR_NOT_FOUND; + } + operationalPhase = mOperationalPhaseList[index]; + return CHIP_NO_ERROR; +} + +void OperationalStateDelegate::HandlePauseStateCallback(GenericOperationalError & err) +{ + // placeholder implementation + mOperationalState.Set(to_underlying(OperationalStateEnum::kPaused)); + err.Set(to_underlying(ErrorStateEnum::kNoError)); +} + +void OperationalStateDelegate::HandleResumeStateCallback(GenericOperationalError & err) +{ + // placeholder implementation + mOperationalState.Set(to_underlying(OperationalStateEnum::kRunning)); + err.Set(to_underlying(ErrorStateEnum::kNoError)); +} + +void OperationalStateDelegate::HandleStartStateCallback(GenericOperationalError & err) +{ + // placeholder implementation + mOperationalState.Set(to_underlying(OperationalStateEnum::kRunning)); + err.Set(to_underlying(ErrorStateEnum::kNoError)); +} + +void OperationalStateDelegate::HandleStopStateCallback(GenericOperationalError & err) +{ + // placeholder implementation + mOperationalState.Set(to_underlying(OperationalStateEnum::kStopped)); + err.Set(to_underlying(ErrorStateEnum::kNoError)); +} + +} // namespace OperationalState +} // namespace Clusters +} // namespace app +} // namespace chip diff --git a/examples/all-clusters-app/all-clusters-common/src/operational-state-delegates.cpp b/examples/all-clusters-app/all-clusters-common/src/operational-state-delegates.cpp new file mode 100644 index 00000000000000..32bf09a4592b3c --- /dev/null +++ b/examples/all-clusters-app/all-clusters-common/src/operational-state-delegates.cpp @@ -0,0 +1,133 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#include +#include +#include +#include +#include + +namespace chip { +namespace app { +namespace Clusters { +namespace OperationalState { + +/** + * class to present Enquiry Table of Delegates + */ +struct DelegatesEnquiryTable +{ + /** + * Endpoint Id + */ + EndpointId mEndpointId; + /** + * Cluster Id + */ + ClusterId mClusterId; + /** + * The delegate for the cluster instance given by mEndpointId and mClusterId. + */ + Delegate * pItem; +}; + +/* + * An example to present device's endpointId + */ +constexpr EndpointId kDemoEndpointId = 1; + +/** + * Operational State List + * Note: User Define + */ +static const GenericOperationalState opStateList[] = { + GenericOperationalState(to_underlying(OperationalStateEnum::kStopped)), + GenericOperationalState(to_underlying(OperationalStateEnum::kRunning)), + GenericOperationalState(to_underlying(OperationalStateEnum::kPaused)), + GenericOperationalState(to_underlying(OperationalStateEnum::kError)), +}; + +/** + * Phase List + * Note: User Define + */ +static const GenericOperationalPhase opPhaseList[] = { + /** + * Phase List is null + */ + GenericOperationalPhase(DataModel::Nullable()), +}; + +/** + * Operational State Delegate + * Note: User Define + */ +static OperationalStateDelegate opStateDelegate(GenericOperationalState(to_underlying(OperationalStateEnum::kStopped)), + GenericOperationalError(to_underlying(ErrorStateEnum::kNoError)), + Span(opStateList), + Span(opPhaseList)); + +/** + * Enquiry Table of Operational State Cluster and alias Cluter Delegate corresponding to endpointId and clusterId + * Note: User Define + */ +constexpr DelegatesEnquiryTable kDelegatesEnquiryTable[] = { + // EndpointId, ClusterId, Delegate + { Clusters::OperationalState::kDemoEndpointId, Clusters::OperationalState::Id, &opStateDelegate }, +}; + +/** + * Get the pointer of target delegate for target endpoint and cluster + * @param[in] aEndpiontId The endpointId + * @param[in] aClusterID The clusterId + * @return the pointer of target delegate + */ +Delegate * getGenericDelegateTable(EndpointId aEndpointId, ClusterId aClusterId) +{ + for (size_t i = 0; i < ArraySize(kDelegatesEnquiryTable); ++i) + { + if (kDelegatesEnquiryTable[i].mEndpointId == aEndpointId && kDelegatesEnquiryTable[i].mClusterId == aClusterId) + { + return kDelegatesEnquiryTable[i].pItem; + } + } + return nullptr; +} + +// @brief Instance getter for the delegate for the given operational state alias cluster on the given endpoint. +// The delegate API assumes there will be separate delegate objects for each cluster instance. +// (i.e. each separate operational state cluster derivation, on each separate endpoint) +// @note This API should always be called prior to using the delegate and the return pointer should never be cached. +// @return Default global delegate instance. +Delegate * GetOperationalStateDelegate(EndpointId endpointId, ClusterId clusterId) +{ + return getGenericDelegateTable(endpointId, clusterId); +} + +} // namespace OperationalState +} // namespace Clusters +} // namespace app +} // namespace chip + +void MatterOperationalStateServerInit() +{ + using namespace chip::app; + static Clusters::OperationalState::OperationalStateServer operationalstateServer(Clusters::OperationalState::kDemoEndpointId, + Clusters::OperationalState::Id); + operationalstateServer.Init(); +} diff --git a/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp b/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp new file mode 100644 index 00000000000000..66f86e5b28ab99 --- /dev/null +++ b/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp @@ -0,0 +1,23 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +bool emberAfPluginSmokeCoAlarmSelfTestRequestCommand(chip::EndpointId endpointId) +{ + return true; +} diff --git a/examples/all-clusters-app/ameba/chip_main.cmake b/examples/all-clusters-app/ameba/chip_main.cmake index 7440551e2fda27..cbb4da68790f63 100755 --- a/examples/all-clusters-app/ameba/chip_main.cmake +++ b/examples/all-clusters-app/ameba/chip_main.cmake @@ -154,6 +154,7 @@ list( APPEND ${list_chip_main_sources} ${chip_dir}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp + ${chip_dir}/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp ${chip_dir}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp ${chip_dir}/examples/all-clusters-app/ameba/main/chipinterface.cpp diff --git a/examples/all-clusters-app/asr/BUILD.gn b/examples/all-clusters-app/asr/BUILD.gn index 7d0b089b657b87..612c02d5126291 100755 --- a/examples/all-clusters-app/asr/BUILD.gn +++ b/examples/all-clusters-app/asr/BUILD.gn @@ -72,6 +72,7 @@ asr_executable("clusters_app") { sources = [ "${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp", "${examples_plat_dir}/ButtonHandler.cpp", "${examples_plat_dir}/CHIPDeviceManager.cpp", diff --git a/examples/all-clusters-app/cc13x2x7_26x2x7/BUILD.gn b/examples/all-clusters-app/cc13x2x7_26x2x7/BUILD.gn index 3194d47bb0f188..c48a3327c8ddaf 100644 --- a/examples/all-clusters-app/cc13x2x7_26x2x7/BUILD.gn +++ b/examples/all-clusters-app/cc13x2x7_26x2x7/BUILD.gn @@ -77,6 +77,7 @@ ti_simplelink_executable("all-clusters-app") { sources = [ "${chip_root}/examples/all-clusters-app/all-clusters-common/src/binding-handler.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp", "${chip_root}/examples/providers/DeviceInfoProviderImpl.cpp", "${project_dir}/main/AppTask.cpp", diff --git a/examples/all-clusters-app/cc13x4_26x4/BUILD.gn b/examples/all-clusters-app/cc13x4_26x4/BUILD.gn index 259fbdfa960eeb..4b15639b6da8a5 100644 --- a/examples/all-clusters-app/cc13x4_26x4/BUILD.gn +++ b/examples/all-clusters-app/cc13x4_26x4/BUILD.gn @@ -77,6 +77,7 @@ ti_simplelink_executable("all-clusters-app") { sources = [ "${chip_root}/examples/all-clusters-app/all-clusters-common/src/binding-handler.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp", "${chip_root}/examples/providers/DeviceInfoProviderImpl.cpp", "${project_dir}/main/AppTask.cpp", diff --git a/examples/all-clusters-app/esp32/main/CMakeLists.txt b/examples/all-clusters-app/esp32/main/CMakeLists.txt index 86249f3d81df0a..c662c8ae951f34 100644 --- a/examples/all-clusters-app/esp32/main/CMakeLists.txt +++ b/examples/all-clusters-app/esp32/main/CMakeLists.txt @@ -71,6 +71,7 @@ set(SRC_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thread-network-diagnostics-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/channel-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/scenes-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/smoke-co-alarm-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/refrigerator-alarm-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/software-diagnostics-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/switch-server" diff --git a/examples/all-clusters-app/infineon/psoc6/BUILD.gn b/examples/all-clusters-app/infineon/psoc6/BUILD.gn index da0b632e4c6902..b8cbc85b7f9f2d 100644 --- a/examples/all-clusters-app/infineon/psoc6/BUILD.gn +++ b/examples/all-clusters-app/infineon/psoc6/BUILD.gn @@ -108,6 +108,7 @@ psoc6_executable("clusters_app") { sources = [ "${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp", "${examples_plat_dir}/LEDWidget.cpp", "${examples_plat_dir}/init_psoc6Platform.cpp", diff --git a/examples/all-clusters-app/linux/BUILD.gn b/examples/all-clusters-app/linux/BUILD.gn index 402649c13bba05..38f40b86f061ba 100644 --- a/examples/all-clusters-app/linux/BUILD.gn +++ b/examples/all-clusters-app/linux/BUILD.gn @@ -24,6 +24,9 @@ source_set("chip-all-clusters-common") { "${chip_root}/examples/all-clusters-app/all-clusters-common/src/binding-handler.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/fan-stub.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/operational-state-delegate-impl.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/operational-state-delegates.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp", "AllClustersCommandDelegate.cpp", "AppOptions.cpp", diff --git a/examples/all-clusters-app/linux/args.gni b/examples/all-clusters-app/linux/args.gni index 703c3576d66c19..49ecbd6dff99e8 100644 --- a/examples/all-clusters-app/linux/args.gni +++ b/examples/all-clusters-app/linux/args.gni @@ -23,3 +23,8 @@ chip_system_project_config_include = "" chip_project_config_include_dirs = [ "${chip_root}/examples/all-clusters-app/linux/include" ] chip_project_config_include_dirs += [ "${chip_root}/config/standalone" ] + +matter_enable_tracing_support = true + +# Perfetto requires C++17 +cpp_standard = "gnu++17" diff --git a/examples/all-clusters-app/linux/main-common.cpp b/examples/all-clusters-app/linux/main-common.cpp index 4c22561146b237..48e81572eb037f 100644 --- a/examples/all-clusters-app/linux/main-common.cpp +++ b/examples/all-clusters-app/linux/main-common.cpp @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -36,17 +35,6 @@ #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; @@ -63,6 +51,10 @@ chip::app::Clusters::WindowCovering::WindowCoveringManager sWindowCoveringManage } // namespace +#ifdef EMBER_AF_PLUGIN_OPERATIONAL_STATE_SERVER +extern void MatterOperationalStateServerInit(); +#endif + void OnIdentifyStart(::Identify *) { ChipLogProgress(Zcl, "OnIdentifyStart"); @@ -105,42 +97,7 @@ static Identify gIdentify1 = { OnTriggerEffect, }; -// Network commissioning namespace { -// This file is being used by platforms other than Linux, so we need this check to disable related features since we only -// implemented them on linux. -constexpr EndpointId kNetworkCommissioningEndpointMain = 0; -constexpr EndpointId kNetworkCommissioningEndpointSecondary = 0xFFFE; - -#if CHIP_DEVICE_LAYER_TARGET_LINUX -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD -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); class ExampleDeviceInstanceInfoProvider : public DeviceInstanceInfoProvider { @@ -200,58 +157,6 @@ ExampleDeviceInstanceInfoProvider gExampleDeviceInstanceInfoProvider; void ApplicationInit() { - (void) kNetworkCommissioningEndpointMain; - // Enable secondary endpoint only when we need it, this should be applied to all platforms. - emberAfEndpointEnableDisable(kNetworkCommissioningEndpointSecondary, false); - - const bool kThreadEnabled = { -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD - LinuxDeviceOptions::GetInstance().mThread -#else - false -#endif - }; - - const bool kWiFiEnabled = { -#if CHIP_DEVICE_CONFIG_ENABLE_WIFI - LinuxDeviceOptions::GetInstance().mWiFi -#else - false -#endif - }; - - if (kThreadEnabled && kWiFiEnabled) - { -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD - sThreadNetworkCommissioningInstance.Init(); -#endif -#if CHIP_DEVICE_CONFIG_ENABLE_WIFI - sWiFiNetworkCommissioningInstance.Init(); -#endif - // Only enable secondary endpoint for network commissioning cluster when both WiFi and Thread are enabled. - emberAfEndpointEnableDisable(kNetworkCommissioningEndpointSecondary, true); - } - else if (kThreadEnabled) - { -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD - sThreadNetworkCommissioningInstance.Init(); -#endif - } - else if (kWiFiEnabled) - { -#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, &sWiFiDriver); - sWiFiNetworkCommissioningInstance.Init(); -#endif - } - else - { - sEthernetNetworkCommissioningInstance.Init(); - } - std::string path = kChipEventFifoPathPrefix + std::to_string(getpid()); if (sChipNamedPipeCommands.Start(path, &sAllClustersCommandDelegate) != CHIP_NO_ERROR) @@ -266,6 +171,9 @@ void ApplicationInit() gExampleDeviceInstanceInfoProvider.Init(defaultProvider); SetDeviceInstanceInfoProvider(&gExampleDeviceInstanceInfoProvider); } +#ifdef EMBER_AF_PLUGIN_OPERATIONAL_STATE_SERVER + MatterOperationalStateServerInit(); +#endif } void ApplicationExit() diff --git a/examples/all-clusters-app/linux/main.cpp b/examples/all-clusters-app/linux/main.cpp index 6da40d72d82d4f..c9d829ba423e44 100644 --- a/examples/all-clusters-app/linux/main.cpp +++ b/examples/all-clusters-app/linux/main.cpp @@ -21,9 +21,15 @@ #include "binding-handler.h" #include "main-common.h" +// Network commissioning +namespace { +constexpr chip::EndpointId kNetworkCommissioningEndpointSecondary = 0xFFFE; +} // anonymous namespace + int main(int argc, char * argv[]) { - VerifyOrDie(ChipLinuxAppInit(argc, argv, AppOptions::GetOptions()) == 0); + VerifyOrDie( + ChipLinuxAppInit(argc, argv, AppOptions::GetOptions(), chip::MakeOptional(kNetworkCommissioningEndpointSecondary)) == 0); VerifyOrDie(InitBindingHandlers() == CHIP_NO_ERROR); LinuxDeviceOptions::GetInstance().dacProvider = AppOptions::GetDACProvider(); diff --git a/examples/all-clusters-app/mbed/CMakeLists.txt b/examples/all-clusters-app/mbed/CMakeLists.txt index a654994ddea9c6..32efe99283f17e 100644 --- a/examples/all-clusters-app/mbed/CMakeLists.txt +++ b/examples/all-clusters-app/mbed/CMakeLists.txt @@ -60,6 +60,7 @@ target_sources(${APP_TARGET} PRIVATE ${MBED_COMMON}/util/LEDWidget.cpp ${MBED_COMMON}/util/DFUManager.cpp ${ALL_CLUSTERS_COMMON}/src/bridged-actions-stub.cpp + ${ALL_CLUSTERS_COMMON}/src/smco-stub.cpp ${ALL_CLUSTERS_COMMON}/src/static-supported-modes-manager.cpp ) diff --git a/examples/all-clusters-app/nrfconnect/CMakeLists.txt b/examples/all-clusters-app/nrfconnect/CMakeLists.txt index 6b28a6e1a61c3c..79582280b31a55 100644 --- a/examples/all-clusters-app/nrfconnect/CMakeLists.txt +++ b/examples/all-clusters-app/nrfconnect/CMakeLists.txt @@ -57,6 +57,7 @@ target_sources(app PRIVATE main/AppTask.cpp main/main.cpp main/ZclDoorLockCallbacks.cpp + ${ALL_CLUSTERS_COMMON_DIR}/src/smco-stub.cpp ${ALL_CLUSTERS_COMMON_DIR}/src/static-supported-modes-manager.cpp ${ALL_CLUSTERS_COMMON_DIR}/src/bridged-actions-stub.cpp ${ALL_CLUSTERS_COMMON_DIR}/src/binding-handler.cpp diff --git a/examples/all-clusters-app/nxp/mw320/BUILD.gn b/examples/all-clusters-app/nxp/mw320/BUILD.gn index 3b3aed0c92d52b..da940a4717912a 100644 --- a/examples/all-clusters-app/nxp/mw320/BUILD.gn +++ b/examples/all-clusters-app/nxp/mw320/BUILD.gn @@ -74,6 +74,7 @@ mw320_executable("shell_mw320") { ] sources = [ "${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp", "${chip_root}/src/lib/shell/streamer_mw320.cpp", "binding-handler.cpp", diff --git a/examples/all-clusters-app/openiotsdk/.gitignore b/examples/all-clusters-app/openiotsdk/.gitignore new file mode 100644 index 00000000000000..567609b1234a9b --- /dev/null +++ b/examples/all-clusters-app/openiotsdk/.gitignore @@ -0,0 +1 @@ +build/ diff --git a/examples/all-clusters-app/openiotsdk/CMakeLists.txt b/examples/all-clusters-app/openiotsdk/CMakeLists.txt new file mode 100644 index 00000000000000..56170710a859bc --- /dev/null +++ b/examples/all-clusters-app/openiotsdk/CMakeLists.txt @@ -0,0 +1,69 @@ +# +# Copyright (c) 2023 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +cmake_minimum_required(VERSION 3.21) + +get_filename_component(CHIP_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../.. REALPATH) +get_filename_component(OPEN_IOT_SDK_CONFIG ${CHIP_ROOT}/config/openiotsdk REALPATH) +get_filename_component(OPEN_IOT_SDK_EXAMPLE_COMMON ${CHIP_ROOT}/examples/platform/openiotsdk REALPATH) +get_filename_component(ALL_CLUSTERS_COMMON ${CHIP_ROOT}/examples/all-clusters-app/all-clusters-common REALPATH) + +list(APPEND CMAKE_MODULE_PATH ${OPEN_IOT_SDK_CONFIG}/cmake) + +set(APP_TARGET chip-openiotsdk-all-clusters-app-example_ns) + +set(TFM_PROJECT_CONFIG_HEADER_FILE "${CMAKE_CURRENT_SOURCE_DIR}/tf-m-config/TfmProjectConfig.h") + +# Toolchain files need to exist before first call to project +include(toolchain) + +project(${APP_TARGET} LANGUAGES C CXX ASM) + +include(sdk) + +add_executable(${APP_TARGET}) + +# Application CHIP build configuration +include(chip) + +add_subdirectory(${OPEN_IOT_SDK_EXAMPLE_COMMON}/app ./app_build) + +chip_add_data_model(openiotsdk-app PUBLIC all-clusters) + +target_include_directories(${APP_TARGET} + PRIVATE + main/include + ${ALL_CLUSTERS_COMMON}/include +) + +target_sources(${APP_TARGET} + PRIVATE + main/main_ns.cpp + ${ALL_CLUSTERS_COMMON}/src/smco-stub.cpp + ${ALL_CLUSTERS_COMMON}/src/bridged-actions-stub.cpp + ${ALL_CLUSTERS_COMMON}/src/static-supported-modes-manager.cpp + ${ALL_CLUSTERS_COMMON}/src/binding-handler.cpp +) + +target_link_libraries(${APP_TARGET} + openiotsdk-startup + openiotsdk-app +) + +include(linker) +set_target_link(${APP_TARGET}) + +sdk_post_build(${APP_TARGET}) diff --git a/examples/all-clusters-app/openiotsdk/README.md b/examples/all-clusters-app/openiotsdk/README.md new file mode 100644 index 00000000000000..269411f9f59bf9 --- /dev/null +++ b/examples/all-clusters-app/openiotsdk/README.md @@ -0,0 +1,100 @@ +# Matter Open IoT SDK All-Clusters-App Example Application + +The Open IoT SDK All Clusters Example demonstrates various ZCL clusters control. + +The example behaves as a Matter accessory, device that can be paired into an +existing Matter network and can be controlled by it. + +You can use this example as a reference for creating your own application. + +## Build-run-test-debug + +For information on how to build, run, test and debug this example and further +information about the platform it is run on see +[Open IoT SDK examples](../../../docs/guides/openiotsdk_examples.md). + +The example name to use in the scripts is `all-clusters-app`. + +## Example output + +When the example runs, these lines should be visible: + +``` +[INF] [-] Open IoT SDK all-clusters-app example application start +... +[INF] [-] Open IoT SDK all-clusters-app example application run +``` + +This means the all-clusters-app application launched correctly and you can +follow traces in the terminal. + +### Commissioning + +Read the +[Open IoT SDK commissioning guide](../../../docs/guides/openiotsdk_commissioning.md) +to see how to use the Matter controller to commission and control the +application. + +### AccessControl cluster usage + +The application fully supports the AccessControl cluster. For more details about +access control please visit +[Access Control Guide](../../../docs/guides/access-control-guide.md). Use +cluster commands to trigger actions on the device. You can issue commands +through the same Matter controller you used to perform the commissioning step +above. + +Example command: + +``` +chip-tool accesscontrol read acl 123 0 +``` + +The numeric arguments are: device node ID and device endpoint ID, respectively. + +The device sent a response and you should see this line in the controller +output: + +``` +CHIP:TOO: Endpoint: 0 Cluster: 0x0000_001F Attribute 0x0000_0000 DataVersion: 3442030892 +CHIP:TOO: ACL: 1 entries +CHIP:TOO: [1]: { +CHIP:TOO: Privilege: 5 +CHIP:TOO: AuthMode: 2 +CHIP:TOO: Subjects: 1 entries +CHIP:TOO: [1]: 112233 +CHIP:TOO: Targets: null +CHIP:TOO: FabricIndex: 1 +CHIP:TOO: } +``` + +These are automatically installed ACL entries after commissioning. + +### BasicInformation cluster usage + +One of the fully supported clusters by this example is BasicInformation cluster. +Use cluster commands to trigger actions on the device. You can issue commands +through the same Matter controller you used to perform the commissioning step +above. + +Example command: + +``` +chip-tool basicinformation read vendor-id 123 0 +``` + +The numeric arguments are: device node ID and device endpoint ID, respectively. + +The device send a response with its vendor ID number and you should see this +line in the controller output: + +``` +CHIP:TOO: VendorID: 65521 +``` + +The `65521` value is the default `vendor ID` for Matter examples. + +**NOTE** + +More details about the `chip-tool` controller can be found +[here](../../chip-tool/README.md). diff --git a/examples/all-clusters-app/openiotsdk/cmsis-config/RTE_Components.h b/examples/all-clusters-app/openiotsdk/cmsis-config/RTE_Components.h new file mode 100644 index 00000000000000..e86df2b4e44e06 --- /dev/null +++ b/examples/all-clusters-app/openiotsdk/cmsis-config/RTE_Components.h @@ -0,0 +1,22 @@ +/* + * + * 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. + */ + +#ifndef RTE_COMPONENTS_H +#define RTE_COMPONENTS_H + +#endif // RTE_COMPONENTS_H diff --git a/examples/all-clusters-app/openiotsdk/freertos-config/FreeRTOSConfig.h b/examples/all-clusters-app/openiotsdk/freertos-config/FreeRTOSConfig.h new file mode 100644 index 00000000000000..9efedc9f133712 --- /dev/null +++ b/examples/all-clusters-app/openiotsdk/freertos-config/FreeRTOSConfig.h @@ -0,0 +1,257 @@ +/* + * + * 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. + */ + +#ifndef FREERTOS_CONFIG_H +#define FREERTOS_CONFIG_H + +/*----------------------------------------------------------- + * Application specific definitions. + * + * These definitions should be adjusted for your particular hardware and + * application requirements. + * + * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE + * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. + * + * See http://www.freertos.org/a00110.html + *----------------------------------------------------------*/ + +#if (defined(__ARMCC_VERSION) || defined(__GNUC__) || defined(__ICCARM__)) +#include + +extern uint32_t SystemCoreClock; +#endif + +// Minimal stack size [words] <0-65535> +// Stack for idle task and default task stack in words. +// Default: 4kB +#define configMINIMAL_STACK_SIZE ((uint16_t)(4 * 1024)) + +// Total heap size [bytes] <0-0xFFFFFFFF> +// Heap memory size in bytes. +// Default: 32kB +#define configTOTAL_HEAP_SIZE ((size_t)(32 * 1024)) + +// Kernel tick frequency [Hz] <0-0xFFFFFFFF> +// Kernel tick rate in Hz. +// Default: 1000 +#define configTICK_RATE_HZ ((TickType_t) 1000) + +// Timer task stack depth [words] <0-65535> +// Stack for timer task in words. +// Default: 80 +#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE + +// Timer task priority <0-56> +// Timer task priority. +// Default: 40 (High) +#define configTIMER_TASK_PRIORITY 40 + +// Timer queue length <0-1024> +// Timer command queue length. +// Default: 5 +#define configTIMER_QUEUE_LENGTH 5 + +// Preemption interrupt priority +// Maximum priority of interrupts that are safe to call FreeRTOS API. +// Default: 16 +#define configMAX_SYSCALL_INTERRUPT_PRIORITY (5 << (8 - configPRIO_BITS)) + +// Use time slicing +// Enable setting to use timeslicing. +// Default: 1 +#define configUSE_TIME_SLICING 1 + +// Idle should yield +// Control Yield behaviour of the idle task. +// Default: 1 +#define configIDLE_SHOULD_YIELD 1 + +// Check for stack overflow +// <0=>Disable <1=>Method one <2=>Method two +// Enable or disable stack overflow checking. +// Callback function vApplicationStackOverflowHook implementation is required when stack checking is enabled. +// Default: 0 +#define configCHECK_FOR_STACK_OVERFLOW 2 + +// Use idle hook +// Enable callback function call on each idle task iteration. +// Callback function vApplicationIdleHook implementation is required when idle hook is enabled. +// Default: 0 +#define configUSE_IDLE_HOOK 0 + +// Use tick hook +// Enable callback function call during each tick interrupt. +// Callback function vApplicationTickHook implementation is required when tick hook is enabled. +// Default: 0 +#define configUSE_TICK_HOOK 0 + +// Use deamon task startup hook +// Enable callback function call when timer service starts. +// Callback function vApplicationDaemonTaskStartupHook implementation is required when deamon task startup hook is +// enabled. Default: 0 +#define configUSE_DAEMON_TASK_STARTUP_HOOK 0 + +// Use malloc failed hook +// Enable callback function call when out of dynamic memory. +// Callback function vApplicationMallocFailedHook implementation is required when malloc failed hook is enabled. +// Default: 0 +#define configUSE_MALLOC_FAILED_HOOK 0 + +// Queue registry size +// Define maximum number of queue objects registered for debug purposes. +// The queue registry is used by kernel aware debuggers to locate queue and semaphore structures and display +// associated text names. Default: 0 +#define configQUEUE_REGISTRY_SIZE 0 + +// Event Recorder configuration +// Initialize and setup Event Recorder level filtering. +// Settings have no effect when Event Recorder is not present. + +// Initialize Event Recorder +// Initialize Event Recorder before FreeRTOS kernel start. +// Default: 1 +#define configEVR_INITIALIZE 1 + +// Setup recording level filter +// Enable configuration of FreeRTOS events recording level +// Default: 1 +#define configEVR_SETUP_LEVEL 1 + +// Tasks functions +// Define event recording level bitmask for events generated from Tasks functions. +// Default: 0x05 +// <0x00=>Off <0x01=>Errors <0x05=>Errors + Operation <0x0F=>All +#define configEVR_LEVEL_TASKS 0x05 + +// Queue functions +// Define event recording level bitmask for events generated from Queue functions. +// Default: 0x05 +// <0x00=>Off <0x01=>Errors <0x05=>Errors + Operation <0x0F=>All +#define configEVR_LEVEL_QUEUE 0x05 + +// Timer functions +// Define event recording level bitmask for events generated from Timer functions. +// Default: 0x05 +// <0x00=>Off <0x01=>Errors <0x05=>Errors + Operation <0x0F=>All +#define configEVR_LEVEL_TIMERS 0x05 + +// Event Groups functions +// Define event recording level bitmask for events generated from Event Groups functions. +// Default: 0x05 +// <0x00=>Off <0x01=>Errors <0x05=>Errors + Operation <0x0F=>All +#define configEVR_LEVEL_EVENTGROUPS 0x05 + +// Heap functions +// Define event recording level bitmask for events generated from Heap functions. +// Default: 0x05 +// <0x00=>Off <0x01=>Errors <0x05=>Errors + Operation <0x0F=>All +#define configEVR_LEVEL_HEAP 0x05 + +// Stream Buffer functions +// Define event recording level bitmask for events generated from Stream Buffer functions. +// Default: 0x05 +// <0x00=>Off <0x01=>Errors <0x05=>Errors + Operation <0x0F=>All +#define configEVR_LEVEL_STREAMBUFFER 0x05 +// +// + +// Port Specific Features +// Enable and configure port specific features. +// Check FreeRTOS documentation for definitions that apply for the used port. + +// Use Floating Point Unit +// Using Floating Point Unit (FPU) affects context handling. +// Enable FPU when application uses floating point operations. +// Default: 1 +#define configENABLE_FPU 1 + +// Use Memory Protection Unit +// Using Memory Protection Unit (MPU) requires detailed memory map definition. +// This setting is only releavant for MPU enabled ports. +// Default: 0 +#define configENABLE_MPU 0 + +// Use TrustZone Secure Side Only +// This settings prevents FreeRTOS contex switch to Non-Secure side. +// Enable this setting when FreeRTOS runs on the Secure side only. +#define configRUN_FREERTOS_SECURE_ONLY 0 + +// Use TrustZone Security Extension +// Using TrustZone affects context handling. +// Enable TrustZone when FreeRTOS runs on the Non-Secure side and calls functions from the Secure side. +// Default: 1 +#define configENABLE_TRUSTZONE 0 + +// Minimal secure stack size [words] <0-65535> +// Stack for idle task Secure side context in words. +// This setting is only relevant when TrustZone extension is enabled. +// Default: 128 +#define configMINIMAL_SECURE_STACK_SIZE ((uint32_t) 128) +// + +#ifdef __NVIC_PRIO_BITS +#define configPRIO_BITS __NVIC_PRIO_BITS +#else +#define configPRIO_BITS 4 +#endif + +//------------- <<< end of configuration section >>> --------------------------- + +/* Defines needed by FreeRTOS to implement CMSIS RTOS2 API. Do not change! */ +#define configCPU_CLOCK_HZ (SystemCoreClock) +#define configSUPPORT_STATIC_ALLOCATION 1 +#define configSUPPORT_DYNAMIC_ALLOCATION 1 +#define configUSE_PREEMPTION 1 +#define configUSE_TIMERS 1 +#define configUSE_MUTEXES 1 +#define configUSE_RECURSIVE_MUTEXES 1 +#define configUSE_COUNTING_SEMAPHORES 1 +#define configUSE_TASK_NOTIFICATIONS 1 +#define configUSE_TRACE_FACILITY 1 +#define configUSE_16_BIT_TICKS 0 +#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 +#define configMAX_PRIORITIES 56 +#define configKERNEL_INTERRUPT_PRIORITY (0x07 << (8 - configPRIO_BITS)) + +/* Defines that include FreeRTOS functions which implement CMSIS RTOS2 API. Do not change! */ +#define INCLUDE_xEventGroupSetBitsFromISR 1 +#define INCLUDE_xSemaphoreGetMutexHolder 1 +#define INCLUDE_vTaskDelay 1 +#define INCLUDE_xTaskDelayUntil 1 +#define INCLUDE_vTaskDelete 1 +#define INCLUDE_xTaskGetCurrentTaskHandle 1 +#define INCLUDE_xTaskGetSchedulerState 1 +#define INCLUDE_uxTaskGetStackHighWaterMark 1 +#define INCLUDE_uxTaskPriorityGet 1 +#define INCLUDE_vTaskPrioritySet 1 +#define INCLUDE_eTaskGetState 1 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_xTimerPendFunctionCall 1 + +/* Map the FreeRTOS port interrupt handlers to their CMSIS standard names. */ +#define xPortPendSVHandler PendSV_Handler +#define vPortSVCHandler SVC_Handler + +/* Ensure Cortex-M port compatibility. */ +#define SysTick_Handler xPortSysTickHandler + +#include "RTE_Components.h" +#include CMSIS_device_header + +#endif /* FREERTOS_CONFIG_H */ diff --git a/examples/all-clusters-app/openiotsdk/main/include/CHIPProjectConfig.h b/examples/all-clusters-app/openiotsdk/main/include/CHIPProjectConfig.h new file mode 100644 index 00000000000000..03c4ba727b64d4 --- /dev/null +++ b/examples/all-clusters-app/openiotsdk/main/include/CHIPProjectConfig.h @@ -0,0 +1,33 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 0 +#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0 + +// Use a default pairing code if one hasn't been provisioned in flash. +#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 +#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 + +// Lock Manager settings +#define CHIP_LOCK_MANAGER_USER_NUMBER 10 +#define CHIP_LOCK_MANAGER_CREDENTIALS_NUMBER 10 +#define CHIP_LOCK_MANAGER_CREDENTIALS_PER_USER_NUMBER 5 +#define CHIP_LOCK_MANAGER_WEEK_DAY_SCHEDULES_PER_USER_NUMBER 10 +#define CHIP_LOCK_MANAGER_YEAR_DAY_SCHEDULES_PER_USER_NUMBER 10 diff --git a/examples/all-clusters-app/openiotsdk/main/main_ns.cpp b/examples/all-clusters-app/openiotsdk/main/main_ns.cpp new file mode 100644 index 00000000000000..63239975e89cc9 --- /dev/null +++ b/examples/all-clusters-app/openiotsdk/main/main_ns.cpp @@ -0,0 +1,72 @@ +/* + * + * 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 +#include + +#include + +#include + +#include "openiotsdk_platform.h" + +int main() +{ + if (openiotsdk_platform_init()) + { + ChipLogError(NotSpecified, "Open IoT SDK platform initialization failed"); + return EXIT_FAILURE; + } + + if (openiotsdk_chip_init()) + { + ChipLogError(NotSpecified, "Open IoT SDK CHIP stack initialization failed"); + return EXIT_FAILURE; + } + + ChipLogProgress(NotSpecified, "Open IoT SDK all-clusters-app example application start"); + + if (openiotsdk_network_init(true)) + { + ChipLogError(NotSpecified, "Network initialization failed"); + return EXIT_FAILURE; + } + + if (openiotsdk_chip_run()) + { + ChipLogError(NotSpecified, "CHIP stack run failed"); + return EXIT_FAILURE; + } + + if (InitBindingHandlers() != CHIP_NO_ERROR) + { + ChipLogError(NotSpecified, "InitBindingHandlers failed"); + return EXIT_FAILURE; + } + + ChipLogProgress(NotSpecified, "Open IoT SDK all-clusters-app example application run"); + + while (true) + { + // Add forever delay to ensure proper workload for this thread + osDelay(osWaitForever); + } + + openiotsdk_chip_shutdown(); + + return EXIT_SUCCESS; +} diff --git a/examples/all-clusters-app/openiotsdk/tf-m-config/TfmProjectConfig.h b/examples/all-clusters-app/openiotsdk/tf-m-config/TfmProjectConfig.h new file mode 100644 index 00000000000000..a792f400bd2660 --- /dev/null +++ b/examples/all-clusters-app/openiotsdk/tf-m-config/TfmProjectConfig.h @@ -0,0 +1,165 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef TFM_PROJECT_CONFIG_H +#define TFM_PROJECT_CONFIG_H + +/* Platform Partition Configs */ + +/* Size of input buffer in platform service */ +#define PLATFORM_SERVICE_INPUT_BUFFER_SIZE 64 + +/* Size of output buffer in platform service */ +#define PLATFORM_SERVICE_OUTPUT_BUFFER_SIZE 64 + +/* The stack size of the Platform Secure Partition */ +#define PLATFORM_SP_STACK_SIZE 0x500 + +/* Disable Non-volatile counter module */ +#define PLATFORM_NV_COUNTER_MODULE_DISABLED 0 + +/* Crypto Partition Configs */ + +/* + * Heap size for the crypto backend + * CRYPTO_ENGINE_BUF_SIZE needs to be >8KB for EC signing by attest module. + */ +#define CRYPTO_ENGINE_BUF_SIZE 0x2080 + +/* The max number of concurrent operations that can be active (allocated) at any time in Crypto */ +#define CRYPTO_CONC_OPER_NUM 8 + +/* Enable PSA Crypto random number generator module */ +#define CRYPTO_RNG_MODULE_ENABLED 1 + +/* Enable PSA Crypto Key module */ +#define CRYPTO_KEY_MODULE_ENABLED 1 + +/* Enable PSA Crypto AEAD module */ +#define CRYPTO_AEAD_MODULE_ENABLED 1 + +/* Enable PSA Crypto MAC module */ +#define CRYPTO_MAC_MODULE_ENABLED 1 + +/* Enable PSA Crypto Hash module */ +#define CRYPTO_HASH_MODULE_ENABLED 1 + +/* Enable PSA Crypto Cipher module */ +#define CRYPTO_CIPHER_MODULE_ENABLED 1 + +/* Enable PSA Crypto asymmetric key signature module */ +#define CRYPTO_ASYM_SIGN_MODULE_ENABLED 1 + +/* Enable PSA Crypto asymmetric key encryption module */ +#define CRYPTO_ASYM_ENCRYPT_MODULE_ENABLED 0 + +/* Enable PSA Crypto key derivation module */ +#define CRYPTO_KEY_DERIVATION_MODULE_ENABLED 1 + +/* Default size of the internal scratch buffer used for PSA FF IOVec allocations */ +#define CRYPTO_IOVEC_BUFFER_SIZE 5120 + +/* Use stored NV seed to provide entropy */ +#define CRYPTO_NV_SEED 1 + +/* + * Only enable multi-part operations in Hash, MAC, AEAD and symmetric ciphers, + * to optimize memory footprint in resource-constrained devices. + */ +#define CRYPTO_SINGLE_PART_FUNCS_DISABLED 0 + +/* The stack size of the Crypto Secure Partition */ +#define CRYPTO_STACK_SIZE 0x1B00 + +/* FWU Partition Configs */ + +/* Size of the FWU internal data transfer buffer */ +#define TFM_FWU_BUF_SIZE PSA_FWU_MAX_WRITE_SIZE + +/* The stack size of the Firmware Update Secure Partition */ +#define FWU_STACK_SIZE 0x600 + +/* Attest Partition Configs */ + +/* Include optional claims in initial attestation token */ +#define ATTEST_INCLUDE_OPTIONAL_CLAIMS 1 + +/* Include COSE key-id in initial attestation token */ +#define ATTEST_INCLUDE_COSE_KEY_ID 0 + +/* The stack size of the Initial Attestation Secure Partition */ +#define ATTEST_STACK_SIZE 0x700 + +/* Set the initial attestation token profile */ +#define ATTEST_TOKEN_PROFILE_PSA_IOT_1 1 + +/* ITS Partition Configs */ + +/* Create flash FS if it doesn't exist for Internal Trusted Storage partition */ +#define ITS_CREATE_FLASH_LAYOUT 1 + +/* Enable emulated RAM FS for platforms that don't have flash for Internal Trusted Storage partition */ +#define ITS_RAM_FS 0 + +/* Validate filesystem metadata every time it is read from flash */ +#define ITS_VALIDATE_METADATA_FROM_FLASH 1 + +/* The maximum asset size to be stored in the Internal Trusted Storage */ +#define ITS_MAX_ASSET_SIZE 512 + +/* Size of the ITS internal data transfer buffer */ +#define ITS_BUF_SIZE 32 + +/* The maximum number of assets to be stored in the Internal Trusted Storage */ +#define ITS_NUM_ASSETS 10 + +/* The stack size of the Internal Trusted Storage Secure Partition */ +#define ITS_STACK_SIZE 0x720 + +/* PS Partition Configs */ + +/* Create flash FS if it doesn't exist for Protected Storage partition */ +#define PS_CREATE_FLASH_LAYOUT 1 + +/* Enable emulated RAM FS for platforms that don't have flash for Protected Storage partition */ +#define PS_RAM_FS 0 + +/* Enable rollback protection for Protected Storage partition */ +#define PS_ROLLBACK_PROTECTION 1 + +/* Validate filesystem metadata every time it is read from flash */ +#define PS_VALIDATE_METADATA_FROM_FLASH 1 + +/* The maximum asset size to be stored in the Protected Storage */ +#define PS_MAX_ASSET_SIZE 2048 + +/* The maximum number of assets to be stored in the Protected Storage */ +#define PS_NUM_ASSETS 30 + +/* The stack size of the Protected Storage Secure Partition */ +#define PS_STACK_SIZE 0x700 + +/* SPM Partition Configs */ + +/* The maximal number of secure services that are connected or requested at the same time */ +#define CONFIG_TFM_CONN_HANDLE_MAX_NUM 8 + +/* Enable the doorbell APIs */ +#define CONFIG_TFM_DOORBELL_API 1 + +#endif /* TFM_PROJECT_CONFIG_H */ diff --git a/examples/all-clusters-app/telink/CMakeLists.txt b/examples/all-clusters-app/telink/CMakeLists.txt index 584806456e5233..b05baa826f7f22 100644 --- a/examples/all-clusters-app/telink/CMakeLists.txt +++ b/examples/all-clusters-app/telink/CMakeLists.txt @@ -70,7 +70,8 @@ add_definitions( target_sources(app PRIVATE src/AppTask.cpp - src/ZclDoorLockCallbacks.cpp + src/ZclDoorLockCallbacks.cpp + ${ALL_CLUSTERS_COMMON_DIR}/src/smco-stub.cpp ${ALL_CLUSTERS_COMMON_DIR}/src/static-supported-modes-manager.cpp ${ALL_CLUSTERS_COMMON_DIR}/src/bridged-actions-stub.cpp ${ALL_CLUSTERS_COMMON_DIR}/src/binding-handler.cpp diff --git a/examples/all-clusters-app/tizen/BUILD.gn b/examples/all-clusters-app/tizen/BUILD.gn index ba1cf3a3ca51bd..3e7f1ed6d976da 100644 --- a/examples/all-clusters-app/tizen/BUILD.gn +++ b/examples/all-clusters-app/tizen/BUILD.gn @@ -25,6 +25,7 @@ source_set("chip-all-clusters-common") { sources = [ "${chip_root}/examples/all-clusters-app/all-clusters-common/src/binding-handler.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp", ] diff --git a/examples/all-clusters-minimal-app/ameba/chip_main.cmake b/examples/all-clusters-minimal-app/ameba/chip_main.cmake index d78344f713497e..95b062a636f0a6 100755 --- a/examples/all-clusters-minimal-app/ameba/chip_main.cmake +++ b/examples/all-clusters-minimal-app/ameba/chip_main.cmake @@ -129,6 +129,7 @@ list( APPEND ${list_chip_main_sources} ${chip_dir}/examples/all-clusters-minimal-app/all-clusters-common/src/bridged-actions-stub.cpp + ${chip_dir}/examples/all-clusters-minimal-app/all-clusters-common/src/smco-stub.cpp ${chip_dir}/examples/all-clusters-minimal-app/all-clusters-common/src/static-supported-modes-manager.cpp ${chip_dir}/examples/all-clusters-minimal-app/ameba/main/chipinterface.cpp diff --git a/examples/all-clusters-minimal-app/asr/BUILD.gn b/examples/all-clusters-minimal-app/asr/BUILD.gn index 752062a9b96ebf..f918700d18e314 100755 --- a/examples/all-clusters-minimal-app/asr/BUILD.gn +++ b/examples/all-clusters-minimal-app/asr/BUILD.gn @@ -72,6 +72,7 @@ asr_executable("clusters_minimal_app") { sources = [ "${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp", "${examples_plat_dir}/CHIPDeviceManager.cpp", "${examples_plat_dir}/LEDWidget.cpp", diff --git a/examples/all-clusters-minimal-app/esp32/main/CMakeLists.txt b/examples/all-clusters-minimal-app/esp32/main/CMakeLists.txt index d8d00a950ba892..3b7a442f18df13 100644 --- a/examples/all-clusters-minimal-app/esp32/main/CMakeLists.txt +++ b/examples/all-clusters-minimal-app/esp32/main/CMakeLists.txt @@ -68,6 +68,7 @@ set(SRC_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thread-network-diagnostics-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/channel-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/scenes-server" + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/smoke-co-alarm-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/software-diagnostics-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/switch-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general-diagnostics-server" diff --git a/examples/all-clusters-minimal-app/infineon/psoc6/BUILD.gn b/examples/all-clusters-minimal-app/infineon/psoc6/BUILD.gn index 970717895d79d8..721b1492d4c1f5 100644 --- a/examples/all-clusters-minimal-app/infineon/psoc6/BUILD.gn +++ b/examples/all-clusters-minimal-app/infineon/psoc6/BUILD.gn @@ -109,6 +109,7 @@ psoc6_executable("clusters_minimal_app") { sources = [ "${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp", "${examples_plat_dir}/LEDWidget.cpp", "${examples_plat_dir}/init_psoc6Platform.cpp", diff --git a/examples/all-clusters-minimal-app/linux/BUILD.gn b/examples/all-clusters-minimal-app/linux/BUILD.gn index 24154fe758f958..ea25284906df07 100644 --- a/examples/all-clusters-minimal-app/linux/BUILD.gn +++ b/examples/all-clusters-minimal-app/linux/BUILD.gn @@ -23,6 +23,7 @@ source_set("chip-all-clusters-common") { sources = [ "${chip_root}/examples/all-clusters-app/all-clusters-common/src/binding-handler.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp", "AppOptions.cpp", "include/tv-callbacks.cpp", diff --git a/examples/all-clusters-minimal-app/linux/args.gni b/examples/all-clusters-minimal-app/linux/args.gni index dc89c1c4d16b31..a87d4da8fd9320 100644 --- a/examples/all-clusters-minimal-app/linux/args.gni +++ b/examples/all-clusters-minimal-app/linux/args.gni @@ -23,3 +23,8 @@ chip_system_project_config_include = "" chip_project_config_include_dirs = [ "${chip_root}/examples/all-clusters-minimal-app/linux/include" ] chip_project_config_include_dirs += [ "${chip_root}/config/standalone" ] + +matter_enable_tracing_support = true + +# Perfetto requires C++17 +cpp_standard = "gnu++17" diff --git a/examples/all-clusters-minimal-app/linux/main-common.cpp b/examples/all-clusters-minimal-app/linux/main-common.cpp index fadc7fc7246ab8..698e1400b8e2b7 100644 --- a/examples/all-clusters-minimal-app/linux/main-common.cpp +++ b/examples/all-clusters-minimal-app/linux/main-common.cpp @@ -21,12 +21,10 @@ #include #include #include -#include #include #include #include #include -#include #include #include #include @@ -84,94 +82,7 @@ static Identify gIdentify1 = { OnTriggerEffect, }; -// Network commissioning -namespace { -// This file is being used by platforms other than Linux, so we need this check to disable related features since we only -// implemented them on linux. -constexpr EndpointId kNetworkCommissioningEndpointMain = 0; -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); -#endif // CHIP_DEVICE_LAYER_TARGET_LINUX -} // namespace - -void ApplicationInit() -{ - (void) kNetworkCommissioningEndpointMain; - // 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 -#else - false -#endif - }; - - const bool kWiFiEnabled = { -#if CHIP_DEVICE_CONFIG_ENABLE_WPA - LinuxDeviceOptions::GetInstance().mWiFi -#else - false -#endif - }; - - if (kThreadEnabled && kWiFiEnabled) - { -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD - sThreadNetworkCommissioningInstance.Init(); -#endif -#if CHIP_DEVICE_CONFIG_ENABLE_WPA - sWiFiNetworkCommissioningInstance.Init(); -#endif - // Only enable secondary endpoint for network commissioning cluster when both WiFi and Thread are enabled. - emberAfEndpointEnableDisable(kNetworkCommissioningEndpointSecondary, true); - } - else if (kThreadEnabled) - { -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD - sThreadNetworkCommissioningInstance.Init(); -#endif - } - else if (kWiFiEnabled) - { -#if CHIP_DEVICE_CONFIG_ENABLE_WPA - // 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); - 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 - } -} +void ApplicationInit() {} void emberAfLowPowerClusterInitCallback(EndpointId endpoint) { diff --git a/examples/all-clusters-minimal-app/linux/main.cpp b/examples/all-clusters-minimal-app/linux/main.cpp index ec71f22c42cc0c..766a5820d0eed3 100644 --- a/examples/all-clusters-minimal-app/linux/main.cpp +++ b/examples/all-clusters-minimal-app/linux/main.cpp @@ -20,9 +20,15 @@ #include "AppOptions.h" #include "binding-handler.h" +// Network commissioning +namespace { +constexpr chip::EndpointId kNetworkCommissioningEndpointSecondary = 0xFFFE; +} // anonymous namespace + int main(int argc, char * argv[]) { - VerifyOrDie(ChipLinuxAppInit(argc, argv, AppOptions::GetOptions()) == 0); + VerifyOrDie( + ChipLinuxAppInit(argc, argv, AppOptions::GetOptions(), chip::MakeOptional(kNetworkCommissioningEndpointSecondary)) == 0); VerifyOrDie(InitBindingHandlers() == CHIP_NO_ERROR); LinuxDeviceOptions::GetInstance().dacProvider = AppOptions::GetDACProvider(); diff --git a/examples/all-clusters-minimal-app/mbed/CMakeLists.txt b/examples/all-clusters-minimal-app/mbed/CMakeLists.txt index dc503a4e9b5970..e50fcef67663f8 100644 --- a/examples/all-clusters-minimal-app/mbed/CMakeLists.txt +++ b/examples/all-clusters-minimal-app/mbed/CMakeLists.txt @@ -60,6 +60,7 @@ target_sources(${APP_TARGET} PRIVATE ${MBED_COMMON}/util/LEDWidget.cpp ${MBED_COMMON}/util/DFUManager.cpp ${ALL_CLUSTERS_COMMON}/src/bridged-actions-stub.cpp + ${ALL_CLUSTERS_COMMON}/src/smco-stub.cpp ${ALL_CLUSTERS_COMMON}/src/static-supported-modes-manager.cpp ) diff --git a/examples/all-clusters-minimal-app/nrfconnect/CMakeLists.txt b/examples/all-clusters-minimal-app/nrfconnect/CMakeLists.txt index 00ecc2ca2fbfc5..2e5c3fbbf1102f 100644 --- a/examples/all-clusters-minimal-app/nrfconnect/CMakeLists.txt +++ b/examples/all-clusters-minimal-app/nrfconnect/CMakeLists.txt @@ -55,6 +55,7 @@ target_include_directories(app PRIVATE target_sources(app PRIVATE main/AppTask.cpp main/main.cpp + ${ALL_CLUSTERS_COMMON_DIR}/src/smco-stub.cpp ${ALL_CLUSTERS_COMMON_DIR}/src/static-supported-modes-manager.cpp ${ALL_CLUSTERS_COMMON_DIR}/src/bridged-actions-stub.cpp ${ALL_CLUSTERS_COMMON_DIR}/src/binding-handler.cpp diff --git a/examples/all-clusters-minimal-app/telink/CMakeLists.txt b/examples/all-clusters-minimal-app/telink/CMakeLists.txt index 0d7e3a5313b12b..410f305c3b317a 100644 --- a/examples/all-clusters-minimal-app/telink/CMakeLists.txt +++ b/examples/all-clusters-minimal-app/telink/CMakeLists.txt @@ -70,6 +70,7 @@ add_definitions( target_sources(app PRIVATE src/AppTask.cpp + ${ALL_CLUSTERS_COMMON_DIR}/src/smco-stub.cpp ${ALL_CLUSTERS_COMMON_DIR}/src/static-supported-modes-manager.cpp ${ALL_CLUSTERS_COMMON_DIR}/src/bridged-actions-stub.cpp ${ALL_CLUSTERS_COMMON_DIR}/src/binding-handler.cpp diff --git a/examples/all-clusters-minimal-app/tizen/BUILD.gn b/examples/all-clusters-minimal-app/tizen/BUILD.gn index 138c6e9c2e6850..5485fdd469d223 100644 --- a/examples/all-clusters-minimal-app/tizen/BUILD.gn +++ b/examples/all-clusters-minimal-app/tizen/BUILD.gn @@ -25,6 +25,7 @@ source_set("chip-all-clusters-common") { sources = [ "${chip_root}/examples/all-clusters-app/all-clusters-common/src/binding-handler.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp", ] diff --git a/examples/android/CHIPTest/app/src/androidTest/java/com/tcl/chip/chiptest/ExampleInstrumentedTest.kt b/examples/android/CHIPTest/app/src/androidTest/java/com/tcl/chip/chiptest/ExampleInstrumentedTest.kt index 0b4a921e467b9b..816d452a6efe00 100644 --- a/examples/android/CHIPTest/app/src/androidTest/java/com/tcl/chip/chiptest/ExampleInstrumentedTest.kt +++ b/examples/android/CHIPTest/app/src/androidTest/java/com/tcl/chip/chiptest/ExampleInstrumentedTest.kt @@ -1,13 +1,11 @@ package com.tcl.chip.chiptest -import androidx.test.platform.app.InstrumentationRegistry import androidx.test.ext.junit.runners.AndroidJUnit4 - +import androidx.test.platform.app.InstrumentationRegistry +import org.junit.Assert.* import org.junit.Test import org.junit.runner.RunWith -import org.junit.Assert.* - /** * Instrumented test, which will execute on an Android device. * @@ -15,10 +13,10 @@ import org.junit.Assert.* */ @RunWith(AndroidJUnit4::class) class ExampleInstrumentedTest { - @Test - fun useAppContext() { - // Context of the app under test. - val appContext = InstrumentationRegistry.getInstrumentation().targetContext - assertEquals("com.tcl.chip.chiptest", appContext.packageName) - } -} \ No newline at end of file + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.tcl.chip.chiptest", appContext.packageName) + } +} diff --git a/examples/android/CHIPTest/app/src/main/java/com/tcl/chip/chiptest/MainActivity.kt b/examples/android/CHIPTest/app/src/main/java/com/tcl/chip/chiptest/MainActivity.kt index 0b914a1745fe99..c29cee70364cd4 100644 --- a/examples/android/CHIPTest/app/src/main/java/com/tcl/chip/chiptest/MainActivity.kt +++ b/examples/android/CHIPTest/app/src/main/java/com/tcl/chip/chiptest/MainActivity.kt @@ -9,50 +9,60 @@ import androidx.appcompat.app.AppCompatActivity import chip.platform.* import com.tcl.chip.chiptest.databinding.ActivityMainBinding - class MainActivity : AppCompatActivity() { - private val msgShowLog = 1 + private val msgShowLog = 1 - private lateinit var binding: ActivityMainBinding - private val mainHandler: Handler = object : Handler(Looper.getMainLooper()) { - override fun handleMessage(msg: Message) { - super.handleMessage(msg) - when (msg.what) { - msgShowLog -> { - binding.testLog.append(msg.obj.toString()) - } - } + private lateinit var binding: ActivityMainBinding + private val mainHandler: Handler = + object : Handler(Looper.getMainLooper()) { + override fun handleMessage(msg: Message) { + super.handleMessage(msg) + when (msg.what) { + msgShowLog -> { + binding.testLog.append(msg.obj.toString()) + } } + } } - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) - binding = ActivityMainBinding.inflate(layoutInflater) - setContentView(binding.root) + binding = ActivityMainBinding.inflate(layoutInflater) + setContentView(binding.root) - binding.testLog.movementMethod = ScrollingMovementMethod(); - TestEngine.setListener { log -> - var msg = mainHandler.obtainMessage(msgShowLog, log) - mainHandler.sendMessage(msg) - } + binding.testLog.movementMethod = ScrollingMovementMethod() + TestEngine.setListener { log -> + var msg = mainHandler.obtainMessage(msgShowLog, log) + mainHandler.sendMessage(msg) + } - binding.runButton.setOnClickListener { - binding.testLog.text = "" - Thread{ - var ret = TestEngine.runTest(); - - var log:String = if (ret == 0) { - getString(R.string.test_finished) - } else { - getString(R.string.test_failed,ret) - } - var msg = mainHandler.obtainMessage(msgShowLog, log) - mainHandler.sendMessage(msg) - }.start() - } + binding.runButton.setOnClickListener { + binding.testLog.text = "" + Thread { + var ret = TestEngine.runTest() - AndroidChipPlatform(AndroidBleManager(), PreferencesKeyValueStoreManager(this), PreferencesConfigurationManager(this), NsdManagerServiceResolver(this), NsdManagerServiceBrowser(this), ChipMdnsCallbackImpl(), DiagnosticDataProviderImpl(this)) + var log: String = + if (ret == 0) { + getString(R.string.test_finished) + } else { + getString(R.string.test_failed, ret) + } + var msg = mainHandler.obtainMessage(msgShowLog, log) + mainHandler.sendMessage(msg) + } + .start() } + + AndroidChipPlatform( + AndroidBleManager(), + PreferencesKeyValueStoreManager(this), + PreferencesConfigurationManager(this), + NsdManagerServiceResolver(this), + NsdManagerServiceBrowser(this), + ChipMdnsCallbackImpl(), + DiagnosticDataProviderImpl(this) + ) + } } diff --git a/examples/android/CHIPTest/app/src/test/java/com/tcl/chip/chiptest/ExampleUnitTest.kt b/examples/android/CHIPTest/app/src/test/java/com/tcl/chip/chiptest/ExampleUnitTest.kt index 803f71dcf64930..a33a8805de2146 100644 --- a/examples/android/CHIPTest/app/src/test/java/com/tcl/chip/chiptest/ExampleUnitTest.kt +++ b/examples/android/CHIPTest/app/src/test/java/com/tcl/chip/chiptest/ExampleUnitTest.kt @@ -1,8 +1,7 @@ package com.tcl.chip.chiptest -import org.junit.Test - import org.junit.Assert.* +import org.junit.Test /** * Example local unit test, which will execute on the development machine (host). @@ -10,8 +9,8 @@ import org.junit.Assert.* * See [testing documentation](http://d.android.com/tools/testing). */ class ExampleUnitTest { - @Test - fun addition_isCorrect() { - assertEquals(4, 2 + 2) - } -} \ No newline at end of file + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/CHIPToolActivity.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/CHIPToolActivity.kt index 07bde0bf7dac57..0284b007fe60ec 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/CHIPToolActivity.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/CHIPToolActivity.kt @@ -60,16 +60,15 @@ class CHIPToolActivity : if (savedInstanceState == null) { val fragment = SelectActionFragment.newInstance() supportFragmentManager - .beginTransaction() - .add(R.id.nav_host_fragment, fragment, fragment.javaClass.simpleName) - .commit() + .beginTransaction() + .add(R.id.nav_host_fragment, fragment, fragment.javaClass.simpleName) + .commit() } else { networkType = - ProvisionNetworkType.fromName(savedInstanceState.getString(ARG_PROVISION_NETWORK_TYPE)) + ProvisionNetworkType.fromName(savedInstanceState.getString(ARG_PROVISION_NETWORK_TYPE)) } - if (intent?.action == NfcAdapter.ACTION_NDEF_DISCOVERED) - onNfcIntent(intent) + if (intent?.action == NfcAdapter.ACTION_NDEF_DISCOVERED) onNfcIntent(intent) if (Intent.ACTION_VIEW == intent?.action) { onReturnIntent(intent) @@ -97,10 +96,8 @@ class CHIPToolActivity : override fun onCommissioningComplete(code: Int) { runOnUiThread { - Toast.makeText( - this, - getString(R.string.commissioning_completed, code), - Toast.LENGTH_SHORT).show() + Toast.makeText(this, getString(R.string.commissioning_completed, code), Toast.LENGTH_SHORT) + .show() } ChipClient.getDeviceController(this).close() showFragment(SelectActionFragment.newInstance(), false) @@ -128,7 +125,8 @@ class CHIPToolActivity : } private fun showFragment(fragment: Fragment, showOnBack: Boolean = true) { - val fragmentTransaction = supportFragmentManager + val fragmentTransaction = + supportFragmentManager .beginTransaction() .replace(R.id.nav_host_fragment, fragment, fragment.javaClass.simpleName) @@ -153,8 +151,7 @@ class CHIPToolActivity : lateinit var setupPayload: OnboardingPayload try { - setupPayload = - OnboardingPayloadParser().parseQrCode(uri.toString().toUpperCase()) + setupPayload = OnboardingPayloadParser().parseQrCode(uri.toString().toUpperCase()) } catch (ex: UnrecognizedQrCodeException) { Log.e(TAG, "Unrecognized QR Code", ex) Toast.makeText(this, "Unrecognized QR Code", Toast.LENGTH_SHORT).show() @@ -163,23 +160,26 @@ class CHIPToolActivity : val deviceInfo = CHIPDeviceInfo.fromSetupPayload(setupPayload) - val buttons = arrayOf( + val buttons = + arrayOf( getString(R.string.nfc_tag_action_show), getString(R.string.nfc_tag_action_wifi), - getString(R.string.nfc_tag_action_thread)) + getString(R.string.nfc_tag_action_thread) + ) AlertDialog.Builder(this) - .setTitle(R.string.nfc_tag_action_title) - .setItems(buttons) { _, which -> - this.networkType = when (which) { + .setTitle(R.string.nfc_tag_action_title) + .setItems(buttons) { _, which -> + this.networkType = + when (which) { 1 -> ProvisionNetworkType.WIFI 2 -> ProvisionNetworkType.THREAD else -> null } - onCHIPDeviceInfoReceived(deviceInfo) - } - .create() - .show() + onCHIPDeviceInfoReceived(deviceInfo) + } + .create() + .show() } private fun onReturnIntent(intent: Intent) { @@ -222,18 +222,13 @@ class CHIPToolActivity : setupPayload.setupPinCode = payload.getLong("setupPinCode") val deviceInfo = CHIPDeviceInfo.fromSetupPayload(setupPayload) - val buttons = arrayOf( - getString(R.string.nfc_tag_action_show) - ) + val buttons = arrayOf(getString(R.string.nfc_tag_action_show)) AlertDialog.Builder(this) .setTitle(R.string.provision_custom_flow_alert_title) - .setItems(buttons) { _, _ -> - onCHIPDeviceInfoReceived(deviceInfo) - } + .setItems(buttons) { _, _ -> onCHIPDeviceInfoReceived(deviceInfo) } .create() .show() - } catch (ex: UnrecognizedQrCodeException) { Log.e(TAG, "Unrecognized Payload", ex) Toast.makeText(this, "Unrecognized Setup Payload", Toast.LENGTH_SHORT).show() diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/ChipClient.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/ChipClient.kt index 84a14de4714e13..d57f63a69a9bee 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/ChipClient.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/ChipClient.kt @@ -47,11 +47,14 @@ object ChipClient { getAndroidChipPlatform(context) if (!this::chipDeviceController.isInitialized) { - chipDeviceController = ChipDeviceController(ControllerParams.newBuilder().setControllerVendorId(VENDOR_ID).build()) + chipDeviceController = + ChipDeviceController(ControllerParams.newBuilder().setControllerVendorId(VENDOR_ID).build()) // Set delegate for attestation trust store for device attestation verifier. // It will replace the default attestation trust store. - chipDeviceController.setAttestationTrustStoreDelegate(ExampleAttestationTrustStoreDelegate(chipDeviceController)) + chipDeviceController.setAttestationTrustStoreDelegate( + ExampleAttestationTrustStoreDelegate(chipDeviceController) + ) } return chipDeviceController @@ -59,9 +62,18 @@ object ChipClient { fun getAndroidChipPlatform(context: Context?): AndroidChipPlatform { if (!this::androidPlatform.isInitialized && context != null) { - //force ChipDeviceController load jni + // force ChipDeviceController load jni ChipDeviceController.loadJni() - androidPlatform = AndroidChipPlatform(AndroidBleManager(context), PreferencesKeyValueStoreManager(context), PreferencesConfigurationManager(context), NsdManagerServiceResolver(context), NsdManagerServiceBrowser(context), ChipMdnsCallbackImpl(), DiagnosticDataProviderImpl(context)) + androidPlatform = + AndroidChipPlatform( + AndroidBleManager(context), + PreferencesKeyValueStoreManager(context), + PreferencesConfigurationManager(context), + NsdManagerServiceResolver(context), + NsdManagerServiceBrowser(context), + ChipMdnsCallbackImpl(), + DiagnosticDataProviderImpl(context) + ) } return androidPlatform @@ -71,25 +83,30 @@ object ChipClient { * Wrapper around [ChipDeviceController.getConnectedDevicePointer] to return the value directly. */ suspend fun getConnectedDevicePointer(context: Context, nodeId: Long): Long { - // TODO (#21539) This is a memory leak because we currently never call releaseConnectedDevicePointer - // once we are done with the returned device pointer. Memory leak was introduced since the refactor - // that introduced it was very large in order to fix a use after free, which was considered to be + // TODO (#21539) This is a memory leak because we currently never call + // releaseConnectedDevicePointer + // once we are done with the returned device pointer. Memory leak was introduced since the + // refactor + // that introduced it was very large in order to fix a use after free, which was considered + // to be // worse than the memory leak that was introduced. return suspendCancellableCoroutine { continuation -> - getDeviceController(context).getConnectedDevicePointer( - nodeId, - object : GetConnectedDeviceCallback { - override fun onDeviceConnected(devicePointer: Long) { - Log.d(TAG, "Got connected device pointer") - continuation.resume(devicePointer) - } + getDeviceController(context) + .getConnectedDevicePointer( + nodeId, + object : GetConnectedDeviceCallback { + override fun onDeviceConnected(devicePointer: Long) { + Log.d(TAG, "Got connected device pointer") + continuation.resume(devicePointer) + } - override fun onConnectionFailure(nodeId: Long, error: Exception) { - val errorMessage = "Unable to get connected device with nodeId $nodeId" - Log.e(TAG, errorMessage, error) - continuation.resumeWithException(IllegalStateException(errorMessage)) + override fun onConnectionFailure(nodeId: Long, error: Exception) { + val errorMessage = "Unable to get connected device with nodeId $nodeId" + Log.e(TAG, errorMessage, error) + continuation.resumeWithException(IllegalStateException(errorMessage)) + } } - }) + ) } } } diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/GenericChipDeviceListener.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/GenericChipDeviceListener.kt index 4ccf1ba6e6a836..1d62115547e305 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/GenericChipDeviceListener.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/GenericChipDeviceListener.kt @@ -23,7 +23,12 @@ open class GenericChipDeviceListener : ChipDeviceController.CompletionListener { // No op } - override fun onReadCommissioningInfo(vendorId: Int,productId: Int, wifiEndpointId: Int, threadEndpointId: Int) { + override fun onReadCommissioningInfo( + vendorId: Int, + productId: Int, + wifiEndpointId: Int, + threadEndpointId: Int + ) { // No op } diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/NetworkCredentialsParcelable.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/NetworkCredentialsParcelable.kt index 4f5d5ffafdeb52..a3295e96fc66cf 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/NetworkCredentialsParcelable.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/NetworkCredentialsParcelable.kt @@ -17,20 +17,19 @@ */ package com.google.chip.chiptool -import android.os.Parcelable import android.os.Parcel +import android.os.Parcelable import android.os.Parcelable.Creator -/** Class for holding WiFi or Thread credentials, but not both. */ +/** Class for holding WiFi or Thread credentials, but not both. */ class NetworkCredentialsParcelable : Parcelable { var wiFiCredentials: WiFiCredentials? private set + var threadCredentials: ThreadCredentials? private set - private constructor( - wifiCredentials: WiFiCredentials?, threadCredentials: ThreadCredentials? - ) { + private constructor(wifiCredentials: WiFiCredentials?, threadCredentials: ThreadCredentials?) { this.wiFiCredentials = wifiCredentials this.threadCredentials = threadCredentials } @@ -136,14 +135,15 @@ class NetworkCredentialsParcelable : Parcelable { } @JvmField - val CREATOR = object : Parcelable.Creator { - override fun createFromParcel(parcel: Parcel): NetworkCredentialsParcelable? { - return NetworkCredentialsParcelable(parcel) + val CREATOR = + object : Parcelable.Creator { + override fun createFromParcel(parcel: Parcel): NetworkCredentialsParcelable? { + return NetworkCredentialsParcelable(parcel) + } + + override fun newArray(size: Int): Array { + return arrayOfNulls(size) + } } - - override fun newArray(size: Int): Array { - return arrayOfNulls(size) - } - } } } diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/SelectActionFragment.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/SelectActionFragment.kt index 38cc5d7fb5cec3..5932acb648d8a5 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/SelectActionFragment.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/SelectActionFragment.kt @@ -40,12 +40,13 @@ import com.google.chip.chiptool.util.FragmentUtil /** Fragment to select from various options to interact with a CHIP device. */ class SelectActionFragment : Fragment() { private var _binding: SelectActionFragmentBinding? = null - private val binding get() = _binding!! + private val binding + get() = _binding!! override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle? + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? ): View { _binding = SelectActionFragmentBinding.inflate(inflater, container, false) @@ -67,9 +68,9 @@ class SelectActionFragment : Fragment() { binding.basicClusterBtn.setOnClickListener { handleBasicClicked() } binding.attestationTestBtn.setOnClickListener { handleAttestationTestClicked() } binding.clusterInteractionBtn.setOnClickListener { handleClusterInteractionClicked() } - binding.provisionCustomFlowBtn.setOnClickListener{ handleProvisionCustomFlowClicked() } + binding.provisionCustomFlowBtn.setOnClickListener { handleProvisionCustomFlowClicked() } binding.wildcardBtn.setOnClickListener { handleWildcardClicked() } - binding.unpairDeviceBtn.setOnClickListener{ handleUnpairDeviceClicked() } + binding.unpairDeviceBtn.setOnClickListener { handleUnpairDeviceClicked() } return binding.root } @@ -153,9 +154,10 @@ class SelectActionFragment : Fragment() { } private fun showFragment(fragment: Fragment, showOnBack: Boolean = true) { - val fragmentTransaction = parentFragmentManager - .beginTransaction() - .replace(R.id.nav_host_fragment, fragment, fragment.javaClass.simpleName) + val fragmentTransaction = + parentFragmentManager + .beginTransaction() + .replace(R.id.nav_host_fragment, fragment, fragment.javaClass.simpleName) if (showOnBack) { fragmentTransaction.addToBackStack(null) @@ -164,95 +166,69 @@ class SelectActionFragment : Fragment() { fragmentTransaction.commit() } - /** - * Notifies listener of Scan QR code button click. - */ + /** Notifies listener of Scan QR code button click. */ private fun handleScanQrCodeClicked() { showFragment(BarcodeFragment.newInstance(), false) } - /** - * Notifies listener of Light On/Off & Level Cluster button click. - */ + /** Notifies listener of Light On/Off & Level Cluster button click. */ private fun handleOnOffClicked() { showFragment(OnOffClientFragment.newInstance()) } - /** - * Notifies listener of Sensor Clusters button click. - */ + /** Notifies listener of Sensor Clusters button click. */ private fun handleSensorClicked() { showFragment(SensorClientFragment.newInstance()) } - /** - * Notifies listener of Multi-admin Clusters button click. - */ + /** Notifies listener of Multi-admin Clusters button click. */ private fun handleMultiAdminClicked() { showFragment(MultiAdminClientFragment.newInstance()) } - /** - * Notifies listener of Operational Credentials Clusters button click. - */ + /** Notifies listener of Operational Credentials Clusters button click. */ private fun handleOpCredClicked() { showFragment(OpCredClientFragment.newInstance()) } - /** - * Notifies listener of Basic Clusters button click. - */ + /** Notifies listener of Basic Clusters button click. */ private fun handleBasicClicked() { showFragment(BasicClientFragment.newInstance()) } - /** - * Notifies listener of attestation command button clicked. - */ + /** Notifies listener of attestation command button clicked. */ private fun handleAttestationTestClicked() { showFragment(AttestationTestFragment.newInstance()) } - /** - * Notifies listener of cluster interaction button click. - */ + /** Notifies listener of cluster interaction button click. */ private fun handleClusterInteractionClicked() { showFragment(ClusterInteractionFragment.newInstance()) } - /** - * Notifies listener of wildcard button click. - */ + /** Notifies listener of wildcard button click. */ private fun handleWildcardClicked() { showFragment(WildcardFragment.newInstance()) } - /** - * Notifies listener of unpair button click. - */ + /** Notifies listener of unpair button click. */ private fun handleUnpairDeviceClicked() { showFragment(UnpairDeviceFragment.newInstance()) } - /** - * Notifies listener of provision-WiFi-credentials button click. - */ + /** Notifies listener of provision-WiFi-credentials button click. */ private fun handleProvisionWiFiCredentialsClicked() { getCallback()?.SetNetworkType(ProvisionNetworkType.WIFI) showFragment(BarcodeFragment.newInstance(), false) } - /** - * Notifies listener of provision-Thread-credentials button click. - */ + /** Notifies listener of provision-Thread-credentials button click. */ private fun handleProvisionThreadCredentialsClicked() { getCallback()?.SetNetworkType(ProvisionNetworkType.THREAD) showFragment(BarcodeFragment.newInstance(), false) } - /** - * Notifies listener of provision-custom-flow button click. - */ + /** Notifies listener of provision-custom-flow button click. */ private fun handleProvisionCustomFlowClicked() { showFragment(BarcodeFragment.newInstance(), false) } diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/attestation/AttestationAppLauncher.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/attestation/AttestationAppLauncher.kt index 3cb19cb4f99437..e3185f34917d30 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/attestation/AttestationAppLauncher.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/attestation/AttestationAppLauncher.kt @@ -16,7 +16,8 @@ object AttestationAppLauncher { caller: ActivityResultCaller, block: (String?) -> Unit ): ActivityResultLauncher { - return caller.registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result -> + return caller.registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { + result -> val data = result.data if (result.resultCode == Activity.RESULT_OK && data != null) { val chipResult = data.getStringExtra(CHIP_RESULT_KEY) @@ -30,9 +31,8 @@ object AttestationAppLauncher { fun getAttestationIntent(context: Context): Intent? { val packageManager = context.packageManager as PackageManager val attestationActivityIntent = Intent(CHIP_ACTION) - val attestationAppInfo = packageManager - .queryIntentActivities(attestationActivityIntent, 0) - .firstOrNull() + val attestationAppInfo = + packageManager.queryIntentActivities(attestationActivityIntent, 0).firstOrNull() return if (attestationAppInfo != null) { attestationActivityIntent.setClassName( diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/attestation/AttestationTestFragment.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/attestation/AttestationTestFragment.kt index d4ff86d3719293..35c50e5384dc54 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/attestation/AttestationTestFragment.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/attestation/AttestationTestFragment.kt @@ -11,7 +11,8 @@ import com.google.chip.chiptool.databinding.AttestationTestFragmentBinding /** Fragment for launching external attestation apps */ class AttestationTestFragment : Fragment() { private var _binding: AttestationTestFragmentBinding? = null - private val binding get() = _binding!! + private val binding + get() = _binding!! override fun onCreateView( inflater: LayoutInflater, @@ -23,8 +24,7 @@ class AttestationTestFragment : Fragment() { binding.attestationText.text = context!!.getString(R.string.attestation_fetching_status) val appIntent = AttestationAppLauncher.getAttestationIntent(requireContext()) if (appIntent != null) { - AttestationAppLauncher - .getLauncher(this@AttestationTestFragment) { result -> + AttestationAppLauncher.getLauncher(this@AttestationTestFragment) { result -> binding.attestationText.text = result } .launch(appIntent) @@ -41,7 +41,6 @@ class AttestationTestFragment : Fragment() { } companion object { - @JvmStatic - fun newInstance(): AttestationTestFragment = AttestationTestFragment() + @JvmStatic fun newInstance(): AttestationTestFragment = AttestationTestFragment() } } diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/attestation/ExampleAttestationTrustStoreDelegate.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/attestation/ExampleAttestationTrustStoreDelegate.kt index c94a64d1b8d00f..f62be2ce7dbbc6 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/attestation/ExampleAttestationTrustStoreDelegate.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/attestation/ExampleAttestationTrustStoreDelegate.kt @@ -1,7 +1,6 @@ package com.google.chip.chiptool.attestation import android.util.Base64 -import android.util.Log import chip.devicecontroller.AttestationTrustStoreDelegate import chip.devicecontroller.ChipDeviceController import java.util.* @@ -14,7 +13,9 @@ class ExampleAttestationTrustStoreDelegate(val chipDeviceController: ChipDeviceC override fun getProductAttestationAuthorityCert(skid: ByteArray): ByteArray? { return paaCerts .map { Base64.decode(it, Base64.DEFAULT) } - .firstOrNull { cert -> Arrays.equals(chipDeviceController.extractSkidFromPaaCert(cert), skid) } + .firstOrNull { cert -> + Arrays.equals(chipDeviceController.extractSkidFromPaaCert(cert), skid) + } } companion object { diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/bluetooth/BluetoothManager.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/bluetooth/BluetoothManager.kt index 4618a0591f9044..16d0f745b5f70f 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/bluetooth/BluetoothManager.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/bluetooth/BluetoothManager.kt @@ -39,14 +39,16 @@ class BluetoothManager : BleCallback { val version = 0 val versionDiscriminator = ((version and 0xf) shl 12) or (discriminator and 0xfff) return intArrayOf(opcode, versionDiscriminator, versionDiscriminator shr 8) - .map { it.toByte() } - .toByteArray() + .map { it.toByte() } + .toByteArray() } private fun getServiceDataMask(isShortDiscriminator: Boolean): ByteArray { - val shortDiscriminatorMask = when(isShortDiscriminator) { - true -> 0x00 false -> 0xff - } + val shortDiscriminatorMask = + when (isShortDiscriminator) { + true -> 0x00 + false -> 0xff + } return intArrayOf(0xff, shortDiscriminatorMask, 0xff).map { it.toByte() }.toByteArray() } @@ -54,52 +56,59 @@ class BluetoothManager : BleCallback { return getBluetoothDevice(context, discriminator, false) } - suspend fun getBluetoothDevice(context: Context, discriminator: Int, isShortDiscriminator: Boolean): BluetoothDevice? { - if (! bluetoothAdapter.isEnabled) { - bluetoothAdapter.enable(); + suspend fun getBluetoothDevice( + context: Context, + discriminator: Int, + isShortDiscriminator: Boolean + ): BluetoothDevice? { + if (!bluetoothAdapter.isEnabled) { + bluetoothAdapter.enable() } - val scanner = bluetoothAdapter.bluetoothLeScanner ?: run { - Log.e(TAG, "No bluetooth scanner found") - return null - } + val scanner = + bluetoothAdapter.bluetoothLeScanner + ?: run { + Log.e(TAG, "No bluetooth scanner found") + return null + } return withTimeoutOrNull(10000) { callbackFlow { - val scanCallback = object : ScanCallback() { - override fun onScanResult(callbackType: Int, result: ScanResult) { - val device = result.device - Log.i(TAG, "Bluetooth Device Scanned Addr: ${device.address}, Name ${device.name}") - - val producerScope: ProducerScope = this@callbackFlow - if (producerScope.channel.isClosedForSend) { - Log.w(TAG, "Bluetooth device was scanned, but channel is already closed") - } else { - offer(device) + val scanCallback = + object : ScanCallback() { + override fun onScanResult(callbackType: Int, result: ScanResult) { + val device = result.device + Log.i(TAG, "Bluetooth Device Scanned Addr: ${device.address}, Name ${device.name}") + + val producerScope: ProducerScope = this@callbackFlow + if (producerScope.channel.isClosedForSend) { + Log.w(TAG, "Bluetooth device was scanned, but channel is already closed") + } else { + offer(device) + } + } + + override fun onScanFailed(errorCode: Int) { + Log.e(TAG, "Scan failed $errorCode") + } } - } - override fun onScanFailed(errorCode: Int) { - Log.e(TAG, "Scan failed $errorCode") - } - } - - val serviceData = getServiceData(discriminator) - val serviceDataMask = getServiceDataMask(isShortDiscriminator) + val serviceData = getServiceData(discriminator) + val serviceDataMask = getServiceDataMask(isShortDiscriminator) - val scanFilter = + val scanFilter = ScanFilter.Builder() - .setServiceData(ParcelUuid(UUID.fromString(CHIP_UUID)), serviceData, serviceDataMask) - .build() + .setServiceData(ParcelUuid(UUID.fromString(CHIP_UUID)), serviceData, serviceDataMask) + .build() - val scanSettings = ScanSettings.Builder() - .setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY) - .build() + val scanSettings = + ScanSettings.Builder().setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).build() - Log.i(TAG, "Starting Bluetooth scan") - scanner.startScan(listOf(scanFilter), scanSettings, scanCallback) - awaitClose { scanner.stopScan(scanCallback) } - }.first() + Log.i(TAG, "Starting Bluetooth scan") + scanner.startScan(listOf(scanFilter), scanSettings, scanCallback) + awaitClose { scanner.stopScan(scanCallback) } + } + .first() } } @@ -125,16 +134,16 @@ class BluetoothManager : BleCallback { continuation: CancellableContinuation ): BluetoothGattCallback { return object : BluetoothGattCallback() { - private val wrappedCallback = ChipClient.getAndroidChipPlatform(context).bleManager.callback; + private val wrappedCallback = ChipClient.getAndroidChipPlatform(context).bleManager.callback + private val coroutineContinuation = continuation - override fun onConnectionStateChange( - gatt: BluetoothGatt?, - status: Int, - newState: Int - ) { + override fun onConnectionStateChange(gatt: BluetoothGatt?, status: Int, newState: Int) { super.onConnectionStateChange(gatt, status, newState) - Log.i(TAG, "${gatt?.device?.name}.onConnectionStateChange status = $status, newState=$newState") + Log.i( + TAG, + "${gatt?.device?.name}.onConnectionStateChange status = $status, newState=$newState" + ) wrappedCallback.onConnectionStateChange(gatt, status, newState) if (newState == BluetoothProfile.STATE_CONNECTED && status == BluetoothGatt.GATT_SUCCESS) { @@ -148,7 +157,7 @@ class BluetoothManager : BleCallback { wrappedCallback.onServicesDiscovered(gatt, status) Log.i("$TAG|onServicesDiscovered", "Services Discovered") - gatt?.requestMtu(247); + gatt?.requestMtu(247) } override fun onMtuChanged(gatt: BluetoothGatt?, mtu: Int, status: Int) { @@ -161,44 +170,44 @@ class BluetoothManager : BleCallback { } override fun onCharacteristicChanged( - gatt: BluetoothGatt, - characteristic: BluetoothGattCharacteristic + gatt: BluetoothGatt, + characteristic: BluetoothGattCharacteristic ) { Log.d(TAG, "${gatt.device.name}.onCharacteristicChanged: ${characteristic.uuid}") wrappedCallback.onCharacteristicChanged(gatt, characteristic) } override fun onCharacteristicRead( - gatt: BluetoothGatt, - characteristic: BluetoothGattCharacteristic, - status: Int + gatt: BluetoothGatt, + characteristic: BluetoothGattCharacteristic, + status: Int ) { Log.d(TAG, "${gatt.device.name}.onCharacteristicRead: ${characteristic.uuid} -> $status") wrappedCallback.onCharacteristicRead(gatt, characteristic, status) } override fun onCharacteristicWrite( - gatt: BluetoothGatt, - characteristic: BluetoothGattCharacteristic, - status: Int + gatt: BluetoothGatt, + characteristic: BluetoothGattCharacteristic, + status: Int ) { Log.d(TAG, "${gatt.device.name}.onCharacteristicWrite: ${characteristic.uuid} -> $status") wrappedCallback.onCharacteristicWrite(gatt, characteristic, status) } override fun onDescriptorRead( - gatt: BluetoothGatt, - descriptor: BluetoothGattDescriptor, - status: Int + gatt: BluetoothGatt, + descriptor: BluetoothGattDescriptor, + status: Int ) { Log.d(TAG, "${gatt.device.name}.onDescriptorRead: ${descriptor.uuid} -> $status") wrappedCallback.onDescriptorRead(gatt, descriptor, status) } override fun onDescriptorWrite( - gatt: BluetoothGatt, - descriptor: BluetoothGattDescriptor, - status: Int + gatt: BluetoothGatt, + descriptor: BluetoothGattDescriptor, + status: Int ) { Log.d(TAG, "${gatt.device.name}.onDescriptorWrite: ${descriptor.uuid} -> $status") wrappedCallback.onDescriptorWrite(gatt, descriptor, status) @@ -227,7 +236,7 @@ class BluetoothManager : BleCallback { } override fun onNotifyChipConnectionClosed(connId: Int) { - bleGatt?.close(); + bleGatt?.close() connectionId = 0 Log.d(TAG, "onNotifyChipConnectionClosed") } diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/AddressUpdateFragment.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/AddressUpdateFragment.kt index 9b69bf751bf9ee..2fc03050bfc2f1 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/AddressUpdateFragment.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/AddressUpdateFragment.kt @@ -11,19 +11,22 @@ import com.google.chip.chiptool.databinding.AddressUpdateFragmentBinding import com.google.chip.chiptool.util.DeviceIdUtil /** Fragment for updating the address of a device given its fabric and node ID. */ -class AddressUpdateFragment: Fragment() { +class AddressUpdateFragment : Fragment() { private val deviceController: ChipDeviceController get() = ChipClient.getDeviceController(requireContext()) val deviceId: Long get() = binding.deviceIdEd.text.toString().toULong().toLong() - var endpointId : Int + + var endpointId: Int get() = binding.epIdEd.text.toString().toInt() set(value) { binding.epIdEd.setText(value.toString()) } + private var _binding: AddressUpdateFragmentBinding? = null - private val binding get() = _binding!! + private val binding + get() = _binding!! override fun onCreateView( inflater: LayoutInflater, @@ -47,4 +50,4 @@ class AddressUpdateFragment: Fragment() { super.onDestroyView() _binding = null } -} \ No newline at end of file +} diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/BasicClientFragment.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/BasicClientFragment.kt index 3f1692f6720795..4d19a56c10c5c5 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/BasicClientFragment.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/BasicClientFragment.kt @@ -10,6 +10,7 @@ import android.widget.ArrayAdapter import androidx.fragment.app.Fragment import androidx.lifecycle.lifecycleScope import chip.devicecontroller.ChipDeviceController +import chip.devicecontroller.ClusterIDMapping.* import chip.devicecontroller.ReportCallback import chip.devicecontroller.WriteAttributesCallback import chip.devicecontroller.model.AttributeWriteRequest @@ -21,11 +22,9 @@ import com.google.chip.chiptool.GenericChipDeviceListener import com.google.chip.chiptool.R import com.google.chip.chiptool.databinding.BasicClientFragmentBinding import com.google.chip.chiptool.util.TlvParseUtil +import java.util.Optional import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch -import java.util.Optional - -import chip.devicecontroller.ClusterIDMapping.* class BasicClientFragment : Fragment() { private val deviceController: ChipDeviceController @@ -36,7 +35,8 @@ class BasicClientFragment : Fragment() { private lateinit var addressUpdateFragment: AddressUpdateFragment private var _binding: BasicClientFragmentBinding? = null - private val binding get() = _binding!! + private val binding + get() = _binding!! override fun onCreateView( inflater: LayoutInflater, @@ -50,25 +50,38 @@ class BasicClientFragment : Fragment() { addressUpdateFragment = childFragmentManager.findFragmentById(R.id.addressUpdateFragment) as AddressUpdateFragment - binding.writeNodeLabelBtn.setOnClickListener { scope.launch { - // TODO : Need to be implement poj-to-tlv - sendWriteAttribute(BasicInformation.Attribute.NodeLabel, TlvParseUtil.encode(binding.nodeLabelEd.text.toString())) - binding.nodeLabelEd.onEditorAction(EditorInfo.IME_ACTION_DONE) - }} - binding.writeLocationBtn.setOnClickListener { scope.launch { - // TODO : Need to be implement poj-to-tlv - sendWriteAttribute(BasicInformation.Attribute.Location, TlvParseUtil.encode(binding.locationEd.text.toString())) - binding.locationEd.onEditorAction(EditorInfo.IME_ACTION_DONE) - }} + binding.writeNodeLabelBtn.setOnClickListener { + scope.launch { + // TODO : Need to be implement poj-to-tlv + sendWriteAttribute( + BasicInformation.Attribute.NodeLabel, + TlvParseUtil.encode(binding.nodeLabelEd.text.toString()) + ) + binding.nodeLabelEd.onEditorAction(EditorInfo.IME_ACTION_DONE) + } + } + binding.writeLocationBtn.setOnClickListener { + scope.launch { + // TODO : Need to be implement poj-to-tlv + sendWriteAttribute( + BasicInformation.Attribute.Location, + TlvParseUtil.encode(binding.locationEd.text.toString()) + ) + binding.locationEd.onEditorAction(EditorInfo.IME_ACTION_DONE) + } + } binding.writeLocalConfigDisabledSwitch.setOnCheckedChangeListener { _, isChecked -> scope.launch { // TODO : Need to be implement poj-to-tlv - sendWriteAttribute(BasicInformation.Attribute.LocalConfigDisabled, TlvParseUtil.encode(isChecked)) + sendWriteAttribute( + BasicInformation.Attribute.LocalConfigDisabled, + TlvParseUtil.encode(isChecked) + ) } } makeAttributeList() binding.attributeNameSpinner.adapter = makeAttributeNamesAdapter() - binding.readAttributeBtn.setOnClickListener { scope.launch { readAttributeButtonClick() }} + binding.readAttributeBtn.setOnClickListener { scope.launch { readAttributeButtonClick() } } return binding.root } @@ -98,15 +111,13 @@ class BasicClientFragment : Fragment() { } } - private fun makeAttributeNamesAdapter(): ArrayAdapter { return ArrayAdapter( - requireContext(), - android.R.layout.simple_spinner_dropdown_item, - ATTRIBUTES.toList() - ).apply { - setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) - } + requireContext(), + android.R.layout.simple_spinner_dropdown_item, + ATTRIBUTES.toList() + ) + .apply { setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) } } private suspend fun readAttributeButtonClick() { @@ -123,21 +134,39 @@ class BasicClientFragment : Fragment() { val attributeName = ATTRIBUTES[itemIndex] val attributeId = BasicInformation.Attribute.valueOf(attributeName).id - val devicePtr = ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) - - ChipClient.getDeviceController(requireContext()).readPath(object: ReportCallback { - override fun onError(attributePath: ChipAttributePath?, eventPath: ChipEventPath?, ex: java.lang.Exception) { - showMessage("Read $attributeName failure $ex") - Log.e(TAG, "Read $attributeName failure", ex) - } - - override fun onReport(nodeState: NodeState?) { - val value = nodeState?.getEndpointState(endpointId)?.getClusterState(clusterId)?.getAttributeState(attributeId)?.value ?: "null" - Log.i(TAG,"[Read Success] $attributeName: $value") - showMessage("[Read Success] $attributeName: $value") - } - - }, devicePtr, listOf(ChipAttributePath.newInstance(endpointId, clusterId, attributeId)), null, false, 0 /* imTimeoutMs */) + val devicePtr = + ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + + ChipClient.getDeviceController(requireContext()) + .readPath( + object : ReportCallback { + override fun onError( + attributePath: ChipAttributePath?, + eventPath: ChipEventPath?, + ex: java.lang.Exception + ) { + showMessage("Read $attributeName failure $ex") + Log.e(TAG, "Read $attributeName failure", ex) + } + + override fun onReport(nodeState: NodeState?) { + val value = + nodeState + ?.getEndpointState(endpointId) + ?.getClusterState(clusterId) + ?.getAttributeState(attributeId) + ?.value + ?: "null" + Log.i(TAG, "[Read Success] $attributeName: $value") + showMessage("[Read Success] $attributeName: $value") + } + }, + devicePtr, + listOf(ChipAttributePath.newInstance(endpointId, clusterId, attributeId)), + null, + false, + 0 /* imTimeoutMs */ + ) } private fun makeAttributeList() { @@ -148,25 +177,38 @@ class BasicClientFragment : Fragment() { private suspend fun sendWriteAttribute(attribute: BasicInformation.Attribute, tlv: ByteArray) { val clusterId = BasicInformation.ID - val devicePtr = ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) - - ChipClient.getDeviceController(requireContext()).write(object: WriteAttributesCallback { - override fun onError(attributePath: ChipAttributePath?, ex: java.lang.Exception?) { - showMessage("Write ${attribute.name} failure $ex") - Log.e(TAG, "Write ${attribute.name} failure", ex) - } - - override fun onResponse(attributePath: ChipAttributePath?) { - showMessage("Write ${attribute.name} success") - } - - }, devicePtr, listOf(AttributeWriteRequest.newInstance(addressUpdateFragment.endpointId, clusterId, attribute.id, tlv, Optional.empty())), 0, 0) + val devicePtr = + ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + + ChipClient.getDeviceController(requireContext()) + .write( + object : WriteAttributesCallback { + override fun onError(attributePath: ChipAttributePath?, ex: java.lang.Exception?) { + showMessage("Write ${attribute.name} failure $ex") + Log.e(TAG, "Write ${attribute.name} failure", ex) + } + + override fun onResponse(attributePath: ChipAttributePath?) { + showMessage("Write ${attribute.name} success") + } + }, + devicePtr, + listOf( + AttributeWriteRequest.newInstance( + addressUpdateFragment.endpointId, + clusterId, + attribute.id, + tlv, + Optional.empty() + ) + ), + 0, + 0 + ) } private fun showMessage(msg: String) { - requireActivity().runOnUiThread { - binding.basicClusterCommandStatus.text = msg - } + requireActivity().runOnUiThread { binding.basicClusterCommandStatus.text = msg } } override fun onResume() { diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/MultiAdminClientFragment.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/MultiAdminClientFragment.kt index ed7ba6f4f692f0..4df9d2a1a1d230 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/MultiAdminClientFragment.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/MultiAdminClientFragment.kt @@ -33,7 +33,8 @@ class MultiAdminClientFragment : Fragment() { private lateinit var addressUpdateFragment: AddressUpdateFragment private var _binding: MultiAdminClientFragmentBinding? = null - private val binding get() = _binding!! + private val binding + get() = _binding!! override fun onCreateView( inflater: LayoutInflater, @@ -48,12 +49,34 @@ class MultiAdminClientFragment : Fragment() { addressUpdateFragment = childFragmentManager.findFragmentById(R.id.addressUpdateFragment) as AddressUpdateFragment - binding.basicCommissioningMethodBtn.setOnClickListener { scope.launch { sendBasicCommissioningCommandClick() } } - binding.enhancedCommissioningMethodBtn.setOnClickListener { scope.launch { sendEnhancedCommissioningCommandClick() } } + binding.basicCommissioningMethodBtn.setOnClickListener { + scope.launch { sendBasicCommissioningCommandClick() } + } + binding.enhancedCommissioningMethodBtn.setOnClickListener { + scope.launch { sendEnhancedCommissioningCommandClick() } + } binding.revokeBtn.setOnClickListener { scope.launch { sendRevokeCommandClick() } } - binding.readWindowStatusBtn.setOnClickListener { scope.launch { readAdministratorCommissioningClusterAttributeClick(AdministratorCommissioning.Attribute.WindowStatus) } } - binding.readAdminFabricIndexBtn.setOnClickListener { scope.launch { readAdministratorCommissioningClusterAttributeClick(AdministratorCommissioning.Attribute.AdminFabricIndex) } } - binding.readAdminVendorIdBtn.setOnClickListener { scope.launch { readAdministratorCommissioningClusterAttributeClick(AdministratorCommissioning.Attribute.AdminVendorId) } } + binding.readWindowStatusBtn.setOnClickListener { + scope.launch { + readAdministratorCommissioningClusterAttributeClick( + AdministratorCommissioning.Attribute.WindowStatus + ) + } + } + binding.readAdminFabricIndexBtn.setOnClickListener { + scope.launch { + readAdministratorCommissioningClusterAttributeClick( + AdministratorCommissioning.Attribute.AdminFabricIndex + ) + } + } + binding.readAdminVendorIdBtn.setOnClickListener { + scope.launch { + readAdministratorCommissioningClusterAttributeClick( + AdministratorCommissioning.Attribute.AdminVendorId + ) + } + } return binding.root } @@ -97,11 +120,9 @@ class MultiAdminClientFragment : Fragment() { private suspend fun sendBasicCommissioningCommandClick() { val testDuration = binding.timeoutEd.text.toString().toInt() deviceController.openPairingWindowCallback( - ChipClient.getConnectedDevicePointer( - requireContext(), - addressUpdateFragment.deviceId - ), testDuration, - object:OpenCommissioningCallback { + ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId), + testDuration, + object : OpenCommissioningCallback { override fun onError(status: Int, deviceId: Long) { showMessage("OpenBasicCommissioning Fail! \nDevice ID : $deviceId\nErrorCode : $status") } @@ -124,15 +145,20 @@ class MultiAdminClientFragment : Fragment() { setupPinCode = binding.setupPinCodeEd.text.toString().toULong().toLong() } deviceController.openPairingWindowWithPINCallback( - devicePointer, testDuration, testIteration.toLong(), - binding.discriminatorEd.text.toString().toInt(), setupPinCode, - object:OpenCommissioningCallback { + devicePointer, + testDuration, + testIteration.toLong(), + binding.discriminatorEd.text.toString().toInt(), + setupPinCode, + object : OpenCommissioningCallback { override fun onError(status: Int, deviceId: Long) { showMessage("OpenCommissioning Fail! \nDevice ID : $deviceId\nErrorCode : $status") } override fun onSuccess(deviceId: Long, manualPairingCode: String?, qrCode: String?) { - showMessage("OpenCommissioning Success! \n Node ID: $deviceId\n\tManual : $manualPairingCode\n\tQRCode : $qrCode") + showMessage( + "OpenCommissioning Success! \n Node ID: $deviceId\n\tManual : $manualPairingCode\n\tQRCode : $qrCode" + ) } } ) @@ -144,42 +170,68 @@ class MultiAdminClientFragment : Fragment() { val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() - val invokeElement = InvokeElement.newInstance(ADMINISTRATOR_COMMISSIONING_CLUSTER_ENDPOINT_ID - , AdministratorCommissioning.ID - , AdministratorCommissioning.Command.RevokeCommissioning.id - , tlvWriter.getEncoded(), null) - - deviceController.invoke(object: InvokeCallback { - override fun onError(ex: Exception?) { - showMessage("Revoke Commissioning failure $ex") - Log.e(TAG, "Revoke Commissioning failure", ex) - } - - override fun onResponse(invokeElement: InvokeElement?, successCode: Long) { - Log.e(TAG, "onResponse : $invokeElement, Code : $successCode") - showMessage("Revoke Commissioning success") - } + val invokeElement = + InvokeElement.newInstance( + ADMINISTRATOR_COMMISSIONING_CLUSTER_ENDPOINT_ID, + AdministratorCommissioning.ID, + AdministratorCommissioning.Command.RevokeCommissioning.id, + tlvWriter.getEncoded(), + null + ) + + deviceController.invoke( + object : InvokeCallback { + override fun onError(ex: Exception?) { + showMessage("Revoke Commissioning failure $ex") + Log.e(TAG, "Revoke Commissioning failure", ex) + } - }, getConnectedDevicePointer(), invokeElement, timedInvokeTimeout, 0) + override fun onResponse(invokeElement: InvokeElement?, successCode: Long) { + Log.e(TAG, "onResponse : $invokeElement, Code : $successCode") + showMessage("Revoke Commissioning success") + } + }, + getConnectedDevicePointer(), + invokeElement, + timedInvokeTimeout, + 0 + ) } - private suspend fun readAdministratorCommissioningClusterAttributeClick(attribute: AdministratorCommissioning.Attribute) { + private suspend fun readAdministratorCommissioningClusterAttributeClick( + attribute: AdministratorCommissioning.Attribute + ) { val endpointId = ADMINISTRATOR_COMMISSIONING_CLUSTER_ENDPOINT_ID val clusterId = AdministratorCommissioning.ID val attributeId = attribute.id val attributeName = attribute.name val attributePath = ChipAttributePath.newInstance(endpointId, clusterId, attributeId) - deviceController.readAttributePath(object: ReportCallback { - override fun onReport(nodeState: NodeState?) { - val value = nodeState?.getEndpointState(endpointId)?.getClusterState(clusterId)?.getAttributeState(attributeId)?.value ?: "null" - Log.i(TAG,"read $attributeName: $value") - showMessage("read $attributeName: $value") - } + deviceController.readAttributePath( + object : ReportCallback { + override fun onReport(nodeState: NodeState?) { + val value = + nodeState + ?.getEndpointState(endpointId) + ?.getClusterState(clusterId) + ?.getAttributeState(attributeId) + ?.value + ?: "null" + Log.i(TAG, "read $attributeName: $value") + showMessage("read $attributeName: $value") + } - override fun onError(attributePath: ChipAttributePath?, eventPath: ChipEventPath?, e: Exception) { - showMessage("read $attributeName - error : ${e?.message}") - } - }, getConnectedDevicePointer(), listOf(attributePath), 0) + override fun onError( + attributePath: ChipAttributePath?, + eventPath: ChipEventPath?, + e: Exception + ) { + showMessage("read $attributeName - error : ${e?.message}") + } + }, + getConnectedDevicePointer(), + listOf(attributePath), + 0 + ) } private suspend fun getConnectedDevicePointer(): Long { @@ -187,14 +239,13 @@ class MultiAdminClientFragment : Fragment() { } private fun showMessage(msg: String) { - requireActivity().runOnUiThread { - binding.multiAdminClusterCommandStatus.text = msg - } + requireActivity().runOnUiThread { binding.multiAdminClusterCommandStatus.text = msg } } companion object { private const val TAG = "MultiAdminClientFragment" private const val ADMINISTRATOR_COMMISSIONING_CLUSTER_ENDPOINT_ID = 0 + fun newInstance(): MultiAdminClientFragment = MultiAdminClientFragment() } } diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/OnOffClientFragment.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/OnOffClientFragment.kt index 5088cd05036d76..b4bc72c103c986 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/OnOffClientFragment.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/OnOffClientFragment.kt @@ -13,6 +13,7 @@ import android.widget.Toast import androidx.fragment.app.Fragment import androidx.lifecycle.lifecycleScope import chip.devicecontroller.ChipDeviceController +import chip.devicecontroller.ClusterIDMapping.* import chip.devicecontroller.InvokeCallback import chip.devicecontroller.ReportCallback import chip.devicecontroller.ResubscriptionAttemptCallback @@ -21,6 +22,8 @@ import chip.devicecontroller.model.ChipAttributePath import chip.devicecontroller.model.ChipEventPath import chip.devicecontroller.model.InvokeElement import chip.devicecontroller.model.NodeState +import chip.tlv.AnonymousTag +import chip.tlv.ContextSpecificTag import chip.tlv.TlvWriter import com.google.chip.chiptool.ChipClient import com.google.chip.chiptool.GenericChipDeviceListener @@ -33,10 +36,6 @@ import java.util.Locale import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch -import chip.devicecontroller.ClusterIDMapping.* -import chip.tlv.AnonymousTag -import chip.tlv.ContextSpecificTag - class OnOffClientFragment : Fragment() { private val deviceController: ChipDeviceController get() = ChipClient.getDeviceController(requireContext()) @@ -46,7 +45,8 @@ class OnOffClientFragment : Fragment() { private lateinit var addressUpdateFragment: AddressUpdateFragment private var _binding: OnOffClientFragmentBinding? = null - private val binding get() = _binding!! + private val binding + get() = _binding!! override fun onCreateView( inflater: LayoutInflater, @@ -62,28 +62,32 @@ class OnOffClientFragment : Fragment() { childFragmentManager.findFragmentById(R.id.addressUpdateFragment) as AddressUpdateFragment binding.onBtn.setOnClickListener { scope.launch { sendOnOffClusterCommand(OnOff.Command.On) } } - binding.offBtn.setOnClickListener { scope.launch { sendOnOffClusterCommand(OnOff.Command.Off) } } - binding.toggleBtn.setOnClickListener { scope.launch { sendOnOffClusterCommand(OnOff.Command.Toggle) } } + binding.offBtn.setOnClickListener { + scope.launch { sendOnOffClusterCommand(OnOff.Command.Off) } + } + binding.toggleBtn.setOnClickListener { + scope.launch { sendOnOffClusterCommand(OnOff.Command.Toggle) } + } binding.readBtn.setOnClickListener { scope.launch { sendReadOnOffClick() } } binding.showSubscribeDialogBtn.setOnClickListener { showSubscribeDialog() } - binding.levelBar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener { - override fun onProgressChanged(seekBar: SeekBar, i: Int, b: Boolean) { - - } + binding.levelBar.setOnSeekBarChangeListener( + object : SeekBar.OnSeekBarChangeListener { + override fun onProgressChanged(seekBar: SeekBar, i: Int, b: Boolean) {} - override fun onStartTrackingTouch(seekBar: SeekBar?) { - } + override fun onStartTrackingTouch(seekBar: SeekBar?) {} - override fun onStopTrackingTouch(seekBar: SeekBar?) { - Toast.makeText( - requireContext(), - "Level is: " + binding.levelBar.progress, - Toast.LENGTH_SHORT - ).show() - scope.launch { sendLevelCommandClick() } + override fun onStopTrackingTouch(seekBar: SeekBar?) { + Toast.makeText( + requireContext(), + "Level is: " + binding.levelBar.progress, + Toast.LENGTH_SHORT + ) + .show() + scope.launch { sendLevelCommandClick() } + } } - }) + ) return binding.root } @@ -100,25 +104,40 @@ class OnOffClientFragment : Fragment() { val attributePath = ChipAttributePath.newInstance(endpointId, clusterId, attributeId) - ChipClient.getDeviceController(requireContext()).readPath(object: ReportCallback { - override fun onError(attributePath: ChipAttributePath?, eventPath: ChipEventPath?, ex: java.lang.Exception) { - Log.e(TAG, "Error reading onOff attribute", ex) - } - - override fun onReport(nodeState: NodeState?) { - val value = nodeState?.getEndpointState(endpointId)?.getClusterState(clusterId)?.getAttributeState(attributeId)?.value ?: "null" - Log.v(TAG, "On/Off attribute value: $value") - showMessage("On/Off attribute value: $value") - } - - }, getConnectedDevicePointer(), listOf(attributePath), null, false, 0 /* imTimeoutMs */) + ChipClient.getDeviceController(requireContext()) + .readPath( + object : ReportCallback { + override fun onError( + attributePath: ChipAttributePath?, + eventPath: ChipEventPath?, + ex: java.lang.Exception + ) { + Log.e(TAG, "Error reading onOff attribute", ex) + } + + override fun onReport(nodeState: NodeState?) { + val value = + nodeState + ?.getEndpointState(endpointId) + ?.getClusterState(clusterId) + ?.getAttributeState(attributeId) + ?.value + ?: "null" + Log.v(TAG, "On/Off attribute value: $value") + showMessage("On/Off attribute value: $value") + } + }, + getConnectedDevicePointer(), + listOf(attributePath), + null, + false, + 0 /* imTimeoutMs */ + ) } private fun showSubscribeDialog() { val dialogView = requireActivity().layoutInflater.inflate(R.layout.subscribe_dialog, null) - val dialog = AlertDialog.Builder(requireContext()).apply { - setView(dialogView) - }.create() + val dialog = AlertDialog.Builder(requireContext()).apply { setView(dialogView) }.create() val minIntervalEd = dialogView.findViewById(R.id.minIntervalEd) val maxIntervalEd = dialogView.findViewById(R.id.maxIntervalEd) @@ -128,13 +147,12 @@ class OnOffClientFragment : Fragment() { minIntervalEd.text.toString().toInt(), maxIntervalEd.text.toString().toInt() ) - requireActivity().runOnUiThread { - dialog.dismiss() - } + requireActivity().runOnUiThread { dialog.dismiss() } } } dialog.show() } + private suspend fun sendSubscribeOnOffClick(minInterval: Int, maxInterval: Int) { val endpointId = addressUpdateFragment.endpointId val clusterId = OnOff.ID @@ -142,46 +160,65 @@ class OnOffClientFragment : Fragment() { val attributePath = ChipAttributePath.newInstance(endpointId, clusterId, attributeId) - val subscriptionEstablishedCallback = - SubscriptionEstablishedCallback { - subscriptionId -> - Log.i(TAG, "Subscription to device established : ${subscriptionId.toULong()}") - requireActivity().runOnUiThread { - Toast.makeText(requireActivity(), "${getString(R.string.wildcard_subscribe_established_toast_message)} : $subscriptionId", Toast.LENGTH_SHORT).show() - } - } + val subscriptionEstablishedCallback = SubscriptionEstablishedCallback { subscriptionId -> + Log.i(TAG, "Subscription to device established : ${subscriptionId.toULong()}") + requireActivity().runOnUiThread { + Toast.makeText( + requireActivity(), + "${getString(R.string.wildcard_subscribe_established_toast_message)} : $subscriptionId", + Toast.LENGTH_SHORT + ) + .show() + } + } val resubscriptionAttemptCallback = - ResubscriptionAttemptCallback { terminationCause, nextResubscribeIntervalMsec - -> Log.i(TAG, "ResubscriptionAttempt terminationCause:$terminationCause, nextResubscribeIntervalMsec:$nextResubscribeIntervalMsec") } - - deviceController.subscribeToPath(subscriptionEstablishedCallback, - resubscriptionAttemptCallback, - object: ReportCallback { - override fun onError(attributePath: ChipAttributePath?, eventPath: ChipEventPath?, ex: Exception) { - Log.e(TAG, "Error configuring on/off attribute", ex) - } - - override fun onReport(nodeState: NodeState?) { - val tlv = nodeState?.getEndpointState(endpointId)?.getClusterState(clusterId)?.getAttributeState(attributeId)?.tlv ?: return - // TODO : Need to be implement poj-to-tlv - val value = TlvParseUtil.decodeBoolean(tlv) - val formatter = SimpleDateFormat("HH:mm:ss", Locale.getDefault()) - val time = formatter.format(Calendar.getInstance(Locale.getDefault()).time) - val message = "Subscribed on/off value at $time: ${if (value) "ON" else "OFF"}" - - Log.v(TAG, message) - showReportMessage(message) - } - }, - getConnectedDevicePointer(), - listOf(attributePath), - null, - minInterval, - maxInterval, - false, - false, - /* imTimeoutMs= */ 0) + ResubscriptionAttemptCallback { terminationCause, nextResubscribeIntervalMsec -> + Log.i( + TAG, + "ResubscriptionAttempt terminationCause:$terminationCause, nextResubscribeIntervalMsec:$nextResubscribeIntervalMsec" + ) + } + + deviceController.subscribeToPath( + subscriptionEstablishedCallback, + resubscriptionAttemptCallback, + object : ReportCallback { + override fun onError( + attributePath: ChipAttributePath?, + eventPath: ChipEventPath?, + ex: Exception + ) { + Log.e(TAG, "Error configuring on/off attribute", ex) + } + + override fun onReport(nodeState: NodeState?) { + val tlv = + nodeState + ?.getEndpointState(endpointId) + ?.getClusterState(clusterId) + ?.getAttributeState(attributeId) + ?.tlv + ?: return + // TODO : Need to be implement poj-to-tlv + val value = TlvParseUtil.decodeBoolean(tlv) + val formatter = SimpleDateFormat("HH:mm:ss", Locale.getDefault()) + val time = formatter.format(Calendar.getInstance(Locale.getDefault()).time) + val message = "Subscribed on/off value at $time: ${if (value) "ON" else "OFF"}" + + Log.v(TAG, message) + showReportMessage(message) + } + }, + getConnectedDevicePointer(), + listOf(attributePath), + null, + minInterval, + maxInterval, + false, + false, + /* imTimeoutMs= */ 0 + ) } inner class ChipControllerCallback : GenericChipDeviceListener() { @@ -209,29 +246,41 @@ class OnOffClientFragment : Fragment() { // TODO : Need to be implement poj-to-tlv val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) - tlvWriter.put(ContextSpecificTag(LevelControl.MoveToLevelCommandField.Level.id), binding.levelBar.progress.toUInt()) + tlvWriter.put( + ContextSpecificTag(LevelControl.MoveToLevelCommandField.Level.id), + binding.levelBar.progress.toUInt() + ) tlvWriter.put(ContextSpecificTag(LevelControl.MoveToLevelCommandField.OptionsMask.id), 0u) tlvWriter.put(ContextSpecificTag(LevelControl.MoveToLevelCommandField.OptionsOverride.id), 0u) tlvWriter.put(ContextSpecificTag(LevelControl.MoveToLevelCommandField.TransitionTime.id), 0u) tlvWriter.endStructure() - val invokeElement = InvokeElement.newInstance(addressUpdateFragment.endpointId - , LevelControl.ID - , LevelControl.Command.MoveToLevel.id - , tlvWriter.getEncoded(), null) - - deviceController.invoke(object: InvokeCallback { - override fun onError(ex: Exception?) { - showMessage("MoveToLevel command failure $ex") - Log.e(TAG, "MoveToLevel command failure", ex) - } - - override fun onResponse(invokeElement: InvokeElement?, successCode: Long) { - Log.e(TAG, "onResponse : $invokeElement, Code : $successCode") - showMessage("MoveToLevel command success") - } + val invokeElement = + InvokeElement.newInstance( + addressUpdateFragment.endpointId, + LevelControl.ID, + LevelControl.Command.MoveToLevel.id, + tlvWriter.getEncoded(), + null + ) + + deviceController.invoke( + object : InvokeCallback { + override fun onError(ex: Exception?) { + showMessage("MoveToLevel command failure $ex") + Log.e(TAG, "MoveToLevel command failure", ex) + } - }, getConnectedDevicePointer(), invokeElement, 0, 0) + override fun onResponse(invokeElement: InvokeElement?, successCode: Long) { + Log.e(TAG, "onResponse : $invokeElement, Code : $successCode") + showMessage("MoveToLevel command success") + } + }, + getConnectedDevicePointer(), + invokeElement, + 0, + 0 + ) } private suspend fun sendOnOffClusterCommand(commandId: OnOff.Command) { @@ -239,23 +288,32 @@ class OnOffClientFragment : Fragment() { val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() - val invokeElement = InvokeElement.newInstance(addressUpdateFragment.endpointId - , OnOff.ID - , commandId.id - , tlvWriter.getEncoded(), null) - - deviceController.invoke(object: InvokeCallback { - override fun onError(ex: Exception?) { - showMessage("${commandId.name} command failure $ex") - Log.e(TAG, "${commandId.name} command failure", ex) - } - - override fun onResponse(invokeElement: InvokeElement?, successCode: Long) { - Log.e(TAG, "onResponse : $invokeElement, Code : $successCode") - showMessage("${commandId.name} command success") - } + val invokeElement = + InvokeElement.newInstance( + addressUpdateFragment.endpointId, + OnOff.ID, + commandId.id, + tlvWriter.getEncoded(), + null + ) + + deviceController.invoke( + object : InvokeCallback { + override fun onError(ex: Exception?) { + showMessage("${commandId.name} command failure $ex") + Log.e(TAG, "${commandId.name} command failure", ex) + } - }, getConnectedDevicePointer(), invokeElement, 0, 0) + override fun onResponse(invokeElement: InvokeElement?, successCode: Long) { + Log.e(TAG, "onResponse : $invokeElement, Code : $successCode") + showMessage("${commandId.name} command success") + } + }, + getConnectedDevicePointer(), + invokeElement, + 0, + 0 + ) } private suspend fun getConnectedDevicePointer(): Long { @@ -263,21 +321,16 @@ class OnOffClientFragment : Fragment() { } private fun showMessage(msg: String) { - requireActivity().runOnUiThread { - binding.commandStatusTv.text = msg - } + requireActivity().runOnUiThread { binding.commandStatusTv.text = msg } } private fun showReportMessage(msg: String) { - requireActivity().runOnUiThread { - binding.reportStatusTv.text = msg - } + requireActivity().runOnUiThread { binding.reportStatusTv.text = msg } } override fun onResume() { super.onResume() addressUpdateFragment.endpointId = ON_OFF_CLUSTER_ENDPOINT - } companion object { diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/OpCredClientFragment.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/OpCredClientFragment.kt index 02dc9912c5597f..734ce12c6810bb 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/OpCredClientFragment.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/OpCredClientFragment.kt @@ -8,13 +8,6 @@ import android.view.ViewGroup import androidx.fragment.app.Fragment import androidx.lifecycle.lifecycleScope import chip.devicecontroller.ChipDeviceController -import com.google.chip.chiptool.ChipClient -import com.google.chip.chiptool.GenericChipDeviceListener -import com.google.chip.chiptool.R -import com.google.chip.chiptool.databinding.OpCredClientFragmentBinding -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.launch - import chip.devicecontroller.ClusterIDMapping.OperationalCredentials import chip.devicecontroller.InvokeCallback import chip.devicecontroller.ReportCallback @@ -25,6 +18,12 @@ import chip.devicecontroller.model.NodeState import chip.tlv.AnonymousTag import chip.tlv.ContextSpecificTag import chip.tlv.TlvWriter +import com.google.chip.chiptool.ChipClient +import com.google.chip.chiptool.GenericChipDeviceListener +import com.google.chip.chiptool.R +import com.google.chip.chiptool.databinding.OpCredClientFragmentBinding +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.launch class OpCredClientFragment : Fragment() { private val deviceController: ChipDeviceController @@ -35,7 +34,8 @@ class OpCredClientFragment : Fragment() { private lateinit var addressUpdateFragment: AddressUpdateFragment private var _binding: OpCredClientFragmentBinding? = null - private val binding get() = _binding!! + private val binding + get() = _binding!! override fun onCreateView( inflater: LayoutInflater, @@ -50,10 +50,18 @@ class OpCredClientFragment : Fragment() { addressUpdateFragment = childFragmentManager.findFragmentById(R.id.addressUpdateFragment) as AddressUpdateFragment - binding.readSupportedFabricBtn.setOnClickListener { scope.launch { readClusterAttribute(OperationalCredentials.Attribute.SupportedFabrics) } } - binding.readCommissionedFabricBtn.setOnClickListener { scope.launch { readClusterAttribute(OperationalCredentials.Attribute.CommissionedFabrics) } } - binding.readFabricsBtn.setOnClickListener { scope.launch { readClusterAttribute(OperationalCredentials.Attribute.Fabrics) } } - binding.removeFabricsBtn.setOnClickListener { scope.launch { sendRemoveFabricsBtnClick(binding.fabricIndexEd.text.toString().toUInt()) } } + binding.readSupportedFabricBtn.setOnClickListener { + scope.launch { readClusterAttribute(OperationalCredentials.Attribute.SupportedFabrics) } + } + binding.readCommissionedFabricBtn.setOnClickListener { + scope.launch { readClusterAttribute(OperationalCredentials.Attribute.CommissionedFabrics) } + } + binding.readFabricsBtn.setOnClickListener { + scope.launch { readClusterAttribute(OperationalCredentials.Attribute.Fabrics) } + } + binding.removeFabricsBtn.setOnClickListener { + scope.launch { sendRemoveFabricsBtnClick(binding.fabricIndexEd.text.toString().toUInt()) } + } return binding.root } @@ -89,53 +97,82 @@ class OpCredClientFragment : Fragment() { val attributeName = attribute.name val attributeId = attribute.id - val devicePtr = ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) - - ChipClient.getDeviceController(requireContext()).readPath(object: ReportCallback { - override fun onError(attributePath: ChipAttributePath?, eventPath: ChipEventPath?, ex: java.lang.Exception) { - showMessage("Read $attributeName failure $ex") - Log.e(TAG, "Read $attributeName failure", ex) - } - - override fun onReport(nodeState: NodeState?) { - val value = nodeState?.getEndpointState(endpointId)?.getClusterState(clusterId)?.getAttributeState(attributeId)?.value ?: "null" - Log.i(TAG,"OpCred $attributeName value: $value") - showMessage("OpCred $attributeName value: $value") - } - - }, devicePtr, listOf(ChipAttributePath.newInstance(endpointId, clusterId, attributeId)), null, false, 0 /* imTimeoutMs */) + val devicePtr = + ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + + ChipClient.getDeviceController(requireContext()) + .readPath( + object : ReportCallback { + override fun onError( + attributePath: ChipAttributePath?, + eventPath: ChipEventPath?, + ex: java.lang.Exception + ) { + showMessage("Read $attributeName failure $ex") + Log.e(TAG, "Read $attributeName failure", ex) + } + + override fun onReport(nodeState: NodeState?) { + val value = + nodeState + ?.getEndpointState(endpointId) + ?.getClusterState(clusterId) + ?.getAttributeState(attributeId) + ?.value + ?: "null" + Log.i(TAG, "OpCred $attributeName value: $value") + showMessage("OpCred $attributeName value: $value") + } + }, + devicePtr, + listOf(ChipAttributePath.newInstance(endpointId, clusterId, attributeId)), + null, + false, + 0 /* imTimeoutMs */ + ) } private suspend fun sendRemoveFabricsBtnClick(fabricIndex: UInt) { - val devicePtr = ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) + val devicePtr = + ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId) // TODO : Need to be implement poj-to-tlv val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) - tlvWriter.put(ContextSpecificTag(OperationalCredentials.RemoveFabricCommandField.FabricIndex.id), fabricIndex) + tlvWriter.put( + ContextSpecificTag(OperationalCredentials.RemoveFabricCommandField.FabricIndex.id), + fabricIndex + ) tlvWriter.endStructure() - val invokeElement = InvokeElement.newInstance(addressUpdateFragment.endpointId - , OperationalCredentials.ID - , OperationalCredentials.Command.RemoveFabric.id - , tlvWriter.getEncoded(), null) - - deviceController.invoke(object: InvokeCallback { - override fun onError(ex: Exception?) { - showMessage("RemoveFabric failure $ex") - Log.e(TAG, "RemoveFabric failure", ex) - } - - override fun onResponse(invokeElement: InvokeElement?, successCode: Long) { - Log.e(TAG, "onResponse : $invokeElement, Code : $successCode") - showMessage("RemoveFabric success") - } - - }, devicePtr, invokeElement, 0, 0) + val invokeElement = + InvokeElement.newInstance( + addressUpdateFragment.endpointId, + OperationalCredentials.ID, + OperationalCredentials.Command.RemoveFabric.id, + tlvWriter.getEncoded(), + null + ) + + deviceController.invoke( + object : InvokeCallback { + override fun onError(ex: Exception?) { + showMessage("RemoveFabric failure $ex") + Log.e(TAG, "RemoveFabric failure", ex) + } + + override fun onResponse(invokeElement: InvokeElement?, successCode: Long) { + Log.e(TAG, "onResponse : $invokeElement, Code : $successCode") + showMessage("RemoveFabric success") + } + }, + devicePtr, + invokeElement, + 0, + 0 + ) } private fun showMessage(msg: String) { - requireActivity().runOnUiThread { - binding.opCredClusterCommandStatus.text = msg - } + requireActivity().runOnUiThread { binding.opCredClusterCommandStatus.text = msg } } override fun onResume() { @@ -146,6 +183,7 @@ class OpCredClientFragment : Fragment() { companion object { private const val TAG = "OpCredClientFragment" private const val OPERATIONAL_CREDENTIALS_ENDPOINT_ID = 0 + fun newInstance(): OpCredClientFragment = OpCredClientFragment() } } diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/SensorClientFragment.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/SensorClientFragment.kt index 8abe61329a9727..53294c8037f981 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/SensorClientFragment.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/SensorClientFragment.kt @@ -12,6 +12,7 @@ import android.widget.Toast import androidx.fragment.app.Fragment import androidx.lifecycle.lifecycleScope import chip.devicecontroller.ChipDeviceController +import chip.devicecontroller.ClusterIDMapping.* import chip.devicecontroller.ReportCallback import chip.devicecontroller.model.ChipAttributePath import chip.devicecontroller.model.ChipEventPath @@ -30,7 +31,6 @@ import java.util.Calendar import java.util.Date import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch -import chip.devicecontroller.ClusterIDMapping.* class SensorClientFragment : Fragment() { private val deviceController: ChipDeviceController @@ -45,12 +45,13 @@ class SensorClientFragment : Fragment() { private var subscribedDevicePtr = 0L private var _binding: SensorClientFragmentBinding? = null - private val binding get() = _binding!! + private val binding + get() = _binding!! override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle? + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? ): View { _binding = SensorClientFragmentBinding.inflate(inflater, container, false) scope = viewLifecycleOwner.lifecycleScope @@ -76,12 +77,14 @@ class SensorClientFragment : Fragment() { } binding.clusterNameSpinner.adapter = makeClusterNamesAdapter() - binding.clusterNameSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener { - override fun onNothingSelected(parent: AdapterView<*>?) = Unit - override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) { - resetSensorGraph() // reset the graph on cluster change + binding.clusterNameSpinner.onItemSelectedListener = + object : AdapterView.OnItemSelectedListener { + override fun onNothingSelected(parent: AdapterView<*>?) = Unit + + override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) { + resetSensorGraph() // reset the graph on cluster change + } } - } binding.readSensorBtn.setOnClickListener { scope.launch { readSensorCluster() } } binding.watchSensorBtn.setOnCheckedChangeListener { _, isChecked -> @@ -96,20 +99,22 @@ class SensorClientFragment : Fragment() { binding.sensorGraph.addSeries(sensorData) binding.sensorGraph.viewport.isXAxisBoundsManual = true binding.sensorGraph.viewport.setMinX(currentTime.toDouble()) - binding.sensorGraph.viewport.setMaxX(currentTime.toDouble() + MIN_REFRESH_PERIOD_S * 1000 * MAX_DATA_POINTS) + binding.sensorGraph.viewport.setMaxX( + currentTime.toDouble() + MIN_REFRESH_PERIOD_S * 1000 * MAX_DATA_POINTS + ) binding.sensorGraph.gridLabelRenderer.padding = 30 binding.sensorGraph.gridLabelRenderer.numHorizontalLabels = 4 binding.sensorGraph.gridLabelRenderer.setHorizontalLabelsAngle(150) - binding.sensorGraph.gridLabelRenderer.labelFormatter = object : LabelFormatter { - override fun setViewport(viewport: Viewport?) = Unit - override fun formatLabel(value: Double, isValueX: Boolean): String { - if (isValueX) - return SimpleDateFormat("H:mm:ss").format(Date(value.toLong())).toString() - if (value >= 100.0) - return "%.1f".format(value) - return "%.2f".format(value) + binding.sensorGraph.gridLabelRenderer.labelFormatter = + object : LabelFormatter { + override fun setViewport(viewport: Viewport?) = Unit + + override fun formatLabel(value: Double, isValueX: Boolean): String { + if (isValueX) return SimpleDateFormat("H:mm:ss").format(Date(value.toLong())).toString() + if (value >= 100.0) return "%.1f".format(value) + return "%.2f".format(value) + } } - } } override fun onStart() { @@ -138,9 +143,8 @@ class SensorClientFragment : Fragment() { requireContext(), android.R.layout.simple_spinner_dropdown_item, CLUSTERS.keys.toList() - ).apply { - setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) - } + ) + .apply { setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) } } private suspend fun readSensorCluster() { @@ -153,7 +157,12 @@ class SensorClientFragment : Fragment() { val device = ChipClient.getConnectedDevicePointer(requireContext(), deviceId) val callback = makeReadCallback(clusterName, false) - deviceController.readAttributePath(callback, device, listOf(ChipAttributePath.newInstance(endpointId, clusterId, attributeId)), 0) + deviceController.readAttributePath( + callback, + device, + listOf(ChipAttributePath.newInstance(endpointId, clusterId, attributeId)), + 0 + ) } catch (ex: Exception) { Log.d(TAG, "Failed to read the sensor : ", ex) showMessage(R.string.sensor_client_read_error_text, ex.toString()) @@ -170,7 +179,15 @@ class SensorClientFragment : Fragment() { val device = ChipClient.getConnectedDevicePointer(requireContext(), deviceId) val callback = makeReadCallback(clusterName, true) - deviceController.subscribeToAttributePath({ Log.d(TAG, "onSubscriptionEstablished") }, callback, device, listOf(ChipAttributePath.newInstance(endpointId, clusterId, attributeId)), MIN_REFRESH_PERIOD_S, MAX_REFRESH_PERIOD_S, 0) + deviceController.subscribeToAttributePath( + { Log.d(TAG, "onSubscriptionEstablished") }, + callback, + device, + listOf(ChipAttributePath.newInstance(endpointId, clusterId, attributeId)), + MIN_REFRESH_PERIOD_S, + MAX_REFRESH_PERIOD_S, + 0 + ) subscribedDevicePtr = device } catch (ex: Exception) { Log.d(TAG, "Failed to subscribe", ex) @@ -179,8 +196,7 @@ class SensorClientFragment : Fragment() { } private fun unsubscribeSensorCluster() { - if (subscribedDevicePtr == 0L) - return + if (subscribedDevicePtr == 0L) return try { ChipClient.getDeviceController(requireContext()).shutdownSubscriptions() @@ -198,21 +214,31 @@ class SensorClientFragment : Fragment() { val attributeId = clusterConfig["attributeId"] as Long override fun onReport(nodeState: NodeState?) { - val tlv = nodeState?.getEndpointState(endpointId)?.getClusterState(clusterId)?.getAttributeState(attributeId)?.tlv ?: return + val tlv = + nodeState + ?.getEndpointState(endpointId) + ?.getClusterState(clusterId) + ?.getAttributeState(attributeId) + ?.tlv + ?: return // TODO : Need to be implement poj-to-tlv val value = - try { - TlvParseUtil.decodeInt(tlv) - } catch (ex: Exception) { - showMessage(R.string.sensor_client_read_error_text, "value is null") - return - } + try { + TlvParseUtil.decodeInt(tlv) + } catch (ex: Exception) { + showMessage(R.string.sensor_client_read_error_text, "value is null") + return + } val unitValue = clusterConfig["unitValue"] as Double val unitSymbol = clusterConfig["unitSymbol"] as String consumeSensorValue(value * unitValue, unitSymbol, addToGraph) } - override fun onError(attributePath: ChipAttributePath?, eventPath: ChipEventPath?, ex: Exception) { + override fun onError( + attributePath: ChipAttributePath?, + eventPath: ChipEventPath?, + ex: Exception + ) { showMessage(R.string.sensor_client_read_error_text, ex.toString()) } } @@ -220,16 +246,16 @@ class SensorClientFragment : Fragment() { private fun consumeSensorValue(value: Double, unitSymbol: String, addToGraph: Boolean) { requireActivity().runOnUiThread { - binding.lastValueTv.text = requireContext().getString( - R.string.sensor_client_last_value_text, value, unitSymbol - ) + binding.lastValueTv.text = + requireContext().getString(R.string.sensor_client_last_value_text, value, unitSymbol) if (addToGraph) { val isFirstSample = sensorData.isEmpty val dataPoint = DataPoint(Calendar.getInstance().time, value) sensorData.appendData(dataPoint, true, MAX_DATA_POINTS) if (isFirstSample) { - // Make the graph visible on the first sample. Also, workaround a bug in graphview + // Make the graph visible on the first sample. Also, workaround a bug in + // graphview // related to calculating the viewport when there is only one data point by // duplicating the first sample. sensorData.appendData(dataPoint, true, MAX_DATA_POINTS) @@ -253,26 +279,30 @@ class SensorClientFragment : Fragment() { private const val MIN_REFRESH_PERIOD_S = 2 private const val MAX_REFRESH_PERIOD_S = 10 private const val MAX_DATA_POINTS = 60 - private val CLUSTERS = mapOf( - "Temperature" to mapOf( + private val CLUSTERS = + mapOf( + "Temperature" to + mapOf( "clusterId" to TemperatureMeasurement.ID, "attributeId" to TemperatureMeasurement.Attribute.MeasuredValue.id, "unitValue" to 0.01, "unitSymbol" to "\u00B0C" - ), - "Pressure" to mapOf( + ), + "Pressure" to + mapOf( "clusterId" to PressureMeasurement.ID, "attributeId" to PressureMeasurement.Attribute.MeasuredValue.id, "unitValue" to 1.0, "unitSymbol" to "hPa" - ), - "Relative Humidity" to mapOf( + ), + "Relative Humidity" to + mapOf( "clusterId" to RelativeHumidityMeasurement.ID, "attributeId" to RelativeHumidityMeasurement.Attribute.MeasuredValue.id, "unitValue" to 0.01, "unitSymbol" to "%" - ) - ) + ) + ) fun newInstance(): SensorClientFragment = SensorClientFragment() } diff --git a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/WildcardFragment.kt b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/WildcardFragment.kt index cff6d0f81cff66..a755b1a441f03a 100644 --- a/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/WildcardFragment.kt +++ b/examples/android/CHIPTool/app/src/main/java/com/google/chip/chiptool/clusterclient/WildcardFragment.kt @@ -34,17 +34,17 @@ import chip.tlv.TlvWriter import com.google.chip.chiptool.ChipClient import com.google.chip.chiptool.R import com.google.chip.chiptool.databinding.WildcardFragmentBinding -import com.google.protobuf.ByteString import java.lang.StringBuilder import java.util.Optional -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.launch import kotlin.coroutines.resume import kotlin.coroutines.suspendCoroutine +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.launch class WildcardFragment : Fragment() { private var _binding: WildcardFragmentBinding? = null - private val binding get() = _binding!! + private val binding + get() = _binding!! private val deviceController: ChipDeviceController get() = ChipClient.getDeviceController(requireContext()) @@ -57,58 +57,62 @@ class WildcardFragment : Fragment() { private val eventPath = ArrayList() private val subscribeIdList = ArrayList() - private val reportCallback = object : ReportCallback { - override fun onError(attributePath: ChipAttributePath?, eventPath: ChipEventPath?, ex: Exception) { - if (attributePath != null) - { - Log.e(TAG, "Report error for $attributePath: $ex") - } - if (eventPath != null) - { - Log.e(TAG, "Report error for $eventPath: $ex") + private val reportCallback = + object : ReportCallback { + override fun onError( + attributePath: ChipAttributePath?, + eventPath: ChipEventPath?, + ex: Exception + ) { + if (attributePath != null) { + Log.e(TAG, "Report error for $attributePath: $ex") + } + if (eventPath != null) { + Log.e(TAG, "Report error for $eventPath: $ex") + } } - } - override fun onReport(nodeState: NodeState) { - Log.i(TAG, "Received wildcard report") + override fun onReport(nodeState: NodeState) { + Log.i(TAG, "Received wildcard report") - val debugString = nodeStateToDebugString(nodeState) - Log.i(TAG, debugString) - requireActivity().runOnUiThread { binding.outputTv.text = debugString } - } + val debugString = nodeStateToDebugString(nodeState) + Log.i(TAG, debugString) + requireActivity().runOnUiThread { binding.outputTv.text = debugString } + } - override fun onDone() { - Log.i(TAG, "wildcard report Done") + override fun onDone() { + Log.i(TAG, "wildcard report Done") + } } - } - private val writeAttributeCallback = object : WriteAttributesCallback { - override fun onError(attributePath: ChipAttributePath?, ex: Exception?) { - Log.e(TAG, "Report error for $attributePath: $ex") - } + private val writeAttributeCallback = + object : WriteAttributesCallback { + override fun onError(attributePath: ChipAttributePath?, ex: Exception?) { + Log.e(TAG, "Report error for $attributePath: $ex") + } - override fun onResponse(attributePath: ChipAttributePath?) { - val text = "$attributePath : Write Success" - requireActivity().runOnUiThread { binding.outputTv.text = text } - } + override fun onResponse(attributePath: ChipAttributePath?) { + val text = "$attributePath : Write Success" + requireActivity().runOnUiThread { binding.outputTv.text = text } + } - override fun onDone() { - Log.i(TAG, "write attribute Done") + override fun onDone() { + Log.i(TAG, "write attribute Done") + } } - } - private val invokeCallback = object : InvokeCallback { - override fun onError(e: java.lang.Exception?) { - Log.e(TAG, "Report error", e) - } + private val invokeCallback = + object : InvokeCallback { + override fun onError(e: java.lang.Exception?) { + Log.e(TAG, "Report error", e) + } - override fun onResponse(invokeElement: InvokeElement?, successCode: Long) { - val text = "Invoke Response : $invokeElement, $successCode" - requireActivity().runOnUiThread { binding.outputTv.text = text } + override fun onResponse(invokeElement: InvokeElement?, successCode: Long) { + val text = "Invoke Response : $invokeElement, $successCode" + requireActivity().runOnUiThread { binding.outputTv.text = text } + } } - } - override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, @@ -159,8 +163,12 @@ class WildcardFragment : Fragment() { return binding.root } - private fun getVisibility(isShowing: Boolean) : Int { - return if (isShowing) { View.VISIBLE } else { View.GONE } + private fun getVisibility(isShowing: Boolean): Int { + return if (isShowing) { + View.VISIBLE + } else { + View.GONE + } } private fun addPathList(type: Int) { @@ -169,7 +177,9 @@ class WildcardFragment : Fragment() { val attributeId = getChipPathIdForText(binding.attributeIdEd.text.toString()) val eventId = getChipPathIdForText(binding.eventIdEd.text.toString()) // Only Subscribe used - val isUrgent = (binding.subscribeRadioBtn.isChecked) && (binding.isUrgentSp.selectedItem.toString().toBoolean()) + val isUrgent = + (binding.subscribeRadioBtn.isChecked) && + (binding.isUrgentSp.selectedItem.toString().toBoolean()) if (type == ATTRIBUTE) { attributePath.add(ChipAttributePath.newInstance(endpointId, clusterId, attributeId)) @@ -212,8 +222,7 @@ class WildcardFragment : Fragment() { stringBuilder.append("\t\t$attributeName: ${attributeState.value}\n") } clusterState.eventStates.forEach { (eventId, events) -> - for (event in events) - { + for (event in events) { stringBuilder.append("\t\teventNumber: ${event.eventNumber}\n") stringBuilder.append("\t\tpriorityLevel: ${event.priorityLevel}\n") stringBuilder.append("\t\tsystemTimeStamp: ${event.systemTimeStamp}\n") @@ -229,48 +238,69 @@ class WildcardFragment : Fragment() { return stringBuilder.toString() } - private suspend fun subscribe(minInterval: Int, maxInterval: Int, keepSubscriptions: Boolean, isFabricFiltered: Boolean, eventMin: Long?) { - val subscriptionEstablishedCallback = - SubscriptionEstablishedCallback { - subscriptionId -> - Log.i(TAG, "Subscription to device established : ${subscriptionId.toULong()}") - subscribeIdList.add(subscriptionId.toULong()) - requireActivity().runOnUiThread { - Toast.makeText(requireActivity(), "${getString(R.string.wildcard_subscribe_established_toast_message)} : $subscriptionId", Toast.LENGTH_SHORT).show() - } + private suspend fun subscribe( + minInterval: Int, + maxInterval: Int, + keepSubscriptions: Boolean, + isFabricFiltered: Boolean, + eventMin: Long? + ) { + val subscriptionEstablishedCallback = SubscriptionEstablishedCallback { subscriptionId -> + Log.i(TAG, "Subscription to device established : ${subscriptionId.toULong()}") + subscribeIdList.add(subscriptionId.toULong()) + requireActivity().runOnUiThread { + Toast.makeText( + requireActivity(), + "${getString(R.string.wildcard_subscribe_established_toast_message)} : $subscriptionId", + Toast.LENGTH_SHORT + ) + .show() } + } val resubscriptionAttemptCallback = - ResubscriptionAttemptCallback { terminationCause, nextResubscribeIntervalMsec - -> Log.i(TAG, "ResubscriptionAttempt terminationCause:$terminationCause, nextResubscribeIntervalMsec:$nextResubscribeIntervalMsec") } - - deviceController.subscribeToPath(subscriptionEstablishedCallback, - resubscriptionAttemptCallback, - reportCallback, - ChipClient.getConnectedDevicePointer(requireContext(), - addressUpdateFragment.deviceId), - attributePath.ifEmpty { null }, - eventPath.ifEmpty { null }, - minInterval, - maxInterval, - keepSubscriptions, - isFabricFiltered, - /* imTimeoutMs= */ 0, - eventMin) + ResubscriptionAttemptCallback { terminationCause, nextResubscribeIntervalMsec -> + Log.i( + TAG, + "ResubscriptionAttempt terminationCause:$terminationCause, nextResubscribeIntervalMsec:$nextResubscribeIntervalMsec" + ) + } + + deviceController.subscribeToPath( + subscriptionEstablishedCallback, + resubscriptionAttemptCallback, + reportCallback, + ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId), + attributePath.ifEmpty { null }, + eventPath.ifEmpty { null }, + minInterval, + maxInterval, + keepSubscriptions, + isFabricFiltered, + /* imTimeoutMs= */ 0, + eventMin + ) } private suspend fun read(isFabricFiltered: Boolean, eventMin: Long?) { - deviceController.readPath(reportCallback, - ChipClient.getConnectedDevicePointer(requireContext(), - addressUpdateFragment.deviceId), - attributePath.ifEmpty { null }, - eventPath.ifEmpty { null }, - isFabricFiltered, - /* imTimeoutMs= */ 0, - eventMin) + deviceController.readPath( + reportCallback, + ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId), + attributePath.ifEmpty { null }, + eventPath.ifEmpty { null }, + isFabricFiltered, + /* imTimeoutMs= */ 0, + eventMin + ) } - private suspend fun write(writeValueType: String, writeValue: String, dataVersion: Int?, timedRequestTimeoutMs: Int, imTimeoutMs: Int) { + private suspend fun write( + writeValueType: String, + writeValue: String, + dataVersion: Int?, + timedRequestTimeoutMs: Int, + imTimeoutMs: Int + ) { val endpointId = getChipPathIdForText(binding.endpointIdEd.text.toString()) val clusterId = getChipPathIdForText(binding.clusterIdEd.text.toString()) val attributeId = getChipPathIdForText(binding.attributeIdEd.text.toString()) @@ -288,15 +318,28 @@ class WildcardFragment : Fragment() { } if (values.size > 1) tlvWriter.endArray() - val version = if (dataVersion == null) { Optional.empty() } else { Optional.of(dataVersion) } + val version = + if (dataVersion == null) { + Optional.empty() + } else { + Optional.of(dataVersion) + } - val writeRequest = AttributeWriteRequest.newInstance(endpointId, clusterId, attributeId, tlvWriter.getEncoded(), version) - deviceController.write(writeAttributeCallback, - ChipClient.getConnectedDevicePointer(requireContext(), - addressUpdateFragment.deviceId), - listOf(writeRequest), - timedRequestTimeoutMs, - imTimeoutMs) + val writeRequest = + AttributeWriteRequest.newInstance( + endpointId, + clusterId, + attributeId, + tlvWriter.getEncoded(), + version + ) + deviceController.write( + writeAttributeCallback, + ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId), + listOf(writeRequest), + timedRequestTimeoutMs, + imTimeoutMs + ) } private suspend fun invoke(invokeField: String, timedRequestTimeoutMs: Int, imTimeoutMs: Int) { @@ -305,7 +348,12 @@ class WildcardFragment : Fragment() { val commandId = getChipPathIdForText(binding.commandIdEd.text.toString()) val tlvWriter = TlvWriter() - val fields = if (invokeField.isEmpty()) { listOf() } else { invokeField.split(",") } + val fields = + if (invokeField.isEmpty()) { + listOf() + } else { + invokeField.split(",") + } var count = 0 tlvWriter.startStructure(AnonymousTag) for (field in fields) { @@ -321,33 +369,43 @@ class WildcardFragment : Fragment() { } } tlvWriter.endStructure() - val invokeElement = InvokeElement.newInstance(endpointId, clusterId, commandId, tlvWriter.getEncoded(), null) - deviceController.invoke(invokeCallback, - ChipClient.getConnectedDevicePointer(requireContext(), - addressUpdateFragment.deviceId), - invokeElement, - timedRequestTimeoutMs, - imTimeoutMs) + val invokeElement = + InvokeElement.newInstance(endpointId, clusterId, commandId, tlvWriter.getEncoded(), null) + deviceController.invoke( + invokeCallback, + ChipClient.getConnectedDevicePointer(requireContext(), addressUpdateFragment.deviceId), + invokeElement, + timedRequestTimeoutMs, + imTimeoutMs + ) } private fun showReadDialog() { if (attributePath.isEmpty() && eventPath.isEmpty()) { requireActivity().runOnUiThread { - Toast.makeText(requireActivity(), R.string.wildcard_empty_error_toast_message, Toast.LENGTH_SHORT).show() + Toast.makeText( + requireActivity(), + R.string.wildcard_empty_error_toast_message, + Toast.LENGTH_SHORT + ) + .show() } return } val dialogView = requireActivity().layoutInflater.inflate(R.layout.read_dialog, null) val eventMinEd = dialogView.findViewById(R.id.eventMinEd) - eventMinEd.visibility = if (eventPath.isNotEmpty()) { View.VISIBLE } else { View.GONE } - val dialog = AlertDialog.Builder(requireContext()).apply { - setView(dialogView) - }.create() + eventMinEd.visibility = + if (eventPath.isNotEmpty()) { + View.VISIBLE + } else { + View.GONE + } + val dialog = AlertDialog.Builder(requireContext()).apply { setView(dialogView) }.create() val isFabricFilteredEd = dialogView.findViewById(R.id.isFabricFilteredSp) dialogView.findViewById